diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-24 19:35:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-24 19:35:12 +0200 |
| commit | c85ab5ad43ccf52881ee224672c41ec30021cf48 (patch) | |
| tree | 8058808d9bfca19383f120c46b34d99ff2f89f63 /src/components/molecules/layout/code.stories.tsx | |
| parent | 52404177c07a2aab7fc894362fb3060dff2431a0 (diff) | |
| parent | 11b9de44a4b2f305a6a484187805e429b2767118 (diff) | |
refactor: use storybook and atomic design (#16)
BREAKING CHANGE: rewrite most of the Typescript types, so the content format (the meta in particular) needs to be updated.
Diffstat (limited to 'src/components/molecules/layout/code.stories.tsx')
| -rw-r--r-- | src/components/molecules/layout/code.stories.tsx | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/components/molecules/layout/code.stories.tsx b/src/components/molecules/layout/code.stories.tsx new file mode 100644 index 0000000..ac0e98f --- /dev/null +++ b/src/components/molecules/layout/code.stories.tsx @@ -0,0 +1,110 @@ +import { ComponentMeta, ComponentStory } from '@storybook/react'; +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, + }, + }, + }, +} as ComponentMeta<typeof CodeComponent>; + +const Template: ComponentStory<typeof CodeComponent> = (args) => ( + <CodeComponent {...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'], +}; |
