diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-12-15 18:35:16 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-12-15 18:49:49 +0100 |
| commit | 0f936ec0e7606cb79434d94096b6e113a7ce78eb (patch) | |
| tree | 465ec7f66ac9459be6a18ac046e10357814c7b92 /src/components/atoms/links | |
| parent | 4e4d2eb25365be861e19f9756cf334ba2faa6911 (diff) | |
refactor(stories): migrate stories to CSF3 format
Diffstat (limited to 'src/components/atoms/links')
5 files changed, 166 insertions, 338 deletions
diff --git a/src/components/atoms/links/link/link.stories.tsx b/src/components/atoms/links/link/link.stories.tsx index 0a6a6c5..30b0eab 100644 --- a/src/components/atoms/links/link/link.stories.tsx +++ b/src/components/atoms/links/link/link.stories.tsx @@ -1,178 +1,84 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import { Link } from './link'; -/** - * Link - Storybook Meta - */ -export default { - title: 'Atoms/Links/Link', +const meta = { component: Link, - argTypes: { - children: { - control: { - type: 'text', - }, - description: 'The link body.', - type: { - name: 'string', - required: true, - }, - }, - className: { - control: { - type: 'text', - }, - description: 'Set additional classnames.', - table: { - category: 'Styles', - }, - type: { - name: 'string', - required: false, - }, - }, - href: { - control: { - type: 'text', - }, - description: 'The link target.', - type: { - name: 'string', - required: true, - }, - }, - isDownload: { - control: { - type: 'boolean', - }, - description: 'Determine if the link purpose is to download a file.', - table: { - category: 'Options', - defaultValue: { summary: false }, - }, - type: { - name: 'boolean', - required: false, - }, - }, - isExternal: { - control: { - type: 'boolean', - }, - description: 'Determine if the link is external of the current website.', - table: { - category: 'Options', - defaultValue: { summary: false }, - }, - type: { - name: 'boolean', - required: false, - }, - }, - lang: { - control: { - type: 'text', - }, - table: { - category: 'Options', - }, - description: 'The target language as code language.', - type: { - name: 'string', - required: false, - }, - }, - }, -} as ComponentMeta<typeof Link>; + title: 'Atoms/Links', +} satisfies Meta<typeof Link>; + +export default meta; -const Template: ComponentStory<typeof Link> = (args) => <Link {...args} />; +type Story = StoryObj<typeof meta>; -/** - * Links Stories - Default - */ -export const Default = Template.bind({}); -Default.args = { - children: 'A link', - href: '#', +export const Default: Story = { + args: { + children: 'A link', + href: '#link', + }, }; -/** - * Links Stories - Download - */ -export const DownloadLink = Template.bind({}); -DownloadLink.args = { - children: 'A link to a file', - href: '#', - isDownload: true, - isExternal: false, +export const WithLang: Story = { + args: { + children: 'Github repository', + href: 'https://github.com/ArmandPhilippot/apcom', + lang: 'en', + }, + render: (args) => ( + <> + Go to the <Link {...args} />. + </> + ), }; -/** - * Links Stories - Download link with lang - */ -export const DownloadLinkWithLang = Template.bind({}); -DownloadLinkWithLang.args = { - children: 'A link to a file', - href: '#', - isDownload: true, - isExternal: false, - lang: 'en', +export const DownloadLink: Story = { + args: { + children: 'Download the file', + href: '#file', + isDownload: true, + }, }; -/** - * Links Stories - External - */ -export const ExternalLink = Template.bind({}); -ExternalLink.args = { - children: 'A link', - href: '#', - isDownload: false, - isExternal: true, +export const DownloadLinkWithLang: Story = { + args: { + children: 'Download the file', + href: '#file', + isDownload: true, + lang: 'en', + }, }; -/** - * Links Stories - External download link - */ -export const ExternalDownload = Template.bind({}); -ExternalDownload.args = { - children: 'A link', - href: '#', - isDownload: true, - isExternal: true, +export const ExternalLink: Story = { + args: { + children: 'Go to the Github repository', + href: 'https://github.com/ArmandPhilippot/apcom', + isExternal: true, + }, }; -/** - * Links Stories - External link with Lang - */ -export const ExternalLinkWithLang = Template.bind({}); -ExternalLinkWithLang.args = { - children: 'A link', - href: '#', - isDownload: false, - isExternal: true, - lang: 'en', +export const ExternalLinkWithLang: Story = { + args: { + children: 'Go to the Github repository', + href: 'https://github.com/ArmandPhilippot/apcom', + isExternal: true, + lang: 'en', + }, }; -/** - * Links Stories - External download with lang - */ -export const ExternalDownloadWithLang = Template.bind({}); -ExternalDownloadWithLang.args = { - children: 'A link', - href: '#', - isDownload: true, - isExternal: true, - lang: 'en', +export const ExternalDownloadLink: Story = { + args: { + children: 'Download the file', + href: '#file', + isDownload: true, + isExternal: true, + }, }; -/** - * Links Stories - With Lang - */ -export const LinkLang = Template.bind({}); -LinkLang.args = { - children: 'A link', - href: '#', - isDownload: false, - isExternal: false, - lang: 'en', +export const ExternalDownloadLinkWithLang: Story = { + args: { + children: 'Download the file', + href: '#file', + isDownload: true, + isExternal: true, + lang: 'en', + }, }; diff --git a/src/components/atoms/links/sharing-link/sharing-link.stories.ts b/src/components/atoms/links/sharing-link/sharing-link.stories.ts new file mode 100644 index 0000000..53d2507 --- /dev/null +++ b/src/components/atoms/links/sharing-link/sharing-link.stories.ts @@ -0,0 +1,59 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { SharingLink } from './sharing-link'; + +const meta = { + component: SharingLink, + title: 'Atoms/Links/Share', +} satisfies Meta<typeof SharingLink>; + +export default meta; + +type Story = StoryObj<typeof meta>; + +export const Diaspora: Story = { + args: { + label: 'Share on Diaspora', + medium: 'diaspora', + url: '#diaspora', + }, +}; + +export const Email: Story = { + args: { + label: 'Share by Email', + medium: 'email', + url: '#email', + }, +}; + +export const Facebook: Story = { + args: { + label: 'Share on Facebook', + medium: 'facebook', + url: '#facebook', + }, +}; + +export const JournalDuHacker: Story = { + args: { + label: 'Share on Journal du Hacker', + medium: 'journal-du-hacker', + url: '#journal-du-hacker', + }, +}; + +export const LinkedIn: Story = { + args: { + label: 'Share on LinkedIn', + medium: 'linkedin', + url: '#linkedin', + }, +}; + +export const Twitter: Story = { + args: { + label: 'Share on Twitter', + medium: 'twitter', + url: '#twitter', + }, +}; diff --git a/src/components/atoms/links/sharing-link/sharing-link.stories.tsx b/src/components/atoms/links/sharing-link/sharing-link.stories.tsx deleted file mode 100644 index 932d468..0000000 --- a/src/components/atoms/links/sharing-link/sharing-link.stories.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { SharingLink } from './sharing-link'; - -/** - * SharingLink - Storybook Meta - */ -export default { - title: 'Atoms/Links/Sharing', - component: SharingLink, - argTypes: { - medium: { - control: { - type: 'select', - }, - description: 'The sharing medium.', - options: [ - 'diaspora', - 'email', - 'facebook', - 'journal-du-hacker', - 'linkedin', - 'twitter', - ], - type: { - name: 'string', - required: true, - }, - }, - label: { - control: { - type: 'text', - }, - description: 'An accessible label that describe the link..', - type: { - name: 'string', - required: true, - }, - }, - url: { - control: { - type: 'text', - }, - description: 'The sharing url.', - type: { - name: 'string', - required: true, - }, - }, - }, -} as ComponentMeta<typeof SharingLink>; - -const Template: ComponentStory<typeof SharingLink> = (args) => ( - <SharingLink {...args} /> -); - -/** - * Sharing Link Stories - Diaspora - */ -export const Diaspora = Template.bind({}); -Diaspora.args = { - label: 'Share on Diaspora', - medium: 'diaspora', - url: '#', -}; - -/** - * Sharing Link Stories - Email - */ -export const Email = Template.bind({}); -Email.args = { - label: 'Share by Email', - medium: 'email', - url: '#', -}; - -/** - * Sharing Link Stories - Facebook - */ -export const Facebook = Template.bind({}); -Facebook.args = { - label: 'Share on Facebook', - medium: 'facebook', - url: '#', -}; - -/** - * Sharing Link Stories - Journal du Hacker - */ -export const JournalDuHacker = Template.bind({}); -JournalDuHacker.args = { - label: 'Share on Journal du Hacker', - medium: 'journal-du-hacker', - url: '#', -}; - -/** - * Sharing Link Stories - LinkedIn - */ -export const LinkedIn = Template.bind({}); -LinkedIn.args = { - label: 'Share on LinkedIn', - medium: 'linkedin', - url: '#', -}; - -/** - * Sharing Link Stories - Twitter - */ -export const Twitter = Template.bind({}); -Twitter.args = { - label: 'Share on Twitter', - medium: 'twitter', - url: '#', -}; diff --git a/src/components/atoms/links/social-link/social-link.stories.ts b/src/components/atoms/links/social-link/social-link.stories.ts new file mode 100644 index 0000000..f7f4302 --- /dev/null +++ b/src/components/atoms/links/social-link/social-link.stories.ts @@ -0,0 +1,43 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { SocialLink } from './social-link'; + +const meta = { + component: SocialLink, + title: 'Atoms/Links/Social', +} satisfies Meta<typeof SocialLink>; + +export default meta; + +type Story = StoryObj<typeof meta>; + +export const Github: Story = { + args: { + icon: 'Github', + label: 'Github profile', + url: '#github', + }, +}; + +export const Gitlab: Story = { + args: { + icon: 'Gitlab', + label: 'Gitlab profile', + url: '#gitlab', + }, +}; + +export const LinkedIn: Story = { + args: { + icon: 'LinkedIn', + label: 'LinkedIn profile', + url: '#linkedin', + }, +}; + +export const Twitter: Story = { + args: { + icon: 'Twitter', + label: 'Twitter profile', + url: '#twitter', + }, +}; diff --git a/src/components/atoms/links/social-link/social-link.stories.tsx b/src/components/atoms/links/social-link/social-link.stories.tsx deleted file mode 100644 index cfb4ac7..0000000 --- a/src/components/atoms/links/social-link/social-link.stories.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { SocialLink } from './social-link'; - -/** - * SocialLink - Storybook Meta - */ -export default { - title: 'Atoms/Links/Social', - component: SocialLink, - argTypes: { - url: { - control: { - type: null, - }, - description: 'Social profile url.', - type: { - name: 'string', - required: true, - }, - }, - }, -} as ComponentMeta<typeof SocialLink>; - -const Template: ComponentStory<typeof SocialLink> = (args) => ( - <SocialLink {...args} /> -); - -/** - * Social Link Stories - Github - */ -export const Github = Template.bind({}); -Github.args = { - icon: 'Github', - label: 'Github profile', - url: '#', -}; - -/** - * Social Link Stories - Gitlab - */ -export const Gitlab = Template.bind({}); -Gitlab.args = { - icon: 'Gitlab', - label: 'Gitlab profile', - url: '#', -}; - -/** - * Social Link Stories - LinkedIn - */ -export const LinkedIn = Template.bind({}); -LinkedIn.args = { - icon: 'LinkedIn', - label: 'LinkedIn profile', - url: '#', -}; - -/** - * Social Link Stories - Twitter - */ -export const Twitter = Template.bind({}); -Twitter.args = { - icon: 'Twitter', - label: 'Twitter profile', - url: '#', -}; |
