diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-20 19:24:21 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-20 19:27:29 +0200 |
| commit | a08291b1586858fc894a27d56f55f87a88f8dbd3 (patch) | |
| tree | 0aa36c8add0ad0ecc07c0f7f20f5af3e2f7abe46 /src/components/organisms/widgets | |
| parent | 362cf45bc520a68a1c1be20e1189ca2307577dde (diff) | |
refactor(storybook): reorganize design system
Add more stories for each components and change some components
categories for better organization.
Diffstat (limited to 'src/components/organisms/widgets')
6 files changed, 125 insertions, 24 deletions
diff --git a/src/components/organisms/widgets/image-widget.module.scss b/src/components/organisms/widgets/image-widget.module.scss index 78c0d26..8e4d0aa 100644 --- a/src/components/organisms/widgets/image-widget.module.scss +++ b/src/components/organisms/widgets/image-widget.module.scss @@ -1,7 +1,6 @@ @use "@styles/abstracts/functions" as fun; .img { - max-height: fun.convert-px(350); margin: 0; } diff --git a/src/components/organisms/widgets/image-widget.stories.tsx b/src/components/organisms/widgets/image-widget.stories.tsx index 1c2397b..27871ae 100644 --- a/src/components/organisms/widgets/image-widget.stories.tsx +++ b/src/components/organisms/widgets/image-widget.stories.tsx @@ -1,10 +1,13 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; -import ImageWidgetComponent from './image-widget'; +import ImageWidget from './image-widget'; +/** + * ImageWidget - Storybook Meta + */ export default { - title: 'Organisms/Widgets', - component: ImageWidgetComponent, + title: 'Organisms/Widgets/Image', + component: ImageWidget, args: { alignment: 'left', }, @@ -58,6 +61,8 @@ export default { level: { control: { type: 'number', + min: 1, + max: 6, }, description: 'The widget title level (hn).', type: { @@ -89,12 +94,17 @@ export default { }, }, }, -} as ComponentMeta<typeof ImageWidgetComponent>; + decorators: [ + (Story) => ( + <IntlProvider locale="en"> + <Story /> + </IntlProvider> + ), + ], +} as ComponentMeta<typeof ImageWidget>; -const Template: ComponentStory<typeof ImageWidgetComponent> = (args) => ( - <IntlProvider locale="en"> - <ImageWidgetComponent {...args} /> - </IntlProvider> +const Template: ComponentStory<typeof ImageWidget> = (args) => ( + <ImageWidget {...args} /> ); const img = { @@ -102,10 +112,51 @@ const img = { height: 480, src: 'http://placeimg.com/640/480/nature', width: 640, + unoptimized: true, }; -export const ImageWidget = Template.bind({}); -ImageWidget.args = { +/** + * ImageWidget Stories - Align left + */ +export const AlignLeft = Template.bind({}); +AlignLeft.args = { + alignment: 'left', + expanded: true, + img, + level: 2, + title: 'Quo et totam', +}; + +/** + * ImageWidget Stories - Align center + */ +export const AlignCenter = Template.bind({}); +AlignCenter.args = { + alignment: 'center', + expanded: true, + img, + level: 2, + title: 'Quo et totam', +}; + +/** + * ImageWidget Stories - Align right + */ +export const AlignRight = Template.bind({}); +AlignRight.args = { + alignment: 'right', + expanded: true, + img, + level: 2, + title: 'Quo et totam', +}; + +/** + * ImageWidget Stories - With description + */ +export const WithDescription = Template.bind({}); +WithDescription.args = { + description: 'Sint enim harum', expanded: true, img, level: 2, diff --git a/src/components/organisms/widgets/links-list-widget.stories.tsx b/src/components/organisms/widgets/links-list-widget.stories.tsx index 528f6f7..0f03a2c 100644 --- a/src/components/organisms/widgets/links-list-widget.stories.tsx +++ b/src/components/organisms/widgets/links-list-widget.stories.tsx @@ -2,8 +2,11 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; import LinksListWidget from './links-list-widget'; +/** + * LinksListWidget - Storybook Meta + */ export default { - title: 'Organisms/Widgets', + title: 'Organisms/Widgets/LinksList', component: LinksListWidget, args: { kind: 'unordered', @@ -35,6 +38,8 @@ export default { level: { control: { type: 'number', + min: 1, + max: 6, }, description: 'The heading level.', type: { @@ -53,12 +58,17 @@ export default { }, }, }, + decorators: [ + (Story) => ( + <IntlProvider locale="en"> + <Story /> + </IntlProvider> + ), + ], } as ComponentMeta<typeof LinksListWidget>; const Template: ComponentStory<typeof LinksListWidget> = (args) => ( - <IntlProvider locale="en"> - <LinksListWidget {...args} /> - </IntlProvider> + <LinksListWidget {...args} /> ); const items = [ @@ -84,9 +94,24 @@ const items = [ { name: 'Level 1: Item 4', url: '#' }, ]; -export const LinksList = Template.bind({}); -LinksList.args = { +/** + * Links List Widget Stories - Unordered + */ +export const Unordered = Template.bind({}); +Unordered.args = { items, + kind: 'unordered', + level: 2, + title: 'A list of links', +}; + +/** + * Links List Widget Stories - Ordered + */ +export const Ordered = Template.bind({}); +Ordered.args = { + items, + kind: 'ordered', level: 2, title: 'A list of links', }; diff --git a/src/components/organisms/widgets/sharing.stories.tsx b/src/components/organisms/widgets/sharing.stories.tsx index be20b84..c3c3488 100644 --- a/src/components/organisms/widgets/sharing.stories.tsx +++ b/src/components/organisms/widgets/sharing.stories.tsx @@ -2,6 +2,9 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; import SharingWidget from './sharing'; +/** + * Sharing - Storybook Meta + */ export default { title: 'Organisms/Widgets', component: SharingWidget, @@ -27,6 +30,8 @@ export default { level: { control: { type: 'number', + min: 1, + max: 6, }, description: 'The heading level.', type: { @@ -55,14 +60,22 @@ export default { }, }, }, + decorators: [ + (Story) => ( + <IntlProvider locale="en"> + <Story /> + </IntlProvider> + ), + ], } as ComponentMeta<typeof SharingWidget>; const Template: ComponentStory<typeof SharingWidget> = (args) => ( - <IntlProvider locale="en"> - <SharingWidget {...args} /> - </IntlProvider> + <SharingWidget {...args} /> ); +/** + * Widgets Stories - Sharing + */ export const Sharing = Template.bind({}); Sharing.args = { expanded: true, diff --git a/src/components/organisms/widgets/sharing.tsx b/src/components/organisms/widgets/sharing.tsx index 571c1a4..05a3f73 100644 --- a/src/components/organisms/widgets/sharing.tsx +++ b/src/components/organisms/widgets/sharing.tsx @@ -21,7 +21,7 @@ export type SharingData = { url: string; }; -export type SharingProps = Omit<WidgetProps, 'children'> & { +export type SharingProps = Pick<WidgetProps, 'expanded' | 'level' | 'title'> & { /** * The page data to share. */ diff --git a/src/components/organisms/widgets/social-media.stories.tsx b/src/components/organisms/widgets/social-media.stories.tsx index 2b84012..2fa8bd7 100644 --- a/src/components/organisms/widgets/social-media.stories.tsx +++ b/src/components/organisms/widgets/social-media.stories.tsx @@ -2,6 +2,9 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; import SocialMediaWidget, { Media } from './social-media'; +/** + * SocialMedia - Storybook Meta + */ export default { title: 'Organisms/Widgets', component: SocialMediaWidget, @@ -9,6 +12,8 @@ export default { level: { control: { type: 'number', + min: 1, + max: 6, }, description: 'The heading level.', type: { @@ -35,12 +40,17 @@ export default { }, }, }, + decorators: [ + (Story) => ( + <IntlProvider locale="en"> + <Story /> + </IntlProvider> + ), + ], } as ComponentMeta<typeof SocialMediaWidget>; const Template: ComponentStory<typeof SocialMediaWidget> = (args) => ( - <IntlProvider locale="en"> - <SocialMediaWidget {...args} /> - </IntlProvider> + <SocialMediaWidget {...args} /> ); const media: Media[] = [ @@ -48,6 +58,9 @@ const media: Media[] = [ { name: 'LinkedIn', url: '#' }, ]; +/** + * Widgets Stories - Social media + */ export const SocialMedia = Template.bind({}); SocialMedia.args = { media, |
