diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-22 18:12:32 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-22 19:01:04 +0100 |
| commit | 329e7c89bac50be9db2c6d2ec6751ab0ffad42ac (patch) | |
| tree | e389de0a3ccda15fa3fb0dbaace185c905449f7b /src/components/molecules/grid/grid-item.tsx | |
| parent | 0ac690339083f01a0b12a74ec117eeccd055e932 (diff) | |
refactor(components): replace items prop in Grid with children prop
It is easier to read and to maintain this way. The `items` prop was not
useful since we are not manipulating the items. Changes:
* extract GridItem component from Grid component
* replace `items` prop of type Array<ReactNode> with `children` prop of
type ReactNode
* remove GridItem styles
Diffstat (limited to 'src/components/molecules/grid/grid-item.tsx')
| -rw-r--r-- | src/components/molecules/grid/grid-item.tsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/components/molecules/grid/grid-item.tsx b/src/components/molecules/grid/grid-item.tsx new file mode 100644 index 0000000..0592cec --- /dev/null +++ b/src/components/molecules/grid/grid-item.tsx @@ -0,0 +1,15 @@ +import { type ForwardRefRenderFunction, forwardRef } from 'react'; +import { ListItem, type ListItemProps } from '../../atoms'; + +export type GridItemProps = ListItemProps; + +const GridItemWithRef: ForwardRefRenderFunction< + HTMLLIElement, + GridItemProps +> = ({ children, ...props }, ref) => ( + <ListItem {...props} ref={ref}> + {children} + </ListItem> +); + +export const GridItem = forwardRef(GridItemWithRef); |
