diff --git a/docs/addons/addons-api.md b/docs/addons/addons-api.md index 5c0e5b2a6463..ec0b1a1ff78b 100644 --- a/docs/addons/addons-api.md +++ b/docs/addons/addons-api.md @@ -235,7 +235,6 @@ Let's say you've got a story like this: 'vue/button-story-with-addon-example.js.mdx', 'angular/button-story-with-addon-example.ts.mdx', 'svelte/button-story-with-addon-example.js.mdx', - 'svelte/button-story-with-addon-example.native-format.mdx', ]} /> diff --git a/docs/addons/writing-addons.md b/docs/addons/writing-addons.md index 6245585bda3d..4486cb6a7420 100644 --- a/docs/addons/writing-addons.md +++ b/docs/addons/writing-addons.md @@ -200,7 +200,6 @@ When Storybook was initialized, it provided a small set of example stories. Chan 'vue/button-story-with-addon-example.js.mdx', 'angular/button-story-with-addon-example.ts.mdx', 'svelte/button-story-with-addon-example.js.mdx', - 'svelte/button-story-with-addon-example.native-format.mdx', ]} /> diff --git a/docs/api/csf.md b/docs/api/csf.md index b96c2fd970e3..cdf0b586b74e 100644 --- a/docs/api/csf.md +++ b/docs/api/csf.md @@ -44,7 +44,6 @@ With CSF, every named export in the file represents a story object by default. 'react/my-component-story-basic-and-props.ts.mdx', 'vue/my-component-story-basic-and-props.js.mdx', 'svelte/my-component-story-basic-and-props.js.mdx', - 'svelte/my-component-story-basic-and-props.native-format.mdx', 'angular/my-component-story-basic-and-props.ts.mdx', ]} /> @@ -92,7 +91,6 @@ Consider Storybook’s ["Button" example](../writing-stories/introduction.md#def 'vue/button-story-click-handler.2.js.mdx', 'vue/button-story-click-handler.3.js.mdx', 'svelte/button-story-click-handler.js.mdx', - 'svelte/button-story-click-handler.native-format.mdx', 'angular/button-story-click-handler.ts.mdx', ]} /> @@ -125,7 +123,6 @@ Or even more simply: 'react/button-story-click-handler-simplificated.js.mdx', 'angular/button-story-click-handler-simplificated.ts.mdx', 'vue/button-story-click-handler-simplificated.js.mdx', - 'svelte/button-story-click-handler-simplificated.native-format.mdx', ]} /> @@ -158,6 +155,28 @@ A good use case for the `play` function is a form component. With previous Story When the story renders in the UI, Storybook executes each step defined in the `play` function and runs the assertions without the need for user interaction. +## Custom render functions + +Starting in Storybook 6.4, you can write your stories as JavaScript objects, reducing the boilerplate code you need to generate to test your components, thus improving functionality and usability. `Render` functions are helpful methods to give you additional control over how the story renders. For example, if you were writing a story as an object and you wanted to specify how your component should render, you could write the following: + + + + + + + +When Storybook loads this story, it will detect the existence of a `render` function and adjust the component rendering accordingly based on what's defined. + ## Storybook export vs. name handling Storybook handles named exports and the `name` option slightly differently. When should you use one vs. the other? diff --git a/docs/api/mdx.md b/docs/api/mdx.md index 4783ec5f12a3..51c166417c71 100644 --- a/docs/api/mdx.md +++ b/docs/api/mdx.md @@ -44,7 +44,6 @@ For example, here's the story from the `Checkbox` example above, rewritten in CS 'react/checkbox-story-csf.ts.mdx', 'vue/checkbox-story-csf.js.mdx', 'angular/checkbox-story-csf.ts.mdx', - 'svelte/checkbox-story-csf.native-format.mdx', ]} /> diff --git a/docs/configure/environment-variables.md b/docs/configure/environment-variables.md index 1109db35c15b..238aababb15f 100644 --- a/docs/configure/environment-variables.md +++ b/docs/configure/environment-variables.md @@ -60,7 +60,6 @@ Then you can access this environment variable anywhere, even within your stories 'angular/my-component-with-env-variables.mdx.mdx', 'web-components/my-component-with-env-variables.js.mdx', 'svelte/my-component-with-env-variables.js.mdx', - 'svelte/my-component-with-env-variables.native-format.mdx', 'svelte/my-component-with-env-variables.mdx.mdx', ]} /> diff --git a/docs/configure/images-and-assets.md b/docs/configure/images-and-assets.md index 8049a22db88a..c30babb303f5 100644 --- a/docs/configure/images-and-assets.md +++ b/docs/configure/images-and-assets.md @@ -24,7 +24,6 @@ Afterward, you can use any asset in your stories: 'angular/component-story-static-asset-with-import.ts.mdx', 'angular/component-story-static-asset-with-import.mdx.mdx', 'svelte/component-story-static-asset-with-import.js.mdx', - 'svelte/component-story-static-asset-with-import.native-format.mdx', 'svelte/component-story-static-asset-with-import.mdx.mdx', ]} /> @@ -61,7 +60,6 @@ Here `../public` is your static directory. Now use it in a component or story li 'angular/component-story-static-asset-without-import.ts.mdx', 'angular/component-story-static-asset-without-import.mdx.mdx', 'svelte/component-story-static-asset-without-import.js.mdx', - 'svelte/component-story-static-asset-without-import.native-format.mdx', 'svelte/component-story-static-asset-without-import.mdx.mdx', ]} /> @@ -112,7 +110,6 @@ Upload your files to an online CDN and reference them. In this example, we’re 'angular/component-story-static-asset-cdn.ts.mdx', 'angular/component-story-static-asset-cdn.mdx.mdx', 'svelte/component-story-static-asset-cdn.js.mdx', - 'svelte/component-story-static-asset-cdn.native-format.mdx', 'svelte/component-story-static-asset-cdn.mdx.mdx', ]} /> diff --git a/docs/contribute/new-snippets.md b/docs/contribute/new-snippets.md index 35a88ea36834..4bb1b6409add 100644 --- a/docs/contribute/new-snippets.md +++ b/docs/contribute/new-snippets.md @@ -47,7 +47,6 @@ Browse the documentation and look for the code snippets you're willing to contri 'vue/your-component.2.js.mdx', 'vue/your-component.3.js.mdx', 'svelte/your-component.js.mdx', - 'svelte/your-component.native-format.mdx', 'web-components/your-component.js.mdx', ]} /> @@ -70,7 +69,6 @@ Create the file `ember/your-component.js.mdx`, similar to the other frameworks, 'vue/your-component.2.js.mdx', 'vue/your-component.3.js.mdx', 'svelte/your-component.js.mdx', - 'svelte/your-component.native-format.mdx', 'web-components/your-component.js.mdx', 'ember/your-component.js.mdx', //πŸ‘ˆπŸΌ The code snippet you created. ]} diff --git a/docs/essentials/controls.md b/docs/essentials/controls.md index 5da997b1fc61..0fa30d0f92e1 100644 --- a/docs/essentials/controls.md +++ b/docs/essentials/controls.md @@ -119,7 +119,6 @@ Until now, we only used auto-generated controls based on the component we're wri 'vue/table-story-fully-customize-controls.mdx-3.mdx.mdx', 'angular/table-story-fully-customize-controls.ts.mdx', 'angular/table-story-fully-customize-controls.mdx.mdx', - 'svelte/table-story-fully-customize-controls.native-format.mdx', ]} /> @@ -151,7 +150,6 @@ One way to deal with this is to use primitive values (e.g., strings) as arg valu 'angular/component-story-custom-args-complex.ts.mdx', 'angular/component-story-custom-args-complex.mdx.mdx', 'svelte/component-story-custom-args-complex.js.mdx', - 'svelte/component-story-custom-args-complex.native-format.mdx', ]} /> diff --git a/docs/essentials/viewport.md b/docs/essentials/viewport.md index 09b1e8cd856b..bc46620afde5 100644 --- a/docs/essentials/viewport.md +++ b/docs/essentials/viewport.md @@ -126,7 +126,6 @@ Update your story through [parameters](../writing-stories/parameters.md) to incl 'angular/my-component-story-configure-viewports.mdx.mdx', 'web-components/my-component-story-configure-viewports.js.mdx', 'svelte/my-component-story-configure-viewports.js.mdx', - 'svelte/my-component-story-configure-viewports.native-format.mdx', 'svelte/my-component-story-configure-viewports.mdx.mdx', ]} /> diff --git a/docs/get-started/setup.md b/docs/get-started/setup.md index 2959e5685ddd..77aa586a2dc5 100644 --- a/docs/get-started/setup.md +++ b/docs/get-started/setup.md @@ -20,7 +20,6 @@ Pick a simple component from your project, like a Button, and write a `.stories. 'vue/your-component.3.js.mdx', 'vue/your-component.mdx-3.mdx.mdx', 'svelte/your-component.js.mdx', - 'svelte/your-component.native-format.mdx', 'svelte/your-component.mdx.mdx', 'web-components/your-component.js.mdx', 'html/your-component.js.mdx', diff --git a/docs/get-started/whats-a-story.md b/docs/get-started/whats-a-story.md index c349c1768787..34cf16d75b59 100644 --- a/docs/get-started/whats-a-story.md +++ b/docs/get-started/whats-a-story.md @@ -22,7 +22,6 @@ Let’s start with the `Button` component. A story is a function that describes 'vue/button-story.js.mdx', 'vue/button-story.mdx.mdx', 'svelte/button-story.js.mdx', - 'svelte/button-story.native-format.mdx', 'svelte/button-story.mdx.mdx', 'web-components/button-story.js.mdx', 'html/button-story.js.mdx', @@ -54,7 +53,6 @@ The above story definition can be further improved to take advantage of [Storybo 'angular/button-story-with-args.mdx.mdx', 'web-components/button-story-with-args.js.mdx', 'svelte/button-story-with-args.js.mdx', - 'svelte/button-story-with-args.native-format.mdx', 'svelte/button-story-with-args.mdx.mdx', 'html/button-story-with-args.js.mdx', 'html/button-story-with-args.ts.mdx', diff --git a/docs/snippets/angular/app-story-with-mock.ts.mdx b/docs/snippets/angular/app-story-with-mock.ts.mdx index c59e28fba4c0..1de9d248997a 100644 --- a/docs/snippets/angular/app-story-with-mock.ts.mdx +++ b/docs/snippets/angular/app-story-with-mock.ts.mdx @@ -1,37 +1,39 @@ ```ts // App.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { AppComponent } from './app.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'App', component: AppComponent, } as Meta; -const Template: Story = () => ({ - props: {}, -}); - -export const Success = Template.bind({}); -Success.parameters = { - fetch: { - json: { - JavaScript: 3390991, - 'C++': 44974, - TypeScript: 15530, - CoffeeScript: 12253, - Python: 9383, - C: 5341, - Shell: 5115, - HTML: 3420, - CSS: 3171, - Makefile: 189, + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Success: Story = { + parameters: { + fetch: { + json: { + JavaScript: 3390991, + 'C++': 44974, + TypeScript: 15530, + CoffeeScript: 12253, + Python: 9383, + C: 5341, + Shell: 5115, + HTML: 3420, + CSS: 3171, + Makefile: 189, + }, }, }, }; diff --git a/docs/snippets/angular/badge-story-starter-example.mdx.mdx b/docs/snippets/angular/badge-story-starter-example.mdx.mdx index 87b96b0ee968..b57a56f5d24e 100644 --- a/docs/snippets/angular/badge-story-starter-example.mdx.mdx +++ b/docs/snippets/angular/badge-story-starter-example.mdx.mdx @@ -12,24 +12,30 @@ import { Icon } from './icon.component'; + + # Badge Let's define a story for our `Badge` component: - - {{ + ({ template:`Positive`, - }} - + })} /> We can drop it in a `Canvas` to get a code snippet: - - {{ + ({ template: `Negative`, - }} - + })} /> We can even preview multiple stories in a block. This @@ -37,37 +43,36 @@ gets rendered as a group, but defines individual stories with unique URLs and isolated snapshot tests. - - {{ + ({ template: `Warning`, - }} - - - {{ + })} /> + ({ template: `Neutral`, - }} - - - {{ - template: `Error`, - }} - + })} /> ({ + template: `Error`, + })} /> + - {{ + ]} + render={() => ({ template: ` with icon `, - }} - + })} /> -``` +``` \ No newline at end of file diff --git a/docs/snippets/angular/badge-story.mdx.mdx b/docs/snippets/angular/badge-story.mdx.mdx index e903fc6b8e56..8785f5c6689c 100644 --- a/docs/snippets/angular/badge-story.mdx.mdx +++ b/docs/snippets/angular/badge-story.mdx.mdx @@ -7,7 +7,11 @@ import { Badge } from './badge.component'; -export const Template = (args) => ({ props: args }); + # Badge @@ -17,10 +21,11 @@ Let's define a story for our `Badge` component: name="positive" args={{ status: 'positive', - label: 'Positive' - }}> - {Template.bind({})} - + label: 'Positive', + }} + render={(args) => ({ + props: args, + })} /> We can drop it in a `Canvas` to get a code snippet: @@ -28,11 +33,12 @@ We can drop it in a `Canvas` to get a code snippet: - {Template.bind({})} - + status: 'negative', + label: 'Negative', + }} + render={(args) => ({ + props: args, + })} /> We can even preview multiple Stories in a block. This @@ -41,36 +47,31 @@ with unique URLs, which is great for review and testing. - {Template.bind({})} - + label: 'Warning', + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - + label: 'Neutral', + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - - with icon) - )}}> - {Template.bind({})} - + label: 'Error', + }} + render={(args) => ({ + props: args, + })} /> -``` +``` \ No newline at end of file diff --git a/docs/snippets/angular/build-storybook-production-mode.with-builder.js.mdx b/docs/snippets/angular/build-storybook-production-mode.with-builder.js.mdx index 7cdd1cc2346a..7ab12337fc6b 100644 --- a/docs/snippets/angular/build-storybook-production-mode.with-builder.js.mdx +++ b/docs/snippets/angular/build-storybook-production-mode.with-builder.js.mdx @@ -1,6 +1,6 @@ ```shell # Builds Storybook with Angular's custom builder -# See https://storybook.js.org/docs/angular/get-started/install +# See https://storybook.js.org/docs/7.0/angular/get-started/install # to learn how to create the custom builder ng run my-project:build-storybook ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-group-story.ts.mdx b/docs/snippets/angular/button-group-story.ts.mdx index ef7332db0db7..0a71e74d5e03 100644 --- a/docs/snippets/angular/button-group-story.ts.mdx +++ b/docs/snippets/angular/button-group-story.ts.mdx @@ -13,9 +13,9 @@ import * as ButtonStories from './Button.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading * to learn how to generate automatic titles - */ + */ title: 'ButtonGroup', component: ButtonGroup, decorators: [ @@ -26,16 +26,15 @@ export default { ], } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const Pair = Template.bind({}); -Pair.args = { - buttons: [ - { ...ButtonStories.Primary.args }, - { ...ButtonStories.Secondary.args }, - ], - orientation: 'horizontal', + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Pair: Story = { + args: { + buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }], + orientation: 'horizontal', + }, }; -``` \ No newline at end of file +``` diff --git a/docs/snippets/angular/button-story-click-handler-args.ts.mdx b/docs/snippets/angular/button-story-click-handler-args.ts.mdx index 024ee79c92a6..000f996bc195 100644 --- a/docs/snippets/angular/button-story-click-handler-args.ts.mdx +++ b/docs/snippets/angular/button-story-click-handler-args.ts.mdx @@ -1,7 +1,7 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { action } from '@storybook/addon-actions'; @@ -9,22 +9,21 @@ import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; -export const Text: Story = ({ label, onClick }) => ({ - props: { - label, - onClick, +export const Text: Story = { + render: (args) => ({ + props: args, + template: ``, + }), + args: { + label: 'Hello', + onClick: action('clicked'), }, -}); - -Text.args = { - label: 'Hello', - onClick: action('clicked'), }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-click-handler-simplificated.ts.mdx b/docs/snippets/angular/button-story-click-handler-simplificated.ts.mdx index 7cb711badc7c..505c0be2c73a 100644 --- a/docs/snippets/angular/button-story-click-handler-simplificated.ts.mdx +++ b/docs/snippets/angular/button-story-click-handler-simplificated.ts.mdx @@ -1,20 +1,20 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; -export const Text: Story = (args) => ({ - props: args, -}); +export const Text: Story = { + args: {...}, +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-click-handler.ts.mdx b/docs/snippets/angular/button-story-click-handler.ts.mdx index 603e95d0fb45..fabf50c1cfc8 100644 --- a/docs/snippets/angular/button-story-click-handler.ts.mdx +++ b/docs/snippets/angular/button-story-click-handler.ts.mdx @@ -1,7 +1,7 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; @@ -9,17 +9,19 @@ import { action } from '@storybook/addon-actions'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ - title: 'Button', + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ + title: 'Button', component: Button, } as Meta; -export const Text: Story = () => ({ - props: { - text: 'Hello Button', - onClick: action('clicked'), - }, -}); +export const Text: Story = { + render: () => ({ + props: { + label: 'Button', + onClick: action('clicked'), + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-component-args-primary.ts.mdx b/docs/snippets/angular/button-story-component-args-primary.ts.mdx index 882b9c223c73..fbab7dec15d1 100644 --- a/docs/snippets/angular/button-story-component-args-primary.ts.mdx +++ b/docs/snippets/angular/button-story-component-args-primary.ts.mdx @@ -1,15 +1,15 @@ ```ts // Button.stories.ts -import { Meta } from '@storybook/angular'; +import type { Meta } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, //πŸ‘‡ Creates specific argTypes diff --git a/docs/snippets/angular/button-story-component-decorator.ts.mdx b/docs/snippets/angular/button-story-component-decorator.ts.mdx index 82bbfb0fd821..a47a543849a6 100644 --- a/docs/snippets/angular/button-story-component-decorator.ts.mdx +++ b/docs/snippets/angular/button-story-component-decorator.ts.mdx @@ -9,9 +9,9 @@ import { Parent } from './parent.component'; // Parent contains ng-content export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, decorators: [ diff --git a/docs/snippets/angular/button-story-decorator.mdx.mdx b/docs/snippets/angular/button-story-decorator.mdx.mdx index ea2980777cca..5b6c7f2f5fb4 100644 --- a/docs/snippets/angular/button-story-decorator.mdx.mdx +++ b/docs/snippets/angular/button-story-decorator.mdx.mdx @@ -13,18 +13,15 @@ import { Parent } from './parent.component'; -export const Template = () => ({ - template: ``, -}); - - `
${story}
`) - ]} > - {Template.bind({})} + ]} + render={() => ({ + template: ``, + })} />
@@ -36,7 +33,9 @@ export const Template = () => ({ declarations: [ParentComponent], }), componentWrapperDecorator(ParentComponent) - ]} > - {Template.bind({})} + ]} + render={() => ({ + template: ``, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-decorator.ts.mdx b/docs/snippets/angular/button-story-decorator.ts.mdx index 58dcfdd08461..f09d0111966a 100644 --- a/docs/snippets/angular/button-story-decorator.ts.mdx +++ b/docs/snippets/angular/button-story-decorator.ts.mdx @@ -8,31 +8,23 @@ import { Parent } from './parent.component'; // Parent contains ng-content export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; -const Template: Story = (args) => ({ - template: '', -}); - -export const Primary = Template.bind({}); -Primary.decorators = [ - componentWrapperDecorator((story) => `
${story}
`), -]; - -export const Primary = { +export const Primary: Story = { decorators: [componentWrapperDecorator((story) => `
${story}
`)], }; -export const InsideParent= Template.bind({}); -InsideParent.decorators = [ - moduleMetadata({ - declarations: [Parent], - }), - componentWrapperDecorator(Parent), -]; +export const InsideParent: Story = { + decorators: [ + moduleMetadata({ + declarations: [Parent], + }), + componentWrapperDecorator(Parent), + ], +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-default-docs-code.mdx.mdx b/docs/snippets/angular/button-story-default-docs-code.mdx.mdx deleted file mode 100644 index 22b41e4136dc..000000000000 --- a/docs/snippets/angular/button-story-default-docs-code.mdx.mdx +++ /dev/null @@ -1,43 +0,0 @@ -```md - - -import { Meta, Story } from '@storybook/addon-docs'; - -import { Button } from './button.component'; - - - - - -export const someFunction = (someValue) => { - return `i am a ${someValue}`; -}; - - - - {(args) => { - const { label } = args; - const functionResult = someFunction(label); - return { - props: { - ...args, - label: functionResult, - }, - }; - }} - -``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-default-docs-code.ts.mdx b/docs/snippets/angular/button-story-default-docs-code.ts.mdx deleted file mode 100644 index a064635bd5dd..000000000000 --- a/docs/snippets/angular/button-story-default-docs-code.ts.mdx +++ /dev/null @@ -1,45 +0,0 @@ -```ts -// Button.stories.ts - -import { Meta, Story } from '@storybook/angular'; - -import { Button } from './button.component'; - -export default { - /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ - title: 'Button', - component: Button, - //πŸ‘‡ Creates specific argTypes - argTypes: { - backgroundColor: { control: 'color' }, - }, -} as Meta; - -//πŸ‘‡ Some function to demonstrate the behavior -const someFunction = (someValue: string) => { - return `i am a ${someValue}`; -}; - - -export const ExampleStory: Story = (args) => { - //πŸ‘‡ Destructure the label from the args object - const { label } = args; - - //πŸ‘‡ Assigns the function result to a variable and pass it as a prop into the component - const functionResult = someFunction(label); - return { - props: { - ...args, - label: functionResult, - }, - }; -}; -ExampleStory.args = { - primary: true, - size: 'small', - label: 'button', -}; -``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-default-export-with-component.ts.mdx b/docs/snippets/angular/button-story-default-export-with-component.ts.mdx index a725407344c8..c17664e80879 100644 --- a/docs/snippets/angular/button-story-default-export-with-component.ts.mdx +++ b/docs/snippets/angular/button-story-default-export-with-component.ts.mdx @@ -1,15 +1,15 @@ ```ts // Button.stories.ts -import { Meta } from '@storybook/angular'; +import type { Meta } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; diff --git a/docs/snippets/angular/button-story-rename-story.ts.mdx b/docs/snippets/angular/button-story-rename-story.ts.mdx index cc7e47168605..a90462526810 100644 --- a/docs/snippets/angular/button-story-rename-story.ts.mdx +++ b/docs/snippets/angular/button-story-rename-story.ts.mdx @@ -1,26 +1,31 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; - -export const Primary: Story = () => ({ - props: { - label: 'Button', - primary: true, - }, -}); - -Primary.storyName = 'I am the primary'; +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + name: 'I am the primary', + render: () => ({ + props: { + label: 'Button', + primary: true, + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-using-args.ts.mdx b/docs/snippets/angular/button-story-using-args.ts.mdx index 33be6ec6ac21..d898ade3b623 100644 --- a/docs/snippets/angular/button-story-using-args.ts.mdx +++ b/docs/snippets/angular/button-story-using-args.ts.mdx @@ -1,45 +1,42 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; - -//πŸ‘‡ We create a β€œtemplate” of how args map to rendering -const Template: Story = (args) => ({ - props: args, -}); - -// πŸ‘‡ Each story then reuses that template -export const Primary= Template.bind({}); -Primary.args = { - label: 'Button', - backgroundColor: '#ff0', + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + args: { + label: 'Button', + backgroundColor: '#ff0', + }, }; - -export const Secondary= Template.bind({}); -Secondary.args = { +export const Secondary: Story = { args: { ...Primary.args, label: 'πŸ˜„πŸ‘πŸ˜πŸ’―', }, }; - -export const Tertiary= Template.bind({}); -Tertiary.args={ - ...Primary.args, - label: 'πŸ“šπŸ“•πŸ“ˆπŸ€“', +export const Tertiary: Story = { + args: { + ...Primary.args, + label: 'πŸ“šπŸ“•πŸ“ˆπŸ€“', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-addon-example.ts.mdx b/docs/snippets/angular/button-story-with-addon-example.ts.mdx index a1809a0ee0bf..37368e73b2a2 100644 --- a/docs/snippets/angular/button-story-with-addon-example.ts.mdx +++ b/docs/snippets/angular/button-story-with-addon-example.ts.mdx @@ -1,15 +1,15 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, //πŸ‘‡ Creates specific parameters for the story @@ -20,7 +20,14 @@ export default { }, } as Meta; -export const Basic: Story = () => ({ - template: `hello`, -}); +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Basic: Story = { + render: () => ({ + template: `hello`, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-args.mdx.mdx b/docs/snippets/angular/button-story-with-args.mdx.mdx index e09bf9d0ea4f..15f9134bde74 100644 --- a/docs/snippets/angular/button-story-with-args.mdx.mdx +++ b/docs/snippets/angular/button-story-with-args.mdx.mdx @@ -7,16 +7,19 @@ import { Button } from './button.component'; - -export const Template = (args) => ({ props: args }); + - - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-args.ts.mdx b/docs/snippets/angular/button-story-with-args.ts.mdx index 9397f8fcbb9b..12f1f9cc4907 100644 --- a/docs/snippets/angular/button-story-with-args.ts.mdx +++ b/docs/snippets/angular/button-story-with-args.ts.mdx @@ -1,29 +1,28 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular/'; +import type { Meta, Story } from '@storybook/angular/'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; -//πŸ‘‡ We create a β€œtemplate” of how args map to rendering -const Template: Story = (args) => ({ - props: args, -}); - -//πŸ‘‡ Each story then reuses that template -export const Primary = Template.bind({}); - -Primary.args = { - primary: true, - label: 'Button', + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + args: { + primary: true, + label: 'Button', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-blue-args.ts.mdx b/docs/snippets/angular/button-story-with-blue-args.ts.mdx index 0883da9d428e..e6a8a4afb695 100644 --- a/docs/snippets/angular/button-story-with-blue-args.ts.mdx +++ b/docs/snippets/angular/button-story-with-blue-args.ts.mdx @@ -1,15 +1,15 @@ ```ts // Button.stories.ts -import { Meta } from '@storybook/angular'; +import type { Meta } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, //πŸ‘‡ Creates specific parameters for the story diff --git a/docs/snippets/angular/button-story-with-emojis.mdx.mdx b/docs/snippets/angular/button-story-with-emojis.mdx.mdx index 8490a0c47ff7..4b262d749f91 100644 --- a/docs/snippets/angular/button-story-with-emojis.mdx.mdx +++ b/docs/snippets/angular/button-story-with-emojis.mdx.mdx @@ -7,30 +7,34 @@ import { Button } from './button.component'; - - {{ + + + ({ props: { - background: '#ff0', + backgroundColor: '#ff0', label: 'Button', }, - }} - - - - {{ + })} /> + ({ props: { - background: '#ff0', + backgroundColor: '#ff0', label: 'πŸ˜„πŸ‘πŸ˜πŸ’―', }, - }} - - - - {{ + })} /> + ({ props: { - background: '#ff0', + backgroundColor: '#ff0', label: 'πŸ“šπŸ“•πŸ“ˆπŸ€“', }, - }} - + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-emojis.ts.mdx b/docs/snippets/angular/button-story-with-emojis.ts.mdx index ce4c5a05ed10..33f59f8e9fbc 100644 --- a/docs/snippets/angular/button-story-with-emojis.ts.mdx +++ b/docs/snippets/angular/button-story-with-emojis.ts.mdx @@ -1,38 +1,48 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; -export const Primary: Story = () => ({ - props: { - label: 'Button', - backgroundColor: '#ff0', - }, -}); - +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + render: () => ({ + props: { + label: 'Button', + backgroundColor: '#ff0', + }, + }), +}; -export const Secondary: Story = () => ({ - props: { - label: 'πŸ˜„πŸ‘πŸ˜πŸ’―', - backgroundColor: '#ff0', - }, -}); +export const Secondary: Story = { + render: () => ({ + props: { + label: 'πŸ˜„πŸ‘πŸ˜πŸ’―', + backgroundColor: '#ff0', + }, + }), +}; -export const Tertiary: Story = () => ({ - props: { - label: 'πŸ“šπŸ“•πŸ“ˆπŸ€“', - backgroundColor: '#ff0', - }, -}); +export const Tertiary: Story = { + render: () => ({ + props: { + label: 'πŸ“šπŸ“•πŸ“ˆπŸ€“', + backgroundColor: '#ff0', + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story-with-parameters.ts.mdx b/docs/snippets/angular/button-story-with-parameters.ts.mdx index a47b5b4d52d3..4bac6bb9b8a8 100644 --- a/docs/snippets/angular/button-story-with-parameters.ts.mdx +++ b/docs/snippets/angular/button-story-with-parameters.ts.mdx @@ -1,15 +1,15 @@ ```ts // Button.stories.ts -import { Meta } from '@storybook/angular'; +import type { Meta } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, parameters: { diff --git a/docs/snippets/angular/button-story.mdx.mdx b/docs/snippets/angular/button-story.mdx.mdx index c0046a7e3fd4..622760377aef 100644 --- a/docs/snippets/angular/button-story.mdx.mdx +++ b/docs/snippets/angular/button-story.mdx.mdx @@ -9,12 +9,12 @@ import { Button } from './button.component.ts'; # Button - - {{ + ({ props: { primary: true, label: 'Button', }, - }} - + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/button-story.ts.mdx b/docs/snippets/angular/button-story.ts.mdx index 6caf51790495..d3fd7c86ceca 100644 --- a/docs/snippets/angular/button-story.ts.mdx +++ b/docs/snippets/angular/button-story.ts.mdx @@ -1,23 +1,30 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, } as Meta; -export const Primary: Story = () => ({ - props: { - label: 'Button', - primary: true, - }, -}); +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + render: () => ({ + props: { + label: 'Button', + primary: true, + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/checkbox-story-csf.ts.mdx b/docs/snippets/angular/checkbox-story-csf.ts.mdx index 482aa27c18f4..0c39202e21dd 100644 --- a/docs/snippets/angular/checkbox-story-csf.ts.mdx +++ b/docs/snippets/angular/checkbox-story-csf.ts.mdx @@ -1,26 +1,33 @@ ```ts // Checkbox.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Checkbox } from './Checkbox.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ - title: 'Checkbox', + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ + title: 'Checkbox', component: Checkbox, } as Meta; -export const allCheckboxes: Story = () => ({ - template: ` -
- - - - - `, -}); +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const allCheckboxes: Story = { + render: () => ({ + template: ` +
+ + + + + `, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/checkbox-story-starter-example.mdx.mdx b/docs/snippets/angular/checkbox-story-starter-example.mdx.mdx index 81d841b07fb7..13a72b787e04 100644 --- a/docs/snippets/angular/checkbox-story-starter-example.mdx.mdx +++ b/docs/snippets/angular/checkbox-story-starter-example.mdx.mdx @@ -7,18 +7,23 @@ import { Checkbox } from './checkbox.component'; + + - {{ + name="MyStory" + render={() => ({ template: `
- - - - - `, - }} + + + + `, + })} >
``` \ No newline at end of file diff --git a/docs/snippets/angular/checkbox-story.mdx.mdx b/docs/snippets/angular/checkbox-story.mdx.mdx index e689fc4facf2..7c948bbbbf02 100644 --- a/docs/snippets/angular/checkbox-story.mdx.mdx +++ b/docs/snippets/angular/checkbox-story.mdx.mdx @@ -7,7 +7,11 @@ import { Checkbox } from './checkbox.component'; -export const Template = (args) => ({ props: args }); + # Checkbox @@ -19,27 +23,28 @@ Markdown documentation. name="Unchecked" args={{ label: 'Unchecked', - }}> - {Template.bind({})} -
- + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - - + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-custom-args-complex.mdx.mdx b/docs/snippets/angular/component-story-custom-args-complex.mdx.mdx index 3386c7ffc963..af0ba520ba35 100644 --- a/docs/snippets/angular/component-story-custom-args-complex.mdx.mdx +++ b/docs/snippets/angular/component-story-custom-args-complex.mdx.mdx @@ -15,22 +15,9 @@ export const someFunction = (valuePropertyA, valuePropertyB) => { }; -export const Template = (args) => { - const { propertyA, propertyB } = args; - - // πŸ‘‡ Assigns the function result to a variable - const someFunctionResult = someFunction(propertyA, propertyB); - return { - props: { - ...args, - someProperty: someFunctionResult, - }, - }; -}; - { args={{ propertyA: 'Item One', propertyB: 'Another Item One', - }}> - {Template.bind({})} - - { + const { propertyA, propertyB } = args; + const someFunctionResult = someFunction(propertyA, propertyB); + return { + props: { + ...args, + someProperty: someFunctionResult, + }, + }; + }} /> + ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-custom-args-complex.ts.mdx b/docs/snippets/angular/component-story-custom-args-complex.ts.mdx index db70034eecf8..3c0e1267c6ea 100644 --- a/docs/snippets/angular/component-story-custom-args-complex.ts.mdx +++ b/docs/snippets/angular/component-story-custom-args-complex.ts.mdx @@ -1,15 +1,15 @@ ```ts // YourComponent.stories.ts -import { Meta, Story} from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { YourComponent } from './your-component.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'YourComponent', component: YourComponent, //πŸ‘‡ Creates specific argTypes with options @@ -29,23 +29,23 @@ const someFunction = (valuePropertyA: String, valuePropertyB: String) => { // Makes some computations and returns something }; -const Template: Story = (args) => { - const { propertyA, propertyB } = args; - - //πŸ‘‡ Assigns the function result to a variable - const someFunctionResult = someFunction(propertyA, propertyB); - - return { - props: { - ...args, - someProperty: someFunctionResult, - }, - }; -}; - -export const ExampleStory = Template.bind({}); -ExampleStory.args= { - propertyA: 'Item One', - propertyB: 'Another Item One', +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const ExampleStory: Story = { + render: (args) => { + const { propertyA, propertyB } = args; + //πŸ‘‡ Assigns the function result to a variable + const someFunctionResult = someFunction(propertyA, propertyB); + return { + props: { + ...args, + someProperty: someFunctionResult, + }, + }; + }, + args: { propertyA: 'Item One', propertyB: 'Another Item One' }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-figma-integration.mdx.mdx b/docs/snippets/angular/component-story-figma-integration.mdx.mdx index 85939ccf81a0..314a0bbe2550 100644 --- a/docs/snippets/angular/component-story-figma-integration.mdx.mdx +++ b/docs/snippets/angular/component-story-figma-integration.mdx.mdx @@ -9,7 +9,11 @@ import { MyComponent } from './MyComponent.component'; -export const Template = () => ({ props: {} }); + ({ props: {} }); url: 'https://www.figma.com/file/Sample-File', }, }} - > - {Template.bind({})} - + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-figma-integration.ts.mdx b/docs/snippets/angular/component-story-figma-integration.ts.mdx index eb0e2565f611..eb1327cb8580 100644 --- a/docs/snippets/angular/component-story-figma-integration.ts.mdx +++ b/docs/snippets/angular/component-story-figma-integration.ts.mdx @@ -1,29 +1,25 @@ ```ts // MyComponent.stories.ts -import { Story, Meta } from '@storybook/angular/'; +import type { Story, Meta } from '@storybook/angular/'; import { withDesign } from 'storybook-addon-designs'; import { MyComponent } from './MyComponent.component'; -// More on default export: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export +// More on default export: https://storybook.js.org/docs/7.0/angular/writing-stories/introduction#default-export export default { title: 'FigmaExample', component: MyComponent, decorators: [withDesign], } as Meta; -// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args -const Template: Story = () => ({ - props: {}, -}); - -export const Example = Template.bind({}); -Example.parameters = { - design: { - type: 'figma', - url: 'https://www.figma.com/file/Sample-File', +export const Example: Story = { + parameters: { + design: { + type: 'figma', + url: 'https://www.figma.com/file/Sample-File', + }, }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-mdx-story-by-name.mdx.mdx b/docs/snippets/angular/component-story-mdx-story-by-name.mdx.mdx index 1bbde792d7ad..9c9002441fde 100644 --- a/docs/snippets/angular/component-story-mdx-story-by-name.mdx.mdx +++ b/docs/snippets/angular/component-story-mdx-story-by-name.mdx.mdx @@ -7,9 +7,18 @@ import { Button } from './button.component'; -export const Template = (args) => ({ props: args }); + - - {Template.bind({})} - + ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-cdn.mdx.mdx b/docs/snippets/angular/component-story-static-asset-cdn.mdx.mdx index dc9bcbf923b8..336ad15470f5 100644 --- a/docs/snippets/angular/component-story-static-asset-cdn.mdx.mdx +++ b/docs/snippets/angular/component-story-static-asset-cdn.mdx.mdx @@ -8,13 +8,15 @@ import { MyComponent } from './MyComponent.component'; + + - {{ - props: { - src: 'https://place-hold.it/350x150', - alt: 'My CDN placeholder', - }, - }} - + name="WithAnImage" + render={() => ({ + template: `My CDN placeholder`, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-cdn.ts.mdx b/docs/snippets/angular/component-story-static-asset-cdn.ts.mdx index 7fb6fa7d8e31..5ee0ebf5c46a 100644 --- a/docs/snippets/angular/component-story-static-asset-cdn.ts.mdx +++ b/docs/snippets/angular/component-story-static-asset-cdn.ts.mdx @@ -1,24 +1,30 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'img', component: MyComponent, } as Meta; - -export const WithAnImage: Story = () => ({ - props: { - src: 'https://place-hold.it/350x150', - alt: 'My CDN placeholder', - }, -}); +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const WithAnImage: Story = { + render: () => ({ + props: { + src: 'https://place-hold.it/350x150', + alt: 'My CDN placeholder', + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-with-import.mdx.mdx b/docs/snippets/angular/component-story-static-asset-with-import.mdx.mdx index 35c9defa8c75..6dfd1477cc01 100644 --- a/docs/snippets/angular/component-story-static-asset-with-import.mdx.mdx +++ b/docs/snippets/angular/component-story-static-asset-with-import.mdx.mdx @@ -9,18 +9,24 @@ import imageFile from './static/image.png'; + + export const image = { src: imageFile, alt: 'my image', }; - - {{ + ({ props: { src: image.src, alt: image.alt, }, template: `{{alt}}`, - }} - + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-with-import.ts.mdx b/docs/snippets/angular/component-story-static-asset-with-import.ts.mdx index c8b078d1ce2f..54ff18d685e4 100644 --- a/docs/snippets/angular/component-story-static-asset-with-import.ts.mdx +++ b/docs/snippets/angular/component-story-static-asset-with-import.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; @@ -9,9 +9,9 @@ import imageFile from './static/image.png'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'img', component: MyComponent, } as Meta; @@ -21,11 +21,18 @@ const image = { alt: 'my image', }; -export const WithAnImage: Story () => ({ - template: `{{alt}}`, - props: { - src: image.src, - alt: image.alt, - }, -}); +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const WithAnImage: Story = { + render: () => ({ + props: { + src: image.src, + alt: image.alt, + }, + template: `{{alt}}`, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-without-import.mdx.mdx b/docs/snippets/angular/component-story-static-asset-without-import.mdx.mdx index 9dbd1623b4ad..de052b06b225 100644 --- a/docs/snippets/angular/component-story-static-asset-without-import.mdx.mdx +++ b/docs/snippets/angular/component-story-static-asset-without-import.mdx.mdx @@ -9,12 +9,8 @@ import { MyComponent } from './MyComponent.component'; - {{ - props: { - src: '/image.png', - alt: 'my image', - }, - }} - + name="withAnImage" + render={() => ({ + template: `my image`, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-static-asset-without-import.ts.mdx b/docs/snippets/angular/component-story-static-asset-without-import.ts.mdx index 04357f1f4557..806ebd115407 100644 --- a/docs/snippets/angular/component-story-static-asset-without-import.ts.mdx +++ b/docs/snippets/angular/component-story-static-asset-without-import.ts.mdx @@ -1,24 +1,26 @@ ```ts // MyComponent.stories.ts -import {Β Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'img', component: MyComponent, } as Meta; // Assume image.png is located in the "public" directory. -export const WithAnImage: Story = () => ({ - props: { - src: '/image.png', - alt: 'my image', - }, -}); +export const WithAnImage: Story = { + render: () => ({ + props: { + src: '/image.png', + alt: 'my image', + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-with-accessibility.mdx.mdx b/docs/snippets/angular/component-story-with-accessibility.mdx.mdx index d267cb707f36..e3871e8be688 100644 --- a/docs/snippets/angular/component-story-with-accessibility.mdx.mdx +++ b/docs/snippets/angular/component-story-with-accessibility.mdx.mdx @@ -16,28 +16,27 @@ import { Button } from './Button.component'; } }} /> -export const Template = (args) => ({ props: args }); - ## This is an accessible story - - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ## This is not - - - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-with-accessibility.ts.mdx b/docs/snippets/angular/component-story-with-accessibility.ts.mdx index 751934b3ea15..1fc0e394e546 100644 --- a/docs/snippets/angular/component-story-with-accessibility.ts.mdx +++ b/docs/snippets/angular/component-story-with-accessibility.ts.mdx @@ -1,14 +1,14 @@ ```ts // Button.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Button } from './Button.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading to learn how to generate automatic titles + */ title: 'Accessibility testing', component: Button, argTypes: { @@ -16,19 +16,18 @@ export default { }, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const Accessible: Story = Template.bind({}); -Accessible.args = { - primary: false, - label: 'Button', +// This is an accessible story +export const Accessible: Story = { + args: { + primary: false, + label: 'Button', + }, }; - -export const Inaccessible: Story = Template.bind({}); -Inaccessible.args = { - ...Accessible.args, - backgroundColor: 'red', +// This is not +export const Inaccessible: Story = { + args: { + ...Accessible.args, + backgroundColor: 'red', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/component-story-with-custom-render-function.ts.mdx b/docs/snippets/angular/component-story-with-custom-render-function.ts.mdx new file mode 100644 index 000000000000..41caa5907d30 --- /dev/null +++ b/docs/snippets/angular/component-story-with-custom-render-function.ts.mdx @@ -0,0 +1,41 @@ +```ts +// MyComponent.stories.ts + +import { Meta, moduleMetadata, Story } from '@storybook/angular'; + +import { CommonModule } from '@angular/common'; + +import { Layout } from './Layout.component'; + +import { MyComponent } from './MyComponent.component'; + +export default { + /* πŸ‘‡ The title prop is optional. + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ + title: 'MyComponent', + component: MyComponent, + decorators: [ + moduleMetadata({ + declarations: [Layout], + imports: [CommonModule], + }), + ], +} as Meta; + +export const Example: Story = { + render: () => ({ + template: ` + +
+

Example

+
+
+ +
+
+ `, + }), +}; +``` \ No newline at end of file diff --git a/docs/snippets/angular/documentscreen-story-msw-graphql-query.ts.mdx b/docs/snippets/angular/documentscreen-story-msw-graphql-query.ts.mdx index 13f45f9fcfe4..14832bc934ff 100644 --- a/docs/snippets/angular/documentscreen-story-msw-graphql-query.ts.mdx +++ b/docs/snippets/angular/documentscreen-story-msw-graphql-query.ts.mdx @@ -1,13 +1,11 @@ ```ts // YourPage.stories.ts -import { Meta, Story } from '@storybook/angular'; +import { Meta, moduleMetadata, Story } from '@storybook/angular'; import { CommonModule } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; -import { Meta, moduleMetadata, Story } from '@storybook/angular'; - import { graphql } from 'msw'; import { DocumentScreen } from './YourPage.component'; @@ -19,9 +17,9 @@ import { MockGraphQLModule } from './mock-graphql.module'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'DocumentScreen', component: DocumentScreen, decorators: [ @@ -81,32 +79,30 @@ const TestData = { ], }; -const PageTemplate: Story = () => ({ - props: {}, -}); - -export const MockedSuccess = PageTemplate.bind({}); -MockedSuccess.parameters = { - msw: [ - graphql.query('AllInfoQuery', (req, res, ctx) => { - return res(ctx.data(TestData)); - }), - ], +export const MockedSuccess: Story = { + parameters: { + msw: [ + graphql.query('AllInfoQuery', (req, res, ctx) => { + return res(ctx.data(TestData)); + }), + ], + }, }; -export const MockedError = PageTemplate.bind({}); -MockedError.parameters = { - msw: [ - graphql.query('AllInfoQuery', (req, res, ctx) => { - return res( - ctx.delay(800), - ctx.errors([ - { - message: 'Access denied', - }, - ]) - ); - }), - ], +export const MockedError: Story = { + parameters: { + msw: [ + graphql.query('AllInfoQuery', (req, res, ctx) => { + return res( + ctx.delay(800), + ctx.errors([ + { + message: 'Access denied', + }, + ]) + ); + }), + ], + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/documentscreen-story-msw-rest-request.ts.mdx b/docs/snippets/angular/documentscreen-story-msw-rest-request.ts.mdx index b322e273b2b2..00475e53bd64 100644 --- a/docs/snippets/angular/documentscreen-story-msw-rest-request.ts.mdx +++ b/docs/snippets/angular/documentscreen-story-msw-rest-request.ts.mdx @@ -1,13 +1,11 @@ ```ts // YourPage.stories.ts -import { Meta, Story } from '@storybook/angular'; +import { Meta, moduleMetadata, Story } from '@storybook/angular'; import { CommonModule } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; -import { Meta, moduleMetadata, Story } from '@storybook/angular'; - import { rest } from 'msw'; import { DocumentScreen } from './YourPage.component'; @@ -17,9 +15,9 @@ import { PageLayout } from './PageLayout.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'DocumentScreen', component: DocumentScreen, decorators: [ @@ -79,25 +77,23 @@ const TestData = { ], }; -const PageTemplate: Story = () => ({ - props: {}, -}); - -export const MockedSuccess = PageTemplate.bind({}); -MockedSuccess.parameters = { - msw: [ - rest.get('https://your-restful-endpoint', (_req, res, ctx) => { - return res(ctx.json(TestData)); - }), - ], +export const MockedSuccess: Story = { + parameters: { + msw: [ + rest.get('https://your-restful-endpoint', (_req, res, ctx) => { + return res(ctx.json(TestData)); + }), + ], + }, }; -export const MockedError = PageTemplate.bind({}); -MockedError.parameters = { - msw: [ - rest.get('https://your-restful-endpoint', (_req, res, ctx) => { - return res(ctx.delay(800), ctx.status(403)); - }), - ], +export const MockedError: Story = { + parameters: { + msw: [ + rest.get('https://your-restful-endpoint', (_req, res, ctx) => { + return res(ctx.delay(800), ctx.status(403)); + }), + ], + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/form-story-component-with-play-function.ts.mdx b/docs/snippets/angular/form-story-component-with-play-function.ts.mdx deleted file mode 100644 index 40c91d9e7389..000000000000 --- a/docs/snippets/angular/form-story-component-with-play-function.ts.mdx +++ /dev/null @@ -1,24 +0,0 @@ -```ts -// Form.stories.ts - -import { userEvent, within } from '@storybook/testing-library'; - -import { LoginForm } from './LoginForm.component'; - -export default { - component: LoginForm, -}; - -export const FilledForm = { - play: async ({ args, canvasElement }) => { - // Starts querying the component from its root element - const canvas = within(canvasElement); - - await userEvent.type(canvas.getByTestId('email'), 'email'); - await userEvent.type(canvas.getByTestId('password'), 'password'); - - // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - await userEvent.click(canvas.getByRole('button')); - }, -}; -``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-expanded.ts.mdx b/docs/snippets/angular/list-story-expanded.ts.mdx index 2a3d5e1c9f82..0cdf2052046c 100644 --- a/docs/snippets/angular/list-story-expanded.ts.mdx +++ b/docs/snippets/angular/list-story-expanded.ts.mdx @@ -10,9 +10,9 @@ import { ListItem } from './list-item.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'List', component: List, decorators: [ @@ -24,26 +24,33 @@ export default { } as Meta; // Always an empty list, not super interesting -export const Empty: Story = (args) => ({ - props: args, - template: ``, -}); +export const Empty: Story = { + render: (args) => ({ + props: args, + template: '', + }), +}; -export const OneItem: Story = (args) => ({ - props: args, - template: ` - - - `, -}); +export const OneItem: Story = { + render: (args) => ({ + props: args, + template: ` + + + `, + }), +}; -export const ManyItems: Story = (args) => ({ - props: args, - template: ` - - - - - `, -}); +export const ManyItems: Story = { + render: (args) => ({ + props: args, + template: ` + + + + + + `, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-reuse-data.ts.mdx b/docs/snippets/angular/list-story-reuse-data.ts.mdx index e58dd12c2aa1..2e758b034060 100644 --- a/docs/snippets/angular/list-story-reuse-data.ts.mdx +++ b/docs/snippets/angular/list-story-reuse-data.ts.mdx @@ -13,9 +13,9 @@ import { Selected, Unselected } from './ListItem.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'List', component: List, decorators: [ @@ -26,19 +26,25 @@ export default { ], } as Meta; - -export const ManyItems: Story = (args) => ({ - props: args, - template: ` - - - - - - `, -}); -ManyItems.args= { - Selected: Selected.args.isSelected, - Unselected: Unselected.args.isSelected, + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const ManyItems: Story = { + args: { + Selected: Selected.args.isSelected, + Unselected: Unselected.args.isSelected, + }, + render: (args) => ({ + props: args, + template: ` + + + + + + `, + }), }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-starter.ts.mdx b/docs/snippets/angular/list-story-starter.ts.mdx index d325679ad9e3..87f234b07a30 100644 --- a/docs/snippets/angular/list-story-starter.ts.mdx +++ b/docs/snippets/angular/list-story-starter.ts.mdx @@ -9,9 +9,9 @@ import { List } from './list.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ component: List, decorators: [ moduleMetadata({ @@ -22,8 +22,10 @@ export default { } as Meta; // Always an empty list, not super interesting -const Template: Story = (args) => ({ - props: args, - template: ``, -}); +export const Empty: Story = { + render: (args) => ({ + props: args, + template: ``, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-template.ts.mdx b/docs/snippets/angular/list-story-template.ts.mdx index bac6ba8fdb19..0848e1c36cca 100644 --- a/docs/snippets/angular/list-story-template.ts.mdx +++ b/docs/snippets/angular/list-story-template.ts.mdx @@ -13,9 +13,9 @@ import { Unchecked } from './ListItem.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'List', component: List, decorators: [ @@ -26,29 +26,33 @@ export default { ], } as Meta; + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +const ListTemplate: Story = { + render: (args) => ({ + props: args, + template: ` + +
+ +
+
+ `, + }), +}; -const ListTemplate: Story = (args) => ({ - props: args, - template: ` - -
- -
-
- `, -}); - -export const Empty = ListTemplate.bind({}); -EmptyListTemplate.args = { - items: [], +export const Empty: Story = { + ...ListTemplate, + args: { items: [] }, }; -export const OneItem = ListTemplate.bind({}); -OneItem.args = { - items: [ - { - ...Unchecked.args, - }, - ], +export const OneItem: Story = { + ...ListTemplate, + args: { + items: [{ ...Unchecked.args }], + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-unchecked.ts.mdx b/docs/snippets/angular/list-story-unchecked.ts.mdx index 017d94620c1c..148bb5da82b1 100644 --- a/docs/snippets/angular/list-story-unchecked.ts.mdx +++ b/docs/snippets/angular/list-story-unchecked.ts.mdx @@ -13,9 +13,9 @@ import { Unchecked } from './ListItem.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'List', component: List, decorators: [ @@ -26,17 +26,22 @@ export default { ], } as Meta; - -export const OneItem: Story = (args) => ({ - props: args, - template: ` - - - - `, -}); - -OneItem.args = { - ...Unchecked.args, +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const OneItem: Story = { + render: (args) => ({ + props: args, + template: ` + + + + `, + }), + args: { + ...Unchecked.args, + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/list-story-with-subcomponents.ts.mdx b/docs/snippets/angular/list-story-with-subcomponents.ts.mdx index 459bf8791a68..373105e347a1 100644 --- a/docs/snippets/angular/list-story-with-subcomponents.ts.mdx +++ b/docs/snippets/angular/list-story-with-subcomponents.ts.mdx @@ -10,9 +10,9 @@ import { ListItem } from './list-item.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'List', component: List, subcomponents: { ListItem }, //πŸ‘ˆ Adds the ListItem component as a subcomponent @@ -24,20 +24,22 @@ export default { ], } as Meta; -export const Empty: Story = () => ({ - props: { - args, - }, -}); + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Empty: Story = {}; -export const OneItem: Story = () => ({ - props: { - args, - }, - template: ` - - - +export const OneItem: Story = { + args: {}, + render: (args) => ({ + props: args, + template: ` + + + `, -}); + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/loader-story.mdx.mdx b/docs/snippets/angular/loader-story.mdx.mdx index b1ea6fa0b5bd..70635ae4aa8a 100644 --- a/docs/snippets/angular/loader-story.mdx.mdx +++ b/docs/snippets/angular/loader-story.mdx.mdx @@ -9,6 +9,12 @@ import fetch from 'node-fetch'; + + - {(args, { loaded: { todo } }) => ({ + ]} + render={(args, { loaded: { todo } }) => ({ props: { - todo: todo, + args, + todo, }, - })} - + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/loader-story.ts.mdx b/docs/snippets/angular/loader-story.ts.mdx index a48f5f9e78f8..515f920b3fc6 100644 --- a/docs/snippets/angular/loader-story.ts.mdx +++ b/docs/snippets/angular/loader-story.ts.mdx @@ -11,9 +11,9 @@ import { TodoItem } from './TodoItem'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Examples/Loader', component: TodoItem, decorators: [ @@ -24,18 +24,22 @@ export default { ], } as Meta; -export const Primary = (args, { loaded: { todo } }) => { - return { + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Primary: Story = { + render: (args, { loaded: { todo } }) => ({ props: { args, todo, }, - }; -}; - -Primary.loaders = [ - async () => ({ - todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(), }), -]; + loaders: [ + async () => ({ + todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(), + }), + ], +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/login-form-with-play-function.mdx.mdx b/docs/snippets/angular/login-form-with-play-function.mdx.mdx index 31443143cd7d..ed6ef23d9f3e 100644 --- a/docs/snippets/angular/login-form-with-play-function.mdx.mdx +++ b/docs/snippets/angular/login-form-with-play-function.mdx.mdx @@ -11,16 +11,21 @@ import { LoginForm } from './LoginForm.component'; -export const Template = (args) => ({ props: args }); + - - {Template.bind({})} - - + ({ + props: args, + })} /> { + play={ async ({ canvasElement }) => { // Starts querying the component from its root element const canvas = within(canvasElement); @@ -29,7 +34,7 @@ export const Template = (args) => ({ props: args }); await userEvent.type(canvas.getByTestId('password'), 'a-random-password'); - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel await userEvent.click(canvas.getByRole('button')); // πŸ‘‡ Assert DOM structure @@ -38,8 +43,9 @@ export const Template = (args) => ({ props: args }); 'Everything is perfect. Your account is ready and we should probably get you started!' ) ).toBeInTheDocument(); - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> -``` \ No newline at end of file +``` diff --git a/docs/snippets/angular/login-form-with-play-function.ts.mdx b/docs/snippets/angular/login-form-with-play-function.ts.mdx index 48df0db4da3c..cc9c0eacbde8 100644 --- a/docs/snippets/angular/login-form-with-play-function.ts.mdx +++ b/docs/snippets/angular/login-form-with-play-function.ts.mdx @@ -1,7 +1,7 @@ ```ts // LoginForm.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { userEvent, within } from '@storybook/testing-library'; @@ -11,37 +11,35 @@ import { LoginForm } from './LoginForm.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Form', component: LoginForm, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); -export const EmptyForm: Story = Template.bind({}); +export const EmptyForm: Story = {}; -export const FilledForm: Story = Template.bind({}); -FilledForm.play = async ({ canvasElement }) => { - // Starts querying the component from its root element - const canvas = within(canvasElement); +export const FilledForm: Story = { + play: async ({ canvasElement }) => { + // Starts querying the component from its root element + const canvas = within(canvasElement); - // πŸ‘‡ Simulate interactions with the component - await userEvent.type(canvas.getByTestId('email'), 'email@provider.com'); + // πŸ‘‡ Simulate interactions with the component + await userEvent.type(canvas.getByTestId('email'), 'email@provider.com'); - await userEvent.type(canvas.getByTestId('password'), 'a-random-password'); + await userEvent.type(canvas.getByTestId('password'), 'a-random-password'); - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - await userEvent.click(canvas.getByRole('button')); + // See https://storybook.js.org/docs/7.0/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + await userEvent.click(canvas.getByRole('button')); - // πŸ‘‡ Assert DOM structure - await expect( - canvas.getByText( - 'Everything is perfect. Your account is ready and we should probably get you started!' - ) - ).toBeInTheDocument(); + // πŸ‘‡ Assert DOM structure + await expect( + canvas.getByText( + 'Everything is perfect. Your account is ready and we should probably get you started!' + ) + ).toBeInTheDocument(); + }, }; -``` \ No newline at end of file +``` diff --git a/docs/snippets/angular/mdx-canvas-multiple-stories.mdx.mdx b/docs/snippets/angular/mdx-canvas-multiple-stories.mdx.mdx index 8f34d74ce589..1e37d2da1eae 100644 --- a/docs/snippets/angular/mdx-canvas-multiple-stories.mdx.mdx +++ b/docs/snippets/angular/mdx-canvas-multiple-stories.mdx.mdx @@ -7,7 +7,11 @@ import { Badge } from './badge.component'; -export const Template = (args) => ({ props: args }); + ({ props: args }); args={{ status: 'warning', label: 'Warning', - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` diff --git a/docs/snippets/angular/my-component-play-function-alt-queries.mdx.mdx b/docs/snippets/angular/my-component-play-function-alt-queries.mdx.mdx index 39d95c5bd919..546d391f02db 100644 --- a/docs/snippets/angular/my-component-play-function-alt-queries.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-alt-queries.mdx.mdx @@ -9,23 +9,28 @@ import { MyComponent } from './MyComponent.component'; -export const Template = (args) => ({ props: args }); + { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + play={ async () => { + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel await userEvent.click(screen.getByRole('button', { name: / button label/i })); - }} > - {Template.bind({})} - - + }} + render={(args) => ({ + props: args, + })} /> { + play={ async () => { // The play function interacts with the component and looks for the text await screen.findByText('example string'); - }} > - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-alt-queries.ts.mdx b/docs/snippets/angular/my-component-play-function-alt-queries.ts.mdx index fae563d58d89..2a0ee07f7cfc 100644 --- a/docs/snippets/angular/my-component-play-function-alt-queries.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-alt-queries.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/addon-docs'; +import type { Meta, Story } from '@storybook/addon-docs'; import { screen, userEvent } from '@storybook/testing-library'; @@ -9,27 +9,24 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'QueryMethods', component: MyComponent, - } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const ExampleWithRole: Story = Template.bind({}); -ExampleWithRole.play = async () => { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - await userEvent.click(screen.getByRole('button', { name: / button label/i })); +export const ExampleWithRole: Story = { + play: async () => { + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + await userEvent.click(screen.getByRole('button', { name: / button label/i })); + }, }; -export const ExampleWithText: Story = Template.bind({}); -ExampleWithText.play = async () => { - // The play function interacts with the component and looks for the text - await screen.findByText('example string'); +export const ExampleWithText: Story = { + play: async () => { + // The play function interacts with the component and looks for the text + await screen.findByText('example string'); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-composition.ts.mdx b/docs/snippets/angular/my-component-play-function-composition.ts.mdx index 818de2f6f011..a30c9235ea87 100644 --- a/docs/snippets/angular/my-component-play-function-composition.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-composition.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { screen, userEvent } from '@storybook/testing-library'; @@ -9,32 +9,31 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'MyComponent', - component: MyComponent, + component: MyComponent, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const FirstStory: Story = Template.bind({}); -FirstStory.play = async () => { - userEvent.type(screen.getByTestId('an-element'), 'example-value'); +export const FirstStory: Story = { + play: async () => { + userEvent.type(screen.getByTestId('an-element'), 'example-value'); + }, }; -export const SecondStory: Story = Template.bind({}); -SecondStory.play = async () => { - await userEvent.type(screen.getByTestId('other-element'), 'another value'); +export const SecondStory: Story = { + play: async () => { + await userEvent.type(screen.getByTestId('other-element'), 'another value'); + }, }; -export const CombinedStories: Story = Template.bind({}); -CombinedStories.play = async () => { - // Runs the FirstStory and Second story play function before running this story's play function - await FirstStory.play(); - await SecondStory.play(); - await userEvent.type(screen.getByTestId('another-element'), 'random value'); +export const CombinedStories: Story = { + play: async () => { + // Runs the FirstStory and Second story play function before running this story's play function + await FirstStory.play(); + await SecondStory.play(); + await userEvent.type(screen.getByTestId('another-element'), 'random value'); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-waitfor.mdx.mdx b/docs/snippets/angular/my-component-play-function-waitfor.mdx.mdx index b0423221fde9..00cbd59e61c8 100644 --- a/docs/snippets/angular/my-component-play-function-waitfor.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-waitfor.mdx.mdx @@ -9,11 +9,15 @@ import { MyComponent } from './MyComponent.component'; -export const Template = (args) => ({ props: args }); + { + play={ async () => { const Input = screen.getByLabelText('Username', { selector: 'input', }); @@ -22,15 +26,16 @@ export const Template = (args) => ({ props: args }); delay: 100, }); - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + const Submit = screen.getByRole('button'); await userEvent.click(Submit); await waitFor(async () => { await userEvent.hover(screen.getByTestId('error')); }); - }} > - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-waitfor.ts.mdx b/docs/snippets/angular/my-component-play-function-waitfor.ts.mdx index bb8cfebfc317..acf07c8f5c80 100644 --- a/docs/snippets/angular/my-component-play-function-waitfor.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-waitfor.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { screen, userEvent, waitFor } from '@storybook/testing-library'; @@ -9,34 +9,30 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'WithAsync', component: MyComponent, - } as Meta; -const Template: Story = (args) => ({ - props: args, -}); +export const ExampleAsyncStory: Story = { + play: async () => { + const Input = screen.getByLabelText('Username', { + selector: 'input', + }); -export const ExampleAsyncStory: Story = Template.bind({}); -ExampleAsyncStory.play = async () => { - const Input = screen.getByLabelText('Username', { - selector: 'input', - }); + await userEvent.type(Input, 'WrongInput', { + delay: 100, + }); - await userEvent.type(Input, 'WrongInput', { - delay: 100, - }); + // See https://storybook.js.org/docs/7.0/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + const Submit = screen.getByRole('button'); + await userEvent.click(Submit); - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - const Submit = screen.getByRole('button'); - await userEvent.click(Submit); - - await waitFor(async () => { - await userEvent.hover(screen.getByTestId('error')); - }); + await waitFor(async () => { + await userEvent.hover(screen.getByTestId('error')); + }); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-canvas.mdx.mdx b/docs/snippets/angular/my-component-play-function-with-canvas.mdx.mdx index 420cd8114f5d..d0ae6d1d3cac 100644 --- a/docs/snippets/angular/my-component-play-function-with-canvas.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-with-canvas.mdx.mdx @@ -9,18 +9,23 @@ import { MyComponent } from './MyComponent.component'; -export const Template = (args) => ({ props: args }); + { - // Assigns canvas to the component root element + // Starts querying the component from its root element const canvas = within(canvasElement); // Starts querying from the component's root element await userEvent.type(canvas.getByTestId('example-element'), 'something'); await userEvent.click(canvas.getByRole('another-element')); - }} > - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-canvas.ts.mdx b/docs/snippets/angular/my-component-play-function-with-canvas.ts.mdx index 1cfc409bb7cc..51e1965ee5a2 100644 --- a/docs/snippets/angular/my-component-play-function-with-canvas.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-with-canvas.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { getByRole, userEvent, within } from '@storybook/testing-library'; @@ -9,24 +9,21 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'WithCanvasElement', component: MyComponent, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); +export const ExampleStory: Story = { + play: async ({ canvasElement }) => { + // Assigns canvas to the component root element + const canvas = within(canvasElement); -export const ExampleStory: Story = Template.bind({}); -ExampleStory.play = async ({ canvasElement }) => { - // Assigns canvas to the component root element - const canvas = within(canvasElement); - - // Starts querying from the component's root element - await userEvent.type(canvas.getByTestId('example-element'), 'something'); - await userEvent.click(canvas.getByRole('another-element')); + // Starts querying from the component's root element + await userEvent.type(canvas.getByTestId('example-element'), 'something'); + await userEvent.click(canvas.getByRole('another-element')); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx b/docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx index f14eb480c156..85ca78cb6491 100644 --- a/docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx @@ -9,23 +9,28 @@ import { MyComponent } from './MyComponent.component'; -export const Template = (args) => ({ props: args }); + { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + play={ async () => { + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel await userEvent.click(screen.getByRole('button')); - }}> - {Template.bind({})} - - + }} + render={(args) => ({ + props: args, + })} /> { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel await fireEvent.click(screen.getByTestId('data-testid')); - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-clickevent.ts.mdx b/docs/snippets/angular/my-component-play-function-with-clickevent.ts.mdx index 87dc0d2f1c74..b1e25712293c 100644 --- a/docs/snippets/angular/my-component-play-function-with-clickevent.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-with-clickevent.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { fireEvent, screen, userEvent } from '@storybook/testing-library'; @@ -9,26 +9,24 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'ClickExamples', component: MyComponent, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const ClickExample: Story = Template.bind({}); -ClickExample.play = async () => { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - await userEvent.click(screen.getByRole('button')); +export const ClickExample: Story = { + play: async () => { + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + await userEvent.click(screen.getByRole('button')); + }, }; -export const FireEventExample: Story = Template.bind({}); -FireEventExample.play = async () => { - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - await fireEvent.click(screen.getByTestId('data-testid')); +export const FireEventExample: Story = { + play: async () => { + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + await fireEvent.click(screen.getByTestId('data-testid')); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-delay.mdx.mdx b/docs/snippets/angular/my-component-play-function-with-delay.mdx.mdx index 6ed819ac2e70..6fd941e4ee27 100644 --- a/docs/snippets/angular/my-component-play-function-with-delay.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-with-delay.mdx.mdx @@ -9,11 +9,15 @@ import { MyComponent } from './MyComponent.component'; -export const Template = (args) => ({ props: args }); + { + play={ async () => { const exampleElement= screen.getByLabelText('example-element'); // The delay option set the amount of milliseconds between characters being typed @@ -25,7 +29,8 @@ export const Template = (args) => ({ props: args }); await userEvent.type(AnotherExampleElement, 'another random string', { delay: 100, }); - }} > - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` diff --git a/docs/snippets/angular/my-component-play-function-with-delay.ts.mdx b/docs/snippets/angular/my-component-play-function-with-delay.ts.mdx index 084f43dd360d..dfc26e57fdd1 100644 --- a/docs/snippets/angular/my-component-play-function-with-delay.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-with-delay.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { screen, userEvent } from '@storybook/testing-library'; @@ -9,28 +9,26 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'WithDelay', component: MyComponent, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); +export const DelayedStory: Story = { + play: async () => { + const exampleElement = screen.getByLabelText('example-element'); -export const DelayedStory: Story = Template.bind({}); -DelayedStory.play = () => { - const exampleElement= screen.getByLabelText('example-element'); - // The delay option set the amount of milliseconds between characters being typed - await userEvent.type(exampleElement, 'random string', { - delay: 100, - }); + // The delay option set the ammount of milliseconds between characters being typed + await userEvent.type(exampleElement, 'random string', { + delay: 100, + }); - const AnotherExampleElement= screen.getByLabelText('another-example-element'); - await userEvent.type(AnotherExampleElement, 'another random string', { - delay: 100, - }); + const AnotherExampleElement = screen.getByLabelText('another-example-element'); + await userEvent.type(AnotherExampleElement, 'another random string', { + delay: 100, + }); + }, }; ``` diff --git a/docs/snippets/angular/my-component-play-function-with-selectevent.mdx.mdx b/docs/snippets/angular/my-component-play-function-with-selectevent.mdx.mdx index 4638665ad343..42c89c623ca6 100644 --- a/docs/snippets/angular/my-component-play-function-with-selectevent.mdx.mdx +++ b/docs/snippets/angular/my-component-play-function-with-selectevent.mdx.mdx @@ -15,11 +15,9 @@ export const sleep= (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; -export const Template = (args) => ({ props: args }); - { + play={ async () => { const select = screen.getByRole('listbox'); await userEvent.selectOptions(select, ['One Item']); @@ -30,7 +28,8 @@ export const Template = (args) => ({ props: args }); await userEvent.selectOptions(select, ['Yet another item']); - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-play-function-with-selectevent.ts.mdx b/docs/snippets/angular/my-component-play-function-with-selectevent.ts.mdx index d88755a5cb1c..b14cc2418506 100644 --- a/docs/snippets/angular/my-component-play-function-with-selectevent.ts.mdx +++ b/docs/snippets/angular/my-component-play-function-with-selectevent.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { screen, userEvent } from '@storybook/testing-library'; @@ -9,9 +9,9 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'WithSelectEvent', component: MyComponent, } as Meta; @@ -21,20 +21,17 @@ function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -const Template: Story = (args) => ({ - props: args, -}); +export const ExampleChangeEvent: Story = { + play: async () => { + const select = screen.getByRole('listbox'); -export const ExampleChangeEvent: Story = Template.bind({}); -ExampleChangeEvent.play = async () => { - const select = screen.getByRole('listbox'); + await userEvent.selectOptions(select, ['One Item']); + await sleep(2000); - await userEvent.selectOptions(select, ['One Item']); - await sleep(2000); + await userEvent.selectOptions(select, ['Another Item']); + await sleep(2000); - await userEvent.selectOptions(select, ['Another Item']); - await sleep(2000); - - await userEvent.selectOptions(select, ['Yet another item']); + await userEvent.selectOptions(select, ['Yet another item']); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-basic-and-props.ts.mdx b/docs/snippets/angular/my-component-story-basic-and-props.ts.mdx index 4d212e54bec1..89485c2789a2 100644 --- a/docs/snippets/angular/my-component-story-basic-and-props.ts.mdx +++ b/docs/snippets/angular/my-component-story-basic-and-props.ts.mdx @@ -1,27 +1,26 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Path/To/MyComponent', component: MyComponent, } as Meta; +export const Default: Story = {}; -export const Default: Story = () => ({ - props: {}, -}); - -export const WithProp: Story = () => ({ - props: { - prop: 'value', - }, -}); +export const WithProp: StoryObj = { + render: () => ({ + props: { + prop: 'value', + }, + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-configure-viewports.mdx.mdx b/docs/snippets/angular/my-component-story-configure-viewports.mdx.mdx index 4e7ecefe55b3..57957a4dd1b2 100644 --- a/docs/snippets/angular/my-component-story-configure-viewports.mdx.mdx +++ b/docs/snippets/angular/my-component-story-configure-viewports.mdx.mdx @@ -17,15 +17,20 @@ import { MyComponent } from './MyComponent.component'; }} component={MyComponent} /> + + - {{ - template: '', }} - + render={() => ({ + template: ``, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-configure-viewports.ts.mdx b/docs/snippets/angular/my-component-story-configure-viewports.ts.mdx index 31b17240aaee..b311827c3cb5 100644 --- a/docs/snippets/angular/my-component-story-configure-viewports.ts.mdx +++ b/docs/snippets/angular/my-component-story-configure-viewports.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'; @@ -9,9 +9,9 @@ import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'MyComponent', component: MyComponent, parameters: { @@ -26,7 +26,14 @@ export default { }, } as Meta; -export const MyStory: Story = () => ({ - template: '', -}); + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const MyStory: Story = { + render: () => ({ + template: '', + }), +}; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-use-globaltype.mdx.mdx b/docs/snippets/angular/my-component-story-use-globaltype.mdx.mdx index ffd8be4ad9e7..25a90d09aa1e 100644 --- a/docs/snippets/angular/my-component-story-use-globaltype.mdx.mdx +++ b/docs/snippets/angular/my-component-story-use-globaltype.mdx.mdx @@ -18,12 +18,12 @@ export const getCaptionForLocale = (locale) => { } }; - - {(args, { globals: { locale } }) => { + { const caption = getCaptionForLocale(locale); return { template: `

${caption}

`, }; - }} -
+ }} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-use-globaltype.ts.mdx b/docs/snippets/angular/my-component-story-use-globaltype.ts.mdx index c0f5e90f1954..bceac3fade0f 100644 --- a/docs/snippets/angular/my-component-story-use-globaltype.ts.mdx +++ b/docs/snippets/angular/my-component-story-use-globaltype.ts.mdx @@ -1,15 +1,15 @@ ```ts // MyComponent.stories.ts -import { Meta } from '@storybook/angular'; +import type { Meta } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'MyComponent', component: MyComponent, } as Meta; @@ -29,10 +29,12 @@ const getCaptionForLocale = (locale) => { } }; -export const StoryWithLocale = (args, { globals: { locale } }) => { - const caption = getCaptionForLocale(locale); - return { - template: `

${caption}

`, - }; +export const StoryWithLocale = { + render: (args, { globals: { locale } }) => { + const caption = getCaptionForLocale(locale); + return { + template: `

${caption}

`, + }; + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-story-with-nonstory.ts.mdx b/docs/snippets/angular/my-component-story-with-nonstory.ts.mdx index 51b639ed1292..57f0fbcff8bf 100644 --- a/docs/snippets/angular/my-component-story-with-nonstory.ts.mdx +++ b/docs/snippets/angular/my-component-story-with-nonstory.ts.mdx @@ -1,7 +1,7 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; @@ -9,29 +9,27 @@ import someData from './data.json'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ - title: 'MyComponent', + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ + title: 'MyComponent', component: MyComponent, includeStories: ['SimpleStory', 'ComplexStory'], // πŸ‘ˆ Storybook loads these stories excludeStories: /.*Data$/, // πŸ‘ˆ Storybook ignores anything that contains Data } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - export const simpleData = { foo: 1, bar: 'baz' }; export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } }; -export const SimpleStory = Template.bind({}); -SimpleStory.args = { - data: simpleData, +export const SimpleStory: Story = { + args: { + data: simpleData, + }, }; -export const ComplexStory = Template.bind({}); -ComplexStory.args = { - data: complexData, +export const ComplexStory: Story = { + args: { + data: complexData, + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-with-env-variables.mdx.mdx b/docs/snippets/angular/my-component-with-env-variables.mdx.mdx index 1ece7ecd9a8d..a7875e1350aa 100644 --- a/docs/snippets/angular/my-component-with-env-variables.mdx.mdx +++ b/docs/snippets/angular/my-component-with-env-variables.mdx.mdx @@ -7,14 +7,14 @@ import { MyComponent } from './my-component.component'; -export const Template = (args) => ({ props: args }); - - {Template.bind({})} + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/my-component-with-env-variables.ts.mdx b/docs/snippets/angular/my-component-with-env-variables.ts.mdx index 46a610aeab4f..176b55f18b1a 100644 --- a/docs/snippets/angular/my-component-with-env-variables.ts.mdx +++ b/docs/snippets/angular/my-component-with-env-variables.ts.mdx @@ -1,25 +1,22 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'MyComponent', component: MyComponent, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const ExampleStory = Template.bind({}); -ExampleStory.args = { - propertyA: process.env.STORYBOOK_DATA_KEY +export const ExampleStory: Story = { + args: { + propertyA: process.env.STORYBOOK_DATA_KEY, + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/page-story-slots.mdx.mdx b/docs/snippets/angular/page-story-slots.mdx.mdx index 333bc3bec80f..9989753de595 100644 --- a/docs/snippets/angular/page-story-slots.mdx.mdx +++ b/docs/snippets/angular/page-story-slots.mdx.mdx @@ -7,20 +7,17 @@ import { Page } from './page.component'; -export const Template = (args) => ({ - props: args, - template:` - - ${args.footer} - - `, -}); - - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + template:` + + ${args.footer} + + `, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/page-story-slots.ts.mdx b/docs/snippets/angular/page-story-slots.ts.mdx index 4a59a2b1b5f7..8bfe40a63d24 100644 --- a/docs/snippets/angular/page-story-slots.ts.mdx +++ b/docs/snippets/angular/page-story-slots.ts.mdx @@ -1,30 +1,34 @@ ```ts // Page.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { Page } from './page.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Page', component: Page, } as Meta; - -const Template: Story = (args) => ({ - props: args, - template: ` - - ${args.footer} - `, -}); - -export const CustomFooter = Template.bind({}); -CustomFooter.args = { - footer: 'Built with Storybook', + /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const CustomFooter: Story = { + render: (args) => ({ + props: args, + template: ` + + ${args.footer} + `, + }), + args: { + footer: 'Built with Storybook', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/page-story-with-args-composition.ts.mdx b/docs/snippets/angular/page-story-with-args-composition.ts.mdx index 6b141cf0a9a7..39732dacb4d8 100644 --- a/docs/snippets/angular/page-story-with-args-composition.ts.mdx +++ b/docs/snippets/angular/page-story-with-args-composition.ts.mdx @@ -17,9 +17,9 @@ import * as DocumentListStories from './DocumentList.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'DocumentScreen', component: DocumentScreen, decorators: [ @@ -30,15 +30,11 @@ export default { ], } as Meta; - -const Template: Story = (args) => ({ - props: args, -}); - -export const Simple = Template.bind({}); -Simple.args = { - user: PageLayoutStories.PageLayoutSimple.args.user, - document: DocumentHeaderStories.DocumentHeaderSimple.args.document, - subdocuments: DocumentListStories.DocumentListSimple.args.documents +export const ExampleWithRole: Story = { + args: { + user: PageLayoutStories.PageLayoutSimple.args.user, + document: DocumentHeaderStories.DocumentHeaderSimple.args.document, + subdocuments: DocumentListStories.DocumentListSimple.args.documents, + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/page-story.ts.mdx b/docs/snippets/angular/page-story.ts.mdx index b10dacff8340..271e9fe2ad09 100644 --- a/docs/snippets/angular/page-story.ts.mdx +++ b/docs/snippets/angular/page-story.ts.mdx @@ -14,9 +14,9 @@ import * as HeaderStories from './Header.stories'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Page', component: Page, decorators: [ @@ -27,11 +27,7 @@ export default { ], } as Meta; -const Template: Story = (args) => ({ - props: args, -}); - -export const LoggedIn = { +export const LoggedIn: Story = { args: { ...HeaderStories.LoggedIn.args, }, diff --git a/docs/snippets/angular/register-component-with-play-function.mdx.mdx b/docs/snippets/angular/register-component-with-play-function.mdx.mdx index e157ee1d754f..0908c9a0e704 100644 --- a/docs/snippets/angular/register-component-with-play-function.mdx.mdx +++ b/docs/snippets/angular/register-component-with-play-function.mdx.mdx @@ -9,11 +9,15 @@ import { RegistrationForm } from './RegistrationForm.component'; -export const Template = (args) => ({ props: args }); + { + play={ async () => { const emailInput = screen.getByLabelText('email', { selector: 'input', }); @@ -29,12 +33,13 @@ export const Template = (args) => ({ props: args }); await userEvent.type(passwordInput, 'ExamplePassword', { delay: 100, }); - - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel const Submit = screen.getByRole('button'); await userEvent.click(Submit); - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/register-component-with-play-function.ts.mdx b/docs/snippets/angular/register-component-with-play-function.ts.mdx index 39f62fd79993..57a13770a312 100644 --- a/docs/snippets/angular/register-component-with-play-function.ts.mdx +++ b/docs/snippets/angular/register-component-with-play-function.ts.mdx @@ -1,7 +1,7 @@ ```ts // RegistrationForm.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { screen, userEvent } from '@storybook/testing-library'; @@ -9,37 +9,34 @@ import { RegistrationForm } from './RegistrationForm.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'RegistrationForm', component: RegistrationForm, } as Meta; -const Template: Story = (args) => ({ - props: args, -}); +export const FilledForm: Story = { + play: async () => { + const emailInput = screen.getByLabelText('email', { + selector: 'input', + }); -export const FilledForm: Story = Template.bind({}); -FilledForm.play = async () => { - const emailInput = screen.getByLabelText('email', { - selector: 'input', - }); + await userEvent.type(emailInput, 'example-email@email.com', { + delay: 100, + }); - await userEvent.type(emailInput, 'example-email@email.com', { - delay: 100, - }); + const passwordInput = screen.getByLabelText('password', { + selector: 'input', + }); - const passwordInput = screen.getByLabelText('password', { - selector: 'input', - }); + await userEvent.type(passwordInput, 'ExamplePassword', { + delay: 100, + }); + // See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel + const submitButton = screen.getByRole('button'); - await userEvent.type(passwordInput, 'ExamplePassword', { - delay: 100, - }); - // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel - const Submit = screen.getByRole('button'); - - await userEvent.click(Submit); + await userEvent.click(submitButton); + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/storybook-addon-a11y-disable.mdx.mdx b/docs/snippets/angular/storybook-addon-a11y-disable.mdx.mdx index 3e1845ee0ffb..da3cb7c98323 100644 --- a/docs/snippets/angular/storybook-addon-a11y-disable.mdx.mdx +++ b/docs/snippets/angular/storybook-addon-a11y-disable.mdx.mdx @@ -9,7 +9,11 @@ import { MyComponent } from './MyComponent.component'; title="Disable a11y addon" component={MyComponent} /> -export const Template = () => ({}); + ({}); // This option disables all a11y checks on this story disable: true, }, - }}> - {Template.bind({})} + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/storybook-addon-a11y-disable.ts.mdx b/docs/snippets/angular/storybook-addon-a11y-disable.ts.mdx index 7b3aec3f59d2..403b182f6ed4 100644 --- a/docs/snippets/angular/storybook-addon-a11y-disable.ts.mdx +++ b/docs/snippets/angular/storybook-addon-a11y-disable.ts.mdx @@ -1,26 +1,25 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Disable a11y addon', component: MyComponent, } as Meta; -const Template: Story = () => ({}); - -export const NonA11yStory = Template.bind({}); -NonA11yStory.parameters = { - a11y: { - // This option disables all a11y checks on this story - disable: true, +export const NonA11yStory: Story = { + parameters: { + a11y: { + // This option disables all a11y checks on this story + disabled: true, + }, }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/storybook-addon-a11y-story-config.mdx.mdx b/docs/snippets/angular/storybook-addon-a11y-story-config.mdx.mdx index 4b39ad459c52..87e00b06da36 100644 --- a/docs/snippets/angular/storybook-addon-a11y-story-config.mdx.mdx +++ b/docs/snippets/angular/storybook-addon-a11y-story-config.mdx.mdx @@ -9,7 +9,11 @@ import { MyComponent } from './MyComponent.component'; title="Configure a11y addon" component={MyComponent} /> -export const Template = () => ({}); + ({}); options: {}, manual: true, }, - }}> - {Template.bind({})} - + }} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/storybook-addon-a11y-story-config.ts.mdx b/docs/snippets/angular/storybook-addon-a11y-story-config.ts.mdx index 9b434d8a6506..e6e38f49c1dc 100644 --- a/docs/snippets/angular/storybook-addon-a11y-story-config.ts.mdx +++ b/docs/snippets/angular/storybook-addon-a11y-story-config.ts.mdx @@ -1,41 +1,40 @@ ```ts // MyComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; +import type { Meta, Story } from '@storybook/angular'; import { MyComponent } from './MyComponent.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Configure a11y addon', component: MyComponent, } as Meta; -const Template: Story = () => ({}); - -export const ExampleStory = Template.bind({}); -ExampleStory.parameters = { - a11y: { - element: '#root', - config: { - rules: [ - { - // The autocomplete rule will not run based on the CSS selector provided - id: 'autocomplete-valid', - selector: '*:not([autocomplete="nope"])', - }, - { - // Setting the enabled option to false will disable checks for this particular rule on all stories. - id: 'image-alt', - enabled: false, - }, - ], +export const ExampleStory: Story = { + parameters: { + a11y: { + element: '#root', + config: { + rules: [ + { + // The autocomplete rule will not run based on the CSS selector provided + id: 'autocomplete-valid', + selector: '*:not([autocomplete="nope"])', + }, + { + // Setting the enabled option to false will disable checks for this particular rule on all stories. + id: 'image-alt', + enabled: false, + }, + ], + }, + options: {}, + manual: true, }, - options: {}, - manual: true, }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/table-story-fully-customize-controls.mdx.mdx b/docs/snippets/angular/table-story-fully-customize-controls.mdx.mdx index 51fccdf7d9fa..4ade6743a4c0 100644 --- a/docs/snippets/angular/table-story-fully-customize-controls.mdx.mdx +++ b/docs/snippets/angular/table-story-fully-customize-controls.mdx.mdx @@ -7,20 +7,11 @@ import { Table } from './Table.component'; -export const TableStory = (args) => ({ - props: args, - template: ` - - - - - - -
- {{data[i][j]}} -
- `, -}); + ({ [4, 5, 6], ], size: 'large', - }}> - {TableStory.bind({})} - + }} + render={(args) => ({ + props: args, + template: ` + + + + + + +
+ {{data[i][j]}} +
+ `, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx b/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx index 17982a224f13..af5932ac3143 100644 --- a/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx +++ b/docs/snippets/angular/table-story-fully-customize-controls.ts.mdx @@ -1,42 +1,46 @@ ```ts // Table.stories.ts -import { Meta, Story } from '@storybook/angular', +import type { Meta, StoryObj } from '@storybook/angular', import { Table } from './Table.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading * to learn how to generate automatic titles */ title: 'Custom Table', component: Table, } as Meta; -const TableStory: Story = (args) => ({ - props: args, - template: ` - - - - - - -
- {{data[i][j]}} -
+ /* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/angular/api/csf + * to learn how to use render functions. + */ +export const Numeric: StoryObj = { + render:(args)=>({ + props: args, + template: ` +
+ + + + + +
+ {{data[i][j]}} +
`, -}); - -export const Numeric = TableStory.bind({}); -Numeric.args = { - //πŸ‘‡ This arg is for the story component - data: [ - [1, 2, 3], - [4, 5, 6], - ], - //πŸ‘‡ The remaining args get passed to the `Table` component - size: 'large', + }), + args:{ + data: [ + [1, 2, 3], + [4, 5, 6], + ], + //πŸ‘‡ The remaining args get passed to the `Table` component + size: 'large', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/angular/your-component-with-decorator.ts.mdx b/docs/snippets/angular/your-component-with-decorator.ts.mdx index 927536968cb5..5a99d33d6f15 100644 --- a/docs/snippets/angular/your-component-with-decorator.ts.mdx +++ b/docs/snippets/angular/your-component-with-decorator.ts.mdx @@ -7,9 +7,9 @@ import { YourComponent } from './your.component'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'YourComponent', component: YourComponent, decorators: [componentWrapperDecorator((story) => `
${story}
`)], diff --git a/docs/snippets/angular/your-component.mdx.mdx b/docs/snippets/angular/your-component.mdx.mdx index 8c2bd62e6f2a..4362e2f6a862 100644 --- a/docs/snippets/angular/your-component.mdx.mdx +++ b/docs/snippets/angular/your-component.mdx.mdx @@ -8,13 +8,13 @@ import { YourComponent } from './your.component'; - -export const Template = (args) => ({ props: args }); ++ - {Template.bind({})} - + args={{}} + render={(args) => ({ + props: args, + })} /> ``` \ No newline at end of file diff --git a/docs/snippets/angular/your-component.ts.mdx b/docs/snippets/angular/your-component.ts.mdx index e33f39347f74..6b772dde7937 100644 --- a/docs/snippets/angular/your-component.ts.mdx +++ b/docs/snippets/angular/your-component.ts.mdx @@ -1,28 +1,23 @@ ```ts // YourComponent.stories.ts -import { Meta, Story } from '@storybook/angular'; - +import type { Meta, Story } from '@storybook/angular'; import { YourComponent } from './your.component'; //πŸ‘‡ This default export determines where your story goes in the story list export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'YourComponent', component: YourComponent, } as Meta; -//πŸ‘‡ We create a β€œtemplate” of how args map to rendering -const Template: Story = (args) => ({ - props:args, -}); - -export const FirstStory = Template.bind({}); -FirstStory.args= { - //πŸ‘‡ The args you need here will depend on your component +export const FirstStory: Story = { + args: { + //πŸ‘‡ The args you need here will depend on your component + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/common/badge-story-custom-argtypes.js.mdx b/docs/snippets/common/badge-story-custom-argtypes.js.mdx index 1a4d2a33ec0a..7fc6076d0d3c 100644 --- a/docs/snippets/common/badge-story-custom-argtypes.js.mdx +++ b/docs/snippets/common/badge-story-custom-argtypes.js.mdx @@ -1,13 +1,13 @@ ```js // Badge.stories.js|jsx|ts|tsx -import { Badge }Β from './Badge'; +import { Badge } from './Badge'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Badge', component: Badge, argTypes: { diff --git a/docs/snippets/common/button-group-story-subcomponents.js.mdx b/docs/snippets/common/button-group-story-subcomponents.js.mdx index 98111438fa22..94e8780fcbce 100644 --- a/docs/snippets/common/button-group-story-subcomponents.js.mdx +++ b/docs/snippets/common/button-group-story-subcomponents.js.mdx @@ -5,9 +5,9 @@ import { Button, ButtonGroup } from './ButtonGroup'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'ButtonGroup', component: ButtonGroup, subcomponents: { Button }, diff --git a/docs/snippets/common/button-group-story-subcomponents.ts.mdx b/docs/snippets/common/button-group-story-subcomponents.ts.mdx index 1b5a6f33bc13..8e5804663e16 100644 --- a/docs/snippets/common/button-group-story-subcomponents.ts.mdx +++ b/docs/snippets/common/button-group-story-subcomponents.ts.mdx @@ -7,9 +7,9 @@ import { Button, ButtonGroup } from './ButtonGroup'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'ButtonGroup', component: ButtonGroup, subcomponents: { Button }, diff --git a/docs/snippets/common/button-story-action-event-handle.js.mdx b/docs/snippets/common/button-story-action-event-handle.js.mdx index 831cd407bcf0..33200075d935 100644 --- a/docs/snippets/common/button-story-action-event-handle.js.mdx +++ b/docs/snippets/common/button-story-action-event-handle.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, parameters: { diff --git a/docs/snippets/common/button-story-argtypes-with-categories.js.mdx b/docs/snippets/common/button-story-argtypes-with-categories.js.mdx index f082f781cb87..f88021cad8db 100644 --- a/docs/snippets/common/button-story-argtypes-with-categories.js.mdx +++ b/docs/snippets/common/button-story-argtypes-with-categories.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-argtypes-with-subcategories.js.mdx b/docs/snippets/common/button-story-argtypes-with-subcategories.js.mdx index 216e23a47816..9f9a4ccbfd9f 100644 --- a/docs/snippets/common/button-story-argtypes-with-subcategories.js.mdx +++ b/docs/snippets/common/button-story-argtypes-with-subcategories.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-controls-primary-variant.js.mdx b/docs/snippets/common/button-story-controls-primary-variant.js.mdx index 4fd71c6e3a0a..c5a03c5a073c 100644 --- a/docs/snippets/common/button-story-controls-primary-variant.js.mdx +++ b/docs/snippets/common/button-story-controls-primary-variant.js.mdx @@ -5,22 +5,13 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; -const Template = (args) => ({ - //πŸ‘‡ Your template goes here -}); - -export const Primary = Template.bind({}); -Primary.args = { - variant: 'primary', -}; - export const Primary = { args: { variant: 'primary', diff --git a/docs/snippets/common/button-story-controls-primary-variant.mdx.mdx b/docs/snippets/common/button-story-controls-primary-variant.mdx.mdx index bf07a883f857..b062be004420 100644 --- a/docs/snippets/common/button-story-controls-primary-variant.mdx.mdx +++ b/docs/snippets/common/button-story-controls-primary-variant.mdx.mdx @@ -7,15 +7,11 @@ import { Button } from './Button'; -export const Template = (args) => ({ - //πŸ‘‡ Your template goes here -}); - - {Template.bind({})} + }} + render={() => ({ // Your implementation here })} /> ``` \ No newline at end of file diff --git a/docs/snippets/common/button-story-controls-radio-group.js.mdx b/docs/snippets/common/button-story-controls-radio-group.js.mdx index f6dbb4bd85c7..b719fb3fddd6 100644 --- a/docs/snippets/common/button-story-controls-radio-group.js.mdx +++ b/docs/snippets/common/button-story-controls-radio-group.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-default-export.js.mdx b/docs/snippets/common/button-story-default-export.js.mdx index a7a5098295c9..db83125c508e 100644 --- a/docs/snippets/common/button-story-default-export.js.mdx +++ b/docs/snippets/common/button-story-default-export.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; diff --git a/docs/snippets/common/button-story-disable-addon.js.mdx b/docs/snippets/common/button-story-disable-addon.js.mdx index 30655cd5be7b..db10fb915189 100644 --- a/docs/snippets/common/button-story-disable-addon.js.mdx +++ b/docs/snippets/common/button-story-disable-addon.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, parameters: { diff --git a/docs/snippets/common/button-story-disable-docspage-component.js.mdx b/docs/snippets/common/button-story-disable-docspage-component.js.mdx index f6da64894f03..c69e2b667993 100644 --- a/docs/snippets/common/button-story-disable-docspage-component.js.mdx +++ b/docs/snippets/common/button-story-disable-docspage-component.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-docs-code-type.js.mdx b/docs/snippets/common/button-story-docs-code-type.js.mdx index 9fe963c74b40..0cb0e70bcf58 100644 --- a/docs/snippets/common/button-story-docs-code-type.js.mdx +++ b/docs/snippets/common/button-story-docs-code-type.js.mdx @@ -5,9 +5,9 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-docspage-with-custom-component.js.mdx b/docs/snippets/common/button-story-docspage-with-custom-component.js.mdx index 49b77125e0ee..176e5513a3b1 100644 --- a/docs/snippets/common/button-story-docspage-with-custom-component.js.mdx +++ b/docs/snippets/common/button-story-docspage-with-custom-component.js.mdx @@ -7,9 +7,9 @@ import { CustomDocumentationComponent } from './CustomDocumentationComponent'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { diff --git a/docs/snippets/common/button-story-docspage-with-mdx.js.mdx b/docs/snippets/common/button-story-docspage-with-mdx.js.mdx index ce8fad9d9645..6b6c426060b9 100644 --- a/docs/snippets/common/button-story-docspage-with-mdx.js.mdx +++ b/docs/snippets/common/button-story-docspage-with-mdx.js.mdx @@ -7,9 +7,9 @@ import CustomMDXDocumentation from './Custom-MDX-Documentation.mdx'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, argTypes: { @@ -22,27 +22,27 @@ export default { }, }; -const Template = (args) => ({ - //πŸ‘‡ Your template goes here -}); - -export const Primary = Template.bind({}); -Primary.args = { - backgroundColor: 'primary', +export const Primary = { + args:{ + backgroundColor: 'primary', + }, }; -export const Secondary = Template.bind({}); -Secondary.args = { - backgroundColor: 'secondary', +export const Secondary = { + args:{ + backgroundColor: 'secondary', + }, }; -export const Large = Template.bind({}); -Large.args = { - size: 'large', +export const Large = = { + args:{ + size:'large', + } }; -export const Small = Template.bind({}); -Small.args = { - size: 'small', +export const Small = { + args:{ + size:'small', + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/common/button-story-grouped.js.mdx b/docs/snippets/common/button-story-grouped.js.mdx index 9028a5814afe..2571067d4208 100644 --- a/docs/snippets/common/button-story-grouped.js.mdx +++ b/docs/snippets/common/button-story-grouped.js.mdx @@ -4,10 +4,10 @@ import { Button } from './Button'; export default { - /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + /* πŸ‘‡ The title prop is optional. + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Design System/Atoms/Button', component: Button, }; diff --git a/docs/snippets/common/button-story-hide-nocontrols-warning.js.mdx b/docs/snippets/common/button-story-hide-nocontrols-warning.js.mdx index c58e8ebc6eb7..c416375d03dd 100644 --- a/docs/snippets/common/button-story-hide-nocontrols-warning.js.mdx +++ b/docs/snippets/common/button-story-hide-nocontrols-warning.js.mdx @@ -5,19 +5,16 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; -const Template = (args) => ({ - //πŸ‘‡ Your template goes here -}); - -export const Large = Template.bind({}); -Large.parameters = { - controls: { hideNoControlsWarning: true }, +export const Large = { + parameters: { + controls: { hideNoControlsWarning: true }, + }, }; ``` \ No newline at end of file diff --git a/docs/snippets/common/button-story-hoisted.js.mdx b/docs/snippets/common/button-story-hoisted.js.mdx index 6ad1284bba47..87334b5f994c 100644 --- a/docs/snippets/common/button-story-hoisted.js.mdx +++ b/docs/snippets/common/button-story-hoisted.js.mdx @@ -5,15 +5,13 @@ import { Button as ButtonComponent } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Design System/Atoms/Button', component: ButtonComponent, }; // This is the only named export in the file, and it matches the component name -export const Button = (args) =>({ - //πŸ‘‡ Your story implementation goes here -}); +export const Button = { }; ``` \ No newline at end of file diff --git a/docs/snippets/common/button-story-hypothetical-example.js.mdx b/docs/snippets/common/button-story-hypothetical-example.js.mdx index bfeefd6567b5..bb610f4187d8 100644 --- a/docs/snippets/common/button-story-hypothetical-example.js.mdx +++ b/docs/snippets/common/button-story-hypothetical-example.js.mdx @@ -5,17 +5,24 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; -export const Sample = () => ({ - template: '; +export const Basic = { + render: () => , +}; ``` \ No newline at end of file diff --git a/docs/snippets/react/button-story-with-addon-example.ts.mdx b/docs/snippets/react/button-story-with-addon-example.ts.mdx index 8c1fd7d10081..5f90996fc267 100644 --- a/docs/snippets/react/button-story-with-addon-example.ts.mdx +++ b/docs/snippets/react/button-story-with-addon-example.ts.mdx @@ -3,15 +3,15 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import type { ComponentStoryObj, ComponentMeta } from '@storybook/react'; import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, //πŸ‘‡ Creates specific parameters for the story @@ -22,5 +22,12 @@ export default { }, } as ComponentMeta; -const Basic: ComponentStory = () => ; +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/react/api/csf + * to learn how to use render functions. + */ +export const Basic: ComponentStoryObj = { + render: () => , +}; ``` \ No newline at end of file diff --git a/docs/snippets/react/button-story-with-args.js.mdx b/docs/snippets/react/button-story-with-args.js.mdx index 430d0187f520..7fcf35be8bde 100644 --- a/docs/snippets/react/button-story-with-args.js.mdx +++ b/docs/snippets/react/button-story-with-args.js.mdx @@ -7,20 +7,17 @@ import { Button } from './Button'; export default { /* πŸ‘‡ The title prop is optional. - * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading - * to learn how to generate automatic titles - */ + * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading + * to learn how to generate automatic titles + */ title: 'Button', component: Button, }; -//πŸ‘‡ We create a β€œtemplate” of how args map to rendering -const Template = (args) => ; +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/react/api/csf + * to learn how to use render functions. + */ +export const Primary = { + render: () => ; +/* + *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/7.0/react/api/csf + * to learn how to use render functions. + */ +export const Primary: ComponentStoryObj = { + render: () =>