From 4f768afe543bbf9e1857c41d03804f8e37ab3512 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 29 Sep 2023 21:29:45 +0200 Subject: refactor(components): rewrite List component * change `items` prop to children * replace `kind` prop with `isHierarchical`, `isOrdered` & `isInline` props * add `hideMarker` prop * add `spacing` prop to control item spacing * move lists styles to Sass placeholders to avoid repeats because of headless WordPress --- src/components/atoms/lists/list/list.stories.tsx | 196 +++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 src/components/atoms/lists/list/list.stories.tsx (limited to 'src/components/atoms/lists/list/list.stories.tsx') diff --git a/src/components/atoms/lists/list/list.stories.tsx b/src/components/atoms/lists/list/list.stories.tsx new file mode 100644 index 0000000..538947a --- /dev/null +++ b/src/components/atoms/lists/list/list.stories.tsx @@ -0,0 +1,196 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import { List, type ListProps } from './list'; +import { ListItem } from './list-item'; + +/** + * List - Storybook Meta + */ +export default { + title: 'Atoms/Lists', + component: List, + args: {}, + argTypes: { + className: { + control: { + type: 'text', + }, + description: 'Set additional classnames to the list wrapper', + table: { + category: 'Styles', + }, + type: { + name: 'string', + required: false, + }, + }, + }, +} as ComponentMeta; + +const Template: ComponentStory = < + O extends boolean, + H extends boolean, +>( + args: ListProps +) => ; + +/** + * List Stories - Hierarchical list + */ +export const Hierarchical = Template.bind({}); +Hierarchical.args = { + children: [ + + Item 1 + + Subitem 1 + Subitem 2 + + , + + Item 2 + + Subitem 1 + + Subitem 2 + + Nested item 1 + Nested item 2 + + + Subitem 3 + + , + Item 3, + ], + isHierarchical: true, +}; + +/** + * List Stories - Ordered list + */ +export const Ordered = Template.bind({}); +Ordered.args = { + children: [ + + Item 1 + + Subitem 1 + Subitem 2 + + , + + Item 2 + + Subitem 1 + + Subitem 2 + + Nested item 1 + Nested item 2 + + + Subitem 3 + + , + Item 3, + ], + isOrdered: true, +}; + +/** + * List Stories - Unordered list + */ +export const Unordered = Template.bind({}); +Unordered.args = { + children: [ + + Item 1 + + Subitem 1 + Subitem 2 + + , + + Item 2 + + Subitem 1 + + Subitem 2 + + Nested item 1 + Nested item 2 + + + Subitem 3 + + , + Item 3, + ], +}; + +const items = [ + { id: 'item-1', label: 'Item 1' }, + { id: 'item-2', label: 'Item 2' }, + { + id: 'item-3', + label: ( + <> + Item 3 + + Subitem 1 + Subitem 2 + + + ), + }, + { id: 'item-4', label: 'Item 4' }, + { id: 'item-5', label: 'Item 5' }, +]; + +/** + * List Stories - Inline and ordered list + */ +export const InlineOrdered = Template.bind({}); +InlineOrdered.args = { + children: items.map((item) => ( + {item.label} + )), + isInline: true, + isOrdered: true, + spacing: 'sm', +}; + +/** + * List Stories - Inline and unordered list + */ +export const InlineUnordered = Template.bind({}); +InlineUnordered.args = { + children: items.map((item) => ( + {item.label} + )), + isInline: true, + spacing: 'sm', +}; + +/** + * List Stories - Ordered list without marker + */ +export const OrderedHideMarker = Template.bind({}); +OrderedHideMarker.args = { + children: items.map((item) => ( + {item.label} + )), + hideMarker: true, + isOrdered: true, +}; + +/** + * List Stories - Unordered list without marker + */ +export const UnorderedHideMarker = Template.bind({}); +UnorderedHideMarker.args = { + children: items.map((item) => ( + {item.label} + )), + hideMarker: true, +}; -- cgit v1.2.3