From 47e35fcd7c2c346f4799630bf6521d6a4bf49e85 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 13 Apr 2022 19:28:16 +0200 Subject: chore: add a Card component --- src/components/atoms/lists/description-list.tsx | 45 ++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'src/components/atoms/lists/description-list.tsx') diff --git a/src/components/atoms/lists/description-list.tsx b/src/components/atoms/lists/description-list.tsx index a5ab1d5..0a92465 100644 --- a/src/components/atoms/lists/description-list.tsx +++ b/src/components/atoms/lists/description-list.tsx @@ -21,10 +21,30 @@ export type DescriptionListProps = { * Set additional classnames to the list wrapper. */ className?: string; + /** + * Set additional classnames to the `dd` element. + */ + descriptionClassName?: string; + /** + * Set additional classnames to the `dt`/`dd` couple wrapper. + */ + groupClassName?: string; /** * The list items. */ items: DescriptionListItem[]; + /** + * The list items layout. Default: column. + */ + layout?: 'inline' | 'column'; + /** + * Define if the layout should automatically create rows/columns. + */ + responsiveLayout?: boolean; + /** + * Set additional classnames to the `dt` element. + */ + termClassName?: string; }; /** @@ -34,8 +54,16 @@ export type DescriptionListProps = { */ const DescriptionList: VFC = ({ className = '', + descriptionClassName = '', + groupClassName = '', items, + layout = 'column', + responsiveLayout = false, + termClassName = '', }) => { + const layoutModifier = `list--${layout}`; + const responsiveModifier = responsiveLayout ? 'list--responsive' : ''; + /** * Retrieve the description list items wrapped in a div element. * @@ -45,10 +73,13 @@ const DescriptionList: VFC = ({ const getItems = (listItems: DescriptionListItem[]): JSX.Element[] => { return listItems.map(({ id, term, value }) => { return ( -
-
{term}
+
+
{term}
{value.map((currentValue, index) => ( -
+
{currentValue}
))} @@ -57,7 +88,13 @@ const DescriptionList: VFC = ({ }); }; - return
{getItems(items)}
; + return ( +
+ {getItems(items)} +
+ ); }; export default DescriptionList; -- cgit v1.2.3