From 0f936ec0e7606cb79434d94096b6e113a7ce78eb Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 15 Dec 2023 18:35:16 +0100 Subject: refactor(stories): migrate stories to CSF3 format --- .../description-list/description-list.stories.tsx | 400 +++++++++++++-------- src/components/atoms/lists/list/list.stories.tsx | 290 ++++++--------- 2 files changed, 377 insertions(+), 313 deletions(-) (limited to 'src/components/atoms/lists') diff --git a/src/components/atoms/lists/description-list/description-list.stories.tsx b/src/components/atoms/lists/description-list/description-list.stories.tsx index d051fcd..65efc28 100644 --- a/src/components/atoms/lists/description-list/description-list.stories.tsx +++ b/src/components/atoms/lists/description-list/description-list.stories.tsx @@ -1,150 +1,270 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import { Description } from './description'; import { DescriptionList } from './description-list'; import { Group } from './group'; import { Term } from './term'; -/** - * DescriptionList - Storybook Meta - */ -export default { - title: 'Atoms/Lists/DescriptionList', +const meta = { component: DescriptionList, + title: 'Atoms/Lists/Description List', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +const Default: Story = { + args: { + children: [ + A term, + A description of the term., + ], + }, +}; + +export const SingleTermSingleDescription: Story = { + args: { + ...Default.args, + }, +}; + +export const MultipleTermsSingleDescription: Story = { + args: { + ...Default.args, + children: [ + First term, + Second term, + Third term, + Description of the terms, + ], + }, +}; + +export const SingleTermMultipleDescriptions: Story = { + args: { + ...Default.args, + children: [ + A term, + + First description of the term + , + + Second description of the term + , + + Third description of the term + , + ], + }, +}; + +export const MultipleTermsMultipleDescriptions: Story = { + args: { + ...Default.args, + children: [ + First term, + + Description of the first term + , + Second term, + Alternative of second term, + + Description of the second term + , + Third term, + + First description of the third term + , + + Second description of the third term + , + ], + }, +}; + +export const GroupOfMultipleTermsMultipleDescriptions: Story = { + args: { + ...Default.args, + children: [ + + First term + Description of the first term + , + + Second term + Alternative of second term + Description of the second term + , + + Third term + First description of the third term + Second description of the third term + , + ], + }, +}; + +export const SpacingXXSWithoutGroup: Story = { + name: 'Spacing: Double extra-small (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: '2xs', + }, +}; + +export const SpacingXSWithoutGroup: Story = { + name: 'Spacing: Extra-small (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: 'xs', + }, +}; + +export const SpacingSMWithoutGroup: Story = { + name: 'Spacing: Small (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: 'sm', + }, +}; + +export const SpacingMDWithoutGroup: Story = { + name: 'Spacing: Medium (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: 'md', + }, +}; + +export const SpacingLGWithoutGroup: Story = { + name: 'Spacing: Large (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: 'lg', + }, +}; + +export const SpacingXLWithoutGroup: Story = { + name: 'Spacing: Extra-large (without group)', args: { - isInline: false, - }, - 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 = (args) => ( - -); - -/** - * Description List Stories - Single term, single description - */ -export const SingleTermSingleDescription = Template.bind({}); -SingleTermSingleDescription.args = { - children: ( - <> - A term - A description of the term. - - ), -}; - -/** - * Description List Stories - Multiple terms, single description - */ -export const MultipleTermsSingleDescription = Template.bind({}); -MultipleTermsSingleDescription.args = { - children: ( - <> - A first term - A second term - A third term - A description of the term. - - ), -}; - -/** - * Description List Stories - Single term, multiple descriptions - */ -export const SingleTermMultipleDescriptions = Template.bind({}); -SingleTermMultipleDescriptions.args = { - children: ( - <> - A term - A first description of the term. - A second description of the term. - A third description of the term. - - ), -}; - -/** - * Description List Stories - Multiple terms, multiple descriptions - */ -export const MultipleTermsMultipleDescriptions = Template.bind({}); -MultipleTermsMultipleDescriptions.args = { - children: ( - <> - A first term - A second term - A third term - A first description of the term. - A second description of the term. - A third description of the term. - - ), -}; - -/** - * Description List Stories - Group of terms & descriptions - */ -export const GroupOfTermsDescriptions = Template.bind({}); -GroupOfTermsDescriptions.args = { - children: ( - <> - + ...MultipleTermsMultipleDescriptions.args, + spacing: 'xl', + }, +}; + +export const SpacingXXLWithoutGroup: Story = { + name: 'Spacing: Double extra-large (without group)', + args: { + ...MultipleTermsMultipleDescriptions.args, + spacing: '2xl', + }, +}; + +export const SpacingXXSWithGroup: Story = { + name: 'Spacing: Double extra-small (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: '2xs', + }, +}; + +export const SpacingXSWithGroup: Story = { + name: 'Spacing: Extra-small (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: 'xs', + }, +}; + +export const SpacingSMWithGroup: Story = { + name: 'Spacing: Small (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: 'sm', + }, +}; + +export const SpacingMDWithGroup: Story = { + name: 'Spacing: Medium (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: 'md', + }, +}; + +export const SpacingLGWithGroup: Story = { + name: 'Spacing: Large (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: 'lg', + }, +}; + +export const SpacingXLWithGroup: Story = { + name: 'Spacing: Extra-large (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: 'xl', + }, +}; + +export const SpacingXXLWithGroup: Story = { + name: 'Spacing: Double extra-large (with group)', + args: { + ...GroupOfMultipleTermsMultipleDescriptions.args, + spacing: '2xl', + }, +}; + +export const InlinedWithoutGroups: Story = { + name: 'Alignment: inlined without groups', + args: { + ...Default.args, + children: [ + A term, + A description., + Another term, + Another description., + ], + isInline: true, + spacing: 'xs', + }, +}; + +export const InlinedWithGroups: Story = { + name: 'Alignment: inlined with groups', + args: { + ...Default.args, + children: [ + A term - A description of the term. - - + A description. + , + Another term - A description of the other term. - - - ), -}; - -/** - * Description List Stories - Inlined list of term and descriptions - */ -export const InlinedList = Template.bind({}); -InlinedList.args = { - children: ( - <> - A term: - A first description of the term. - A second description of the term. - A third description of the term. - - ), - isInline: true, - spacing: 'xs', -}; - -/** - * Description List Stories - Inlined group of terms & descriptions - */ -export const InlinedGroupOfTermsDescriptions = Template.bind({}); -InlinedGroupOfTermsDescriptions.args = { - children: ( - <> - - A term: - A description of the term. - - - Another term: - A description of the other term. - - - ), + Another description. + , + ], + isInline: true, + spacing: 'xs', + }, +}; + +export const InlinedWithInlinedGroups: Story = { + name: 'Alignment: inlined with inlined groups', + args: { + ...Default.args, + children: [ + + A term + A description. + , + + Another term + Another description. + , + ], + isInline: true, + spacing: 'xs', + }, }; diff --git a/src/components/atoms/lists/list/list.stories.tsx b/src/components/atoms/lists/list/list.stories.tsx index 538947a..6e7d254 100644 --- a/src/components/atoms/lists/list/list.stories.tsx +++ b/src/components/atoms/lists/list/list.stories.tsx @@ -1,196 +1,140 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { List, type ListProps } from './list'; +import type { Meta, StoryObj } from '@storybook/react'; +import { List } from './list'; import { ListItem } from './list-item'; -/** - * List - Storybook Meta - */ -export default { - title: 'Atoms/Lists', +const meta = { 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; + title: 'Atoms/Lists/List', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; -const Template: ComponentStory = < - O extends boolean, - H extends boolean, ->( - args: ListProps -) => ; +export const Default: Story = { + args: { + children: [ + Item 1, + Item 2, + Item 3, + ], + }, +}; -/** - * 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, +export const OrderedList: Story = { + args: { + ...Default.args, + isOrdered: 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, +export const UnorderedList: Story = { + args: { + ...Default.args, + isOrdered: false, + }, }; -/** - * 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, - ], +export const Nested: Story = { + args: { + ...Default.args, + children: [ + Item 1, + + Item 2 + + Nested item 1 + Nested item 2 + + Nested item 3 + + Deeper item 1 + Deeper item 2 + Deeper item 3 + + + + , + Item 3, + ], + isOrdered: false, + }, }; -const items = [ - { id: 'item-1', label: 'Item 1' }, - { id: 'item-2', label: 'Item 2' }, - { - id: 'item-3', - label: ( - <> - Item 3 - +export const HierarchicalList: Story = { + args: { + ...OrderedList.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, }, - { 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', +export const WithMarker: Story = { + args: { + ...Default.args, + hideMarker: false, + }, }; -/** - * List Stories - Inline and unordered list - */ -export const InlineUnordered = Template.bind({}); -InlineUnordered.args = { - children: items.map((item) => ( - {item.label} - )), - isInline: true, - spacing: 'sm', +export const WithoutMarker: Story = { + args: { + ...Default.args, + hideMarker: true, + }, }; -/** - * List Stories - Ordered list without marker - */ -export const OrderedHideMarker = Template.bind({}); -OrderedHideMarker.args = { - children: items.map((item) => ( - {item.label} - )), - hideMarker: true, - isOrdered: true, +export const InlineList: Story = { + args: { + ...Default.args, + children: [ + Item 1, + {'>'}, + Item 2, + {'>'}, + Item 3, + ], + hideMarker: true, + isInline: true, + spacing: 'xs', + }, }; -/** - * List Stories - Unordered list without marker - */ -export const UnorderedHideMarker = Template.bind({}); -UnorderedHideMarker.args = { - children: items.map((item) => ( - {item.label} - )), - hideMarker: true, +export const ListInInlineList: Story = { + args: { + ...InlineList.args, + children: [ + Item 1, + + Item 2 + + Nested item 1 + Nested item 2 + + , + Item 3, + ], + }, }; -- cgit v1.2.3