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 --- .../molecules/branding/branding.stories.tsx | 114 +-- .../buttons/back-to-top/back-to-top.stories.ts | 18 + .../buttons/back-to-top/back-to-top.stories.tsx | 58 -- .../buttons/help-button/help-button.stories.ts | 17 + .../buttons/help-button/help-button.stories.tsx | 50 -- src/components/molecules/card/card.stories.tsx | 871 +++++++++++---------- src/components/molecules/code/code.stories.ts | 140 ++++ src/components/molecules/code/code.stories.tsx | 192 ----- .../molecules/collapsible/collapsible.stories.ts | 31 + .../molecules/collapsible/collapsible.stories.tsx | 72 -- .../molecules/colophon/colophon.stories.tsx | 102 +-- .../molecules/copyright/copyright.stories.ts | 26 + .../molecules/copyright/copyright.stories.tsx | 65 -- .../labelled-field/labelled-field.stories.tsx | 386 ++++++--- .../forms/radio-group/radio-group.stories.tsx | 140 ++-- .../molecules/forms/switch/switch.stories.tsx | 99 ++- src/components/molecules/grid/grid.stories.tsx | 430 +++++----- .../images/flipping-logo/flipping-logo.stories.tsx | 47 +- .../meta-list/meta-item/meta-item.stories.tsx | 149 ++-- .../molecules/meta-list/meta-list.stories.tsx | 49 +- .../molecules/modals/modal/modal.stories.tsx | 337 ++++---- .../molecules/modals/tooltip/tooltip.stories.tsx | 44 +- .../molecules/nav/nav-item/nav-item.stories.tsx | 46 +- .../molecules/nav/nav-link/nav-link.stories.tsx | 202 ++--- .../molecules/nav/nav-list/nav-list.stories.tsx | 41 +- 25 files changed, 1745 insertions(+), 1981 deletions(-) create mode 100644 src/components/molecules/buttons/back-to-top/back-to-top.stories.ts delete mode 100644 src/components/molecules/buttons/back-to-top/back-to-top.stories.tsx create mode 100644 src/components/molecules/buttons/help-button/help-button.stories.ts delete mode 100644 src/components/molecules/buttons/help-button/help-button.stories.tsx create mode 100644 src/components/molecules/code/code.stories.ts delete mode 100644 src/components/molecules/code/code.stories.tsx create mode 100644 src/components/molecules/collapsible/collapsible.stories.ts delete mode 100644 src/components/molecules/collapsible/collapsible.stories.tsx create mode 100644 src/components/molecules/copyright/copyright.stories.ts delete mode 100644 src/components/molecules/copyright/copyright.stories.tsx (limited to 'src/components/molecules') diff --git a/src/components/molecules/branding/branding.stories.tsx b/src/components/molecules/branding/branding.stories.tsx index c2f216a..e0b8a16 100644 --- a/src/components/molecules/branding/branding.stories.tsx +++ b/src/components/molecules/branding/branding.stories.tsx @@ -1,92 +1,42 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import NextImage from 'next/image'; import { Heading } from '../../atoms'; import { Branding } from './branding'; -/** - * Branding - Storybook Meta - */ -export default { - title: 'Molecules/Branding', +const meta = { component: Branding, - args: {}, - argTypes: { - baseline: { - control: { - type: 'object', - }, - description: 'The brand baseline.', - type: { - name: 'function', - required: false, - }, - }, - logo: { - control: { - type: 'object', - }, - description: 'The brand logo.', - type: { - name: 'function', - required: true, - }, - }, - name: { - control: { - type: 'object', - }, - description: 'The brand name.', - type: { - name: 'function', - required: true, - }, - }, - url: { - control: { - type: 'string', - }, - description: 'The homepage url.', - type: { - name: 'string', - required: false, - }, - }, - }, -} as ComponentMeta; + title: 'Molecules/Branding', +} satisfies Meta; -const Template: ComponentStory = (args) => ( - -); +export default meta; -/** - * Branding Stories - Logo and title - */ -export const LogoAndTitle = Template.bind({}); -LogoAndTitle.args = { - logo: ( - - ), - name: Your brand name, +type Story = StoryObj; + +export const LogoAndTitle: Story = { + args: { + logo: ( + + ), + name: Your brand name, + }, }; -/** - * Branding Stories - Logo, title and baseline - */ -export const LogoTitleAndBaseline = Template.bind({}); -LogoTitleAndBaseline.args = { - baseline:
Your brand baseline if any
, - logo: ( - - ), - name: Your brand name, +export const LogoTitleAndBaseline: Story = { + args: { + baseline:
Your brand baseline if any
, + logo: ( + + ), + name: Your brand name, + }, }; diff --git a/src/components/molecules/buttons/back-to-top/back-to-top.stories.ts b/src/components/molecules/buttons/back-to-top/back-to-top.stories.ts new file mode 100644 index 0000000..dddfa18 --- /dev/null +++ b/src/components/molecules/buttons/back-to-top/back-to-top.stories.ts @@ -0,0 +1,18 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { BackToTop } from './back-to-top'; + +const meta = { + component: BackToTop, + title: 'Molecules/Buttons/BackToTop', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Example: Story = { + args: { + anchor: '#top', + label: 'Back to top', + }, +}; diff --git a/src/components/molecules/buttons/back-to-top/back-to-top.stories.tsx b/src/components/molecules/buttons/back-to-top/back-to-top.stories.tsx deleted file mode 100644 index 3abb59d..0000000 --- a/src/components/molecules/buttons/back-to-top/back-to-top.stories.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { BackToTop as BackToTopComponent } from './back-to-top'; - -/** - * BackToTop - Storybook Meta - */ -export default { - title: 'Molecules/Buttons', - component: BackToTopComponent, - argTypes: { - anchor: { - control: { - type: 'text', - }, - description: 'An element id with leading hashtag to use as anchor.', - type: { - name: 'string', - required: true, - }, - }, - className: { - control: { - type: 'text', - }, - description: 'Set additional classnames to the button wrapper.', - table: { - category: 'Styles', - }, - type: { - name: 'string', - required: false, - }, - }, - label: { - control: { - type: 'text', - }, - description: 'An accessible name for the button.', - type: { - name: 'string', - required: true, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ( - -); - -/** - * Buttons Stories - Back to top - */ -export const BackToTop = Template.bind({}); -BackToTop.args = { - anchor: '#top', - label: 'Back to top', -}; diff --git a/src/components/molecules/buttons/help-button/help-button.stories.ts b/src/components/molecules/buttons/help-button/help-button.stories.ts new file mode 100644 index 0000000..294959b --- /dev/null +++ b/src/components/molecules/buttons/help-button/help-button.stories.ts @@ -0,0 +1,17 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { HelpButton } from './help-button'; + +const meta = { + component: HelpButton, + title: 'Molecules/Buttons/Help', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Example: Story = { + args: { + label: 'Help', + }, +}; diff --git a/src/components/molecules/buttons/help-button/help-button.stories.tsx b/src/components/molecules/buttons/help-button/help-button.stories.tsx deleted file mode 100644 index 556dd74..0000000 --- a/src/components/molecules/buttons/help-button/help-button.stories.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { HelpButton as HelpButtonComponent } from './help-button'; - -/** - * HelpButton - Storybook Meta - */ -export default { - title: 'Molecules/Buttons', - component: HelpButtonComponent, - argTypes: { - className: { - control: { - type: 'text', - }, - description: 'Set additional classnames to the button wrapper.', - table: { - category: 'Options', - }, - type: { - name: 'string', - required: false, - }, - }, - onClick: { - control: { - type: null, - }, - description: 'A callback function to handle click on button.', - table: { - category: 'Events', - }, - type: { - name: 'function', - required: false, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ( - -); - -/** - * Help Button Stories - Level 1 - */ -export const HelpButton = Template.bind({}); -HelpButton.args = { - label: 'Help', -}; diff --git a/src/components/molecules/card/card.stories.tsx b/src/components/molecules/card/card.stories.tsx index 7cc2ad4..55a0609 100644 --- a/src/components/molecules/card/card.stories.tsx +++ b/src/components/molecules/card/card.stories.tsx @@ -1,8 +1,8 @@ -import type { ComponentMeta, Story } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import NextImage from 'next/image'; import { Button, ButtonLink, Link, Time } from '../../atoms'; import { MetaItem } from '../meta-list'; -import { Card, type CardProps } from './card'; +import { Card } from './card'; import { CardActions } from './card-actions'; import { CardBody } from './card-body'; import { CardCover } from './card-cover'; @@ -11,228 +11,138 @@ import { CardHeader } from './card-header'; import { CardMeta } from './card-meta'; import { CardTitle } from './card-title'; -/** - * Card - Storybook Meta - */ -export default { - title: 'Molecules/Card', +const meta = { component: Card, - argTypes: {}, -} as ComponentMeta; - -const Template: Story> = < - T extends string | undefined, ->( - args: CardProps -) => ; + title: 'Molecules/Card', +} satisfies Meta; -/** - * Card Stories - Default - */ -export const Default = Template.bind({}); -Default.args = { - children: 'The card contents.', -}; +export default meta; -/** - * Card Stories - AsLink - */ -export const AsLink = Template.bind({}); -AsLink.args = { - 'aria-label': 'Learn more about this card', - children: 'The card contents.', - linkTo: '#card', -}; +type Story = StoryObj; -export const HeaderCover = Template.bind({}); -HeaderCover.args = { - children: , - cover: ( - - - - ), +export const Default: Story = { + args: { + children: 'The card contents.', + }, }; -export const HeaderTitle = Template.bind({}); -HeaderTitle.args = { - children: ( - - The card title - - ), +export const AsLink: Story = { + args: { + 'aria-label': 'Learn more about this card', + children: 'The card contents.', + linkTo: '#card', + }, }; -export const HeaderMeta = Template.bind({}); -HeaderMeta.args = { - children: ( - - - - } +export const HeaderCover: Story = { + args: { + children: , + cover: ( + + - - - ), + + ), + }, }; -export const BodyContents = Template.bind({}); -BodyContents.args = { - children: The card contents, +export const HeaderTitle: Story = { + args: { + children: ( + + The card title + + ), + }, }; -export const FooterActions = Template.bind({}); -FooterActions.args = { - children: ( - - - Read more - - - - ), +export const HeaderMeta: Story = { + args: { + children: ( + + + + } + /> + + + ), + }, }; -export const FooterMeta = Template.bind({}); -FooterMeta.args = { - children: , - meta: ( - - Category 1 }, - { id: 'cat-2', value: Category 2 }, - ]} - /> - - - ), +export const BodyContents: Story = { + args: { + children: The card contents, + }, }; -export const CompositionCoverTitle = Template.bind({}); -CompositionCoverTitle.args = { - children: ( - - The card title - - ), - cover: ( - - - - ), +export const FooterActions: Story = { + args: { + children: ( + + + Read more + + + + ), + }, }; -export const CompositionTitleMeta = Template.bind({}); -CompositionTitleMeta.args = { - children: ( - - The card title - - +export const FooterMeta: Story = { + args: { + children: , + meta: ( + } + label="Categories:" + value={[ + { id: 'cat-1', value: Category 1 }, + { id: 'cat-2', value: Category 2 }, + ]} /> - - - ), -}; - -export const CompositionCoverTitleMeta = Template.bind({}); -CompositionCoverTitleMeta.args = { - children: ( - - The card title - - } + label="Tags:" + value={[ + { id: 'tag-1', value: 'Tag 1' }, + { id: 'tag-2', value: 'Tag 2' }, + { id: 'tag-3', value: 'Tag 3' }, + ]} /> - - ), - cover: ( - - - - ), -}; - -export const CompositionTitleBody = Template.bind({}); -CompositionTitleBody.args = { - children: ( - <> - - The card title - - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - ), + ), + }, }; -export const CompositionCoverTitleBody = Template.bind({}); -CompositionCoverTitleBody.args = { - children: ( - <> +export const CompositionCoverTitle: Story = { + args: { + children: ( The card title - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - ), - cover: ( - - - - ), + ), + cover: ( + + + + ), + }, }; -export const CompositionTitleMetaBody = Template.bind({}); -CompositionTitleMetaBody.args = { - children: ( - <> +export const CompositionTitleMeta: Story = { + args: { + children: ( The card title @@ -243,20 +153,13 @@ CompositionTitleMetaBody.args = { /> - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - ), + ), + }, }; -export const CompositionCoverTitleMetaBody = Template.bind({}); -CompositionCoverTitleMetaBody.args = { - children: ( - <> +export const CompositionCoverTitleMeta: Story = { + args: { + children: ( The card title @@ -267,242 +170,348 @@ CompositionCoverTitleMetaBody.args = { /> - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - ), - cover: ( - - - - ), + ), + cover: ( + + + + ), + }, }; -export const CompositionTitleActions = Template.bind({}); -CompositionTitleActions.args = { - children: ( - <> - - The card title - - - - Read more - - - - - ), +export const CompositionTitleBody: Story = { + args: { + children: ( + <> + + The card title + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + ), + }, }; -export const CompositionCoverTitleActions = Template.bind({}); -CompositionCoverTitleActions.args = { - children: ( - <> - - The card title - - - - Read more - - - - - ), - cover: ( - - - - ), +export const CompositionCoverTitleBody: Story = { + args: { + children: ( + <> + + The card title + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + ), + cover: ( + + + + ), + }, }; -export const CompositionTitleBodyActions = Template.bind({}); -CompositionTitleBodyActions.args = { - children: ( - <> - - The card title - - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - - Read more - - - - - ), +export const CompositionTitleMetaBody: Story = { + args: { + children: ( + <> + + The card title + + + } + /> + + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + ), + }, }; -export const CompositionTitleBodyActionsMeta = Template.bind({}); -CompositionTitleBodyActionsMeta.args = { - children: ( - <> - - The card title - - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - - Read more - - - - - ), - meta: ( - - Category 1 }, - { id: 'cat-2', value: Category 2 }, - ]} - /> - - - ), +export const CompositionCoverTitleMetaBody: Story = { + args: { + children: ( + <> + + The card title + + + } + /> + + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + ), + cover: ( + + + + ), + }, }; -export const CompositionCoverTitleBodyActionsMeta = Template.bind({}); -CompositionCoverTitleBodyActionsMeta.args = { - children: ( - <> - - The card title - - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - - Read more - - - - - ), - cover: ( - - - - ), - meta: ( - - Category 1 }, - { id: 'cat-2', value: Category 2 }, - ]} - /> - - - ), +export const CompositionTitleActions: Story = { + args: { + children: ( + <> + + The card title + + + + Read more + + + + + ), + }, }; -export const CompositionAllContents = Template.bind({}); -CompositionAllContents.args = { - children: ( - <> - - The card title - - - } - /> - - - - Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et - necessitatibus esse laudantium sequi ad. Et est quas pariatur facere - velit veritatis nihil. Ratione aperiam omnis quia ut asperiores tenetur - dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. - - - - Read more - - - - - ), - cover: ( - - - - ), - meta: ( - - Category 1 }, - { id: 'cat-2', value: Category 2 }, - ]} - /> - - - ), +export const CompositionCoverTitleActions: Story = { + args: { + children: ( + <> + + The card title + + + + Read more + + + + + ), + cover: ( + + + + ), + }, +}; + +export const CompositionTitleBodyActions: Story = { + args: { + children: ( + <> + + The card title + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + + Read more + + + + + ), + }, +}; + +export const CompositionTitleBodyActionsMeta: Story = { + args: { + children: ( + <> + + The card title + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + + Read more + + + + + ), + meta: ( + + Category 1 }, + { id: 'cat-2', value: Category 2 }, + ]} + /> + + + ), + }, +}; + +export const CompositionCoverTitleBodyActionsMeta: Story = { + args: { + children: ( + <> + + The card title + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + + Read more + + + + + ), + cover: ( + + + + ), + meta: ( + + Category 1 }, + { id: 'cat-2', value: Category 2 }, + ]} + /> + + + ), + }, +}; + +export const CompositionAllContents: Story = { + args: { + children: ( + <> + + The card title + + + } + /> + + + + Nihil magnam tempora voluptatem. Reiciendis ut cum vel. Odit et + necessitatibus esse laudantium sequi ad. Et est quas pariatur facere + velit veritatis nihil. Ratione aperiam omnis quia ut asperiores + tenetur dolores veniam. Nostrum est ullam aliquam aliquid expedita ea. + + + + Read more + + + + + ), + cover: ( + + + + ), + meta: ( + + Category 1 }, + { id: 'cat-2', value: Category 2 }, + ]} + /> + + + ), + }, }; diff --git a/src/components/molecules/code/code.stories.ts b/src/components/molecules/code/code.stories.ts new file mode 100644 index 0000000..38a9ef8 --- /dev/null +++ b/src/components/molecules/code/code.stories.ts @@ -0,0 +1,140 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { Code } from './code'; + +const meta = { + component: Code, + title: 'Molecules/Code', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +const javascriptCodeSample = ` +const foo = () => { + return 'bar'; +} +`; + +export const CodeSample: Story = { + args: { + children: javascriptCodeSample, + language: 'javascript', + }, +}; + +/** + * @todo Find a way to make it working: line-highlight plugin is not loaded. + */ +export const Highlighting: Story = { + args: { + children: javascriptCodeSample, + highlight: '3', + language: 'javascript', + }, +}; + +// cSpell:ignore xinitrc +const commandLineCode = ` +ls -lah +#output#drwxr-x---+ 42 armand armand 4,0K 17 april 11:15 . +#output#drwxr-xr-x 4 root root 4,0K 30 mai 2021 .. +#output#-rw-r--r-- 1 armand armand 2,0K 21 jul. 2021 .xinitrc +`; + +export const CommandLine: Story = { + args: { + children: commandLineCode, + cmdOutputFilter: '#output#', + isCmd: true, + language: 'bash', + }, +}; + +// cSpell:ignore lcov +const treeSample = ` +. +├── bin +│ └── deploy.sh +├── CHANGELOG.md +├── commitlint.config.cjs +├── coverage +│ ├── clover.xml +│ ├── coverage-final.json +│ ├── lcov-report +│ └── lcov.info +├── cspell.json +├── cypress.config.js +├── docker-compose.yml +├── Dockerfile +├── jest.config.js +├── jest.setup.js +├── lang +│ ├── en.json +│ └── fr.json +├── LICENSE +├── lint-staged.config.js +├── mdx.d.ts +├── next-env.d.ts +├── next-sitemap.config.cjs +├── next.config.js +├── package.json +├── public +│ ├── apple-touch-icon.png +│ ├── armand-philippot.jpg +│ ├── favicon.ico +│ ├── icon-192.png +│ ├── icon-512.png +│ ├── icon.svg +│ ├── manifest.webmanifest +│ ├── prism +│ ├── projects +│ ├── robots.txt +│ ├── sitemap-0.xml +│ ├── sitemap.xml +│ └── vercel.svg +├── README.md +├── src +│ ├── assets +│ ├── components +│ ├── content +│ ├── i18n +│ ├── pages +│ ├── services +│ ├── styles +│ ├── types +│ └── utils +├── tests +│ ├── cypress +│ ├── jest +│ └── utils +├── tsconfig.eslint.json +├── tsconfig.json +├── tsconfig.tsbuildinfo +└── yarn.lock`; + +/** + * @todo Find a way to make it working: treeview plugin is not loaded. + */ +export const TreeView: Story = { + args: { + children: treeSample, + language: 'treeview', + }, +}; + +const diffSample = ` +--- file1.js 2023-10-13 19:17:05.540644084 +0200 ++++ file2.js 2023-10-13 19:17:15.310564281 +0200 +@@ -1,2 +1 @@ +-let foo = bar.baz([1, 2, 3]); +-foo = foo + 1; ++const foo = bar.baz([1, 2, 3]) + 1;`; + +export const Diff: Story = { + args: { + children: diffSample, + isDiff: true, + language: 'diff', + }, +}; diff --git a/src/components/molecules/code/code.stories.tsx b/src/components/molecules/code/code.stories.tsx deleted file mode 100644 index 1127839..0000000 --- a/src/components/molecules/code/code.stories.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { Code } from './code'; - -/** - * Code - Storybook Meta - */ -export default { - title: 'Molecules/Code', - component: Code, - argTypes: { - children: { - control: { - type: 'text', - }, - description: 'The code sample.', - type: { - name: 'string', - required: true, - }, - }, - filterPattern: { - control: { - type: 'text', - }, - description: 'Define a pattern to filter the command line output.', - table: { - category: 'Options', - }, - type: { - name: 'string', - required: false, - }, - }, - language: { - control: { - type: 'text', - }, - description: 'The code sample language.', - type: { - name: 'string', - required: true, - }, - }, - plugins: { - description: 'An array of Prism plugins to activate.', - type: { - name: 'object', - required: false, - value: {}, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ; - -const javascriptCodeSample = ` -const foo = () => { - return 'bar'; -} -`; - -/** - * Code Stories - Code sample - */ -export const CodeSample = Template.bind({}); -CodeSample.args = { - children: javascriptCodeSample, - language: 'javascript', -}; - -/** - * Code Stories - Highlighting - * - * @todo Find a way to make it working: line-highlight plugin is not loaded. - */ -export const Highlighting = Template.bind({}); -Highlighting.args = { - children: javascriptCodeSample, - highlight: '3', - language: 'javascript', -}; - -// cSpell:ignore xinitrc -const commandLineCode = ` -ls -lah -#output#drwxr-x---+ 42 armand armand 4,0K 17 april 11:15 . -#output#drwxr-xr-x 4 root root 4,0K 30 mai 2021 .. -#output#-rw-r--r-- 1 armand armand 2,0K 21 jul. 2021 .xinitrc -`; - -/** - * Code Stories - Command Line - */ -export const CommandLine = Template.bind({}); -CommandLine.args = { - children: commandLineCode, - cmdOutputFilter: '#output#', - isCmd: true, - language: 'bash', -}; - -// cSpell:ignore lcov -const treeSample = ` -. -├── bin -│ └── deploy.sh -├── CHANGELOG.md -├── commitlint.config.cjs -├── coverage -│ ├── clover.xml -│ ├── coverage-final.json -│ ├── lcov-report -│ └── lcov.info -├── cspell.json -├── cypress.config.js -├── docker-compose.yml -├── Dockerfile -├── jest.config.js -├── jest.setup.js -├── lang -│ ├── en.json -│ └── fr.json -├── LICENSE -├── lint-staged.config.js -├── mdx.d.ts -├── next-env.d.ts -├── next-sitemap.config.cjs -├── next.config.js -├── package.json -├── public -│ ├── apple-touch-icon.png -│ ├── armand-philippot.jpg -│ ├── favicon.ico -│ ├── icon-192.png -│ ├── icon-512.png -│ ├── icon.svg -│ ├── manifest.webmanifest -│ ├── prism -│ ├── projects -│ ├── robots.txt -│ ├── sitemap-0.xml -│ ├── sitemap.xml -│ └── vercel.svg -├── README.md -├── src -│ ├── assets -│ ├── components -│ ├── content -│ ├── i18n -│ ├── pages -│ ├── services -│ ├── styles -│ ├── types -│ └── utils -├── tests -│ ├── cypress -│ ├── jest -│ └── utils -├── tsconfig.eslint.json -├── tsconfig.json -├── tsconfig.tsbuildinfo -└── yarn.lock`; - -/** - * Code Stories - Tree view - * - * @todo Find a way to make it working: treeview plugin is not loaded. - */ -export const TreeView = Template.bind({}); -TreeView.args = { - children: treeSample, - language: 'treeview', -}; - -const diffSample = ` ---- file1.js 2023-10-13 19:17:05.540644084 +0200 -+++ file2.js 2023-10-13 19:17:15.310564281 +0200 -@@ -1,2 +1 @@ --let foo = bar.baz([1, 2, 3]); --foo = foo + 1; -+const foo = bar.baz([1, 2, 3]) + 1;`; - -/** - * Code Stories - Diff - */ -export const Diff = Template.bind({}); -Diff.args = { - children: diffSample, - isDiff: true, - language: 'diff', -}; diff --git a/src/components/molecules/collapsible/collapsible.stories.ts b/src/components/molecules/collapsible/collapsible.stories.ts new file mode 100644 index 0000000..e869306 --- /dev/null +++ b/src/components/molecules/collapsible/collapsible.stories.ts @@ -0,0 +1,31 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { Collapsible } from './collapsible'; + +const meta = { + component: Collapsible, + title: 'Molecules/Collapsible', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +const heading = 'Your title'; +const body = + 'Eius et eum ex voluptas laboriosam aliquid quas necessitatibus. Molestiae eius voluptatem qui voluptas eaque et totam. Ut ipsum ea sit. Quos molestiae id est consequatur. Suscipit illo at. Omnis non suscipit. Qui itaque laboriosam quos ut est laudantium. Iusto recusandae excepturi quia labore voluptatem quod recusandae. Quod ducimus ut rem dolore et.'; + +export const Collapsed: Story = { + args: { + children: body, + heading, + isCollapsed: true, + }, +}; + +export const Expanded: Story = { + args: { + children: body, + heading, + isCollapsed: false, + }, +}; diff --git a/src/components/molecules/collapsible/collapsible.stories.tsx b/src/components/molecules/collapsible/collapsible.stories.tsx deleted file mode 100644 index 7cac64d..0000000 --- a/src/components/molecules/collapsible/collapsible.stories.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { Heading } from '../../atoms'; -import { Collapsible } from './collapsible'; - -/** - * HeadingButton - Storybook Meta - */ -export default { - title: 'Molecules/Collapsible', - component: Collapsible, - argTypes: { - heading: { - control: { - type: 'text', - }, - description: 'Define the collapsible heading.', - type: { - name: 'function', - required: true, - }, - }, - isCollapsed: { - control: { - type: 'boolean', - }, - description: 'Define if the component should be collapsed or expanded.', - table: { - category: 'Options', - defaultValue: { summary: false }, - }, - type: { - name: 'boolean', - required: true, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = ({ heading, ...args }) => ( - - {heading} - - } - /> -); - -const heading = 'Your title'; -const body = - 'Eius et eum ex voluptas laboriosam aliquid quas necessitatibus. Molestiae eius voluptatem qui voluptas eaque et totam. Ut ipsum ea sit. Quos molestiae id est consequatur. Suscipit illo at. Omnis non suscipit. Qui itaque laboriosam quos ut est laudantium. Iusto recusandae excepturi quia labore voluptatem quod recusandae. Quod ducimus ut rem dolore et.'; - -/** - * Collapsible Stories - Collapsed - */ -export const Collapsed = Template.bind({}); -Collapsed.args = { - children: body, - heading, - isCollapsed: true, -}; - -/** - * Collapsible Stories - Expanded - */ -export const Expanded = Template.bind({}); -Expanded.args = { - children: body, - heading, - isCollapsed: false, -}; diff --git a/src/components/molecules/colophon/colophon.stories.tsx b/src/components/molecules/colophon/colophon.stories.tsx index 7baecad..83db4f4 100644 --- a/src/components/molecules/colophon/colophon.stories.tsx +++ b/src/components/molecules/colophon/colophon.stories.tsx @@ -1,83 +1,47 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import { Icon } from '../../atoms'; import { Copyright } from '../copyright'; import { Colophon } from './colophon'; -/** - * Colophon - Storybook Meta - */ -export default { - title: 'Molecules/Colophon', +const meta = { component: Colophon, - argTypes: { - copyright: { - description: 'The website copyright.', - type: { - name: 'object', - required: true, - value: {}, - }, - }, - links: { - control: { - type: 'object', - }, - description: - 'Adds links to the colophon (a Legal Notice link for example).', - table: { - category: 'Options', - }, - type: { - name: 'object', - required: false, - value: {}, - }, - }, - }, -} as ComponentMeta; + title: 'Molecules/Colophon', +} satisfies Meta; + +export default meta; -const Template: ComponentStory = (args) => ( - -); +type Story = StoryObj; -/** - * Colophon Stories - Default - */ -export const Default = Template.bind({}); -Default.args = { - copyright: , +export const Default: Story = { + args: { + copyright: , + }, }; -/** - * Colophon Stories - WithLicense - */ -export const WithLicense = Template.bind({}); -WithLicense.args = { - copyright: , - license: , +export const WithLicense: Story = { + args: { + copyright: , + license: , + }, }; -/** - * Colophon Stories - WithLinks - */ -export const WithLinks = Template.bind({}); -WithLinks.args = { - copyright: , - links: [ - { href: '#legal', id: 'item-1', label: 'Legal notice' }, - { href: '#credits', id: 'item-2', label: 'Credits' }, - ], +export const WithLinks: Story = { + args: { + copyright: , + links: [ + { href: '#legal', id: 'item-1', label: 'Legal notice' }, + { href: '#credits', id: 'item-2', label: 'Credits' }, + ], + }, }; -/** - * Colophon Stories - WithLicenseAndLinks - */ -export const WithLicenseAndLinks = Template.bind({}); -WithLicenseAndLinks.args = { - copyright: , - license: , - links: [ - { href: '#legal', id: 'item-1', label: 'Legal notice' }, - { href: '#credits', id: 'item-2', label: 'Credits' }, - ], +export const WithLicenseAndLinks: Story = { + args: { + copyright: , + license: , + links: [ + { href: '#legal', id: 'item-1', label: 'Legal notice' }, + { href: '#credits', id: 'item-2', label: 'Credits' }, + ], + }, }; diff --git a/src/components/molecules/copyright/copyright.stories.ts b/src/components/molecules/copyright/copyright.stories.ts new file mode 100644 index 0000000..6ef32c9 --- /dev/null +++ b/src/components/molecules/copyright/copyright.stories.ts @@ -0,0 +1,26 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { Copyright } from './copyright'; + +const meta = { + component: Copyright, + title: 'Molecules/Copyright', +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + from: '2012', + owner: 'Your brand', + }, +}; + +export const WithEndYear: Story = { + args: { + from: '2012', + owner: 'Your brand', + to: '2023', + }, +}; diff --git a/src/components/molecules/copyright/copyright.stories.tsx b/src/components/molecules/copyright/copyright.stories.tsx deleted file mode 100644 index 58a82e9..0000000 --- a/src/components/molecules/copyright/copyright.stories.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { Copyright } from './copyright'; - -/** - * Copyright - Storybook Meta - */ -export default { - title: 'Molecules/Copyright', - component: Copyright, - argTypes: { - from: { - control: { - type: 'text', - }, - description: 'The copyright start date.', - type: { - name: 'string', - required: true, - }, - }, - owner: { - control: { - type: 'text', - }, - description: 'The copyright owner.', - type: { - name: 'string', - required: true, - }, - }, - to: { - control: { - type: 'text', - }, - description: 'The copyright end date.', - type: { - name: 'string', - required: false, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = (args) => ( - -); - -/** - * Copyright Stories - Default - */ -export const Default = Template.bind({}); -Default.args = { - from: '2012', - owner: 'Your brand', -}; - -/** - * Copyright Stories - WithEndYear - */ -export const WithEndYear = Template.bind({}); -WithEndYear.args = { - from: '2012', - owner: 'Your brand', - to: '2023', -}; diff --git a/src/components/molecules/forms/labelled-field/labelled-field.stories.tsx b/src/components/molecules/forms/labelled-field/labelled-field.stories.tsx index 1d1af70..47ded7b 100644 --- a/src/components/molecules/forms/labelled-field/labelled-field.stories.tsx +++ b/src/components/molecules/forms/labelled-field/labelled-field.stories.tsx @@ -1,130 +1,270 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { type ChangeEvent, useState, useCallback } from 'react'; -import { Input, Label } from '../../../atoms'; +import type { Meta, StoryObj } from '@storybook/react'; +import { type ChangeEvent, useCallback, useState } from 'react'; +import { + Checkbox, + type CheckboxProps, + Radio, + type RadioProps, + Input, + type InputProps, + type TextAreaProps, + TextArea, + Label, +} from '../../../atoms'; +import { ControlledSelect } from '../../../atoms/forms/fields/select/select.stories'; import { LabelledField } from './labelled-field'; -/** - * LabelledField - Storybook Meta - */ -export default { - title: 'Molecules/Forms/Field', +const meta = { + title: 'Molecules/Forms/Labelled Field', component: LabelledField, - argTypes: { - className: { - control: { - type: 'text', - }, - description: 'Set additional classnames to the field.', - table: { - category: 'Styles', - }, - type: { - name: 'string', - required: false, - }, - }, - field: { - control: { - type: null, - }, - description: 'A component: Checkbox, Input, Select, Radio or TextArea.', - type: { - name: 'function', - required: true, - }, - }, - label: { - control: { - type: null, - }, - description: 'A Label component.', - type: { - name: 'function', - required: true, - }, - }, - isInline: { - control: { - type: 'boolean', - }, - description: 'Should the label and the field be inlined?', - table: { - category: 'Options', - defaultValue: { summary: false }, - }, - type: { - name: 'boolean', - required: false, - }, - }, - isReversedOrder: { - control: { - type: 'boolean', - }, - description: 'Should the label and the field be reversed?', - table: { - category: 'Options', - defaultValue: { summary: false }, - }, - type: { - name: 'boolean', - required: false, - }, - }, - }, -} as ComponentMeta; - -const Template: ComponentStory = ({ ...args }) => { - const id = 'sunt'; - const [value, setValue] = useState(''); - const updateValue = useCallback((e: ChangeEvent) => { +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +const ControlledCheckbox = ({ + isChecked: checked = false, + ...args +}: CheckboxProps) => { + const [isChecked, setIsChecked] = useState(checked); + + const handleChange = useCallback((e: ChangeEvent) => { + setIsChecked(e.target.checked); + }, []); + + return ; +}; + +const ControlledInput = ({ value: defaultValue, ...args }: InputProps) => { + const [value, setValue] = useState(defaultValue); + + const handleChange = useCallback((e: ChangeEvent) => { + setValue(e.target.value); + }, []); + + return ; +}; + +const ControlledRadio = ({ + isChecked: checked = false, + ...args +}: RadioProps) => { + const [isChecked, setIsChecked] = useState(checked); + + const handleChange = useCallback((e: ChangeEvent) => { + setIsChecked(e.target.checked); + }, []); + + return ; +}; + +const ControlledTextArea = ({ + value: defaultValue, + ...args +}: TextAreaProps) => { + const [value, setValue] = useState(defaultValue); + + const handleChange = useCallback((e: ChangeEvent) => { setValue(e.target.value); }, []); - return ( - - } - label={} - /> - ); -}; - -/** - * Labelled Field Stories - Left - */ -export const Left = Template.bind({}); -Left.args = { - isInline: true, -}; - -/** - * Labelled Field Stories - Right - */ -export const Right = Template.bind({}); -Right.args = { - isInline: true, - isReversedOrder: true, -}; - -/** - * Labelled Field Stories - Top - */ -export const Top = Template.bind({}); -Top.args = {}; - -/** - * Labelled Field Stories - Bottom - */ -export const Bottom = Template.bind({}); -Bottom.args = { - isReversedOrder: true, + return