From 6bee07d8ea7d975df5197a27fcebe0f1c0c72b87 Mon Sep 17 00:00:00 2001 From: jonniebigodes Date: Tue, 5 Nov 2024 10:48:44 +0000 Subject: [PATCH 01/12] Docs: Svelte CSF snippets --- docs/_snippets/button-group-story.md | 19 +- .../button-story-component-args-primary.md | 69 +++- .../button-story-component-decorator.md | 65 +++- .../button-story-controls-primary-variant.md | 95 ++++- .../button-story-controls-radio-group.md | 105 +++++- docs/_snippets/button-story-decorator.md | 73 +++- .../button-story-default-docs-code.md | 67 ---- ...ton-story-default-export-with-component.md | 43 ++- .../button-story-primary-composition.md | 89 ++++- .../button-story-primary-long-name.md | 89 ++++- docs/_snippets/button-story-rename-story.md | 7 +- docs/_snippets/button-story-using-args.md | 139 +++++-- .../button-story-with-addon-example.md | 84 ++++- docs/_snippets/button-story-with-args.md | 78 ++-- docs/_snippets/button-story-with-emojis.md | 121 ++++-- docs/_snippets/button-story.md | 78 ++-- docs/_snippets/checkbox-story-csf.md | 126 ++++++- docs/_snippets/checkbox-story.md | 16 +- ...y-conditional-controls-mutual-exclusion.md | 138 ++++++- ...onent-story-conditional-controls-toggle.md | 120 +++++- .../component-story-custom-args-complex.md | 40 +- .../component-story-custom-args-mapping.md | 108 +++++- .../component-story-disable-controls-alt.md | 108 +++++- .../component-story-disable-controls-regex.md | 233 +++++++++++- .../component-story-disable-controls.md | 120 +++++- .../component-story-sort-controls.md | 81 +++- .../component-story-static-asset-cdn.md | 91 +++-- ...omponent-story-static-asset-with-import.md | 93 ++++- ...onent-story-static-asset-without-import.md | 75 +++- .../component-story-with-accessibility.md | 78 +++- .../gizmo-story-controls-customization.md | 354 +++++++++++++++++- docs/_snippets/histogram-story.md | 103 +++-- docs/_snippets/list-story-expanded.md | 47 +-- docs/_snippets/list-story-starter.md | 103 ++++- .../login-form-with-play-function.md | 191 ++++++++-- .../main-config-csf-addon-register.md | 28 -- .../main-config-svelte-csf-register.md | 24 ++ docs/_snippets/margindecorator.md | 42 ++- docs/_snippets/my-component-disable-toc.md | 119 +++++- .../my-component-play-function-alt-queries.md | 158 +++++++- ...my-component-play-function-query-findby.md | 170 ++++++++- .../my-component-play-function-waitfor.md | 236 +++++++++++- .../my-component-play-function-with-canvas.md | 152 +++++++- ...component-play-function-with-clickevent.md | 218 ++++++++++- .../my-component-play-function-with-delay.md | 215 ++++++++++- ...omponent-play-function-with-selectevent.md | 243 +++++++++++- .../my-component-story-basic-and-props.md | 80 +++- .../my-component-vite-env-variables.md | 116 +++++- .../my-component-with-env-variables.md | 124 +++++- docs/_snippets/page-story-slots.md | 32 +- docs/_snippets/page-story.md | 19 +- docs/_snippets/parameters-in-meta.md | 145 +++++-- docs/_snippets/parameters-in-story.md | 126 ++++++- .../register-component-with-play-function.md | 271 +++++++++++++- .../storybook-addon-a11y-component-config.md | 201 +++++++++- .../_snippets/storybook-addon-a11y-disable.md | 73 +++- .../storybook-addon-a11y-story-config.md | 118 +++++- .../storybook-auto-docs-baseline-example.md | 42 +-- .../storybook-auto-docs-custom-file.md | 14 +- ...ybook-auto-docs-mdx-docs-docs-only-page.md | 8 +- .../storybook-auto-docs-mdx-docs-dos-donts.md | 10 +- .../storybook-auto-docs-mdx-docs-imports.md | 6 +- ...storybook-auto-docs-mdx-docs-meta-block.md | 6 +- .../storybook-auto-docs-mdx-docs-story.md | 6 +- .../_snippets/storybook-auto-docs-mdx-file.md | 7 +- .../storybook-auto-docs-standalone-page.md | 5 +- .../storybook-auto-docs-starter-example.md | 5 +- .../storybook-custom-docs-markdown.md | 5 +- docs/_snippets/svelte-csf-addon-options.md | 31 ++ docs/_snippets/svelte-csf-addon-tags.md | 33 ++ .../svelte-csf-story-custom-children.md | 39 ++ docs/_snippets/svelte-csf-story-migration.md | 28 ++ .../svelte-vite-framework-options.md | 27 ++ .../svelte-webpack-framework-options.md | 27 ++ docs/_snippets/sveltekit-framework-options.md | 27 ++ .../table-story-fully-customize-controls.md | 30 -- docs/_snippets/tags-autodocs-in-meta.md | 79 +++- .../tags-autodocs-remove-component.md | 79 +++- docs/_snippets/tags-autodocs-remove-story.md | 107 +++++- docs/_snippets/tags-combo-example.md | 50 +-- docs/_snippets/tags-docs-only-in-meta.md | 161 ++++++-- docs/_snippets/tags-in-meta-and-story.md | 319 ++++++++++++---- docs/_snippets/tags-in-preview.md | 21 +- docs/_snippets/tags-remove-in-story.md | 151 ++++++-- .../your-component-with-decorator.md | 66 +++- docs/_snippets/your-component.md | 88 +++-- docs/essentials/controls.mdx | 36 +- docs/get-started/browse-stories.mdx | 2 +- docs/get-started/frameworks/svelte-vite.mdx | 133 ++++++- .../frameworks/svelte-webpack5.mdx | 45 +-- docs/get-started/frameworks/sveltekit.mdx | 141 +++++-- docs/get-started/install.mdx | 16 +- docs/get-started/setup.mdx | 6 +- docs/get-started/whats-a-story.mdx | 26 +- docs/writing-docs/autodocs.mdx | 10 +- docs/writing-docs/mdx.mdx | 2 +- docs/writing-stories/args.mdx | 36 +- docs/writing-stories/decorators.mdx | 68 +++- docs/writing-stories/index.mdx | 143 +++++-- docs/writing-stories/parameters.mdx | 34 +- docs/writing-stories/play-function.mdx | 18 +- docs/writing-stories/typescript.mdx | 2 +- docs/writing-tests/accessibility-testing.mdx | 31 +- 103 files changed, 7457 insertions(+), 1125 deletions(-) delete mode 100644 docs/_snippets/button-story-default-docs-code.md delete mode 100644 docs/_snippets/main-config-csf-addon-register.md create mode 100644 docs/_snippets/main-config-svelte-csf-register.md create mode 100644 docs/_snippets/svelte-csf-addon-options.md create mode 100644 docs/_snippets/svelte-csf-addon-tags.md create mode 100644 docs/_snippets/svelte-csf-story-custom-children.md create mode 100644 docs/_snippets/svelte-csf-story-migration.md create mode 100644 docs/_snippets/svelte-vite-framework-options.md create mode 100644 docs/_snippets/svelte-webpack-framework-options.md create mode 100644 docs/_snippets/sveltekit-framework-options.md delete mode 100644 docs/_snippets/table-story-fully-customize-controls.md diff --git a/docs/_snippets/button-group-story.md b/docs/_snippets/button-group-story.md index e7695e6334a4..8b2fe3766d62 100644 --- a/docs/_snippets/button-group-story.md +++ b/docs/_snippets/button-group-story.md @@ -160,7 +160,11 @@ export const Pair: Story = { }; ``` -```js filename="ButtonGroup.stories.js" renderer="svelte" language="js" +```svelte filename="ButtonGroup.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" + +``` + +```js filename="ButtonGroup.stories.js" renderer="svelte" language="js" tabTitle="CSF" import ButtonGroup from '../ButtonGroup.svelte'; //πŸ‘‡ Imports the Button stories @@ -178,7 +182,11 @@ export const Pair = { }; ``` -```ts filename="ButtonGroup.stories.ts" renderer="svelte" language="ts-4-9" +```svelte filename="ButtonGroup.stories.svelte" renderer="svelte" language="ts-4-9" tabTitle="Svelte CSF" + +``` + +```ts filename="ButtonGroup.stories.ts" renderer="svelte" language="ts-4-9" tabTitle="CSF" import type { Meta, StoryObj } from '@storybook/svelte'; import ButtonGroup from './ButtonGroup.svelte'; @@ -201,7 +209,11 @@ export const Pair: Story = { }; ``` -```ts filename="ButtonGroup.stories.ts" renderer="svelte" language="ts" +```svelte filename="ButtonGroup.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" + +``` + +```ts filename="ButtonGroup.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" import type { Meta, StoryObj } from '@storybook/svelte'; import ButtonGroup from './ButtonGroup.svelte'; @@ -350,4 +362,3 @@ export const Pair: Story = { }, }; ``` - diff --git a/docs/_snippets/button-story-component-args-primary.md b/docs/_snippets/button-story-component-args-primary.md index 81b292e7a885..9dabf008185e 100644 --- a/docs/_snippets/button-story-component-args-primary.md +++ b/docs/_snippets/button-story-component-args-primary.md @@ -134,7 +134,27 @@ export default meta; type Story = StoryObj; ``` -```js filename="Button.stories.js" renderer="svelte" language="js" +```svelte filename="Button.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" + +``` + +```js filename="Button.stories.js" renderer="svelte" language="js" tabTitle="CSF" import Button from './Button.svelte'; export default { @@ -150,19 +170,27 @@ export default { }; ``` -```html renderer="svelte" language="ts" tabTitle="native-format" -{/* Button.stories.svelte */} - - - + const { Story } = defineMeta({ + component: Button, + //πŸ‘‡ Creates specific argTypes + argTypes: { + backgroundColor: { control: 'color' }, + }, + args: { + //πŸ‘‡ Now all Button stories will be primary. + primary: true, + }, + }); + ``` -```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9" +```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9" tabTitle="CSF" import type { Meta } from '@storybook/svelte'; import Button from './Button.svelte'; @@ -182,7 +210,27 @@ const meta = { export default meta; ``` -```ts filename="Button.stories.ts" renderer="svelte" language="ts" +```svelte filename="Button.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" + +``` + +```ts filename="Button.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" import type { Meta } from '@storybook/svelte'; import Button from './Button.svelte'; @@ -289,4 +337,3 @@ const meta: Meta = { export default meta; ``` - diff --git a/docs/_snippets/button-story-component-decorator.md b/docs/_snippets/button-story-component-decorator.md index a50f6e1e6034..5f2929bcc764 100644 --- a/docs/_snippets/button-story-component-decorator.md +++ b/docs/_snippets/button-story-component-decorator.md @@ -190,7 +190,23 @@ const meta: Meta = { export default meta; ``` -```js filename="Button.stories.js" renderer="svelte" language="js" +```svelte filename="Button.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" + +``` + +```js filename="Button.stories.js" renderer="svelte" language="js" tabTitle="CSF" import Button from './Button.svelte'; import MarginDecorator from './MarginDecorator.svelte'; @@ -200,27 +216,23 @@ export default { }; ``` -```html renderer="svelte" language="ts" tabTitle="native-format" -{/* Button.stories.svelte */} - - - - - - ``` -```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9" +```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9" tabTitle="CSF" import type { Meta } from '@storybook/svelte'; import Button from './Button.svelte'; @@ -229,12 +241,28 @@ import MarginDecorator from './MarginDecorator.svelte'; const meta = { component: Button, decorators: [() => MarginDecorator], -}; +} satisfies Meta; export default meta; ``` -```ts filename="Button.stories.ts" renderer="svelte" language="ts" +```svelte filename="Button.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" + +``` + +```ts filename="Button.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" import type { Meta } from '@storybook/svelte'; import Button from './Button.svelte'; @@ -309,4 +337,3 @@ type Story = StoryObj; export const Example: Story = {}; ``` - diff --git a/docs/_snippets/button-story-controls-primary-variant.md b/docs/_snippets/button-story-controls-primary-variant.md index c3b6dc562ca1..bec2cf1b1044 100644 --- a/docs/_snippets/button-story-controls-primary-variant.md +++ b/docs/_snippets/button-story-controls-primary-variant.md @@ -17,6 +17,34 @@ export const Primary: Story = { }; ``` +```svelte filename="Button.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" + + + +``` + +```js filename="Button.stories.js" renderer="svelte" language="js" tabTitle="CSF" +import Button from './Button.svelte'; + +export default { + component: Button, +}; + +export const Primary = { + args: { + variant: 'primary', + }, +}; +``` + ```js filename="Button.stories.js|jsx" renderer="common" language="js" import { Button } from './Button'; @@ -31,6 +59,39 @@ export const Primary = { }; ``` +```svelte filename="Button.stories.svelte" renderer="svelte" language="ts-4-9" tabTitle="Svelte CSF" + + + +``` + +```ts filename="Button.stories.ts" renderer="svelte" language="ts-4-9" tabTitle="CSF" +import type { Meta, StoryObj } from '@storybook/svelte'; + +import Button from './Button.svelte'; + +const meta = { + component: Button, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Primary: Story = { + args: { + variant: 'primary', + }, +}; +``` + ```ts filename="Button.stories.ts|tsx" renderer="common" language="ts-4-9" // Replace your-framework with the name of your framework import type { Meta, StoryObj } from '@storybook/your-framework'; @@ -51,6 +112,39 @@ export const Primary: Story = { }; ``` +```svelte filename="Button.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" + + + +``` + +```ts filename="Button.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" +import type { Meta, StoryObj } from '@storybook/svelte'; + +import Button from './Button.svelte'; + +const meta: Meta = { + component: Button, +}; + +export default meta; +type Story = StoryObj; + +export const Primary: Story = { + args: { + variant: 'primary', + }, +}; +``` + ```ts filename="Button.stories.ts|tsx" renderer="common" language="ts" // Replace your-framework with the name of your framework import type { Meta, StoryObj } from '@storybook/your-framework'; @@ -99,4 +193,3 @@ export const Primary: Story = { }, }; ``` - diff --git a/docs/_snippets/button-story-controls-radio-group.md b/docs/_snippets/button-story-controls-radio-group.md index 7a548bee60a4..19a3386680f4 100644 --- a/docs/_snippets/button-story-controls-radio-group.md +++ b/docs/_snippets/button-story-controls-radio-group.md @@ -16,6 +16,38 @@ const meta: Meta