From a08291b1586858fc894a27d56f55f87a88f8dbd3 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 20 Apr 2022 19:24:21 +0200 Subject: refactor(storybook): reorganize design system Add more stories for each components and change some components categories for better organization. --- .../organisms/forms/comment-form.stories.tsx | 31 ++++++++++----- .../organisms/forms/contact-form.stories.tsx | 29 +++++++++----- .../organisms/forms/search-form.stories.tsx | 46 +++++++++++++++++----- 3 files changed, 79 insertions(+), 27 deletions(-) (limited to 'src/components/organisms/forms') diff --git a/src/components/organisms/forms/comment-form.stories.tsx b/src/components/organisms/forms/comment-form.stories.tsx index 670176c..f66d35c 100644 --- a/src/components/organisms/forms/comment-form.stories.tsx +++ b/src/components/organisms/forms/comment-form.stories.tsx @@ -1,10 +1,13 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; -import CommentFormComponent from './comment-form'; +import CommentForm from './comment-form'; +/** + * CommentForm - Storybook Meta + */ export default { title: 'Organisms/Forms', - component: CommentFormComponent, + component: CommentForm, argTypes: { className: { control: { @@ -58,6 +61,8 @@ export default { titleLevel: { control: { type: 'number', + min: 1, + max: 6, }, description: 'The title level (hn).', table: { @@ -69,16 +74,24 @@ export default { }, }, }, -} as ComponentMeta; + decorators: [ + (Story) => ( + + + + ), + ], +} as ComponentMeta; -const Template: ComponentStory = (args) => ( - - - +const Template: ComponentStory = (args) => ( + ); -export const CommentForm = Template.bind({}); -CommentForm.args = { +/** + * Forms Stories - Comment + */ +export const Comment = Template.bind({}); +Comment.args = { saveComment: (reset: () => void) => { reset(); }, diff --git a/src/components/organisms/forms/contact-form.stories.tsx b/src/components/organisms/forms/contact-form.stories.tsx index 2c8ab32..9b936f9 100644 --- a/src/components/organisms/forms/contact-form.stories.tsx +++ b/src/components/organisms/forms/contact-form.stories.tsx @@ -1,10 +1,13 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; -import ContactFormComponent from './contact-form'; +import ContactForm from './contact-form'; +/** + * ContactForm - Storybook Meta + */ export default { title: 'Organisms/Forms', - component: ContactFormComponent, + component: ContactForm, argTypes: { className: { control: { @@ -43,16 +46,24 @@ export default { }, }, }, -} as ComponentMeta; + decorators: [ + (Story) => ( + + + + ), + ], +} as ComponentMeta; -const Template: ComponentStory = (args) => ( - - - +const Template: ComponentStory = (args) => ( + ); -export const ContactForm = Template.bind({}); -ContactForm.args = { +/** + * Forms Stories - Contact + */ +export const Contact = Template.bind({}); +Contact.args = { sendMail: (reset: () => void) => { reset(); }, diff --git a/src/components/organisms/forms/search-form.stories.tsx b/src/components/organisms/forms/search-form.stories.tsx index 4ec1c21..7f4c7c0 100644 --- a/src/components/organisms/forms/search-form.stories.tsx +++ b/src/components/organisms/forms/search-form.stories.tsx @@ -1,10 +1,16 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; -import SearchFormComponent from './search-form'; +import SearchForm from './search-form'; +/** + * SearchForm - Storybook Meta + */ export default { title: 'Organisms/Forms', - component: SearchFormComponent, + component: SearchForm, + args: { + hideLabel: false, + }, argTypes: { className: { control: { @@ -19,16 +25,38 @@ export default { required: false, }, }, + hideLabel: { + control: { + type: 'boolean', + }, + description: 'Determine if the input label should be visually hidden.', + table: { + category: 'Options', + defaultValue: { summary: false }, + }, + type: { + name: 'boolean', + required: false, + }, + }, }, -} as ComponentMeta; + decorators: [ + (Story) => ( + + + + ), + ], +} as ComponentMeta; -const Template: ComponentStory = (args) => ( - - - +const Template: ComponentStory = (args) => ( + ); -export const SearchForm = Template.bind({}); -SearchForm.args = { +/** + * Forms Stories - Search + */ +export const Search = Template.bind({}); +Search.args = { hideLabel: true, }; -- cgit v1.2.3