fix(striker-ui): add wrapper around Grid to make it compatible with FlexBox spacing

main
Tsu-ba-me 2 years ago
parent e41bc3a572
commit 06b33273f3
  1. 6
      striker-ui/components/Grid.tsx
  2. 1
      striker-ui/types/Grid.d.ts

@ -1,9 +1,10 @@
import { Grid as MUIGrid } from '@mui/material'; import { Box as MUIBox, Grid as MUIGrid } from '@mui/material';
import { FC, useMemo } from 'react'; import { FC, useMemo } from 'react';
const Grid: FC<GridProps> = ({ const Grid: FC<GridProps> = ({
calculateItemBreakpoints = () => ({ xs: 1 }), calculateItemBreakpoints = () => ({ xs: 1 }),
layout, layout,
wrapperBoxProps,
...restGridProps ...restGridProps
}) => { }) => {
const itemElements = useMemo(() => { const itemElements = useMemo(() => {
@ -24,9 +25,12 @@ const Grid: FC<GridProps> = ({
}, [calculateItemBreakpoints, layout]); }, [calculateItemBreakpoints, layout]);
return ( return (
// Make Grid compatible with FlexBox by adding an extra empty wrapper.
<MUIBox {...wrapperBoxProps}>
<MUIGrid container {...restGridProps}> <MUIGrid container {...restGridProps}>
{itemElements} {itemElements}
</MUIGrid> </MUIGrid>
</MUIBox>
); );
}; };

@ -9,6 +9,7 @@ type GridOptionalProps = {
) => Partial< ) => Partial<
Pick<import('@mui/material').GridProps, 'xs' | 'sm' | 'md' | 'lg' | 'xl'> Pick<import('@mui/material').GridProps, 'xs' | 'sm' | 'md' | 'lg' | 'xl'>
>; >;
wrapperBoxProps?: import('@mui/material').BoxProps;
}; };
type GridProps = import('@mui/material').GridProps & type GridProps = import('@mui/material').GridProps &

Loading…
Cancel
Save