diff --git a/striker-ui/components/Grid.tsx b/striker-ui/components/Grid.tsx new file mode 100644 index 00000000..d7763c8a --- /dev/null +++ b/striker-ui/components/Grid.tsx @@ -0,0 +1,33 @@ +import { Grid as MUIGrid } from '@mui/material'; +import { FC, useMemo } from 'react'; + +const Grid: FC = ({ + calculateItemBreakpoints = () => ({ xs: 1 }), + layout, + ...restGridProps +}) => { + const itemElements = useMemo(() => { + const items = Object.entries(layout); + + return items.map(([itemId, itemGridProps], index) => { + const key = itemId; + + return ( + + ); + }); + }, [calculateItemBreakpoints, layout]); + + return ( + + {itemElements} + + ); +}; + +export default Grid; diff --git a/striker-ui/types/Grid.d.ts b/striker-ui/types/Grid.d.ts new file mode 100644 index 00000000..01880dca --- /dev/null +++ b/striker-ui/types/Grid.d.ts @@ -0,0 +1,17 @@ +type GridLayout = { + [id: string]: import('@mui/material').GridProps; +}; + +type GridOptionalProps = { + calculateItemBreakpoints?: ( + index: number, + key: string, + ) => Partial< + Pick + >; +}; + +type GridProps = import('@mui/material').GridProps & + GridOptionalProps & { + layout: GridLayout; + };