From 362cf45bc520a68a1c1be20e1189ca2307577dde Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 19 Apr 2022 12:12:15 +0200 Subject: chore: add a Code component --- src/components/molecules/layout/code.stories.tsx | 118 +++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/components/molecules/layout/code.stories.tsx (limited to 'src/components/molecules/layout/code.stories.tsx') diff --git a/src/components/molecules/layout/code.stories.tsx b/src/components/molecules/layout/code.stories.tsx new file mode 100644 index 0000000..a2a6b2c --- /dev/null +++ b/src/components/molecules/layout/code.stories.tsx @@ -0,0 +1,118 @@ +import { ComponentMeta, ComponentStory } from '@storybook/react'; +import { IntlProvider } from 'react-intl'; +import CodeComponent from './code'; + +/** + * Code - Storybook Meta + */ +export default { + title: 'Molecules/Layout/Code', + component: CodeComponent, + args: { + filterOutput: false, + outputPattern: '#output#', + }, + argTypes: { + children: { + control: { + type: 'text', + }, + description: 'The code sample.', + type: { + name: 'string', + required: true, + }, + }, + filterOutput: { + control: { + type: 'boolean', + }, + description: 'Filter the command line output.', + table: { + category: 'Options', + defaultValue: { summary: false }, + }, + type: { + name: 'boolean', + 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: {}, + }, + }, + outputPattern: { + control: { + type: 'text', + }, + description: 'The command line output pattern.', + table: { + category: 'Options', + defaultValue: { summary: '#output#' }, + }, + type: { + name: 'string', + required: false, + }, + }, + }, + decorators: [ + (Story) => ( + + + + ), + ], +} 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', + plugins: ['line-numbers'], +}; + +const commandLineCode = ` +ls -lah +#output#drwxr-x---+ 42 armand armand 4,0K 17 avril 11:15 . +#output#drwxr-xr-x 4 root root 4,0K 30 mai 2021 .. +#output#-rw-r--r-- 1 armand armand 2,0K 21 juil. 2021 .xinitrc +`; + +/** + * Code Stories - Command Line + */ +export const CommandLine = Template.bind({}); +CommandLine.args = { + children: commandLineCode, + filterOutput: true, + language: 'bash', + plugins: ['command-line'], +}; -- cgit v1.2.3 From 4581c262ca06704baaa3c0a172d509207f41f5c3 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 21 May 2022 18:42:19 +0200 Subject: chore: complete Storybook stories --- .../atoms/buttons/button-link.stories.tsx | 14 ++++++ src/components/atoms/icons/cc-by-sa.stories.tsx | 8 ---- src/components/atoms/layout/copyright.stories.tsx | 8 ---- src/components/atoms/layout/sidebar.stories.tsx | 8 ---- .../atoms/links/sharing-link.stories.tsx | 5 +-- .../atoms/lists/description-list-item.stories.tsx | 2 +- src/components/atoms/lists/list.stories.tsx | 13 ++++++ src/components/atoms/loaders/spinner.stories.tsx | 8 ---- .../molecules/buttons/back-to-top.stories.tsx | 8 ---- .../molecules/buttons/heading-button.stories.tsx | 1 + .../molecules/buttons/help-button.stories.tsx | 8 ---- src/components/molecules/buttons/help-button.tsx | 11 ++--- .../molecules/forms/labelled-field.stories.tsx | 1 + .../forms/select-with-tooltip.stories.tsx | 8 ---- .../molecules/images/responsive-image.stories.tsx | 13 ++++++ .../molecules/layout/branding.stories.tsx | 9 +--- src/components/molecules/layout/code.stories.tsx | 8 ---- src/components/molecules/layout/code.tsx | 36 ++-------------- src/components/molecules/layout/meta.stories.tsx | 34 +++++++-------- src/components/molecules/layout/widget.stories.tsx | 50 +++++++++++++--------- src/components/molecules/modals/modal.stories.tsx | 13 ++++++ .../molecules/nav/breadcrumb.stories.tsx | 8 ---- src/components/molecules/nav/nav.stories.tsx | 8 ---- .../molecules/nav/pagination.stories.tsx | 12 ++---- .../organisms/forms/comment-form.stories.tsx | 21 +++++++++ .../organisms/forms/contact-form.stories.tsx | 11 ++--- .../organisms/forms/search-form.stories.tsx | 10 +++++ .../organisms/forms/settings-form.stories.tsx | 20 +++++++++ .../organisms/layout/comment.stories.tsx | 1 + .../organisms/layout/comments-list.stories.tsx | 4 +- src/components/organisms/layout/header.stories.tsx | 10 +++++ .../organisms/layout/posts-list.stories.tsx | 44 +++++++++++++++++++ .../organisms/modals/search-modal.stories.tsx | 10 +++++ .../organisms/modals/settings-modal.stories.tsx | 20 +++++++++ .../organisms/toolbar/main-nav.stories.tsx | 11 ++--- .../organisms/toolbar/search.stories.tsx | 13 ++++++ .../organisms/toolbar/settings.stories.tsx | 3 ++ src/components/organisms/toolbar/settings.tsx | 9 +--- .../organisms/toolbar/toolbar.stories.tsx | 10 +++++ .../organisms/widgets/image-widget.stories.tsx | 21 +++++---- .../widgets/links-list-widget.stories.tsx | 21 +++++---- .../organisms/widgets/social-media.stories.tsx | 8 ---- .../widgets/table-of-contents.stories.tsx | 8 ---- src/components/templates/layout/layout.stories.tsx | 26 +++++++++++ .../templates/page/page-layout.stories.tsx | 24 +++++++++++ 45 files changed, 362 insertions(+), 237 deletions(-) (limited to 'src/components/molecules/layout/code.stories.tsx') diff --git a/src/components/atoms/buttons/button-link.stories.tsx b/src/components/atoms/buttons/button-link.stories.tsx index 2e1c040..d06aff3 100644 --- a/src/components/atoms/buttons/button-link.stories.tsx +++ b/src/components/atoms/buttons/button-link.stories.tsx @@ -47,6 +47,20 @@ export default { required: false, }, }, + external: { + control: { + type: 'boolean', + }, + description: 'Determine if the link is an external link.', + table: { + category: 'Options', + defaultValue: { summary: false }, + }, + type: { + name: 'boolean', + required: false, + }, + }, kind: { control: { type: 'select', diff --git a/src/components/atoms/icons/cc-by-sa.stories.tsx b/src/components/atoms/icons/cc-by-sa.stories.tsx index f2bc8f0..4229725 100644 --- a/src/components/atoms/icons/cc-by-sa.stories.tsx +++ b/src/components/atoms/icons/cc-by-sa.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import CCBySAIcon from './cc-by-sa'; /** @@ -23,13 +22,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/atoms/layout/copyright.stories.tsx b/src/components/atoms/layout/copyright.stories.tsx index b988165..612b114 100644 --- a/src/components/atoms/layout/copyright.stories.tsx +++ b/src/components/atoms/layout/copyright.stories.tsx @@ -1,6 +1,5 @@ import CCBySA from '@components/atoms/icons/cc-by-sa'; import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import CopyrightComponent from './copyright'; /** @@ -39,13 +38,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/atoms/layout/sidebar.stories.tsx b/src/components/atoms/layout/sidebar.stories.tsx index 175af94..6876f95 100644 --- a/src/components/atoms/layout/sidebar.stories.tsx +++ b/src/components/atoms/layout/sidebar.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import SidebarComponent from './sidebar'; /** @@ -46,13 +45,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/atoms/links/sharing-link.stories.tsx b/src/components/atoms/links/sharing-link.stories.tsx index c91e938..e6bd11b 100644 --- a/src/components/atoms/links/sharing-link.stories.tsx +++ b/src/components/atoms/links/sharing-link.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import SharingLinkComponent from './sharing-link'; /** @@ -41,9 +40,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = (args) => ( - - - + ); /** diff --git a/src/components/atoms/lists/description-list-item.stories.tsx b/src/components/atoms/lists/description-list-item.stories.tsx index e05493c..c7beb0d 100644 --- a/src/components/atoms/lists/description-list-item.stories.tsx +++ b/src/components/atoms/lists/description-list-item.stories.tsx @@ -52,7 +52,7 @@ export default { description: 'The item layout.', options: ['inline', 'inline-values', 'stacked'], table: { - category: 'Styles', + category: 'Options', defaultValue: { summary: 'stacked' }, }, type: { diff --git a/src/components/atoms/lists/list.stories.tsx b/src/components/atoms/lists/list.stories.tsx index 54fdd3a..eac3cd3 100644 --- a/src/components/atoms/lists/list.stories.tsx +++ b/src/components/atoms/lists/list.stories.tsx @@ -35,6 +35,19 @@ export default { value: {}, }, }, + itemsClassName: { + control: { + type: 'text', + }, + description: 'Set additional classnames to the list items.', + table: { + category: 'Styles', + }, + type: { + name: 'string', + required: false, + }, + }, kind: { control: { type: 'select', diff --git a/src/components/atoms/loaders/spinner.stories.tsx b/src/components/atoms/loaders/spinner.stories.tsx index dc577dc..1792c6c 100644 --- a/src/components/atoms/loaders/spinner.stories.tsx +++ b/src/components/atoms/loaders/spinner.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import SpinnerComponent from './spinner'; /** @@ -23,13 +22,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/molecules/buttons/back-to-top.stories.tsx b/src/components/molecules/buttons/back-to-top.stories.tsx index 7d4bc39..a338b8b 100644 --- a/src/components/molecules/buttons/back-to-top.stories.tsx +++ b/src/components/molecules/buttons/back-to-top.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import BackToTopComponent from './back-to-top'; /** @@ -33,13 +32,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/molecules/buttons/heading-button.stories.tsx b/src/components/molecules/buttons/heading-button.stories.tsx index d1b5ed4..59f7be9 100644 --- a/src/components/molecules/buttons/heading-button.stories.tsx +++ b/src/components/molecules/buttons/heading-button.stories.tsx @@ -1,3 +1,4 @@ +import headingStories from '@components/atoms/headings/heading.stories'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import { useState } from 'react'; import HeadingButtonComponent from './heading-button'; diff --git a/src/components/molecules/buttons/help-button.stories.tsx b/src/components/molecules/buttons/help-button.stories.tsx index cfc603e..4968b27 100644 --- a/src/components/molecules/buttons/help-button.stories.tsx +++ b/src/components/molecules/buttons/help-button.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import HelpButtonComponent from './help-button'; /** @@ -36,13 +35,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/molecules/buttons/help-button.tsx b/src/components/molecules/buttons/help-button.tsx index e351453..ccf1ebd 100644 --- a/src/components/molecules/buttons/help-button.tsx +++ b/src/components/molecules/buttons/help-button.tsx @@ -3,12 +3,7 @@ import { forwardRef, ForwardRefRenderFunction } from 'react'; import { useIntl } from 'react-intl'; import styles from './help-button.module.scss'; -export type HelpButtonProps = Pick & { - /** - * Set additional classnames to the button wrapper. - */ - className?: string; -}; +export type HelpButtonProps = Pick; /** * HelpButton component @@ -18,7 +13,7 @@ export type HelpButtonProps = Pick & { const HelpButton: ForwardRefRenderFunction< HTMLButtonElement, HelpButtonProps -> = ({ className = '', onClick }, ref) => { +> = ({ className = '', ...props }, ref) => { const intl = useIntl(); const text = intl.formatMessage({ defaultMessage: 'Help', @@ -29,9 +24,9 @@ const HelpButton: ForwardRefRenderFunction< return (