From d5ade2359539648845a5854ed353b29367961d74 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Nov 2023 11:02:20 +0100 Subject: refactor(components): extract MetaItem from MetaList * replace `items` prop on MetaList with `children` prop: it was too restrictive and the global options was not really useful. It is better too give control to the consumers. --- src/components/molecules/meta-list/meta-list.tsx | 72 +++++++----------------- 1 file changed, 20 insertions(+), 52 deletions(-) (limited to 'src/components/molecules/meta-list/meta-list.tsx') diff --git a/src/components/molecules/meta-list/meta-list.tsx b/src/components/molecules/meta-list/meta-list.tsx index 288fd9a..c19f0fd 100644 --- a/src/components/molecules/meta-list/meta-list.tsx +++ b/src/components/molecules/meta-list/meta-list.tsx @@ -1,54 +1,32 @@ -import { type ForwardRefRenderFunction, forwardRef } from 'react'; +import { + type ForwardRefRenderFunction, + forwardRef, + type ReactNode, +} from 'react'; import { DescriptionList, type DescriptionListProps } from '../../atoms'; -import { MetaItem, type MetaItemProps } from './meta-item'; import styles from './meta-list.module.scss'; -export type MetaItemData = Pick< - MetaItemProps, - | 'hasBorderedValues' - | 'hasInlinedValues' - | 'isCentered' - | 'isInline' - | 'label' - | 'value' +export type MetaListProps = Omit< + DescriptionListProps, + 'children' | 'spacing' > & { - id: string; + /** + * The meta items. + */ + children: ReactNode; + /** + * Should the meta be centered? + * + * @default false + */ + isCentered?: boolean; }; -export type MetaListProps = Omit & - Pick & { - /** - * Should the items be inlined? - * - * @default false - */ - hasInlinedItems?: boolean; - /** - * Should the meta be centered? - * - * @default false - */ - isCentered?: boolean; - /** - * The meta items. - */ - items: MetaItemData[]; - }; - const MetaListWithRef: ForwardRefRenderFunction< HTMLDListElement, MetaListProps > = ( - { - className = '', - hasBorderedValues = false, - hasInlinedItems = false, - hasInlinedValues = false, - isCentered = false, - isInline = false, - items, - ...props - }, + { children, className = '', isCentered = false, isInline = false, ...props }, ref ) => { const listClass = [ @@ -60,17 +38,7 @@ const MetaListWithRef: ForwardRefRenderFunction< return ( - {items.map(({ id, ...item }) => ( - - ))} + {children} ); }; -- cgit v1.2.3