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:
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.
-```
+```
\ 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.
-```
+```
\ 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) => `
+ `,
+ })} />
```
\ 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
+ ),
+ ],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-default-docs-code.js.mdx b/docs/snippets/react/button-story-default-docs-code.js.mdx
deleted file mode 100644
index b31ce637273a..000000000000
--- a/docs/snippets/react/button-story-default-docs-code.js.mdx
+++ /dev/null
@@ -1,39 +0,0 @@
-```js
-// Button.stories.js|jsx
-
-import React from '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
- */
- title: 'Button',
- component: Button,
- //π Creates specific argTypes
- argTypes: {
- backgroundColor: { control: 'color' },
- },
-};
-
-//π Some function to demonstrate the behavior
-const someFunction = (someValue) => {
- return `i am a ${someValue}`;
-};
-
-export const ExampleStory = (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 ;
-};
-ExampleStory.args = {
- primary: true,
- size: 'small',
- label: 'button',
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-default-docs-code.mdx.mdx b/docs/snippets/react/button-story-default-docs-code.mdx.mdx
deleted file mode 100644
index c5900e20d2ae..000000000000
--- a/docs/snippets/react/button-story-default-docs-code.mdx.mdx
+++ /dev/null
@@ -1,39 +0,0 @@
-```md
-
-
-import { Meta, Story } from '@storybook/addon-docs';
-
-import { Button } from './Button';
-
-
-
-
-
-export const someFunction = (someValue) => {
- return `i am a ${someValue}`;
-};
-
-
-
-
- {(args) => {
- const { label } = args;
- const functionResult = someFunction(label);
- return ;
- }}
-
-```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-default-docs-code.ts.mdx b/docs/snippets/react/button-story-default-docs-code.ts.mdx
deleted file mode 100644
index 13abf6e69b8a..000000000000
--- a/docs/snippets/react/button-story-default-docs-code.ts.mdx
+++ /dev/null
@@ -1,41 +0,0 @@
-```ts
-// Button.stories.ts|tsx
-
-import React from 'react';
-
-import { ComponentStory, ComponentMeta } from '@storybook/react';
-
-import { Button } from './Button';
-
-//π Some function to demonstrate the behavior
-const someFunction = (someValue: String) => {
- return `i am a ${someValue}`;
-};
-
-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
- */
- title: 'Button',
- component: Button,
- //π Creates specific argTypes
- argTypes: {
- backgroundColor: { control: 'color' },
- },
-} as ComponentMeta;
-
-export const ExampleStory: ComponentStory = (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 ;
-};
-ExampleStory.args = {
- primary: true,
- size: 'small',
- label: 'button',
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-default-export-with-component.js.mdx b/docs/snippets/react/button-story-default-export-with-component.js.mdx
index f7b5b88f05c2..e21e8f0e8d0e 100644
--- a/docs/snippets/react/button-story-default-export-with-component.js.mdx
+++ b/docs/snippets/react/button-story-default-export-with-component.js.mdx
@@ -7,7 +7,7 @@ import { Button } from './Button';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/react/button-story-default-export-with-component.ts.mdx b/docs/snippets/react/button-story-default-export-with-component.ts.mdx
index 3cb7e46e9fee..85cbe1053071 100644
--- a/docs/snippets/react/button-story-default-export-with-component.ts.mdx
+++ b/docs/snippets/react/button-story-default-export-with-component.ts.mdx
@@ -3,15 +3,15 @@
import React from 'react';
-import { ComponentMeta } from '@storybook/react';
+import type { 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,
} as ComponentMeta;
diff --git a/docs/snippets/react/button-story-rename-story.js.mdx b/docs/snippets/react/button-story-rename-story.js.mdx
index a9d0dc818383..cbcbc49d8e87 100644
--- a/docs/snippets/react/button-story-rename-story.js.mdx
+++ b/docs/snippets/react/button-story-rename-story.js.mdx
@@ -7,13 +7,15 @@ import { Button } from './Button';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * 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 Primary = () => ;
-Primary.storyName = 'I am the primary';
+export const Primary= {
+ name: 'I am the primary',
+ render: () => ,
+}
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-rename-story.ts.mdx b/docs/snippets/react/button-story-rename-story.ts.mdx
index 368c94a2a84b..fa122eced248 100644
--- a/docs/snippets/react/button-story-rename-story.ts.mdx
+++ b/docs/snippets/react/button-story-rename-story.ts.mdx
@@ -3,19 +3,26 @@
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,
} as ComponentMeta;
-export const Primary: ComponentStory = () => ;
-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/react/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: ComponentStoryObj = {
+ name: 'I am the primary',
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-using-args.js.mdx b/docs/snippets/react/button-story-using-args.js.mdx
index b7baafb461b6..6d604199eebd 100644
--- a/docs/snippets/react/button-story-using-args.js.mdx
+++ b/docs/snippets/react/button-story-using-args.js.mdx
@@ -7,23 +7,31 @@ 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) => ;
-
-// π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { backgroundColor: '#ff0', label: 'Button' };
+export const Primary = {
+ args: {
+ backgroundColor: '#ff0',
+ label: 'Button',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-using-args.ts.mdx b/docs/snippets/react/button-story-using-args.ts.mdx
index 60590f4dfe21..a558e441b958 100644
--- a/docs/snippets/react/button-story-using-args.ts.mdx
+++ b/docs/snippets/react/button-story-using-args.ts.mdx
@@ -3,29 +3,35 @@
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,
} as ComponentMeta;
-//π We create a βtemplateβ of how args map to rendering
-const Template: ComponentStory = (args) => ;
-
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { backgroundColor: '#ff0', label: 'Button' };
-
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
-
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Primary: ComponentStoryObj = {
+ backgroundColor: '#ff0',
+ label: 'Button',
+};
+
+export const Secondary: ComponentStoryObj = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
+
+export const Tertiary: ComponentStoryObj = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-with-addon-example.js.mdx b/docs/snippets/react/button-story-with-addon-example.js.mdx
index 02ba3fec7e98..97a0d181b699 100644
--- a/docs/snippets/react/button-story-with-addon-example.js.mdx
+++ b/docs/snippets/react/button-story-with-addon-example.js.mdx
@@ -7,18 +7,20 @@ 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
parameters: {
myAddon: {
- data: 'this data is passed to the addon',
+ data: 'This data is passed to the addon',
},
},
};
-export const Basic = () => ;
+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) => ;
-
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = {
- primary: true,
- label: 'Button',
+export const Primary = {
+ args: {
+ label: 'Button',
+ primary: true,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-with-args.mdx.mdx b/docs/snippets/react/button-story-with-args.mdx.mdx
index e7ceed0467f5..b5505d8c2e6c 100644
--- a/docs/snippets/react/button-story-with-args.mdx.mdx
+++ b/docs/snippets/react/button-story-with-args.mdx.mdx
@@ -5,19 +5,19 @@ import { Meta, Story } from '@storybook/addon-docs';
import { Button } from './Button';
-
+
-
+
-export const Template = (args) => ;
-
-
- {Template.bind({})}
-
+ }}
+ render={(args) => } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-with-args.ts.mdx b/docs/snippets/react/button-story-with-args.ts.mdx
index 76b502fa348d..91b96dba0452 100644
--- a/docs/snippets/react/button-story-with-args.ts.mdx
+++ b/docs/snippets/react/button-story-with-args.ts.mdx
@@ -3,26 +3,23 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { Button, ButtonProps } 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,
} as ComponentMeta;
-//π We create a βtemplateβ of how args map to rendering
-const Template: ComponentStory = (args) => ;
-
-export const Primary = Template.bind({});
-
-Primary.args = {
- primary: true,
- label: 'Button',
+export const Primary: ComponentStoryObj = {
+ args: {
+ primary: true,
+ label: 'Button',
+ },
};
```
diff --git a/docs/snippets/react/button-story-with-blue-args.js.mdx b/docs/snippets/react/button-story-with-blue-args.js.mdx
index 27ee66e8f691..0625d9d041ad 100644
--- a/docs/snippets/react/button-story-with-blue-args.js.mdx
+++ b/docs/snippets/react/button-story-with-blue-args.js.mdx
@@ -7,7 +7,7 @@ import { Button } from './Button';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/react/button-story-with-blue-args.mdx.mdx b/docs/snippets/react/button-story-with-blue-args.mdx.mdx
index 7c5e3c682781..07520139721d 100644
--- a/docs/snippets/react/button-story-with-blue-args.mdx.mdx
+++ b/docs/snippets/react/button-story-with-blue-args.mdx.mdx
@@ -6,6 +6,7 @@ import { Meta } from '@storybook/addon-docs';
import { Button } from './Button';
+
;
-export const Secondary = () => ;
-export const Tertiary = () => ;
+
+/*
+ *π 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: () => ,
+};
+
+export const Secondary = {
+ render: () => ,
+};
+
+export const Tertiary = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-with-emojis.mdx.mdx b/docs/snippets/react/button-story-with-emojis.mdx.mdx
index 61a12324bdce..13423a727ecd 100644
--- a/docs/snippets/react/button-story-with-emojis.mdx.mdx
+++ b/docs/snippets/react/button-story-with-emojis.mdx.mdx
@@ -5,7 +5,8 @@ import { Meta, Story } from '@storybook/addon-docs';
import { Button } from './Button';
-
+
+
diff --git a/docs/snippets/react/button-story-with-emojis.ts.mdx b/docs/snippets/react/button-story-with-emojis.ts.mdx
index 67c84733adf7..894a0b6ad6f1 100644
--- a/docs/snippets/react/button-story-with-emojis.ts.mdx
+++ b/docs/snippets/react/button-story-with-emojis.ts.mdx
@@ -3,28 +3,33 @@
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,
} as ComponentMeta;
-export const Primary: 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 Primary: ComponentStoryObj = {
+ render: () => ,
+};
-export const Secondary: ComponentStory = () => (
-
-);
+export const Secondary: ComponentStoryObj = {
+ render: () => ,
+};
-export const Tertiary: ComponentStory = () => (
-
+export const Tertiary: ComponentStoryObj = {
+ render: () =>
);
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story-with-parameters.js.mdx b/docs/snippets/react/button-story-with-parameters.js.mdx
index fad4c9f8d853..d384bcee7923 100644
--- a/docs/snippets/react/button-story-with-parameters.js.mdx
+++ b/docs/snippets/react/button-story-with-parameters.js.mdx
@@ -7,7 +7,7 @@ import { Button } from './Button';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/react/button-story-with-parameters.ts.mdx b/docs/snippets/react/button-story-with-parameters.ts.mdx
index bf1efee5237b..b62a2481400b 100644
--- a/docs/snippets/react/button-story-with-parameters.ts.mdx
+++ b/docs/snippets/react/button-story-with-parameters.ts.mdx
@@ -5,11 +5,11 @@ import React from 'react';
import { Button } from './Button';
-import { ComponentMeta } from '@storybook/react';
+import type { ComponentMeta } from '@storybook/react';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/react/button-story-with-sample.js.mdx b/docs/snippets/react/button-story-with-sample.js.mdx
index 77accffcd239..e31674ddd6eb 100644
--- a/docs/snippets/react/button-story-with-sample.js.mdx
+++ b/docs/snippets/react/button-story-with-sample.js.mdx
@@ -7,12 +7,19 @@ 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
- */
- title: 'Button',
+ * 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 = () => ;
+/*
+ *π 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 Sample = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story.js.mdx b/docs/snippets/react/button-story.js.mdx
index 4942dabf0aa9..88c65efb4862 100644
--- a/docs/snippets/react/button-story.js.mdx
+++ b/docs/snippets/react/button-story.js.mdx
@@ -7,12 +7,19 @@ 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 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/react/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story.mdx-with-hooks.mdx.mdx b/docs/snippets/react/button-story.mdx-with-hooks.mdx.mdx
index 41d981b81380..68a86334b504 100644
--- a/docs/snippets/react/button-story.mdx-with-hooks.mdx.mdx
+++ b/docs/snippets/react/button-story.mdx-with-hooks.mdx.mdx
@@ -9,22 +9,23 @@ import { Button } from './Button';
+
+
+export const ButtonWithHooks = () => {
+ // Sets the hooks for both the label and primary props
+ const [value, setValue] = useState("Secondary");
+ const [isPrimary, setIsPrimary] = useState(false);
+ // Sets a click handler to change the label's value
+ const handleOnChange = () => {
+ if (!isPrimary) {
+ setIsPrimary(true);
+ setValue("Primary");
+ }
+ };
+ return ;
+};
+
-
- {() => {
- const [value, setValue] = useState('Secondary');
- const [isPrimary, setIsPrimary] = useState(false);
- // Sets a click handler to change the label's value
- const handleOnChange = () => {
- if (!isPrimary) {
- setIsPrimary(true);
- setValue("Primary");
- }
- };
- return (
-
- );
- }}
-
+ } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story.ts.mdx b/docs/snippets/react/button-story.ts.mdx
index 50a95e304e45..28f7a2c6f17b 100644
--- a/docs/snippets/react/button-story.ts.mdx
+++ b/docs/snippets/react/button-story.ts.mdx
@@ -3,18 +3,25 @@
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,
} as ComponentMeta;
-export const Primary: 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 Primary: ComponentStoryObj = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/button-story.with-hooks.js.mdx b/docs/snippets/react/button-story.with-hooks.js.mdx
index a55ac3a4bc24..cc1ad75e73cc 100644
--- a/docs/snippets/react/button-story.with-hooks.js.mdx
+++ b/docs/snippets/react/button-story.with-hooks.js.mdx
@@ -7,9 +7,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,
};
@@ -18,7 +18,7 @@ export default {
* Example Button story with React Hooks.
* See note below related to this example.
*/
-export const Primary = () => {
+const ButtonWithHooks = () => {
// Sets the hooks for both the label and primary props
const [value, setValue] = useState('Secondary');
const [isPrimary, setIsPrimary] = useState(false);
@@ -32,4 +32,8 @@ export const Primary = () => {
};
return ;
};
+
+export const Primary = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/checkbox-story-csf.js.mdx b/docs/snippets/react/checkbox-story-csf.js.mdx
index 460b871a04bc..356e9fa8486c 100644
--- a/docs/snippets/react/checkbox-story-csf.js.mdx
+++ b/docs/snippets/react/checkbox-story-csf.js.mdx
@@ -7,18 +7,20 @@ import { Checkbox } from './Checkbox';
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
- */
- title: 'Checkbox',
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Checkbox',
component: Checkbox,
};
-export const allCheckboxes = () => (
-
-);
+export const allCheckboxes = {
+ render: () => (
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/checkbox-story-csf.ts.mdx b/docs/snippets/react/checkbox-story-csf.ts.mdx
index 503a2f991320..10874756af63 100644
--- a/docs/snippets/react/checkbox-story-csf.ts.mdx
+++ b/docs/snippets/react/checkbox-story-csf.ts.mdx
@@ -3,24 +3,31 @@
import React from 'react';
-import { ComponentMeta, ComponentStory } from '@storybook/react';
+import type { ComponentStoryObj, ComponentStory } from '@storybook/react';
import { Checkbox } from './Checkbox';
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
- */
- title: 'Checkbox',
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Checkbox',
component: Checkbox,
} as ComponentMeta;
-export const allCheckboxes: 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 allCheckboxes: ComponentStoryObj = {
+ render: () => (
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/checkbox-story.mdx.mdx b/docs/snippets/react/checkbox-story.mdx.mdx
index 2621dc968d12..075b110a0676 100644
--- a/docs/snippets/react/checkbox-story.mdx.mdx
+++ b/docs/snippets/react/checkbox-story.mdx.mdx
@@ -19,27 +19,22 @@ Markdown documentation.
name="Unchecked"
args={{
label: 'Unchecked',
- }}>
- {Template.bind({})}
-
-
+ }}
+ render={(args) => } />
- {Template.bind({})}
-
-
+ }}
+ render={(args) => } />
- {Template.bind({})}
-
+ }}
+ render={(args) => } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-custom-args-complex.js.mdx b/docs/snippets/react/component-story-custom-args-complex.js.mdx
index 870ce8bdd85d..5b6dc7b38c24 100644
--- a/docs/snippets/react/component-story-custom-args-complex.js.mdx
+++ b/docs/snippets/react/component-story-custom-args-complex.js.mdx
@@ -7,9 +7,9 @@ import { YourComponent } from './your-component';
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: 'YourComponent',
component: YourComponent,
//π Creates specific argTypes with options
@@ -29,16 +29,17 @@ const someFunction = (valuePropertyA, valuePropertyB) => {
// Makes some computations and returns something
};
-const Template = ({ propertyA, propertyB, ...rest }) => {
- //π Assigns the function result to a variable
- const someFunctionResult = someFunction(propertyA, propertyB);
+export const ExampleStory = {
+ render: (args) => {
+ const { propertyA, propertyB } = args;
+ //π Assigns the function result to a variable
+ const someFunctionResult = someFunction(propertyA, propertyB);
- return ;
-};
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args= {
- propertyA: 'Item One',
- propertyB: 'Another Item One',
+ return ;
+ },
+ args: {
+ propertyA: 'Item One',
+ propertyB: 'Another Item One',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-custom-args-complex.mdx.mdx b/docs/snippets/react/component-story-custom-args-complex.mdx.mdx
index fcb607b642a6..b33381e0ce27 100644
--- a/docs/snippets/react/component-story-custom-args-complex.mdx.mdx
+++ b/docs/snippets/react/component-story-custom-args-complex.mdx.mdx
@@ -5,7 +5,25 @@ import { Canvas, Meta, Story } from '@storybook/addon-docs';
import { YourComponent } from './your-component';
-
+
@@ -13,37 +31,17 @@ export const someFunction = (valuePropertyA, valuePropertyB) => {
// Makes some computations and returns something
};
-export const Template = ({propertyA,propertyB,...rest})=>{
- //π Assigns the function result to a variable
-
-const someFunctionResult = someFunction(propertyA, propertyB);
- return ;
-}
-
- {Template.bind({})}
-
+ }}
+ render={(args) => {
+ const { propertyA, propertyB } = args;
+ const someFunctionResult = someFunction(propertyA, propertyB);
+ return ;
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-custom-args-complex.ts.mdx b/docs/snippets/react/component-story-custom-args-complex.ts.mdx
index be64e1f14af5..d658823f93ad 100644
--- a/docs/snippets/react/component-story-custom-args-complex.ts.mdx
+++ b/docs/snippets/react/component-story-custom-args-complex.ts.mdx
@@ -3,26 +3,21 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { YourComponent } from './your-component';
-//π Some function to demonstrate the behavior
-const someFunction = (valuePropertyA, valuePropertyB) => {
- // Makes some computations and returns something
-};
-
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: 'YourComponent',
//π Creates specific argTypes with options
argTypes: {
propertyA: {
options: ['Item One', 'Item Two', 'Item Three'],
- control: { type: 'select' } // Automatically inferred when 'options' is defined
+ control: { type: 'select' }, // Automatically inferred when 'options' is defined
},
propertyB: {
options: ['Another Item One', 'Another Item Two', 'Another Item Three'],
@@ -30,16 +25,22 @@ export default {
},
} as ComponentMeta;
-const Template: ComponentStory = ({ propertyA, propertyB, ...rest }) => {
- //π Assigns the result from the function to a variable
- const someFunctionResult = someFunction(propertyA, propertyB);
-
- return ;
+//π Some function to demonstrate the behavior
+const someFunction = (valuePropertyA, valuePropertyB) => {
+ // Makes some computations and returns something
};
-export const ExampleStory = Template.bind({});
-ExampleStory.args= {
- propertyA: 'Item One',
- propertyB: 'Another Item One',
+export const ExampleStory: ComponentStoryObj = {
+ render: (args) => {
+ const { propertyA, propertyB } = args;
+ //π Assigns the function result to a variable
+ const someFunctionResult = someFunction(propertyA, propertyB);
+
+ return ;
+ },
+ args: {
+ propertyA: 'Item One',
+ propertyB: 'Another Item One',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-figma-integration.js.mdx b/docs/snippets/react/component-story-figma-integration.js.mdx
index 57ecc2750431..d67bccc53ba6 100644
--- a/docs/snippets/react/component-story-figma-integration.js.mdx
+++ b/docs/snippets/react/component-story-figma-integration.js.mdx
@@ -7,21 +7,19 @@ import { withDesign } from 'storybook-addon-designs';
import { MyComponent } from './MyComponent';
-// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
+// More on default export: https://storybook.js.org/docs/7.0/react/writing-stories/introduction#default-export
export default {
title: 'FigmaExample',
component: MyComponent,
decorators: [withDesign],
};
-// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
-const Template = () => ;
-
-export const Example = Template.bind({});
-Example.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/Sample-File',
+export const Example = {
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/Sample-File',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-figma-integration.mdx.mdx b/docs/snippets/react/component-story-figma-integration.mdx.mdx
index 455cb3a10eaa..cc29d5bb78b9 100644
--- a/docs/snippets/react/component-story-figma-integration.mdx.mdx
+++ b/docs/snippets/react/component-story-figma-integration.mdx.mdx
@@ -9,8 +9,6 @@ import { MyComponent } from './MyComponent';
-export const Template = () => ;
-
;
type: 'figma',
url: 'https://www.figma.com/file/Sample-File',
},
- }}
- >
- {Template.bind({})}
+ }}>
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-figma-integration.ts.mdx b/docs/snippets/react/component-story-figma-integration.ts.mdx
index 1b54ea82e143..471b76a0db01 100644
--- a/docs/snippets/react/component-story-figma-integration.ts.mdx
+++ b/docs/snippets/react/component-story-figma-integration.ts.mdx
@@ -3,27 +3,25 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { withDesign } from 'storybook-addon-designs';
import { MyComponent } from './MyComponent';
-// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
+// More on default export: https://storybook.js.org/docs/7.0/react/writing-stories/introduction#default-export
export default {
title: 'FigmaExample',
component: MyComponent,
decorators: [withDesign],
} as ComponentMeta;
-// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
-const Template: ComponentStory = () => ;
-
-export const Example = Template.bind({});
-Example.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/Sample-File',
+export const Example: ComponentStoryObj = {
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/Sample-File',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-mdx-story-by-name.mdx.mdx b/docs/snippets/react/component-story-mdx-story-by-name.mdx.mdx
index 327ceab03a2d..5c9a5ce7fa91 100644
--- a/docs/snippets/react/component-story-mdx-story-by-name.mdx.mdx
+++ b/docs/snippets/react/component-story-mdx-story-by-name.mdx.mdx
@@ -7,13 +7,16 @@ import { Button } from './Button';
-export const Template = (args) => ;
+
- {Template.bind({})}
-
+ }}
+ render={(args)=> } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-cdn.js.mdx b/docs/snippets/react/component-story-static-asset-cdn.js.mdx
index 1343f1e1f692..1b32c6eae4c0 100644
--- a/docs/snippets/react/component-story-static-asset-cdn.js.mdx
+++ b/docs/snippets/react/component-story-static-asset-cdn.js.mdx
@@ -1,15 +1,22 @@
```js
-// MyComponent.stories.js|jsx
+// MyComponent.stories.js|jsx|ts|tsx
import React from 'react';
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: 'img',
};
-export const WithAnImage = () => ;
+/*
+ *π 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 WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-cdn.mdx.mdx b/docs/snippets/react/component-story-static-asset-cdn.mdx.mdx
index c2be3438add0..43536bd96a7b 100644
--- a/docs/snippets/react/component-story-static-asset-cdn.mdx.mdx
+++ b/docs/snippets/react/component-story-static-asset-cdn.mdx.mdx
@@ -7,8 +7,7 @@ import { MyComponent } from './MyComponent';
-
+
}
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-cdn.ts.mdx b/docs/snippets/react/component-story-static-asset-cdn.ts.mdx
index 902c61d9baca..27782d0de62c 100644
--- a/docs/snippets/react/component-story-static-asset-cdn.ts.mdx
+++ b/docs/snippets/react/component-story-static-asset-cdn.ts.mdx
@@ -3,15 +3,17 @@
import React from 'react';
-import { Meta } from '@storybook/react';
+import type { Meta } from '@storybook/react';
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: 'img',
} as Meta;
-export const WithAnImage = () => ;
+export const WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-with-import.js.mdx b/docs/snippets/react/component-story-static-asset-with-import.js.mdx
index 2e0e9672a329..ad03dcac5056 100644
--- a/docs/snippets/react/component-story-static-asset-with-import.js.mdx
+++ b/docs/snippets/react/component-story-static-asset-with-import.js.mdx
@@ -1,5 +1,5 @@
```js
-// MyComponent.stories.js|jsx
+// MyComponent.stories.js|jsx|ts|tsx
import React from 'react';
@@ -7,9 +7,9 @@ import imageFile from './static/image.png';
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: 'img',
};
@@ -18,5 +18,12 @@ const image = {
alt: 'my image',
};
-export const WithAnImage = () => ;
+/*
+ *π 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 WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-with-import.ts.mdx b/docs/snippets/react/component-story-static-asset-with-import.ts.mdx
index 4d5665e7cf05..cb70866d6f3a 100644
--- a/docs/snippets/react/component-story-static-asset-with-import.ts.mdx
+++ b/docs/snippets/react/component-story-static-asset-with-import.ts.mdx
@@ -5,13 +5,13 @@ import React from 'react';
import imageFile from './static/image.png';
-import { Meta } from '@storybook/react';
+import type { Meta } from '@storybook/react';
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: 'img',
} as Meta;
@@ -20,5 +20,13 @@ const image = {
alt: 'my image',
};
-export const WithAnImage = () => ;
+/*
+ *π 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 WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-without-import.js.mdx b/docs/snippets/react/component-story-static-asset-without-import.js.mdx
index 1c9cfe4fe771..b53e69dbdd19 100644
--- a/docs/snippets/react/component-story-static-asset-without-import.js.mdx
+++ b/docs/snippets/react/component-story-static-asset-without-import.js.mdx
@@ -1,16 +1,18 @@
```js
-// MyComponent.stories.js|jsx
+// MyComponent.stories.js|jsx|ts|tsx
import React from 'react';
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: 'img',
};
// Assume image.png is located in the "public" directory.
-export const WithAnImage = () => ;
+export const WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-static-asset-without-import.ts.mdx b/docs/snippets/react/component-story-static-asset-without-import.ts.mdx
index 4f47a7c9718d..94806a2821c2 100644
--- a/docs/snippets/react/component-story-static-asset-without-import.ts.mdx
+++ b/docs/snippets/react/component-story-static-asset-without-import.ts.mdx
@@ -5,13 +5,13 @@ import React from 'react';
import imageFile from './static/image.png';
-import { Meta } from '@storybook/react';
+import type { Meta } from '@storybook/react';
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: 'img',
} as Meta;
@@ -20,5 +20,7 @@ const image = {
alt: 'my image',
};
// Assume image.png is located in the "public" directory.
-export const WithAnImage = () => ;
+export const WithAnImage = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-with-accessibility.js.mdx b/docs/snippets/react/component-story-with-accessibility.js.mdx
index 6f46af0ede4f..469d4e7d41b2 100644
--- a/docs/snippets/react/component-story-with-accessibility.js.mdx
+++ b/docs/snippets/react/component-story-with-accessibility.js.mdx
@@ -7,8 +7,8 @@ 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: 'Accessibility testing',
component: Button,
argTypes: {
@@ -16,19 +16,19 @@ export default {
},
};
-const Template = (args) => ;
-
// This is an accessible story
-export const Accessible = Template.bind({});
-Accessible.args = {
- primary: false,
- label: 'Button',
+export const Accessible = {
+ args: {
+ primary: false,
+ label: 'Button',
+ },
};
// This is not
-export const Inaccessible = Template.bind({});
-Inaccessible.args = {
- ...Accessible.args,
- backgroundColor: 'red',
+export const Inaccessible = {
+ args: {
+ ...Accessible.args,
+ backgroundColor: 'red',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-with-accessibility.mdx.mdx b/docs/snippets/react/component-story-with-accessibility.mdx.mdx
index 280fe7353e17..54edba8df817 100644
--- a/docs/snippets/react/component-story-with-accessibility.mdx.mdx
+++ b/docs/snippets/react/component-story-with-accessibility.mdx.mdx
@@ -15,8 +15,12 @@ import { Button } from './Button';
}
}
}} />
-
-export const Template = (args) => ;
+
+
## This is an accessible story
@@ -25,9 +29,9 @@ export const Template = (args) => ;
args={{
primary: false,
label: 'Button'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args)=> } />
+
## This is not
@@ -37,7 +41,6 @@ export const Template = (args) => ;
primary: false,
label: 'Button',
backgroundColor: 'red'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args)=> } />
```
diff --git a/docs/snippets/react/component-story-with-accessibility.ts.mdx b/docs/snippets/react/component-story-with-accessibility.ts.mdx
index 84fd419b4457..9342cf921e37 100644
--- a/docs/snippets/react/component-story-with-accessibility.ts.mdx
+++ b/docs/snippets/react/component-story-with-accessibility.ts.mdx
@@ -3,14 +3,14 @@
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: 'Accessibility testing',
component: Button,
argTypes: {
@@ -18,20 +18,19 @@ export default {
},
} as ComponentMeta;
-
-const Template: ComponentStory = (args) => ;
-
// This is an accessible story
-export const Accessible = Template.bind({});
-Accessible.args = {
- primary: false,
- label: 'Button',
+export const Accessible: ComponentStoryObj = {
+ args: {
+ primary: false,
+ label: 'Button',
+ },
};
// This is not
-export const Inaccessible = Template.bind({});
-Inaccessible.args = {
- ...Accessible.args,
- backgroundColor: 'red',
+export const Inaccessible: ComponentStoryObj = {
+ args: {
+ ...Accessible.args,
+ backgroundColor: 'red',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-with-custom-render-function.js.mdx b/docs/snippets/react/component-story-with-custom-render-function.js.mdx
new file mode 100644
index 000000000000..eaf97ebc9b4a
--- /dev/null
+++ b/docs/snippets/react/component-story-with-custom-render-function.js.mdx
@@ -0,0 +1,32 @@
+```js
+// MyComponent.stories.js|jsx
+
+import React from 'react';
+
+import { Layout } from './Layout';
+
+import { MyComponent } from './MyComponent';
+
+export default {
+ /* π 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: 'MyComponent',
+ component: MyComponent,
+};
+
+// This story uses a render function to fully control how the component renders.
+export const Example = {
+ render: () => (
+
+
+
Example
+
+
+
+
+
+ ),
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/react/component-story-with-custom-render-function.ts.mdx b/docs/snippets/react/component-story-with-custom-render-function.ts.mdx
new file mode 100644
index 000000000000..d23f3ba4e32c
--- /dev/null
+++ b/docs/snippets/react/component-story-with-custom-render-function.ts.mdx
@@ -0,0 +1,34 @@
+```ts
+// MyComponent.stories.ts|tsx
+
+import React from 'react';
+
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
+
+import { Layout } from './Layout';
+
+import { MyComponent } from './MyComponent';
+
+export default {
+ /* π 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: 'MyComponent',
+ component: MyComponent,
+} as ComponentMeta;
+
+// This story uses a render function to fully control how the component renders.
+export const Example: ComponentStoryObj = {
+ render: () => (
+
+
+
Example
+
+
+
+
+
+ ),
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/react/documentscreen-story-msw-graphql-query.js.mdx b/docs/snippets/react/documentscreen-story-msw-graphql-query.js.mdx
index af165ffcc2ad..b8d5d408b4fa 100644
--- a/docs/snippets/react/documentscreen-story-msw-graphql-query.js.mdx
+++ b/docs/snippets/react/documentscreen-story-msw-graphql-query.js.mdx
@@ -9,15 +9,6 @@ import { graphql } from 'msw';
import { DocumentScreen } from './YourPage';
-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
- */
- title: 'DocumentScreen',
- component: DocumentScreen,
-};
-
const mockedClient = new ApolloClient({
uri: 'https://your-graphql-endpoint',
cache: new InMemoryCache(),
@@ -82,34 +73,46 @@ const TestData = {
],
};
-const PageTemplate = () => (
-
-
-
-);
-
-export const MockedSuccess = PageTemplate.bind({});
-MockedSuccess.parameters = {
- msw: [
- graphql.query('AllInfoQuery', (req, res, ctx) => {
- return res(ctx.data(TestData));
- }),
+export default {
+ /* π 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: 'DocumentScreen',
+ component: DocumentScreen,
+ decorators: [
+ (Story) => (
+
+
+
+ ),
],
};
-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 MockedSuccess = {
+ parameters: {
+ msw: [
+ graphql.query('AllInfoQuery', (req, res, ctx) => {
+ return res(ctx.data(TestData));
+ }),
+ ],
+ },
+};
+
+export const MockedError = {
+ 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/react/documentscreen-story-msw-rest-request.js.mdx b/docs/snippets/react/documentscreen-story-msw-rest-request.js.mdx
index 07aba40a9fe6..aa1232cd9153 100644
--- a/docs/snippets/react/documentscreen-story-msw-rest-request.js.mdx
+++ b/docs/snippets/react/documentscreen-story-msw-rest-request.js.mdx
@@ -9,9 +9,9 @@ import { DocumentScreen } from './YourPage';
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: 'DocumentScreen',
component: DocumentScreen,
};
@@ -65,23 +65,23 @@ const TestData = {
],
};
-const PageTemplate = () => ;
-
-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 = {
+ 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 = {
+ 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/react/form-story-component-with-play-function.js.mdx b/docs/snippets/react/form-story-component-with-play-function.js.mdx
deleted file mode 100644
index 78dfc8aa8f51..000000000000
--- a/docs/snippets/react/form-story-component-with-play-function.js.mdx
+++ /dev/null
@@ -1,25 +0,0 @@
-```js
-// Form.stories.js|jsx|ts|tsx
-
-import { userEvent, within } from '@storybook/testing-library';
-
-import { LoginForm } from './LoginForm';
-
-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/react/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/react/list-story-expanded.js.mdx b/docs/snippets/react/list-story-expanded.js.mdx
index c8caeb837367..e3569cded2a8 100644
--- a/docs/snippets/react/list-story-expanded.js.mdx
+++ b/docs/snippets/react/list-story-expanded.js.mdx
@@ -8,26 +8,35 @@ import { ListItem } from './ListItem';
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: 'List',
component: List,
};
-export const Empty = (args) => ;
+export const Empty = {};
-export const OneItem = (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 OneItem = {
+ render: (args) => (
+
+
+
+ ),
+};
-export const ManyItems = (args) => (
-
-
-
-
-
-);
+export const ManyItems = {
+ render: (args) => (
+
+
+
+
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-expanded.ts.mdx b/docs/snippets/react/list-story-expanded.ts.mdx
index 78f814a4add9..03b0424da88b 100644
--- a/docs/snippets/react/list-story-expanded.ts.mdx
+++ b/docs/snippets/react/list-story-expanded.ts.mdx
@@ -3,33 +3,42 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { List } from './List';
import { ListItem } from './ListItem';
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: 'List',
component: List,
} as ComponentMeta;
-export const Empty: ComponentStory = (args) => ;
+export const Empty: ComponentStoryObj = {};
-export const OneItem: ComponentStory = (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 OneItem: ComponentStoryObj = {
+ render: (args) => (
+
+
+
+ ),
+};
-export const ManyItems: ComponentStory = (args) => (
-
-
-
-
-
-);
+export const ManyItems: ComponentStoryObj = {
+ render: (args) => (
+
+
+
+
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-reuse-data.js.mdx b/docs/snippets/react/list-story-reuse-data.js.mdx
index ca1159e54c60..296c1b80b799 100644
--- a/docs/snippets/react/list-story-reuse-data.js.mdx
+++ b/docs/snippets/react/list-story-reuse-data.js.mdx
@@ -11,18 +11,26 @@ import { Selected, Unselected } from './ListItem.stories';
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: 'List',
component: List,
};
-export const ManyItems = (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 ManyItems = {
+ render: (args) => (
+
+
+
+
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-reuse-data.ts.mdx b/docs/snippets/react/list-story-reuse-data.ts.mdx
index 231dfa5662e9..61d40e14af88 100644
--- a/docs/snippets/react/list-story-reuse-data.ts.mdx
+++ b/docs/snippets/react/list-story-reuse-data.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { List } from './List';
import { ListItem } from './ListItem';
@@ -13,18 +13,25 @@ import * as ListItemStories from './ListItemStories';
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: 'List',
component: List,
} as ComponentMeta;
-export const ManyItems: ComponentStory = (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 ManyItems: ComponentStoryObj = {
+ render: (args) => (
+
+
+
+
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-starter.js.mdx b/docs/snippets/react/list-story-starter.js.mdx
index d03dbc9ddd30..66ad660c9fc8 100644
--- a/docs/snippets/react/list-story-starter.js.mdx
+++ b/docs/snippets/react/list-story-starter.js.mdx
@@ -7,13 +7,14 @@ import { List } from './List';
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: 'List',
component: List,
};
// Always an empty list, not super interesting
-const Template = (args) => ;
+
+export const Empty = {};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-starter.ts.mdx b/docs/snippets/react/list-story-starter.ts.mdx
index 608c8383fc68..fa887d219714 100644
--- a/docs/snippets/react/list-story-starter.ts.mdx
+++ b/docs/snippets/react/list-story-starter.ts.mdx
@@ -3,19 +3,20 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { List } from './List';
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: 'List',
component: List,
} as ComponentMeta;
//π Always an empty list, not super interesting
-const Template: ComponentStory = (args) => ;
+
+const Template: ComponentStoryObj = {};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-template.js.mdx b/docs/snippets/react/list-story-template.js.mdx
index c43e38e571b2..2b2ef5cda2c4 100644
--- a/docs/snippets/react/list-story-template.js.mdx
+++ b/docs/snippets/react/list-story-template.js.mdx
@@ -11,30 +11,41 @@ import { Unchecked } from './ListItem.stories';
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: 'List',
component: List,
};
-const ListTemplate = ({ items, ...args }) => (
-
- {items.map((item) => (
-
- ))}
-
-);
+//π The ListTemplate construct will be spread to the existing stories.
+const ListTemplate = {
+ render: ({ items, ...args }) => {
+ return (
+
+ {items.map((item) => (
+
+ ))}
+
+ );
+ },
+};
-export const Empty = ListTemplate.bind({});
-Empty.args = { items: [] };
+export const Empty = {
+ ...ListTemplate,
+ args: {
+ items: [],
+ },
+};
-export const OneItem = ListTemplate.bind({});
-OneItem.args = {
- items: [
- {
- ...Unchecked.args,
- },
- ],
+export const OneItem = {
+ ...ListTemplate,
+ args: {
+ items: [
+ {
+ ...Unchecked.args,
+ },
+ ],
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-template.ts.mdx b/docs/snippets/react/list-story-template.ts.mdx
index b8b8e736411d..6a337e138c58 100644
--- a/docs/snippets/react/list-story-template.ts.mdx
+++ b/docs/snippets/react/list-story-template.ts.mdx
@@ -1,9 +1,9 @@
-```js
+```ts
// List.stories.ts|tsx
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { List } from './List';
import { ListItem } from './ListItem';
@@ -13,32 +13,41 @@ import { Unchecked } from './ListItem.stories';
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
- */
+ * Seehttps://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
} as ComponentMeta;
-const ListTemplate: ComponentStory = (args) => {
- const { items } = args;
- return (
-
- {items.map((item) => (
-
- ))}
-
-)};
-
-export const Empty = ListTemplate.bind({});
-Empty.args = { items: [] };
-
-export const OneItem = ListTemplate.bind({});
-OneItem.args = {
- items: [
- {
- ...Unchecked.args,
- },
- ],
+//π The ListTemplate construct will be spread to the existing stories.
+const ListTemplate: ComponentStoryObj = {
+ render: ({ items, ...args }) => {
+ return (
+
+ {items.map((item) => (
+
+ ))}
+
+ );
+ },
+};
+
+export const Empty = {
+ ...ListTemplate,
+ args: {
+ items: [],
+ },
+};
+
+export const OneItem = {
+ ...ListTemplate,
+ args: {
+ items: [
+ {
+ ...Unchecked.args,
+ },
+ ],
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-unchecked.js.mdx b/docs/snippets/react/list-story-unchecked.js.mdx
index d0669a6bd8b2..760f91d53d66 100644
--- a/docs/snippets/react/list-story-unchecked.js.mdx
+++ b/docs/snippets/react/list-story-unchecked.js.mdx
@@ -10,9 +10,9 @@ import { Unchecked } from './ListItem.stories';
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: 'List',
component: List,
};
diff --git a/docs/snippets/react/list-story-unchecked.ts.mdx b/docs/snippets/react/list-story-unchecked.ts.mdx
index 07da8038142d..04ca37e7f96f 100644
--- a/docs/snippets/react/list-story-unchecked.ts.mdx
+++ b/docs/snippets/react/list-story-unchecked.ts.mdx
@@ -12,7 +12,7 @@ import { Unchecked } from './ListItem.stories';
export defaultΒ {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
diff --git a/docs/snippets/react/list-story-with-subcomponents.js.mdx b/docs/snippets/react/list-story-with-subcomponents.js.mdx
index e81a24462c7d..190656650ae2 100644
--- a/docs/snippets/react/list-story-with-subcomponents.js.mdx
+++ b/docs/snippets/react/list-story-with-subcomponents.js.mdx
@@ -8,19 +8,21 @@ import { ListItem } from './ListItem';
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: 'List',
component: List,
subcomponents: { ListItem }, //π Adds the ListItem component as a subcomponent
};
-export const Empty = (args) => ;
+export const Empty = {};
-export const OneItem = (args) => (
-
-
-
-);
+export const OneItem = {
+ render: (args) => (
+
+
+
+ ),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/list-story-with-subcomponents.ts.mdx b/docs/snippets/react/list-story-with-subcomponents.ts.mdx
index 5c0b520bf1df..b5cada02e91c 100644
--- a/docs/snippets/react/list-story-with-subcomponents.ts.mdx
+++ b/docs/snippets/react/list-story-with-subcomponents.ts.mdx
@@ -3,26 +3,28 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { List } from './List';
import { ListItem } from './ListItem';
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: 'List',
component: List,
subcomponents: { ListItem }, //π Adds the ListItem component as a subcomponent
} as ComponentMeta;
-const Empty: ComponentStory = (args) => ;
+export const Empty: ComponentStoryObj = {};
-const OneItem: ComponentStory = (args) =>(
-
-
-
-);
+export const OneItem: ComponentStoryObj = {
+ render: (args) => (
+
+
+
+ ),
+};
```
diff --git a/docs/snippets/react/list-story-with-unchecked-children.js.mdx b/docs/snippets/react/list-story-with-unchecked-children.js.mdx
index 0a56226a15eb..0cf8714df29f 100644
--- a/docs/snippets/react/list-story-with-unchecked-children.js.mdx
+++ b/docs/snippets/react/list-story-with-unchecked-children.js.mdx
@@ -10,7 +10,7 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
diff --git a/docs/snippets/react/list-story-with-unchecked-children.ts.mdx b/docs/snippets/react/list-story-with-unchecked-children.ts.mdx
index f77d847ad0dc..4c71fe6e5a00 100644
--- a/docs/snippets/react/list-story-with-unchecked-children.ts.mdx
+++ b/docs/snippets/react/list-story-with-unchecked-children.ts.mdx
@@ -12,7 +12,7 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
diff --git a/docs/snippets/react/loader-story.js.mdx b/docs/snippets/react/loader-story.js.mdx
index d048c0f36bb4..a1e44437d462 100644
--- a/docs/snippets/react/loader-story.js.mdx
+++ b/docs/snippets/react/loader-story.js.mdx
@@ -9,17 +9,21 @@ import { TodoItem } from './TodoItem';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Examples/Loader'
component: TodoItem,
+ render: (args, { loaded: { todo } }) => ,
};
-export const Primary = (args, { loaded: { todo } }) => ;
-Primary.loaders = [
+export const Primary = {
+ loaders: [
async () => ({
- todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
+ todo: await (
+ await fetch('https://jsonplaceholder.typicode.com/todos/1')
+ ).json(),
}),
-];
+ ],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/loader-story.mdx.mdx b/docs/snippets/react/loader-story.mdx.mdx
index 9298c9bfcd58..566cd5e39ca8 100644
--- a/docs/snippets/react/loader-story.mdx.mdx
+++ b/docs/snippets/react/loader-story.mdx.mdx
@@ -9,6 +9,12 @@ import { TodoItem } from './TodoItem';
+
+
- {(args, { loaded: { todo } }) => (
-
- )}
-} />
```
\ No newline at end of file
diff --git a/docs/snippets/react/login-form-with-play-function.js.mdx b/docs/snippets/react/login-form-with-play-function.js.mdx
index ca6e59d02331..686ebc05e65b 100644
--- a/docs/snippets/react/login-form-with-play-function.js.mdx
+++ b/docs/snippets/react/login-form-with-play-function.js.mdx
@@ -1,9 +1,7 @@
```js
// LoginForm.stories.js|jsx
-import React from 'react';
-
-import { within, userEvent } from '@storybook/testing-library';
+import { userEvent, within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
@@ -11,35 +9,34 @@ import { LoginForm } from './LoginForm';
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: 'Form',
component: LoginForm,
};
-const Template = (args) => ;
+export const EmptyForm = {};
-export const EmptyForm = Template.bind({});
+export const FilledForm = {
+ play: async ({ canvasElement }) => {
+ // Starts querying the component from its root element
+ const canvas = within(canvasElement);
-export const FilledForm = Template.bind({});
-FilledForm.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/react/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/react/login-form-with-play-function.mdx.mdx b/docs/snippets/react/login-form-with-play-function.mdx.mdx
index 327a8ae55c42..a37280ade7f4 100644
--- a/docs/snippets/react/login-form-with-play-function.mdx.mdx
+++ b/docs/snippets/react/login-form-with-play-function.mdx.mdx
@@ -11,16 +11,14 @@ import { LoginForm } from './LoginForm';
-export const Template = (args) => ;
- {Template.bind({})}
+
-
{
+ play={ async ({ canvasElement }) => {
// Starts querying the component from its root element
const canvas = within(canvasElement);
@@ -29,7 +27,7 @@ export const Template = (args) => ;
await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // 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
@@ -39,7 +37,7 @@ export const Template = (args) => ;
)
).toBeInTheDocument();
}}>
- {Template.bind({})}
+
```
diff --git a/docs/snippets/react/login-form-with-play-function.ts.mdx b/docs/snippets/react/login-form-with-play-function.ts.mdx
index 05b3e8395739..da31e63ec267 100644
--- a/docs/snippets/react/login-form-with-play-function.ts.mdx
+++ b/docs/snippets/react/login-form-with-play-function.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { within, userEvent } from '@storybook/testing-library';
@@ -13,35 +13,34 @@ import { LoginForm } from './LoginForm';
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: 'Form',
component: LoginForm,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+export const EmptyForm: ComponentStoryObj = {};
-export const EmptyForm = Template.bind({});
+export const FilledForm: ComponentStoryObj = {
+ play: async ({ canvasElement }) => {
+ // Starts querying the component from its root element
+ const canvas = within(canvasElement);
-export const FilledForm = Template.bind({});
-FilledForm.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/react/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/react/mdx-canvas-multiple-stories.mdx.mdx b/docs/snippets/react/mdx-canvas-multiple-stories.mdx.mdx
index 65bc82c2e41f..8ac8e7702f91 100644
--- a/docs/snippets/react/mdx-canvas-multiple-stories.mdx.mdx
+++ b/docs/snippets/react/mdx-canvas-multiple-stories.mdx.mdx
@@ -7,7 +7,11 @@ import { Badge } from './Badge';
-export const Template = (args) => ;
+
;
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => } />
- {Template.bind({})}
-
+ }}
+ render={(args) => } />
- {Template.bind({})}
-
+ }}
+ render={(args) => } />
```
diff --git a/docs/snippets/react/mock-context-container-global.js.mdx b/docs/snippets/react/mock-context-container-global.js.mdx
index 0d9582e5be1c..057c8f69120e 100644
--- a/docs/snippets/react/mock-context-container-global.js.mdx
+++ b/docs/snippets/react/mock-context-container-global.js.mdx
@@ -16,6 +16,5 @@ const AppDecorator = (storyFn) => {
{storyFn()}
);
};
-
-addDecorator(AppDecorator);
+export const decorators = [AppDecorator];
```
\ No newline at end of file
diff --git a/docs/snippets/react/mock-context-container.js.mdx b/docs/snippets/react/mock-context-container.js.mdx
index ca752289d6d8..7184cafc16f4 100644
--- a/docs/snippets/react/mock-context-container.js.mdx
+++ b/docs/snippets/react/mock-context-container.js.mdx
@@ -7,13 +7,13 @@ import { ProfilePage } from './ProfilePage';
import { UserPosts } from './UserPosts';
//π Imports a specific story from a story file
-import { normal as UserFriendsNormal } from './UserFriends.stories';
+import { Normal as UserFriendsNormal } from './UserFriends.stories';
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: 'ProfilePage',
component: ProfilePage,
};
@@ -34,11 +34,11 @@ const context = {
UserFriendsContainer: UserFriendsNormal,
};
-export const normal = () => {
- return (
+export const Normal = {
+ render: () => (
- );
+ ),
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/mock-context-create.js.mdx b/docs/snippets/react/mock-context-create.js.mdx
index 5c935b9476e3..ee65d1327e48 100644
--- a/docs/snippets/react/mock-context-create.js.mdx
+++ b/docs/snippets/react/mock-context-create.js.mdx
@@ -1,5 +1,5 @@
```js
-// ProfilePageContext.js | ProfilePageContext.jsx
+// ProfilePageContext.js|jsx
import { createContext } from 'react';
diff --git a/docs/snippets/react/my-component-play-function-alt-queries.js.mdx b/docs/snippets/react/my-component-play-function-alt-queries.js.mdx
index 129856ff200d..2b1101f8e042 100644
--- a/docs/snippets/react/my-component-play-function-alt-queries.js.mdx
+++ b/docs/snippets/react/my-component-play-function-alt-queries.js.mdx
@@ -1,32 +1,30 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { screen, userEvent } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'QueryMethods',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const ExampleWithRole = Template.bind({});
-ExampleWithRole.play = async () => {
- // See https://storybook.js.org/docs/react/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 = {
+ play: async () => {
+ // 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(screen.getByRole('button', { name: / button label/i }));
+ },
};
-export const ExampleWithText = 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 = {
+ 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/react/my-component-play-function-alt-queries.mdx.mdx b/docs/snippets/react/my-component-play-function-alt-queries.mdx.mdx
index 1ba347c2964b..8ece56cb44a1 100644
--- a/docs/snippets/react/my-component-play-function-alt-queries.mdx.mdx
+++ b/docs/snippets/react/my-component-play-function-alt-queries.mdx.mdx
@@ -9,23 +9,21 @@ import { MyComponent } from './MyComponent';
-export const Template = (args) => ;
-
{
- // See https://storybook.js.org/docs/react/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/react/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({})}
+ {
+ play={ async () => {
// The play function interacts with the component and looks for the text
await screen.findByText('example string');
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-alt-queries.ts.mdx b/docs/snippets/react/my-component-play-function-alt-queries.ts.mdx
index 753b76843dce..8b257888c313 100644
--- a/docs/snippets/react/my-component-play-function-alt-queries.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-alt-queries.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { screen, userEvent } from '@storybook/testing-library';
@@ -11,24 +11,24 @@ import { MyComponent } from './MyComponent';
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: 'QueryMethods',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
-
-export const ExampleWithRole = Template.bind({});
-ExampleWithRole.play = async () => {
- // See https://storybook.js.org/docs/react/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: ComponentStoryObj = {
+ play: async () => {
+ // 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(screen.getByRole('button', { name: / button label/i }));
+ },
};
-export const ExampleWithText = 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: ComponentStoryObj = {
+ 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/react/my-component-play-function-composition.js.mdx b/docs/snippets/react/my-component-play-function-composition.js.mdx
index a6eb763cf286..7b17b60735a9 100644
--- a/docs/snippets/react/my-component-play-function-composition.js.mdx
+++ b/docs/snippets/react/my-component-play-function-composition.js.mdx
@@ -1,38 +1,37 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { screen, userEvent } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const FirstStory = Template.bind({});
-FirstStory.play = async () => {
- await userEvent.type(screen.getByTestId('an-element'), 'example-value');
+export const FirstStory = {
+ play: async () => {
+ userEvent.type(screen.getByTestId('an-element'), 'example-value');
+ },
};
-export const SecondStory = Template.bind({});
-SecondStory.play = async () => {
- await userEvent.type(screen.getByTestId('other-element'), 'another value');
+export const SecondStory = {
+ play: async () => {
+ await userEvent.type(screen.getByTestId('other-element'), 'another value');
+ },
};
-export const CombinedStories = 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 = {
+ 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/react/my-component-play-function-composition.ts.mdx b/docs/snippets/react/my-component-play-function-composition.ts.mdx
index 963c4333adb2..5506b0b02e6f 100644
--- a/docs/snippets/react/my-component-play-function-composition.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-composition.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { screen, userEvent } from '@storybook/testing-library';
@@ -11,30 +11,31 @@ import { MyComponent } from './MyComponent';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/eact/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: 'MyComponent',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
-
-export const FirstStory = Template.bind({});
-FirstStory.play = async () => {
- await userEvent.type(screen.getByTestId('an-element'), 'example-value');
+export const FirstStory: ComponentStoryObj = {
+ play: async () => {
+ userEvent.type(screen.getByTestId('an-element'), 'example-value');
+ },
};
-export const SecondStory = Template.bind({});
-SecondStory.play = async () => {
- await userEvent.type(screen.getByTestId('other-element'), 'another value');
+export const SecondStory: ComponentStoryObj = {
+ play: async () => {
+ await userEvent.type(screen.getByTestId('other-element'), 'another value');
+ },
};
-export const CombinedStories = 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: ComponentStoryObj = {
+ 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/react/my-component-play-function-waitfor.js.mdx b/docs/snippets/react/my-component-play-function-waitfor.js.mdx
index 644d84dcd2ba..e6ba8ea5d22b 100644
--- a/docs/snippets/react/my-component-play-function-waitfor.js.mdx
+++ b/docs/snippets/react/my-component-play-function-waitfor.js.mdx
@@ -1,39 +1,36 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { screen, userEvent, waitFor } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'WithAsync',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const ExampleAsyncStory = Template.bind({});
-ExampleAsyncStory.play = async () => {
- const Input = screen.getByLabelText('Username', {
- selector: 'input',
- });
+export const ExampleAsyncStory = {
+ play: async () => {
+ const Input = screen.getByLabelText('Username', {
+ selector: 'input',
+ });
- await userEvent.type(Input, 'WrongInput', {
- delay: 100,
- });
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- const Submit = screen.getByRole('button');
+ await userEvent.type(Input, 'WrongInput', {
+ delay: 100,
+ });
- await userEvent.click(Submit);
+ // 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);
- 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/react/my-component-play-function-waitfor.mdx.mdx b/docs/snippets/react/my-component-play-function-waitfor.mdx.mdx
index 5f8283aec0ff..ba2de20bb456 100644
--- a/docs/snippets/react/my-component-play-function-waitfor.mdx.mdx
+++ b/docs/snippets/react/my-component-play-function-waitfor.mdx.mdx
@@ -9,11 +9,9 @@ import { MyComponent } from './MyComponent';
-export const Template = (args) => ;
-
{
+ play={ async () => {
const Input = screen.getByLabelText('Username', {
selector: 'input',
});
@@ -22,7 +20,7 @@ export const Template = (args) => ;
delay: 100,
});
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // 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);
@@ -31,6 +29,6 @@ export const Template = (args) => ;
await userEvent.hover(screen.getByTestId('error'));
});
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-waitfor.ts.mdx b/docs/snippets/react/my-component-play-function-waitfor.ts.mdx
index 9244723af719..e145f8962501 100644
--- a/docs/snippets/react/my-component-play-function-waitfor.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-waitfor.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { screen, userEvent, waitFor } from '@storybook/testing-library';
@@ -11,31 +11,30 @@ import { MyComponent } from './MyComponent';
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: 'WithAsync',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+export const ExampleAsyncStory: ComponentStoryObj = {
+ play: async () => {
+ const Input = screen.getByLabelText('Username', {
+ selector: 'input',
+ });
-export const ExampleAsyncStory = 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/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- const Submit = screen.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
+ const Submit = screen.getByRole('button');
+ await userEvent.click(Submit);
- 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/react/my-component-play-function-with-canvas.js.mdx b/docs/snippets/react/my-component-play-function-with-canvas.js.mdx
index 8919922d972b..49a4d60c8551 100644
--- a/docs/snippets/react/my-component-play-function-with-canvas.js.mdx
+++ b/docs/snippets/react/my-component-play-function-with-canvas.js.mdx
@@ -1,30 +1,27 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { getByRole, userEvent, within } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'WithCanvasElement',
component: MyComponent,
};
-const Template = () => ;
-
-export const ExampleStory = Template.bind({});
-ExampleStory.play = async ({ canvasElement }) => {
- // Assigns canvas to the component root element
- const canvas = within(canvasElement);
+export const 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/react/my-component-play-function-with-canvas.mdx.mdx b/docs/snippets/react/my-component-play-function-with-canvas.mdx.mdx
index fb0229cc7336..3ab138987002 100644
--- a/docs/snippets/react/my-component-play-function-with-canvas.mdx.mdx
+++ b/docs/snippets/react/my-component-play-function-with-canvas.mdx.mdx
@@ -7,11 +7,9 @@ import { MyComponent } from './MyComponent';
-export const Template = (args) => ;
-
{
+ play={ async ({ canvasElement }) => {
// Assigns canvas to the component root element
const canvas = within(canvasElement);
@@ -19,6 +17,6 @@ export const Template = (args) => ;
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-with-canvas.ts.mdx b/docs/snippets/react/my-component-play-function-with-canvas.ts.mdx
index 30b939abf272..f0a7942d48e3 100644
--- a/docs/snippets/react/my-component-play-function-with-canvas.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-with-canvas.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { userEvent, within } from '@storybook/testing-library';
@@ -11,22 +11,21 @@ import { MyComponent } from './MyComponent';
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: 'WithCanvasElement',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+export const ExampleStory: ComponentStoryObj = {
+ play: async ({ canvasElement }) => {
+ // Assigns canvas to the component root element
+ const canvas = within(canvasElement);
-export const ExampleStory = 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/react/my-component-play-function-with-clickevent.js.mdx b/docs/snippets/react/my-component-play-function-with-clickevent.js.mdx
index fe4c017e7113..4b9959f264f9 100644
--- a/docs/snippets/react/my-component-play-function-with-clickevent.js.mdx
+++ b/docs/snippets/react/my-component-play-function-with-clickevent.js.mdx
@@ -1,32 +1,30 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { fireEvent, screen, userEvent } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'ClickExamples',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const ClickExample = Template.bind({});
-ClickExample.play = async () => {
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(screen.getByRole('button'));
+export const ClickExample = {
+ play: async () => {
+ // 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(screen.getByRole('button'));
+ },
};
-export const FireEventExample = Template.bind({});
-FireEventExample.play = async () => {
- // See https://storybook.js.org/docs/react/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 = {
+ play: async () => {
+ // 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 fireEvent.click(screen.getByTestId('data-testid'));
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-with-clickevent.mdx.mdx b/docs/snippets/react/my-component-play-function-with-clickevent.mdx.mdx
index bb3ff3e9b31c..c94aea01fb62 100644
--- a/docs/snippets/react/my-component-play-function-with-clickevent.mdx.mdx
+++ b/docs/snippets/react/my-component-play-function-with-clickevent.mdx.mdx
@@ -9,23 +9,21 @@ import { MyComponent } from './MyComponent';
-export const Template = (args) => ;
-
{
- // See https://storybook.js.org/docs/react/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/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await userEvent.click(screen.getByRole('button'));
}}>
- {Template.bind({})}
+ {
- // See https://storybook.js.org/docs/react/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/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await fireEvent.click(screen.getByTestId('data-testid'));
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-with-clickevent.ts.mdx b/docs/snippets/react/my-component-play-function-with-clickevent.ts.mdx
index 876c1cc32015..2deaa5daf555 100644
--- a/docs/snippets/react/my-component-play-function-with-clickevent.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-with-clickevent.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { fireEvent, screen, userEvent } from '@storybook/testing-library';
@@ -11,24 +11,24 @@ import { MyComponent } from './MyComponent';
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: 'ClickExamples',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
-
-export const ClickExample = Template.bind({});
-ClickExample.play = async () => {
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(screen.getByRole('button'));
+export const ClickExample: ComponentStoryObj = {
+ play: async () => {
+ // 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(screen.getByRole('button'));
+ },
};
-export const FireEventExample = Template.bind({});
-FireEventExample.play = async () => {
- // See https://storybook.js.org/docs/react/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: ComponentStoryObj = {
+ play: async () => {
+ // 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 fireEvent.click(screen.getByTestId('data-testid'));
+ },
};
-```
\ No newline at end of file
+```
diff --git a/docs/snippets/react/my-component-play-function-with-delay.js.mdx b/docs/snippets/react/my-component-play-function-with-delay.js.mdx
index ffda0d5edec1..f0f38d5a71f7 100644
--- a/docs/snippets/react/my-component-play-function-with-delay.js.mdx
+++ b/docs/snippets/react/my-component-play-function-with-delay.js.mdx
@@ -1,35 +1,32 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { screen, userEvent } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'WithDelay',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const DelayedStory = Template.bind({});
-DelayedStory.play = async () => {
- const exampleElement= screen.getByLabelText('example-element');
+export const DelayedStory = {
+ play: async () => {
+ 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/react/my-component-play-function-with-delay.mdx.mdx b/docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
index 56ab5df2ebcc..6f925fd8b7f7 100644
--- a/docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
+++ b/docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
@@ -9,11 +9,9 @@ import { MyComponent } from './MyComponent';
-export const Template = (args) => ;
-
{
+ play={ async () => {
const exampleElement= screen.getByLabelText('example-element');
// The delay option set the amount of milliseconds between characters being typed
@@ -26,6 +24,6 @@ export const Template = (args) => ;
delay: 100,
});
}}>
- {Template.bind({})}
+
```
diff --git a/docs/snippets/react/my-component-play-function-with-delay.ts.mdx b/docs/snippets/react/my-component-play-function-with-delay.ts.mdx
index 0d806f32d210..e9966a552b14 100644
--- a/docs/snippets/react/my-component-play-function-with-delay.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-with-delay.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { screen, userEvent } from '@storybook/testing-library';
@@ -11,27 +11,26 @@ import { MyComponent } from './MyComponent';
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: 'WithDelay',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+export const DelayedStory: ComponentStoryObj = {
+ play: async () => {
+ const exampleElement = screen.getByLabelText('example-element');
-export const DelayedStory = Template.bind({});
-DelayedStory.play = async () => {
- const exampleElement= screen.getByLabelText('example-element');
+ // The delay option set the ammount of milliseconds between characters being typed
+ await userEvent.type(exampleElement, 'random string', {
+ delay: 100,
+ });
- // The delay option set the amount 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/react/my-component-play-function-with-selectevent.js.mdx b/docs/snippets/react/my-component-play-function-with-selectevent.js.mdx
index 82bf334a5062..742038b8cee7 100644
--- a/docs/snippets/react/my-component-play-function-with-selectevent.js.mdx
+++ b/docs/snippets/react/my-component-play-function-with-selectevent.js.mdx
@@ -1,17 +1,15 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { userEvent, screen } from '@storybook/testing-library';
import { MyComponent } from './MyComponent';
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: 'WithSelectEvent',
component: MyComponent,
};
@@ -21,18 +19,19 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
-const Template = (args) => ;
+// Queries the element by it's role and fires the event
-export const ExampleChangeEvent = Template.bind({});
-ExampleChangeEvent.play = async () => {
- const select = screen.getByRole('listbox');
+export const 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/react/my-component-play-function-with-selectevent.mdx.mdx b/docs/snippets/react/my-component-play-function-with-selectevent.mdx.mdx
index e0e16944bee0..168ee8e35b6b 100644
--- a/docs/snippets/react/my-component-play-function-with-selectevent.mdx.mdx
+++ b/docs/snippets/react/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) => ;
-
{
+ play={ async () => {
const select = screen.getByRole('listbox');
await userEvent.selectOptions(select, ['One Item']);
@@ -31,6 +29,6 @@ export const Template = (args) => ;
await userEvent.selectOptions(select, ['Yet another item']);
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-play-function-with-selectevent.ts.mdx b/docs/snippets/react/my-component-play-function-with-selectevent.ts.mdx
index 2bc79c8dd1fa..f97d551f7494 100644
--- a/docs/snippets/react/my-component-play-function-with-selectevent.ts.mdx
+++ b/docs/snippets/react/my-component-play-function-with-selectevent.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { userEvent, screen } from '@storybook/testing-library';
@@ -11,9 +11,9 @@ import { MyComponent } from './MyComponent';
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: 'WithSelectEvent',
component: MyComponent,
} as ComponentMeta;
@@ -23,18 +23,19 @@ function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
-const Template: ComponentStory = (args) => ;
+// Queries the element by it's role and fires the event
-export const ExampleChangeEvent = Template.bind({});
-ExampleChangeEvent.play = async () => {
- const select = screen.getByRole('listbox');
+export const ExampleChangeEvent: ComponentStoryObj = {
+ 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/react/my-component-story-basic-and-props.js.mdx b/docs/snippets/react/my-component-story-basic-and-props.js.mdx
index 71d3ea0da3d3..ad5fa295738e 100644
--- a/docs/snippets/react/my-component-story-basic-and-props.js.mdx
+++ b/docs/snippets/react/my-component-story-basic-and-props.js.mdx
@@ -7,14 +7,16 @@ import { MyComponent } from './MyComponent';
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: 'Path/To/MyComponent',
component: MyComponent,
};
-export const Basic = () => ;
+export const Basic = {};
-export const WithProp = () => ;
+export const WithProp = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-basic-and-props.ts.mdx b/docs/snippets/react/my-component-story-basic-and-props.ts.mdx
index 62acb5a7bc20..62798b6d4ed8 100644
--- a/docs/snippets/react/my-component-story-basic-and-props.ts.mdx
+++ b/docs/snippets/react/my-component-story-basic-and-props.ts.mdx
@@ -3,20 +3,22 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { MyComponent } from './MyComponent';
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: 'Path/To/MyComponent',
component: MyComponent,
} as ComponentMeta;
-export const Basic: ComponentStory = () => ;
+export const Basic: ComponentStoryObj = {};
-export const WithProp: ComponentStory = () => ;
+export const WithProp: ComponentStoryObj = {
+ render: () => ,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-configure-viewports.js.mdx b/docs/snippets/react/my-component-story-configure-viewports.js.mdx
index cbfb8999e9ab..85d6233282b0 100644
--- a/docs/snippets/react/my-component-story-configure-viewports.js.mdx
+++ b/docs/snippets/react/my-component-story-configure-viewports.js.mdx
@@ -1,17 +1,15 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
parameters: {
@@ -25,10 +23,11 @@ export default {
},
};
-export const MyStory = () => ;
-MyStory.parameters = {
- viewport: {
- defaultViewport: 'iphonex',
+export const MyStory = {
+ parameters: {
+ viewport: {
+ defaultViewport: 'iphonex',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-configure-viewports.ts.mdx b/docs/snippets/react/my-component-story-configure-viewports.ts.mdx
index 8ab4c0a95185..384076a66d64 100644
--- a/docs/snippets/react/my-component-story-configure-viewports.ts.mdx
+++ b/docs/snippets/react/my-component-story-configure-viewports.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
@@ -11,9 +11,9 @@ import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
parameters: {
@@ -27,10 +27,11 @@ export default {
},
} as ComponentMeta;
-export const MyStory: ComponentStory = () => ;
-MyStory.parameters = {
- viewport: {
- defaultViewport: 'iphonex',
+export const MyStory: ComponentStoryObj = {
+ parameters: {
+ viewport: {
+ defaultViewport: 'iphonex',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-use-globaltype-backwards-compat.js.mdx b/docs/snippets/react/my-component-story-use-globaltype-backwards-compat.js.mdx
index ab59221464e8..8b56d5b88a65 100644
--- a/docs/snippets/react/my-component-story-use-globaltype-backwards-compat.js.mdx
+++ b/docs/snippets/react/my-component-story-use-globaltype-backwards-compat.js.mdx
@@ -3,6 +3,6 @@
export const StoryWithLocale = ({ globals: { locale } }) => {
const caption = getCaptionForLocale(locale);
- return <>{caption}>;
+ return
{caption}
;
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-use-globaltype.js.mdx b/docs/snippets/react/my-component-story-use-globaltype.js.mdx
index 03f49fbe2eb5..db294a0081a4 100644
--- a/docs/snippets/react/my-component-story-use-globaltype.js.mdx
+++ b/docs/snippets/react/my-component-story-use-globaltype.js.mdx
@@ -7,9 +7,9 @@ import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
};
@@ -29,8 +29,15 @@ const getCaptionForLocale = (locale) => {
}
};
-export const StoryWithLocale = (args, { globals: { locale } }) => {
- const caption = getCaptionForLocale(locale);
- return <>{caption}>;
+/*
+ *π 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 StoryWithLocale = {
+ render: (args, { globals: { locale } }) => {
+ const caption = getCaptionForLocale(locale);
+ return
{caption}
;
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-use-globaltype.mdx.mdx b/docs/snippets/react/my-component-story-use-globaltype.mdx.mdx
index 55c5ca4ab813..07553b06e43b 100644
--- a/docs/snippets/react/my-component-story-use-globaltype.mdx.mdx
+++ b/docs/snippets/react/my-component-story-use-globaltype.mdx.mdx
@@ -18,10 +18,16 @@ export const getCaptionForLocale = (locale) => {
}
};
-
- {(args, { globals: { locale } }) => {
+
+
+ {
const caption = getCaptionForLocale(locale);
return <>{caption}>;
- }}
-
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-with-nonstory.js.mdx b/docs/snippets/react/my-component-story-with-nonstory.js.mdx
index 6f07127c2e6b..438611688594 100644
--- a/docs/snippets/react/my-component-story-with-nonstory.js.mdx
+++ b/docs/snippets/react/my-component-story-with-nonstory.js.mdx
@@ -1,18 +1,16 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { MyComponent } from './MyComponent';
import someData from './data.json';
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
- */
- title: 'MyComponent',
+ * See https://storybook.js.org/docs/7.0/react/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
@@ -21,16 +19,15 @@ export default {
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
-
-const Template = (args) => ;
-
-export const SimpleStory = Template.bind({});
-SimpleStory.args = {
- data: simpleData,
+export const SimpleStory = {
+ args: {
+ data: simpleData,
+ },
};
-export const ComplexStory = Template.bind({});
-ComplexStory.args = {
- data: complexData,
+export const ComplexStory = {
+ args: {
+ data: complexData,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-story-with-nonstory.ts.mdx b/docs/snippets/react/my-component-story-with-nonstory.ts.mdx
index b3f0a65f7897..38467c5f18d2 100644
--- a/docs/snippets/react/my-component-story-with-nonstory.ts.mdx
+++ b/docs/snippets/react/my-component-story-with-nonstory.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { MyComponent } from './MyComponent';
@@ -11,10 +11,10 @@ import someData from './data.json';
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
- */
- title: 'MyComponent',
+ * See https://storybook.js.org/docs/7.0/react/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
@@ -23,15 +23,15 @@ export default {
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
-const Template: ComponentStory = (args) => ;
-
-export const SimpleStory = Template.bind({});
-SimpleStory.args = {
- data: simpleData,
+export const SimpleStory: ComponentStoryObj = {
+ args: {
+ data: simpleData,
+ },
};
-export const ComplexStory = Template.bind({});
-ComplexStory.args = {
- data: complexData,
+export const ComplexStory: ComponentStoryObj = {
+ args: {
+ data: complexData,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-with-env-variables.js.mdx b/docs/snippets/react/my-component-with-env-variables.js.mdx
index b54d5ffa125b..9fdf5755862c 100644
--- a/docs/snippets/react/my-component-with-env-variables.js.mdx
+++ b/docs/snippets/react/my-component-with-env-variables.js.mdx
@@ -1,23 +1,20 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
};
-const Template = (args) => ;
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY,
+export const ExampleStory = {
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-with-env-variables.mdx.mdx b/docs/snippets/react/my-component-with-env-variables.mdx.mdx
index 69b94fd67797..40f690100faf 100644
--- a/docs/snippets/react/my-component-with-env-variables.mdx.mdx
+++ b/docs/snippets/react/my-component-with-env-variables.mdx.mdx
@@ -3,18 +3,22 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs';
-import MyComponent from './MyComponent';
+import { } from './MyComponent';
-
+
-export const Template = (args) =>
+
- {Template.bind({})}
+ }}
+ render={(args) => } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/my-component-with-env-variables.ts.mdx b/docs/snippets/react/my-component-with-env-variables.ts.mdx
index d92592bccfbe..c61e637c8d2f 100644
--- a/docs/snippets/react/my-component-with-env-variables.ts.mdx
+++ b/docs/snippets/react/my-component-with-env-variables.ts.mdx
@@ -3,23 +3,22 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { MyComponent } from './MyComponent';
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: 'MyComponent',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY,
+export const ExampleStory: ComponentStoryObj = {
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/page-story-slots.js.mdx b/docs/snippets/react/page-story-slots.js.mdx
index 11d4bc89c9b5..b1505265d54e 100644
--- a/docs/snippets/react/page-story-slots.js.mdx
+++ b/docs/snippets/react/page-story-slots.js.mdx
@@ -7,21 +7,26 @@ import { Page } from './Page';
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: 'Page',
component: Page,
};
-const Template = (args) => (
-
-
-
-);
-
-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/react/api/csf
+ * to learn how to use render functions.
+ */
+export const CustomFooter = {
+ render: (args) => (
+
+
+
+ ),
+ args: {
+ footer: 'Built with Storybook',
+ },
};
```
diff --git a/docs/snippets/react/page-story-slots.mdx.mdx b/docs/snippets/react/page-story-slots.mdx.mdx
index fc0f0220bb3e..fa2c0d613a52 100644
--- a/docs/snippets/react/page-story-slots.mdx.mdx
+++ b/docs/snippets/react/page-story-slots.mdx.mdx
@@ -7,18 +7,20 @@ import { Page } from './Page';
-
-export const Template = (args) => (
-
-
-
-);
+
- {Template.bind({})}
-
+ }}
+ render={(args) => (
+
+
+
+ )} />
```
\ No newline at end of file
diff --git a/docs/snippets/react/page-story-slots.ts.mdx b/docs/snippets/react/page-story-slots.ts.mdx
index 46feb98468c5..02dbbc54a737 100644
--- a/docs/snippets/react/page-story-slots.ts.mdx
+++ b/docs/snippets/react/page-story-slots.ts.mdx
@@ -3,27 +3,27 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { Page } from './Page';
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: 'Page',
component: Page,
} as ComponentMeta;
-const Template: ComponentStory = (args) => (
-
-
-
-);
-
-export const CustomFooter = Template.bind({});
-CustomFooter.args = {
- footer: 'Built with Storybook',
+export const CustomFooter: ComponentStoryObj = {
+ render: (args) => (
+
+
+
+ ),
+ args: {
+ footer: 'Built with Storybook',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/page-story-with-args-composition.js.mdx b/docs/snippets/react/page-story-with-args-composition.js.mdx
index f111fbf2d215..fb3eecd81707 100644
--- a/docs/snippets/react/page-story-with-args-composition.js.mdx
+++ b/docs/snippets/react/page-story-with-args-composition.js.mdx
@@ -1,8 +1,6 @@
```js
// YourPage.stories.js|jsx
-import React from 'react';
-
import { DocumentScreen } from './YourPage';
//π Imports the required stories
@@ -12,19 +10,18 @@ import * as DocumentList from './DocumentList.stories';
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: 'DocumentScreen',
component: DocumentScreen,
};
-const Template = (args) => ;
-
-export const Simple = Template.bind({});
-Simple.args = {
- user: PageLayout.Simple.args.user,
- document: DocumentHeader.Simple.args.document,
- subdocuments: DocumentList.Simple.args.documents,
+export const Simple = {
+ args: {
+ user: PageLayout.Simple.args.user,
+ document: DocumentHeader.Simple.args.document,
+ subdocuments: DocumentList.Simple.args.documents,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/page-story-with-args-composition.ts.mdx b/docs/snippets/react/page-story-with-args-composition.ts.mdx
index be960adff652..83c9734b3da0 100644
--- a/docs/snippets/react/page-story-with-args-composition.ts.mdx
+++ b/docs/snippets/react/page-story-with-args-composition.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { DocumentScreen } from './YourPage';
@@ -13,20 +13,18 @@ import DocumentList from './DocumentList.stories';
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: 'DocumentScreen',
component: DocumentScreen,
} as ComponentMeta;
-
-const Template: ComponentStory = (args) => ;
-
-export const Simple = Template.bind({});
-Simple.args = {
- user: PageLayout.Simple.args.user,
- document: DocumentHeader.Simple.args.document,
- subdocuments: DocumentList.Simple.args.documents,
+export const Simple: ComponentStoryObj = {
+ args: {
+ user: PageLayout.Simple.args.user,
+ document: DocumentHeader.Simple.args.document,
+ subdocuments: DocumentList.Simple.args.documents,
+ },
};
```
diff --git a/docs/snippets/react/page-story.js.mdx b/docs/snippets/react/page-story.js.mdx
index a294dfedbfaf..f35a189c0953 100644
--- a/docs/snippets/react/page-story.js.mdx
+++ b/docs/snippets/react/page-story.js.mdx
@@ -1,8 +1,6 @@
```js
// Page.stories.js|jsx
-import React from 'react';
-
import { Page } from './Page';
//π Imports all Header stories
@@ -10,17 +8,16 @@ import * as HeaderStories from './Header.stories';
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: 'Page',
component: Page,
};
-const Template = (args) => ;
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- ...HeaderStories.LoggedIn.args,
+export const LoggedIn = {
+ args: {
+ ...HeaderStories.LoggedIn.args,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/page-story.ts.mdx b/docs/snippets/react/page-story.ts.mdx
index d1757de939a6..dfb8c0149c66 100644
--- a/docs/snippets/react/page-story.ts.mdx
+++ b/docs/snippets/react/page-story.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { Page } from './Page';
@@ -12,17 +12,16 @@ import * as HeaderStories from './Header.stories';
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: 'Page',
component: Page,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- ...HeaderStories.LoggedIn.args,
+export const LoggedIn: ComponentStoryObj = {
+ args: {
+ ...HeaderStories.LoggedIn.args,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/register-component-with-play-function.js.mdx b/docs/snippets/react/register-component-with-play-function.js.mdx
index 84ce6df35c49..bcb456e1c94e 100644
--- a/docs/snippets/react/register-component-with-play-function.js.mdx
+++ b/docs/snippets/react/register-component-with-play-function.js.mdx
@@ -1,43 +1,40 @@
```js
// RegistrationForm.stories.js|jsx
-import React from 'react';
-
import { screen, userEvent } from '@storybook/testing-library';
import { RegistrationForm } from './RegistrationForm';
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: 'RegistrationForm',
component: RegistrationForm,
};
-const Template = (args) => ;
-
-export const FilledForm = Template.bind({});
-FilledForm.play = async () => {
- const emailInput = screen.getByLabelText('email', {
- selector: 'input',
- });
+export const 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/react/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/7.0/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ const submitButton = screen.getByRole('button');
- await userEvent.click(submitButton);
+ await userEvent.click(submitButton);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/register-component-with-play-function.mdx.mdx b/docs/snippets/react/register-component-with-play-function.mdx.mdx
index 3efb0b00bf4c..3faec01dbe12 100644
--- a/docs/snippets/react/register-component-with-play-function.mdx.mdx
+++ b/docs/snippets/react/register-component-with-play-function.mdx.mdx
@@ -9,11 +9,9 @@ import { RegistrationForm } from './RegistrationForm';
-export const Template = (args) => ;
-
{
+ play={ async () => {
const emailInput = screen.getByLabelText('email', {
selector: 'input',
});
@@ -29,11 +27,11 @@ export const Template = (args) => ;
await userEvent.type(passwordInput, 'ExamplePassword', {
delay: 100,
});
- // See https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // 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 submitButton = screen.getByRole('button');
await userEvent.click(submitButton);
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/register-component-with-play-function.ts.mdx b/docs/snippets/react/register-component-with-play-function.ts.mdx
index 31bdad97cb54..2fce7c72a1d2 100644
--- a/docs/snippets/react/register-component-with-play-function.ts.mdx
+++ b/docs/snippets/react/register-component-with-play-function.ts.mdx
@@ -3,7 +3,7 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { screen, userEvent } from '@storybook/testing-library';
@@ -11,35 +11,34 @@ import { RegistrationForm } from './RegistrationForm';
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: 'RegistrationForm',
component: RegistrationForm,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+export const FilledForm: ComponentStoryObj = {
+ play: async () => {
+ const emailInput = screen.getByLabelText('email', {
+ selector: 'input',
+ });
-export const FilledForm = 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/react/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/react/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- const submitButton = screen.getByRole('button');
-
- await userEvent.click(submitButton);
+ await userEvent.click(submitButton);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/storybook-addon-a11y-disable.js.mdx b/docs/snippets/react/storybook-addon-a11y-disable.js.mdx
index 84e5a531fdc7..58dbe375c9c0 100644
--- a/docs/snippets/react/storybook-addon-a11y-disable.js.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-disable.js.mdx
@@ -1,26 +1,23 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { MyComponent } from './MyComponent';
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: 'Disable a11y addon',
component: MyComponent,
};
-const Template = () => ;
-
-export const NonA11yStory = Template.bind({});
-NonA11yStory.parameters = {
- a11y: {
- // This option disables all a11y checks on this story
- disable: true,
+export const NonA11yStory = {
+ parameters: {
+ a11y: {
+ // This option disables all a11y checks on this story
+ disable: true,
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/storybook-addon-a11y-disable.mdx.mdx b/docs/snippets/react/storybook-addon-a11y-disable.mdx.mdx
index 5347735e74ae..4862f1babef3 100644
--- a/docs/snippets/react/storybook-addon-a11y-disable.mdx.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-disable.mdx.mdx
@@ -9,8 +9,6 @@ import { MyComponent } from './MyComponent';
title="Disable a11y addon"
component={MyComponent} />
-export const Template = () => ;
-
;
disable: true,
},
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/storybook-addon-a11y-disable.ts.mdx b/docs/snippets/react/storybook-addon-a11y-disable.ts.mdx
index 113f6fd5127a..05edd53befb8 100644
--- a/docs/snippets/react/storybook-addon-a11y-disable.ts.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-disable.ts.mdx
@@ -3,26 +3,25 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { MyComponent } from './MyComponent';
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: 'Disable a11y addon',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = () => ;
-
-export const NonA11yStory = Template.bind({});
-NonA11yStory.parameters = {
- a11y: {
- // This option disables all a11y checks on this story
- disable: true,
+export const NonA11yStory: ComponentStoryObj = {
+ parameters: {
+ a11y: {
+ // This option disables all a11y checks on this story
+ disable: true,
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/storybook-addon-a11y-story-config.js.mdx b/docs/snippets/react/storybook-addon-a11y-story-config.js.mdx
index cc39f6799564..7fb87ca1156c 100644
--- a/docs/snippets/react/storybook-addon-a11y-story-config.js.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-story-config.js.mdx
@@ -1,41 +1,38 @@
```js
// MyComponent.stories.js|jsx
-import React from 'react';
-
import { MyComponent } from './MyComponent';
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: 'Configure a11y addon',
component: MyComponent,
};
-const Template = () => ;
-
-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 = {
+ 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/react/storybook-addon-a11y-story-config.mdx.mdx b/docs/snippets/react/storybook-addon-a11y-story-config.mdx.mdx
index 8b1ed8796ccd..42224490b34c 100644
--- a/docs/snippets/react/storybook-addon-a11y-story-config.mdx.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-story-config.mdx.mdx
@@ -9,8 +9,6 @@ import { MyComponent } from './MyComponent';
title="Configure A11y addon"
component={MyComponent} />
-export const Template = () => ;
-
;
manual: true,
},
}}>
- {Template.bind({})}
+
```
\ No newline at end of file
diff --git a/docs/snippets/react/storybook-addon-a11y-story-config.ts.mdx b/docs/snippets/react/storybook-addon-a11y-story-config.ts.mdx
index 9ae7ea00ea79..f75499b42b50 100644
--- a/docs/snippets/react/storybook-addon-a11y-story-config.ts.mdx
+++ b/docs/snippets/react/storybook-addon-a11y-story-config.ts.mdx
@@ -3,41 +3,40 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { MyComponent } from './MyComponent';
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: 'Configure a11y addon',
component: MyComponent,
} as ComponentMeta;
-const Template: ComponentStory = () => ;
-
-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: ComponentStoryObj = {
+ 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/react/storybook-preview-global-decorator.story-function.js.mdx b/docs/snippets/react/storybook-preview-global-decorator.story-function.js.mdx
index 46e393bdf808..9cffd503437f 100644
--- a/docs/snippets/react/storybook-preview-global-decorator.story-function.js.mdx
+++ b/docs/snippets/react/storybook-preview-global-decorator.story-function.js.mdx
@@ -1,13 +1,7 @@
```js
// .storybook/preview.js
-import React from "react";
+import React from 'react';
-export const decorators = [
- (Story) => (
-
- {Story()}
-
- ),
-];
+export const decorators = [(Story) =>
{Story()}
];
```
\ No newline at end of file
diff --git a/docs/snippets/react/table-story-fully-customize-controls.js.mdx b/docs/snippets/react/table-story-fully-customize-controls.js.mdx
index 0778b994fd6f..8e1163eecaa2 100644
--- a/docs/snippets/react/table-story-fully-customize-controls.js.mdx
+++ b/docs/snippets/react/table-story-fully-customize-controls.js.mdx
@@ -9,30 +9,38 @@ import { TR } from './TableRow';
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: 'Custom Table',
component: Table,
};
-const TableStory = ({ data, ...args}) => (
-
- {data.map((row) => (
-
- {row.map((item) => (
-
{item}
- ))}
-
- ))}
-
-);
-
-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',
+/*
+ *π 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 TableStory = {
+ render: ({ data, ...args }) => (
+
+ {data.map((row) => (
+
+ {row.map((item) => (
+
{item}
+ ))}
+
+ ))}
+
+ ),
+ 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',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/react/table-story-fully-customize-controls.mdx.mdx b/docs/snippets/react/table-story-fully-customize-controls.mdx.mdx
index f656ff9b88b6..0611c9129490 100644
--- a/docs/snippets/react/table-story-fully-customize-controls.mdx.mdx
+++ b/docs/snippets/react/table-story-fully-customize-controls.mdx.mdx
@@ -9,18 +9,27 @@ import { TR } from './TableRow';
-export const TableStory = ({ data, ...args }) => (
-
+ )}/>
```
\ No newline at end of file
diff --git a/docs/snippets/react/your-component-with-decorator.js.mdx b/docs/snippets/react/your-component-with-decorator.js.mdx
index 9b2d3f20058b..3b6ffa7b81a8 100644
--- a/docs/snippets/react/your-component-with-decorator.js.mdx
+++ b/docs/snippets/react/your-component-with-decorator.js.mdx
@@ -1,13 +1,15 @@
```js
// YourComponent.stories.js|jsx
+import React from 'react';
+
import { YourComponent } from './YourComponent';
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: 'YourComponent',
component: YourComponent,
decorators: [
diff --git a/docs/snippets/react/your-component-with-decorator.story-function-js.js.mdx b/docs/snippets/react/your-component-with-decorator.story-function-js.js.mdx
index f7cfb381d284..a2ec1f492a0d 100644
--- a/docs/snippets/react/your-component-with-decorator.story-function-js.js.mdx
+++ b/docs/snippets/react/your-component-with-decorator.story-function-js.js.mdx
@@ -1,16 +1,18 @@
```js
// YourComponent.stories.js|jsx
+import React from 'react';
+
import { YourComponent } from './YourComponent';
// Replacing the element with a Story function is also a good way of writing decorators.
// Useful to prevent the full remount of the component's story.
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: 'YourComponent',
component: YourComponent,
decorators: [(Story) =>
{Story()}
],
diff --git a/docs/snippets/react/your-component-with-decorator.story-function-ts.ts.mdx b/docs/snippets/react/your-component-with-decorator.story-function-ts.ts.mdx
index 9ba55b1da62c..1c47e59bc50b 100644
--- a/docs/snippets/react/your-component-with-decorator.story-function-ts.ts.mdx
+++ b/docs/snippets/react/your-component-with-decorator.story-function-ts.ts.mdx
@@ -1,6 +1,8 @@
```ts
// YourComponent.stories.ts|tsx
+import React from 'react';
+
import { ComponentMeta } from '@storybook/react';
import { YourComponent } from './YourComponent';
@@ -9,17 +11,11 @@ import { YourComponent } from './YourComponent';
// Useful to prevent the full remount of the component's story.
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: 'YourComponent',
component: YourComponent,
- decorators: [
- (Story) => (
-
- {Story()}
-
- ),
- ],
+ decorators: [(Story) =>
{Story()}
],
} as ComponentMeta;
```
\ No newline at end of file
diff --git a/docs/snippets/react/your-component-with-decorator.ts.mdx b/docs/snippets/react/your-component-with-decorator.ts.mdx
index dc89e46e4c69..c60a314816e6 100644
--- a/docs/snippets/react/your-component-with-decorator.ts.mdx
+++ b/docs/snippets/react/your-component-with-decorator.ts.mdx
@@ -1,21 +1,23 @@
```ts
// YourComponent.stories.ts|tsx
+import React from 'react';
+
import { ComponentMeta } from '@storybook/react';
import { YourComponent } from './YourComponent';
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: 'YourComponent',
component: YourComponent,
decorators: [
(Story) => (
-
+
),
],
diff --git a/docs/snippets/react/your-component.js.mdx b/docs/snippets/react/your-component.js.mdx
index 5b3121d657ac..2e06e8e384f2 100644
--- a/docs/snippets/react/your-component.js.mdx
+++ b/docs/snippets/react/your-component.js.mdx
@@ -6,16 +6,13 @@ import { YourComponent } from './YourComponent';
//π 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/react/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/eact/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = (args) => ;
-
export const FirstStory = {
args: {
//π The args you need here will depend on your component
diff --git a/docs/snippets/react/your-component.mdx.mdx b/docs/snippets/react/your-component.mdx.mdx
index 432f8a5f1703..d28dcfca0f00 100644
--- a/docs/snippets/react/your-component.mdx.mdx
+++ b/docs/snippets/react/your-component.mdx.mdx
@@ -8,13 +8,9 @@ import { YourComponent } from './YourComponent';
-
-export const Template = (args) => ;
-
- {Template.bind({})}
-
+ args={{}}
+ render={(args) => } />
```
\ No newline at end of file
diff --git a/docs/snippets/react/your-component.ts.mdx b/docs/snippets/react/your-component.ts.mdx
index cabd3abcb3e7..6871d8461af1 100644
--- a/docs/snippets/react/your-component.ts.mdx
+++ b/docs/snippets/react/your-component.ts.mdx
@@ -3,26 +3,23 @@
import React from 'react';
-import { ComponentStory, ComponentMeta } from '@storybook/react';
+import type { ComponentStoryObj, ComponentMeta } from '@storybook/react';
import { YourComponent } from './YourComponent';
//π 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/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: 'YourComponent',
component: YourComponent,
} as ComponentMeta;
-//π We create a βtemplateβ of how args map to rendering
-const Template: ComponentStory = (args) => ;
-
-export const FirstStory = Template.bind({});
-
-FirstStory.args = {
- /*π The args you need here will depend on your component */
+export const FirstStory: ComponentStoryObj = {
+ args: {
+ //π The args you need here will depend on your component
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/badge-story.mdx.mdx b/docs/snippets/svelte/badge-story.mdx.mdx
index 06a6c95b9386..f30d432b4d38 100644
--- a/docs/snippets/svelte/badge-story.mdx.mdx
+++ b/docs/snippets/svelte/badge-story.mdx.mdx
@@ -7,11 +7,6 @@ import Badge from './Badge.svelte';
-export const Template = (args) => ({
- Component: Badge,
- props: args,
-});
-
# Badge
Let's define a story for our `Badge` component:
@@ -21,9 +16,11 @@ Let's define a story for our `Badge` component:
args={{
status: 'positive',
label: 'Positive'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
We can drop it in a `Canvas` to get a code snippet:
@@ -33,9 +30,11 @@ We can drop it in a `Canvas` to get a code snippet:
args={{
status: 'negative',
label: 'Negative'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
We can even preview multiple Stories in a block. This
@@ -48,32 +47,30 @@ with unique URLs, which is great for review and testing.
args={{
status: 'warning',
label: 'Warning'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
- {Template.bind({})}
-
- with icon)
- )}}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
```
diff --git a/docs/snippets/svelte/button-group-story.js.mdx b/docs/snippets/svelte/button-group-story.js.mdx
index 78ebad33838c..16db4a2ef26f 100644
--- a/docs/snippets/svelte/button-group-story.js.mdx
+++ b/docs/snippets/svelte/button-group-story.js.mdx
@@ -8,24 +8,26 @@ import * as ButtonStories from './Button.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ButtonGroup',
component: ButtonGroup,
};
-const Template = (args) => ({
- Component: ButtonGroup,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Pair = {
+ render: (args) => ({
+ Component: ButtonGroup,
+ props: args,
+ }),
+ args: {
+ buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
+ orientation: 'horizontal',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-click-handler-args.js.mdx b/docs/snippets/svelte/button-story-click-handler-args.js.mdx
index 9970840aa256..140ae8dff1df 100644
--- a/docs/snippets/svelte/button-story-click-handler-args.js.mdx
+++ b/docs/snippets/svelte/button-story-click-handler-args.js.mdx
@@ -7,25 +7,26 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = ({ label, click }) => ({
- Component: Button,
- props: {
- label,
+export const Text = {
+ render: ({ label, click }) => ({
+ Component: Button,
+ props: {
+ label,
+ },
+ on: {
+ click,
+ },
+ }),
+ args: {
+ label: 'Hello',
+ click: action('clicked'),
},
- on: {
- click,
- },
-});
-
-Text.args = {
- label: 'Hello',
- click: action('clicked'),
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-click-handler-simplificated.native-format.mdx b/docs/snippets/svelte/button-story-click-handler-simplificated.native-format.mdx
index b56d194e15b3..b295452cdc4b 100644
--- a/docs/snippets/svelte/button-story-click-handler-simplificated.native-format.mdx
+++ b/docs/snippets/svelte/button-story-click-handler-simplificated.native-format.mdx
@@ -7,7 +7,7 @@
diff --git a/docs/snippets/svelte/button-story-click-handler.js.mdx b/docs/snippets/svelte/button-story-click-handler.js.mdx
index 822519e0f529..c75cd6f9a972 100644
--- a/docs/snippets/svelte/button-story-click-handler.js.mdx
+++ b/docs/snippets/svelte/button-story-click-handler.js.mdx
@@ -7,20 +7,22 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = () => ({
- Component: Button,
- props:{
- label: 'Hello',
- },
- on: {
- click: action('clicked'),
- },
-});
+export const Text = {
+ render: () => ({
+ Component: Button,
+ props: {
+ label: 'Hello',
+ },
+ on: {
+ click: action('clicked'),
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-component-args-primary.js.mdx b/docs/snippets/svelte/button-story-component-args-primary.js.mdx
index cf7b5b6e0856..1de418bc0c03 100644
--- a/docs/snippets/svelte/button-story-component-args-primary.js.mdx
+++ b/docs/snippets/svelte/button-story-component-args-primary.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/svelte/button-story-component-decorator.js.mdx b/docs/snippets/svelte/button-story-component-decorator.js.mdx
index 65ee7698d751..499f675bab4e 100644
--- a/docs/snippets/svelte/button-story-component-decorator.js.mdx
+++ b/docs/snippets/svelte/button-story-component-decorator.js.mdx
@@ -6,7 +6,7 @@ import MarginDecorator from './MarginDecorator.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/svelte/button-story-decorator.js.mdx b/docs/snippets/svelte/button-story-decorator.js.mdx
index 41232c9df617..420042d1ba8d 100644
--- a/docs/snippets/svelte/button-story-decorator.js.mdx
+++ b/docs/snippets/svelte/button-story-decorator.js.mdx
@@ -6,17 +6,22 @@ import MarginDecorator from './MarginDecorator.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-const Template = () => ({
- Component: Button,
-})
-
-export const Primary = Template.bind({});
-Primary.decorators = [() => MarginDecorator]
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ component: Button,
+ }),
+ decorators: [() => MarginDecorator],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-decorator.mdx.mdx b/docs/snippets/svelte/button-story-decorator.mdx.mdx
index 101b6c3d6db8..6368983838f0 100644
--- a/docs/snippets/svelte/button-story-decorator.mdx.mdx
+++ b/docs/snippets/svelte/button-story-decorator.mdx.mdx
@@ -8,12 +8,18 @@ import MarginDecorator from './MarginDecorator.svelte';
-export const Template = () => ({ Component:Button });
+
MarginDecorator]}>
- {Template.bind({})}
-
+ decorators={[() => MarginDecorator]}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-default-docs-code.js.mdx b/docs/snippets/svelte/button-story-default-docs-code.js.mdx
index b2fec6cfe5f1..9c2b7da35eb1 100644
--- a/docs/snippets/svelte/button-story-default-docs-code.js.mdx
+++ b/docs/snippets/svelte/button-story-default-docs-code.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/svelte/button-story-default-export-with-component.js.mdx b/docs/snippets/svelte/button-story-default-export-with-component.js.mdx
index e155ce8c3d43..d15838083b74 100644
--- a/docs/snippets/svelte/button-story-default-export-with-component.js.mdx
+++ b/docs/snippets/svelte/button-story-default-export-with-component.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/svelte/button-story-rename-story.js.mdx b/docs/snippets/svelte/button-story-rename-story.js.mdx
index 230ba0631042..a82c46b59411 100644
--- a/docs/snippets/svelte/button-story-rename-story.js.mdx
+++ b/docs/snippets/svelte/button-story-rename-story.js.mdx
@@ -5,20 +5,26 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- Component: Button,
- props: {
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = ({
+ name: 'I am the primary',
+ render: () => ({
+ Component: Button,
+ props: {
primary: true,
label: 'Button',
},
-});
-
-Primary.storyName = 'I am the primary';
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-using-args.js.mdx b/docs/snippets/svelte/button-story-using-args.js.mdx
index 8aa730112e10..8cca071da12d 100644
--- a/docs/snippets/svelte/button-story-using-args.js.mdx
+++ b/docs/snippets/svelte/button-story-using-args.js.mdx
@@ -5,26 +5,48 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/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) => ({
- Component: Button,
- props: args,
-});
-
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ backgroundColor: '#ff0',
+ label: 'Button',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-with-addon-example.js.mdx b/docs/snippets/svelte/button-story-with-addon-example.js.mdx
index 876b38d4aae5..d829880a92a9 100644
--- a/docs/snippets/svelte/button-story-with-addon-example.js.mdx
+++ b/docs/snippets/svelte/button-story-with-addon-example.js.mdx
@@ -5,9 +5,9 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
//π Creates specific parameters for the story
parameters: {
@@ -17,7 +17,15 @@ export default {
},
};
-export const Basic = () => ({
- Component: 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Basic = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-with-args.js.mdx b/docs/snippets/svelte/button-story-with-args.js.mdx
index 3453d89898b2..f7c749fca636 100644
--- a/docs/snippets/svelte/button-story-with-args.js.mdx
+++ b/docs/snippets/svelte/button-story-with-args.js.mdx
@@ -5,23 +5,26 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/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)=>({
- component: Button,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ primary: true,
+ label: 'Button',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-with-args.mdx.mdx b/docs/snippets/svelte/button-story-with-args.mdx.mdx
index cd26e64a3168..e3c78745fdec 100644
--- a/docs/snippets/svelte/button-story-with-args.mdx.mdx
+++ b/docs/snippets/svelte/button-story-with-args.mdx.mdx
@@ -7,20 +7,20 @@ import Button from './Button.svelte';
-
+
-export const Template = (args) => ({
- Component: Button,
- props: args,
-});
-
-
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Button,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-with-blue-args.js.mdx b/docs/snippets/svelte/button-story-with-blue-args.js.mdx
index 953d7a9da43b..f6665b8c7e24 100644
--- a/docs/snippets/svelte/button-story-with-blue-args.js.mdx
+++ b/docs/snippets/svelte/button-story-with-blue-args.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/svelte/button-story-with-emojis.js.mdx b/docs/snippets/svelte/button-story-with-emojis.js.mdx
index 5dabb1d51468..a14cadc32956 100644
--- a/docs/snippets/svelte/button-story-with-emojis.js.mdx
+++ b/docs/snippets/svelte/button-story-with-emojis.js.mdx
@@ -5,34 +5,45 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- Component: Button,
- props: {
- background: '#ff0',
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ Component: Button,
+ props: {
+ backgroundColor: '#ff0',
+ label: 'Button',
+ },
+ }),
+};
-export const Secondary = () => ({
- Component: Button,
- props: {
- background: '#ff0',
- label: 'ππππ―',
- },
-});
+export const Secondary = {
+ render: () => ({
+ Component: Button,
+ props: {
+ backgroundColor: '#ff0',
+ label: 'ππππ―',
+ },
+ }),
+};
-export const Tertiary = () => ({
- Component: Button,
- props: {
- background: '#ff0',
- label: 'ππππ€',
- },
-});
+export const Tertiary = {
+ render: () => ({
+ Component: Button,
+ props: {
+ backgroundColor: '#ff0',
+ label: 'ππππ€',
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story-with-emojis.mdx.mdx b/docs/snippets/svelte/button-story-with-emojis.mdx.mdx
index b9690ff2e4db..3e4950c92166 100644
--- a/docs/snippets/svelte/button-story-with-emojis.mdx.mdx
+++ b/docs/snippets/svelte/button-story-with-emojis.mdx.mdx
@@ -7,31 +7,37 @@ import Button from './Button.svelte';
+
-
- {{
+ ({
+ Component: Button,
props: {
- background: '#ff0',
+ backgroundColor: '#ff0',
label: 'Button',
- },
- }}
-
-
-
- {{
+ }
+ })} />
+ ({
+ Component: Button,
props: {
background: '#ff0',
label: 'ππππ―',
},
- }}
-
-
-
- {{
+ })} />
+ ({
+ Component: Button,
props: {
background: '#ff0',
label: 'ππππ€',
},
- }}
-
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story.js.mdx b/docs/snippets/svelte/button-story.js.mdx
index a79a36bf5398..f34e8b52b3d2 100644
--- a/docs/snippets/svelte/button-story.js.mdx
+++ b/docs/snippets/svelte/button-story.js.mdx
@@ -5,18 +5,25 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- Component: Button,
- props: {
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ Component: Button,
+ props: {
+ primary: true,
+ label: 'Button',
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/button-story.mdx.mdx b/docs/snippets/svelte/button-story.mdx.mdx
index 43d30f351676..b49f20627d86 100644
--- a/docs/snippets/svelte/button-story.mdx.mdx
+++ b/docs/snippets/svelte/button-story.mdx.mdx
@@ -9,12 +9,19 @@ import Button from './Button.svelte';
# Button
-
- {{
+
+
+ ({
+ Component:Button,
props: {
primary: true,
label: 'Button',
},
- }}
-
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/checkbox-story.mdx.mdx b/docs/snippets/svelte/checkbox-story.mdx.mdx
index e3f325b59ac4..1e417a83ff55 100644
--- a/docs/snippets/svelte/checkbox-story.mdx.mdx
+++ b/docs/snippets/svelte/checkbox-story.mdx.mdx
@@ -7,42 +7,49 @@ import Checkbox from './Checkbox.svelte';
+
+
# Checkbox
With `MDX`, we can define a story for `Checkbox` right in the middle of our
Markdown documentation.
-export const Template = (args) => ({
- Component: Button,
- props: args,
-});
-
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Checkbox,
+ props: args
+ })} />
- {Template.bind({})}
-
-
+ }}
+ render={(args) => ({
+ Component: Checkbox,
+ props: args
+ })} />
+
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Checkbox,
+ props: args
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-custom-args-complex.js.mdx b/docs/snippets/svelte/component-story-custom-args-complex.js.mdx
index 917f82f212d7..a64143e69353 100644
--- a/docs/snippets/svelte/component-story-custom-args-complex.js.mdx
+++ b/docs/snippets/svelte/component-story-custom-args-complex.js.mdx
@@ -5,9 +5,9 @@ import YourComponent from './YourComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
//π Creates specific argTypes
@@ -27,23 +27,26 @@ const someFunction = (valuePropertyA, valuePropertyB) => {
// Makes some computations and returns something
};
-const Template = (args) => {
- const { propertyA, propertyB } = args;
-
- //π Assigns the function result to a variable
- const someFunctionResult = someFunction(propertyA, propertyB);
- return {
- Component: YourComponent,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: ({ propertyA, propertyB }) => {
+ //π Assigns the function result to a variable
+ const someFunctionResult = someFunction(propertyA, propertyB);
+ return {
+ Component: YourComponent,
+ props: {
+ ...args,
+ someProperty: someFunctionResult,
+ },
+ };
+ },
+ args: {
+ propertyA: 'Item One',
+ propertyB: 'Another Item One',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-figma-integration.js.mdx b/docs/snippets/svelte/component-story-figma-integration.js.mdx
index a509ab634c30..9b88fccbe207 100644
--- a/docs/snippets/svelte/component-story-figma-integration.js.mdx
+++ b/docs/snippets/svelte/component-story-figma-integration.js.mdx
@@ -5,24 +5,28 @@ import { withDesign } from 'storybook-addon-designs';
import MyComponent from './MyComponent.svelte';
-// More on default export: https://storybook.js.org/docs/svelte/writing-stories/introduction#default-export
+// More on default export: https://storybook.js.org/docs/7.0/svelte/writing-stories/introduction#default-export
export default {
title: 'FigmaExample',
component: { MyComponent },
decorators: [withDesign],
};
-// More on component templates: https://storybook.js.org/docs/svelte/writing-stories/introduction#using-args
-const Template = () => ({
- props: {},
- Component: MyComponent,
-});
-
-export const Example = Template.bind({});
-Example.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/Sample-File',
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Example = {
+ render: () => ({
+ Component: MyComponent,
+ props: {},
+ }),
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/Sample-File',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-figma-integration.mdx.mdx b/docs/snippets/svelte/component-story-figma-integration.mdx.mdx
index 3dcfbcfd35e0..5a90970810d1 100644
--- a/docs/snippets/svelte/component-story-figma-integration.mdx.mdx
+++ b/docs/snippets/svelte/component-story-figma-integration.mdx.mdx
@@ -13,10 +13,11 @@ import MyComponent from './MyComponent.svelte';
decorators={[withDesign]}
/>
-export const Template = () => ({
- props: {},
- Component: MyComponent,
-});
+
({
url: 'https://www.figma.com/file/Sample-File',
},
}}
- >
- {Template.bind({})}
-
+ render={() => ({
+ Component: MyComponent,
+ props: {}
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-mdx-story-by-name.mdx.mdx b/docs/snippets/svelte/component-story-mdx-story-by-name.mdx.mdx
index bcd700c06fbd..652c6e9524d1 100644
--- a/docs/snippets/svelte/component-story-mdx-story-by-name.mdx.mdx
+++ b/docs/snippets/svelte/component-story-mdx-story-by-name.mdx.mdx
@@ -7,12 +7,17 @@ import Button from './Button.svelte';
-export const Template = (args) => ({
- Component: Button,
- props: args,
-});
+
-
- {Template.bind({})}
-
+ ({
+ Component: Button,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-cdn.js.mdx b/docs/snippets/svelte/component-story-static-asset-cdn.js.mdx
index 0ac4fa2292d8..e70308d74ff8 100644
--- a/docs/snippets/svelte/component-story-static-asset-cdn.js.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-cdn.js.mdx
@@ -5,18 +5,25 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
component: MyComponent,
};
-export const WithAnImage = () => ({
- Component: MyComponent,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
+ Component: MyComponent,
+ props: {
+ src: 'https://place-hold.it/350x150',
+ alt: 'My CDN placeholder',
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-cdn.mdx.mdx b/docs/snippets/svelte/component-story-static-asset-cdn.mdx.mdx
index 5358e00db8da..f56dd4eb360e 100644
--- a/docs/snippets/svelte/component-story-static-asset-cdn.mdx.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-cdn.mdx.mdx
@@ -7,16 +7,19 @@ import MyComponent from './MyComponent.svelte';
+
+
- {() => {
- return {
- Component: MyComponent,
- props: {
- src: 'https://place-hold.it/350x150',
- alt: 'my image',
- },
- };
- }}
-
+ name="WithAnImage"
+ render={() => ({
+ Component: MyComponent,
+ props: {
+ src: 'https://place-hold.it/350x150',
+ alt: 'my image',
+ },
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-with-import.js.mdx b/docs/snippets/svelte/component-story-static-asset-with-import.js.mdx
index 3249a2362673..d909211f3a01 100644
--- a/docs/snippets/svelte/component-story-static-asset-with-import.js.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-with-import.js.mdx
@@ -7,9 +7,9 @@ import imageFile from './static/image.png';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
component: MyComponent,
};
@@ -19,10 +19,15 @@ const image = {
alt: 'my image',
};
-export const WithAnImage = () => ({
- Component: MyComponent,
- props: {
- image: image
- },
-});
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
+ Component: MyComponent,
+ props: image,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-with-import.mdx.mdx b/docs/snippets/svelte/component-story-static-asset-with-import.mdx.mdx
index af8e70fc9e73..7d1d6376a34a 100644
--- a/docs/snippets/svelte/component-story-static-asset-with-import.mdx.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-with-import.mdx.mdx
@@ -9,19 +9,21 @@ import imageFile from './static/image.png';
+
+
export const image = {
src: imageFile,
alt: 'my image',
};
-
- {() => {
- return {
- Component: MyComponent,
- props: {
- image: image,
- },
- };
- }}
-
+ ({
+ Component: MyComponent,
+ props: image
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-without-import.js.mdx b/docs/snippets/svelte/component-story-static-asset-without-import.js.mdx
index ac464f27b845..35ed6dc6122b 100644
--- a/docs/snippets/svelte/component-story-static-asset-without-import.js.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-without-import.js.mdx
@@ -5,19 +5,25 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
component: MyComponent,
};
-// Assume image.png is located in the "public" directory.
-export const WithAnImage = () => ({
- Component: MyComponent,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
+ Component: MyComponent,
props: {
- src: '/image.png',
+ src: '/image.png', //π Assume image.png is located in the "public" directory.
alt: 'my image',
},
-});
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-static-asset-without-import.mdx.mdx b/docs/snippets/svelte/component-story-static-asset-without-import.mdx.mdx
index 8012053b0c52..5d7141fd087e 100644
--- a/docs/snippets/svelte/component-story-static-asset-without-import.mdx.mdx
+++ b/docs/snippets/svelte/component-story-static-asset-without-import.mdx.mdx
@@ -9,15 +9,13 @@ import MyComponent from './MyComponent.svelte0;
-
- {() => {
- return {
- Component: MyComponent,
- props: {
- src: '/image.png',
- alt: 'my image',
- },
- };
- }}
-
+ ({
+ Component: MyComponent,
+ props: {
+ src: '/image.png',
+ alt: 'my image',
+ },
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-with-accessibility.js.mdx b/docs/snippets/svelte/component-story-with-accessibility.js.mdx
index 64f63c7edf34..2fe14a937108 100644
--- a/docs/snippets/svelte/component-story-with-accessibility.js.mdx
+++ b/docs/snippets/svelte/component-story-with-accessibility.js.mdx
@@ -5,9 +5,9 @@ import Button from './Button.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Accessibility testing',
component: Button,
argTypes: {
@@ -15,22 +15,27 @@ export default {
},
};
-const Template = (args) => ({
- Component: Button,
- props: args,
-});
-
// This is an accessible story
-export const Accessible = Template.bind({});
-Accessible.args = {
- primary: false,
- label: 'Button',
+export const Accessible = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ primary: false,
+ label: 'Button',
+ },
};
// This is not
-export const Inaccessible = Template.bind({});
-Inaccessible.args = {
- ...Accessible.args,
- backgroundColor: 'red',
+export const Inaccessible = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ args: {
+ ...Accessible.args,
+ backgroundColor: 'red',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/component-story-with-accessibility.mdx.mdx b/docs/snippets/svelte/component-story-with-accessibility.mdx.mdx
index c0a6bb1202da..154cfbca0dc2 100644
--- a/docs/snippets/svelte/component-story-with-accessibility.mdx.mdx
+++ b/docs/snippets/svelte/component-story-with-accessibility.mdx.mdx
@@ -16,10 +16,11 @@ import Button from './Button.svelte';
}
}} />
-export const Template = (args) => ({
- Component: Button,
- props: args,
-});
+
## This is an accessible story
@@ -28,10 +29,12 @@ export const Template = (args) => ({
args={{
primary: false,
label: 'Button'
- }}>
- {Template.bind({})}
-
-
+ }}
+ render={(args) => ({
+ Component: Button,
+ props: args,
+ })} />
+
## This is not
({
primary: false,
label: 'Button',
backgroundColor: 'red'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Button,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/documentscreen-story-msw-graphql-query.js.mdx b/docs/snippets/svelte/documentscreen-story-msw-graphql-query.js.mdx
index ee5818cedfbf..4de0633ff067 100644
--- a/docs/snippets/svelte/documentscreen-story-msw-graphql-query.js.mdx
+++ b/docs/snippets/svelte/documentscreen-story-msw-graphql-query.js.mdx
@@ -8,9 +8,9 @@ import MockApolloWrapperClient from './MockApolloWrapperClient.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
decorators: [() => MockGraphqlProvider],
@@ -65,31 +65,36 @@ const TestData = {
],
};
-const PageTemplate = () => ({
- Component: DocumentScreen,
-});
-
-export const MockedSuccess = PageTemplate.bind({});
-MockedSuccess.parameters = {
- msw: [
- graphql.query('AllInfoQuery', (req, res, ctx) => {
- return res(ctx.data(TestData));
- }),
- ],
+export const MockedSuccess = {
+ render: () => ({
+ Component: DocumentScreen,
+ }),
+ 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 = {
+ render: () => ({
+ Component: DocumentScreen,
+ }),
+ 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/svelte/documentscreen-story-msw-rest-request.js.mdx b/docs/snippets/svelte/documentscreen-story-msw-rest-request.js.mdx
index e828bb388f32..3247b130184e 100644
--- a/docs/snippets/svelte/documentscreen-story-msw-rest-request.js.mdx
+++ b/docs/snippets/svelte/documentscreen-story-msw-rest-request.js.mdx
@@ -7,9 +7,9 @@ import { rest } from 'msw';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
@@ -63,25 +63,29 @@ const TestData = {
],
};
-const PageTemplate = () => ({
- Component: DocumentScreen,
-});
-
-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 = {
+ render: (args) => ({
+ Component: DocumentScreen,
+ }),
+ 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 = {
+ render: (args) => ({
+ Component: DocumentScreen,
+ }),
+ 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/svelte/form-story-component-with-play-function.js.mdx b/docs/snippets/svelte/form-story-component-with-play-function.js.mdx
deleted file mode 100644
index 8b87a8998a13..000000000000
--- a/docs/snippets/svelte/form-story-component-with-play-function.js.mdx
+++ /dev/null
@@ -1,27 +0,0 @@
-```js
-// Form.stories.js
-
-import { userEvent, within } from '@storybook/testing-library';
-
-import LoginForm from './LoginForm.svelte';
-
-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/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('button'));
- },
- render: (args) => {
- Component: LoginForm,
- props: args,
- },
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/svelte/loader-story.js.mdx b/docs/snippets/svelte/loader-story.js.mdx
index 6cf31b630e77..24945db86ab3 100644
--- a/docs/snippets/svelte/loader-story.js.mdx
+++ b/docs/snippets/svelte/loader-story.js.mdx
@@ -7,21 +7,30 @@ import TodoItem from './TodoItem.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Examples/Loader',
component: TodoItem,
};
-export const Primary = (args, { loaded: { todo } }) => ({
- Component: TodoItem,
- props: { ...args, ...todo },
-});
-
-Primary.loaders = [
- async () => ({
- todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args, { loaded: { todo } }) => ({
+ Component: TodoItem,
+ props: {
+ ...args,
+ todo,
+ },
}),
-];
+ loaders: [
+ async () => ({
+ todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
+ }),
+ ],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/loader-story.mdx.mdx b/docs/snippets/svelte/loader-story.mdx.mdx
index b068479999f2..80dec358b839 100644
--- a/docs/snippets/svelte/loader-story.mdx.mdx
+++ b/docs/snippets/svelte/loader-story.mdx.mdx
@@ -9,21 +9,26 @@ import fetch from 'node-fetch';
+
+
({
todo: await (
- await fetch("https://jsonplaceholder.typicode.com/todos/1")
+ await fetch('https://jsonplaceholder.typicode.com/todos/1')
).json(),
}),
- ]}>
- {(args, { loaded: { todo } }) => ({
+ ]}
+ render={(args, { loaded: { todo } }) => ({
Component: TodoItem,
props: {
...args,
todo,
},
- })}
-
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/login-form-with-play-function.js.mdx b/docs/snippets/svelte/login-form-with-play-function.js.mdx
index e06ea2235a84..010a758118ae 100644
--- a/docs/snippets/svelte/login-form-with-play-function.js.mdx
+++ b/docs/snippets/svelte/login-form-with-play-function.js.mdx
@@ -9,38 +9,48 @@ import LoginForm from './LoginForm.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Form',
component: LoginForm,
};
-const Template = (args) => ({
- Component: LoginForm,
- props: args,
-});
-
-export const EmptyForm = Template.bind({});
-
-export const FilledForm = Template.bind({});
-FilledForm.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');
-
- await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
-
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const EmptyForm = {
+ render: (args) => ({
+ Component: LoginForm,
+ props: args,
+ }),
+};
- // π Assert DOM structure
- await expect(
- canvas.getByText(
- 'Everything is perfect. Your account is ready and we should probably get you started!'
- )
- ).toBeInTheDocument();
+export const FilledForm = {
+ render: (args) => ({
+ Component: LoginForm,
+ props: args,
+ }),
+ 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');
+
+ await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
+
+ // See https://storybook.js.org/docs/7.0/svelte/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();
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/login-form-with-play-function.mdx.mdx b/docs/snippets/svelte/login-form-with-play-function.mdx.mdx
index 8f5e3441bf6c..06ce15dc6b70 100644
--- a/docs/snippets/svelte/login-form-with-play-function.mdx.mdx
+++ b/docs/snippets/svelte/login-form-with-play-function.mdx.mdx
@@ -11,19 +11,26 @@ import LoginForm from './LoginForm.svelte';
-export const Template = (args) => ({
- Component: LoginForm,
- props: args,
-});
+
-
- {Template.bind({})}
-
-
+ ({
+ Component: LoginForm,
+ props: args,
+ })} />
{
+ render={(args) => ({
+ Component: LoginForm,
+ props: args,
+ })}
+ play={ async ({ canvasElement }) => {
// Starts querying the component from its root element
const canvas = within(canvasElement);
@@ -32,7 +39,7 @@ export const Template = (args) => ({
await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await userEvent.click(canvas.getByRole('button'));
// π Assert DOM structure
@@ -41,8 +48,6 @@ export const Template = (args) => ({
'Everything is perfect. Your account is ready and we should probably get you started!'
)
).toBeInTheDocument();
- }}>
- {Template.bind({})}
-
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/mdx-canvas-multiple-stories.mdx.mdx b/docs/snippets/svelte/mdx-canvas-multiple-stories.mdx.mdx
index 2b5c5d2ee1a4..cb3367d2f4ef 100644
--- a/docs/snippets/svelte/mdx-canvas-multiple-stories.mdx.mdx
+++ b/docs/snippets/svelte/mdx-canvas-multiple-stories.mdx.mdx
@@ -7,10 +7,11 @@ import Badge from './Badge.svelte';
-export const Template = (args) => ({
- Component: Badge,
- props: args,
-});
+
({
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: Badge,
+ props: args,
+ })} />
```
diff --git a/docs/snippets/svelte/my-component-play-function-alt-queries.js.mdx b/docs/snippets/svelte/my-component-play-function-alt-queries.js.mdx
index 43e558f83e01..1385646d5086 100644
--- a/docs/snippets/svelte/my-component-play-function-alt-queries.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-alt-queries.js.mdx
@@ -7,27 +7,37 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'QueryMethods',
component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-export const ExampleWithRole = Template.bind({});
-ExampleWithRole.play = async () => {
- // See https://storybook.js.org/docs/svelte/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 }));
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleWithRole = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/svelte/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 = 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 = {
+ render: (args) => ({
+ Component: Button,
+ props: args,
+ }),
+ 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/svelte/my-component-play-function-alt-queries.mdx.mdx b/docs/snippets/svelte/my-component-play-function-alt-queries.mdx.mdx
index d1514e09e9f8..01cd59c66709 100644
--- a/docs/snippets/svelte/my-component-play-function-alt-queries.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-alt-queries.mdx.mdx
@@ -9,26 +9,30 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
{
- // See https://storybook.js.org/docs/svelte/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/svelte/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) => ({
+ Component: MyComponent,
+ 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) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-composition.js.mdx b/docs/snippets/svelte/my-component-play-function-composition.js.mdx
index f863d7ea4bf9..1b28803f27c4 100644
--- a/docs/snippets/svelte/my-component-play-function-composition.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-composition.js.mdx
@@ -7,33 +7,49 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
-export const FirstStory = Template.bind({});
-FirstStory.play = async () => {
- userEvent.type(screen.getByTestId('an-element'), 'example-value');
+export const FirstStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ userEvent.type(screen.getByTestId('an-element'), 'example-value');
+ },
};
-export const SecondStory = Template.bind({});
-SecondStory.play = async () => {
- await userEvent.type(screen.getByTestId('other-element'), 'another value');
+export const SecondStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ await userEvent.type(screen.getByTestId('other-element'), 'another value');
+ },
};
-export const CombinedStories = 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 = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ 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/svelte/my-component-play-function-waitfor.js.mdx b/docs/snippets/svelte/my-component-play-function-waitfor.js.mdx
index 2697261ca5a7..b68676b2696a 100644
--- a/docs/snippets/svelte/my-component-play-function-waitfor.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-waitfor.js.mdx
@@ -7,34 +7,40 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithAsync',
component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-export const ExampleAsyncStory = Template.bind({});
-ExampleAsyncStory.play = async () => {
- const Input = screen.getByLabelText('Username', {
- selector: 'input',
- });
-
- await userEvent.type(Input, 'WrongInput', {
- delay: 100,
- });
-
- // See https://storybook.js.org/docs/svelte/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'));
- });
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleAsyncStory = {
+ render: (args) => ({
+ component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ const exampleElement = screen.getByLabelText('Username', {
+ selector: 'input',
+ });
+
+ // The delay option set the ammount of milliseconds between characters being typed
+ await userEvent.type(exampleElement, 'WrongInput', {
+ delay: 100,
+ });
+
+ // See https://storybook.js.org/docs/7.0/svelte/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'));
+ });
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-waitfor.mdx.mdx b/docs/snippets/svelte/my-component-play-function-waitfor.mdx.mdx
index 07b8966a6a6f..e3e2c204d784 100644
--- a/docs/snippets/svelte/my-component-play-function-waitfor.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-waitfor.mdx.mdx
@@ -9,14 +9,15 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
{
+ play={ async () => {
const Input = screen.getByLabelText('Username', {
selector: 'input',
});
@@ -25,14 +26,16 @@ export const Template = (args) => ({
delay: 100,
});
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/svelte/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) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-with-canvas.js.mdx b/docs/snippets/svelte/my-component-play-function-with-canvas.js.mdx
index 1f826ddccc8d..c10eba0e2760 100644
--- a/docs/snippets/svelte/my-component-play-function-with-canvas.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-canvas.js.mdx
@@ -7,25 +7,25 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithCanvasElement',
- component: MyComponent,
+ component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-export const ExampleStory = Template.bind({});
-ExampleStory.play = async ({ canvasElement }) => {
- // Assigns canvas to the component root element
+export const ExampleStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ 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'));
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-with-canvas.mdx.mdx b/docs/snippets/svelte/my-component-play-function-with-canvas.mdx.mdx
index 7fdbc2663300..1891e842d70b 100644
--- a/docs/snippets/svelte/my-component-play-function-with-canvas.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-canvas.mdx.mdx
@@ -9,21 +9,24 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
{
+ 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'));
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-with-clickevent.js.mdx b/docs/snippets/svelte/my-component-play-function-with-clickevent.js.mdx
index e1e8931e911a..ef7da34712c9 100644
--- a/docs/snippets/svelte/my-component-play-function-with-clickevent.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-clickevent.js.mdx
@@ -7,27 +7,38 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ClickExamples',
component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
-export const ClickExample = Template.bind({});
-ClickExample.play = async () => {
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(screen.getByRole('button'));
+export const ClickExample = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ await userEvent.click(screen.getByRole('button'));
+ },
};
-export const FireEventExample = Template.bind({});
-FireEventExample.play = async () => {
- // See https://storybook.js.org/docs/svelte/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 = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/svelte/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/svelte/my-component-play-function-with-clickevent.mdx.mdx b/docs/snippets/svelte/my-component-play-function-with-clickevent.mdx.mdx
index 29618daa1302..3cb43de88f88 100644
--- a/docs/snippets/svelte/my-component-play-function-with-clickevent.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-clickevent.mdx.mdx
@@ -9,26 +9,30 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
{
- // See https://storybook.js.org/docs/svelte/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/svelte/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) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
{
- // See https://storybook.js.org/docs/svelte/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/svelte/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) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-with-delay.js.mdx b/docs/snippets/svelte/my-component-play-function-with-delay.js.mdx
index 47ce8d030ca1..32648be43be6 100644
--- a/docs/snippets/svelte/my-component-play-function-with-delay.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-delay.js.mdx
@@ -7,30 +7,35 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithDelay',
component: MyComponent,
};
-const Template = (args) => ({
- Component: MyComponent,
- 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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const DelayedStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ const exampleElement = screen.getByLabelText('example-element');
-export const DelayedStory = Template.bind({});
-DelayedStory.play = async () => {
- 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 amount 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/svelte/my-component-play-function-with-delay.mdx.mdx b/docs/snippets/svelte/my-component-play-function-with-delay.mdx.mdx
index 2706786d7110..41ebd73e086c 100644
--- a/docs/snippets/svelte/my-component-play-function-with-delay.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-delay.mdx.mdx
@@ -9,14 +9,15 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
{
+ play={ async () => {
const exampleElement= screen.getByLabelText('example-element');
// The delay option set the amount of milliseconds between characters being typed
@@ -28,7 +29,9 @@ export const Template = (args) => ({
await userEvent.type(AnotherExampleElement, 'another random string', {
delay: 100,
});
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
diff --git a/docs/snippets/svelte/my-component-play-function-with-selectevent.js.mdx b/docs/snippets/svelte/my-component-play-function-with-selectevent.js.mdx
index f5bd1ffc6204..b5461b9e438f 100644
--- a/docs/snippets/svelte/my-component-play-function-with-selectevent.js.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-selectevent.js.mdx
@@ -7,9 +7,9 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithSelectEvent',
component: MyComponent,
};
@@ -19,21 +19,26 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-export const ExampleChangeEvent = Template.bind({});
-ExampleChangeEvent.play = async () => {
- const select = screen.getByRole('listbox');
-
- await userEvent.selectOptions(select, ['One Item']);
- await sleep(2000);
-
- await userEvent.selectOptions(select, ['Another Item']);
- await sleep(2000);
-
- await userEvent.selectOptions(select, ['Yet another item']);
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleChangeEvent = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ play: async () => {
+ const select = screen.getByRole('listbox');
+
+ await userEvent.selectOptions(select, ['One Item']);
+ await sleep(2000);
+
+ await userEvent.selectOptions(select, ['Another Item']);
+ await sleep(2000);
+
+ await userEvent.selectOptions(select, ['Yet another item']);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-play-function-with-selectevent.mdx.mdx b/docs/snippets/svelte/my-component-play-function-with-selectevent.mdx.mdx
index 6bae3642ade7..bba4c2db104e 100644
--- a/docs/snippets/svelte/my-component-play-function-with-selectevent.mdx.mdx
+++ b/docs/snippets/svelte/my-component-play-function-with-selectevent.mdx.mdx
@@ -15,10 +15,11 @@ export const sleep(ms) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
-export const Template= (args)=>({
- Component: MyComponent,
- props: args,
-});
+
({
await userEvent.selectOptions(select, ['Yet another item']);
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-basic-and-props.js.mdx b/docs/snippets/svelte/my-component-story-basic-and-props.js.mdx
index a67422f4d357..97ad38ff5e70 100644
--- a/docs/snippets/svelte/my-component-story-basic-and-props.js.mdx
+++ b/docs/snippets/svelte/my-component-story-basic-and-props.js.mdx
@@ -5,21 +5,25 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Path/To/MyComponent',
component: MyComponent,
};
-export const Basic = () => ({
- Component: MyComponent,
-});
+export const Basic = {
+ render: () => ({
+ Component: MyComponent,
+ }),
+};
-export const WithProp = () => ({
- Component: MyComponent,
- props:{
- prop: 'value',
- },
-});
+export const WithProp = {
+ render: () => ({
+ Component: MyComponent,
+ props: {
+ prop: 'value',
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-configure-viewports.js.mdx b/docs/snippets/svelte/my-component-story-configure-viewports.js.mdx
index 3720e5ed3998..0d53c78ddab8 100644
--- a/docs/snippets/svelte/my-component-story-configure-viewports.js.mdx
+++ b/docs/snippets/svelte/my-component-story-configure-viewports.js.mdx
@@ -7,9 +7,9 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
parameters: {
@@ -23,12 +23,19 @@ export default {
},
};
-export const MyStory = () => ({
- Component: MyComponent,
-});
-MyStory.parameters = {
- viewport: {
- defaultViewport: 'iphonex',
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const MyStory = {
+ render: () => ({
+ Component: MyComponent,
+ }),
+ parameters: {
+ viewport: {
+ defaultViewport: 'iphonex',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-configure-viewports.mdx.mdx b/docs/snippets/svelte/my-component-story-configure-viewports.mdx.mdx
index afd1ced8915a..55db71066347 100644
--- a/docs/snippets/svelte/my-component-story-configure-viewports.mdx.mdx
+++ b/docs/snippets/svelte/my-component-story-configure-viewports.mdx.mdx
@@ -17,17 +17,21 @@ import MyComponent from './MyComponent.svelte';
}}
component={MyComponent} />
+
+
- {() => {
- return {
- Component: MyComponent,
- };
}}
-
+ render={(args) => ({
+ Component: MyComponent,
+ props: {},
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-use-globaltype.js.mdx b/docs/snippets/svelte/my-component-story-use-globaltype.js.mdx
index 510c59460176..6a3b2c5f9beb 100644
--- a/docs/snippets/svelte/my-component-story-use-globaltype.js.mdx
+++ b/docs/snippets/svelte/my-component-story-use-globaltype.js.mdx
@@ -5,9 +5,9 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
@@ -27,13 +27,20 @@ const getCaptionForLocale = (locale) => {
}
};
-export const StoryWithLocale = (args, { globals: { locale } }) => {
- const caption = getCaptionForLocale(locale);
- return {
- component: MyComponent,
- props: {
- locale: caption,
- },
- };
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const StoryWithLocale = {
+ render: (args, { globals: { locale } }) => {
+ const caption = getCaptionForLocale(locale);
+ return {
+ component: MyComponent,
+ props: {
+ locale: caption,
+ },
+ };
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-use-globaltype.mdx.mdx b/docs/snippets/svelte/my-component-story-use-globaltype.mdx.mdx
index 07fca01dd1c8..8616875818d4 100644
--- a/docs/snippets/svelte/my-component-story-use-globaltype.mdx.mdx
+++ b/docs/snippets/svelte/my-component-story-use-globaltype.mdx.mdx
@@ -18,8 +18,15 @@ export const getCaptionForLocale = (locale) => {
}
};
-
- {(args, { globals: { locale } }) => {
+
+
+ {
const caption = getCaptionForLocale(locale);
return {
component: MyComponent,
@@ -27,6 +34,5 @@ export const getCaptionForLocale = (locale) => {
locale: caption,
},
};
- }}
-
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-story-with-nonstory.js.mdx b/docs/snippets/svelte/my-component-story-with-nonstory.js.mdx
index 43779b2731ab..6e1b1d7ac763 100644
--- a/docs/snippets/svelte/my-component-story-with-nonstory.js.mdx
+++ b/docs/snippets/svelte/my-component-story-with-nonstory.js.mdx
@@ -7,10 +7,10 @@ import someData from './data.json';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'MyComponent',
+ * See https://storybook.js.org/docs/7.0/svelte/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
@@ -19,20 +19,28 @@ export default {
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
-
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-
-export const SimpleStory = Template.bind({});
-SimpleStory.args = {
- data: simpleData,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const SimpleStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ args: {
+ data: simpleData,
+ },
};
-export const ComplexStory = Template.bind({});
-ComplexStory.args = {
- data: complexData,
+export const ComplexStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ args: {
+ data: complexData,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-with-env-variables.js.mdx b/docs/snippets/svelte/my-component-with-env-variables.js.mdx
index 6dfb2cfbe662..2d64ce457d36 100644
--- a/docs/snippets/svelte/my-component-with-env-variables.js.mdx
+++ b/docs/snippets/svelte/my-component-with-env-variables.js.mdx
@@ -5,21 +5,25 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
-
-const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/my-component-with-env-variables.mdx.mdx b/docs/snippets/svelte/my-component-with-env-variables.mdx.mdx
index 9dfc843bad60..803105fa297a 100644
--- a/docs/snippets/svelte/my-component-with-env-variables.mdx.mdx
+++ b/docs/snippets/svelte/my-component-with-env-variables.mdx.mdx
@@ -7,17 +7,21 @@ import MyComponent from './MyComponent.svelte';
-export const Template = (args) => ({
- Component: MyComponent,
- props: args,
-});
+
- {Template.bind({})}
+ }}
+ render={(args) => ({
+ Component: MyComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/page-story-with-args-composition.js.mdx b/docs/snippets/svelte/page-story-with-args-composition.js.mdx
index 9501dcd295e9..7fd600d4c084 100644
--- a/docs/snippets/svelte/page-story-with-args-composition.js.mdx
+++ b/docs/snippets/svelte/page-story-with-args-composition.js.mdx
@@ -10,23 +10,27 @@ import * as DocumentListStories from './DocumentList.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
-
-const Template = (args) => ({
- component: DocumentScreen,
- props: args,
-});
-
-export const SimplePage = Template.bind({});
-SimplePage.args = {
- user: PageLayoutStories.Simple.args.user,
- document: DocumentHeaderStories.Simple.args.document,
- subdocuments: DocumentListStories.Simple.args.documents,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const SimplePage = {
+ render: (args) => ({
+ Component: DocumentScreen,
+ props: args,
+ }),
+ args: {
+ user: PageLayoutStories.Simple.args.user,
+ document: DocumentHeaderStories.Simple.args.document,
+ subdocuments: DocumentListStories.Simple.args.documents,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/page-story.js.mdx b/docs/snippets/svelte/page-story.js.mdx
index f6f88c50c350..8f75ccbdd52a 100644
--- a/docs/snippets/svelte/page-story.js.mdx
+++ b/docs/snippets/svelte/page-story.js.mdx
@@ -8,20 +8,25 @@ import * as HeaderStories from './Header.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Page',
component: Page,
};
-const Template = (args) => ({
- Component: Page,
- props: args,
-});
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- ...HeaderStories.LoggedIn.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/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const LoggedIn = {
+ render: (args) => ({
+ Component: Page,
+ props: args,
+ }),
+ args: {
+ ...HeaderStories.LoggedIn.args,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/register-component-with-play-function.js.mdx b/docs/snippets/svelte/register-component-with-play-function.js.mdx
index 9ca947780a30..f30390cf6252 100644
--- a/docs/snippets/svelte/register-component-with-play-function.js.mdx
+++ b/docs/snippets/svelte/register-component-with-play-function.js.mdx
@@ -7,38 +7,44 @@ import RegistrationForm from './RegistrationForm.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'RegistrationForm',
component: RegistrationForm,
};
-const Template = (args) => ({
- Component: RegistrationForm,
- props: args,
-});
-
-export const FilledForm = Template.bind({});
-FilledForm.play = async () => {
- const emailInput = screen.getByLabelText('email', {
- selector: 'input',
- });
-
- await userEvent.type(emailInput, 'example-email@email.com', {
- delay: 100,
- });
-
- const passwordInput = screen.getByLabelText('password', {
- selector: 'input',
- });
-
- await userEvent.type(passwordInput, 'ExamplePassword', {
- delay: 100,
- });
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- const submitButton = screen.getByRole('button');
-
- await userEvent.click(submitButton);
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+
+export const FilledForm = {
+ render: (args) => ({
+ Component: RegistrationForm,
+ props: args,
+ }),
+ play: async () => {
+ const emailInput = screen.getByLabelText('email', {
+ selector: 'input',
+ });
+
+ await userEvent.type(emailInput, 'example-email@email.com', {
+ delay: 100,
+ });
+
+ const passwordInput = screen.getByLabelText('password', {
+ selector: 'input',
+ });
+
+ await userEvent.type(passwordInput, 'ExamplePassword', {
+ delay: 100,
+ });
+ // See https://storybook.js.org/docs/7.0/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ const submitButton = screen.getByRole('button');
+
+ await userEvent.click(submitButton);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/register-component-with-play-function.mdx.mdx b/docs/snippets/svelte/register-component-with-play-function.mdx.mdx
index ed9ab116afdc..0f7dc0717ef6 100644
--- a/docs/snippets/svelte/register-component-with-play-function.mdx.mdx
+++ b/docs/snippets/svelte/register-component-with-play-function.mdx.mdx
@@ -9,14 +9,15 @@ import RegistrationForm from './RegistrationForm.svelte';
-export const Template = (args) => ({
- Component: RegistrationForm,
- props: args,
-});
+
{
+ play={ async () => {
const emailInput = screen.getByLabelText('email', {
selector: 'input',
});
@@ -31,10 +32,12 @@ export const Template = (args) => ({
await userEvent.type(passwordInput, 'ExamplePassword', {
delay: 100,
});
- // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
const submitButton = screen.getByRole('button');
await userEvent.click(submitButton);
- }}>
- {Template.bind({})}
-
+ }
+ render={() => ({
+ component: RegistrationForm,
+ props: {},
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/storybook-addon-a11y-disable.js.mdx b/docs/snippets/svelte/storybook-addon-a11y-disable.js.mdx
index 11a55bbc244f..4d39da409e61 100644
--- a/docs/snippets/svelte/storybook-addon-a11y-disable.js.mdx
+++ b/docs/snippets/svelte/storybook-addon-a11y-disable.js.mdx
@@ -5,20 +5,29 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Disable a11y addon',
component: MyComponent,
};
-const Template = () => ({ Component: MyComponent });
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
-export const NonA11yStory = Template.bind({});
-NonA11yStory.parameters = {
- a11y: {
- // This option disables all a11y checks on this story
- disable: true,
+export const NonA11yStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ parameters: {
+ a11y: {
+ // This option disables all a11y checks on this story
+ disable: true,
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/storybook-addon-a11y-disable.mdx.mdx b/docs/snippets/svelte/storybook-addon-a11y-disable.mdx.mdx
index e5020c45ed4d..0ce1c81432ae 100644
--- a/docs/snippets/svelte/storybook-addon-a11y-disable.mdx.mdx
+++ b/docs/snippets/svelte/storybook-addon-a11y-disable.mdx.mdx
@@ -9,7 +9,11 @@ import MyComponent from './MyComponent.svelte';
title="Disable a11y addon"
component={MyComponent} />
-export const Template = () => ({ Component: MyComponent });
+
({ Component: MyComponent });
// This option disables all a11y checks on this story
disable: true,
},
- }}>
- {Template.bind({})}
-
+ }}
+ render={() => ({
+ Component: MyComponent,
+ props: {},
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/storybook-addon-a11y-story-config.js.mdx b/docs/snippets/svelte/storybook-addon-a11y-story-config.js.mdx
index 92b58d82a4f2..580d26aa0768 100644
--- a/docs/snippets/svelte/storybook-addon-a11y-story-config.js.mdx
+++ b/docs/snippets/svelte/storybook-addon-a11y-story-config.js.mdx
@@ -5,35 +5,43 @@ import MyComponent from './MyComponent.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Configure a11y addon',
component: MyComponent,
};
-const Template = () => ({ Component: MyComponent });
-
-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,
- },
- ],
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: (args) => ({
+ Component: MyComponent,
+ props: args,
+ }),
+ 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/svelte/storybook-addon-a11y-story-config.mdx.mdx b/docs/snippets/svelte/storybook-addon-a11y-story-config.mdx.mdx
index 8fb7b459a044..77ffa3d57120 100644
--- a/docs/snippets/svelte/storybook-addon-a11y-story-config.mdx.mdx
+++ b/docs/snippets/svelte/storybook-addon-a11y-story-config.mdx.mdx
@@ -9,7 +9,11 @@ import MyComponent from './MyComponent.svelte';
title="Configure a11y addon"
component={MyComponent} />
-export const Template = () => ({ Component: MyComponent });
+
({ Component: MyComponent });
options: {},
manual: true,
},
- }}>
- {Template.bind({})}
-
+ }}
+ render={() => ({
+ Component: MyComponent,
+ props: {},
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/your-component-with-decorator.js.mdx b/docs/snippets/svelte/your-component-with-decorator.js.mdx
index 66408444bb56..874a7d75da3c 100644
--- a/docs/snippets/svelte/your-component-with-decorator.js.mdx
+++ b/docs/snippets/svelte/your-component-with-decorator.js.mdx
@@ -7,7 +7,7 @@ import MarginDecorator from './MarginDecorator.svelte';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'YourComponent',
diff --git a/docs/snippets/svelte/your-component.js.mdx b/docs/snippets/svelte/your-component.js.mdx
index 89578545f2cb..f2e0697e997f 100644
--- a/docs/snippets/svelte/your-component.js.mdx
+++ b/docs/snippets/svelte/your-component.js.mdx
@@ -6,20 +6,25 @@ import YourComponent from './YourComponent.svelte';
//π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/svelte/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = (args) => ({
- props: args,
-});
-
-export const FirstStory = Template.bind({});
-FirstStory.args= {
- //π The args you need here will depend on your component
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/svelte/api/csf
+ * to learn how to use render functions.
+ */
+export const FirstStory = {
+ render: (args) => ({
+ Component: YourComponent,
+ props: args,
+ }),
+ args: {
+ //π The args you need here will depend on your component
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/svelte/your-component.mdx.mdx b/docs/snippets/svelte/your-component.mdx.mdx
index a0d8259cefd1..8f63ceffc626 100644
--- a/docs/snippets/svelte/your-component.mdx.mdx
+++ b/docs/snippets/svelte/your-component.mdx.mdx
@@ -9,16 +9,12 @@ import YourComponent from './YourComponent.svelte';
-
-export const Template = (args) => ({
- Component: YourComponent,
- props: args,
-});
-
- {Template.bind({})}
-
+ args={{}}
+ render={(args) => ({
+ component: YourComponent,
+ props: args,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/app-story-with-mock.js.mdx b/docs/snippets/vue/app-story-with-mock.js.mdx
index f6266eb076ac..6890cf9d7964 100644
--- a/docs/snippets/vue/app-story-with-mock.js.mdx
+++ b/docs/snippets/vue/app-story-with-mock.js.mdx
@@ -5,34 +5,39 @@ import App from './App.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'App',
component: App,
};
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
-const Template = () => ({
- components: { App },
- template: '',
-});
-
-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
- }
- }
+export const 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: (args) => ({
+ components: { App },
+ template: '',
+ }),
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/badge-story-starter-example.mdx.mdx b/docs/snippets/vue/badge-story-starter-example.mdx.mdx
index 3b228d2840a9..8dc01331a330 100644
--- a/docs/snippets/vue/badge-story-starter-example.mdx.mdx
+++ b/docs/snippets/vue/badge-story-starter-example.mdx.mdx
@@ -8,30 +8,32 @@ import Icon from './Icon.vue';
+
+
# Badge
Let's define a story for our `Badge` component:
-
- {() => {
- return {
- components: { Badge },
- template: `Positive`,
- };
- }}
-
+ ({
+ components: { Badge },
+ template: `Positive`,
+ })} />
We can drop it in a `Canvas` to get a code snippet:
-
- {() => {
- return {
- components: { Badge },
- template: `Negative`,
- };
- }}
-
+ ({
+ components: { Badge },
+ template: `Negative`,
+ })} />
We can even preview multiple stories in a block. This
@@ -39,41 +41,33 @@ gets rendered as a group, but defines individual stories
with unique URLs and isolated snapshot tests.
-
- {() => {
- return {
- components: { Badge },
- template: `Warning`,
- };
- }}
-
-
- {() => {
- return {
- components: { Badge },
- template: `Neutral`,
- };
- }}
-
-
- {() => {
- return {
- components: { Badge },
- template: `Error`,
- };
- }}
-
-
- {() => {
- return {
- components: { Badge, Icon },
- template: `
-
-
- with icon
- `,
- };
- }}
-
+ ({
+ components: { Badge },
+ template: `Warning`,
+ })} />
+ ({
+ components: { Badge },
+ template: `Neutral`,
+ })} />
+ ({
+ components: { Badge },
+ template: `Error`,
+ })} />
+ ({
+ components: { Badge, Icon },
+ template: `
+
+
+ with icon
+ `,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/badge-story.mdx-2.mdx.mdx b/docs/snippets/vue/badge-story.mdx-2.mdx.mdx
index 32ed8f0726b5..464655e42792 100644
--- a/docs/snippets/vue/badge-story.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/badge-story.mdx-2.mdx.mdx
@@ -7,24 +7,27 @@ import Badge from './Badge.vue';
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Badge },
- template: '',
-});
+
# Badge
Let's define a story for our `Badge` component:
-
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
We can drop it in a `Canvas` to get a code snippet:
@@ -34,9 +37,12 @@ We can drop it in a `Canvas` to get a code snippet:
args={{
status: 'negative',
label: 'Negative',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
We can even preview multiple Stories in a block. This
@@ -49,24 +55,33 @@ with unique URLs, which is great for review and testing.
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/badge-story.mdx-3.mdx.mdx b/docs/snippets/vue/badge-story.mdx-3.mdx.mdx
index d4909ef78c70..b6010a1cd555 100644
--- a/docs/snippets/vue/badge-story.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/badge-story.mdx-3.mdx.mdx
@@ -7,13 +7,11 @@ import Badge from './Badge.vue';
-export const Template = (args) => ({
- components: { Badge },
- setup() {
- return { args };
- },
- template: '',
-});
+
# Badge
@@ -24,9 +22,14 @@ Let's define a story for our `Badge` component:
args={{
status: 'positive',
label: 'Positive'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
We can drop it in a `Canvas` to get a code snippet:
@@ -36,9 +39,14 @@ We can drop it in a `Canvas` to get a code snippet:
args={{
status: 'negative',
label: 'Negative',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
We can even preview multiple Stories in a block. This
@@ -51,24 +59,39 @@ with unique URLs, which is great for review and testing.
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-group-story.2.js.mdx b/docs/snippets/vue/button-group-story.2.js.mdx
index a083bfbce036..62e2e4934165 100644
--- a/docs/snippets/vue/button-group-story.2.js.mdx
+++ b/docs/snippets/vue/button-group-story.2.js.mdx
@@ -8,25 +8,27 @@ import * as ButtonStories from './Button.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ButtonGroup',
component: ButtonGroup,
};
-const Template = (args, { argTypes }) => ({
- components: { ButtonGroup },
- props: Object.keys(argTypes),
- template: '',
-});
-
-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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Pair = {
+ render: (args, { argTypes }) => ({
+ components: { ButtonGroup },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
+ orientation: 'horizontal',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-group-story.3.js.mdx b/docs/snippets/vue/button-group-story.3.js.mdx
index 6197ffd73ae4..f4f074c61a16 100644
--- a/docs/snippets/vue/button-group-story.3.js.mdx
+++ b/docs/snippets/vue/button-group-story.3.js.mdx
@@ -8,27 +8,29 @@ import * as ButtonStories from './Button.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ButtonGroup',
component: ButtonGroup,
};
-const Template = (args) => ({
- components: { ButtonGroup },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Pair = {
+ render: (args) => ({
+ components: { ButtonGroup },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
+ orientation: 'horizontal',
},
- template: '',
-});
-
-export const Pair = Template.bind({});
-Pair.args = {
- buttons: [
- { ...ButtonStories.Primary.args },
- { ...ButtonStories.Secondary.args }
- ],
- orientation: 'horizontal',
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-group-story.ts-2.ts.mdx b/docs/snippets/vue/button-group-story.ts-2.ts.mdx
index d0e1eb3adadc..b55030242c7b 100644
--- a/docs/snippets/vue/button-group-story.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-group-story.ts-2.ts.mdx
@@ -10,7 +10,7 @@ import * as ButtonStories from './Button.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'ButtonGroup',
diff --git a/docs/snippets/vue/button-group-story.ts-3.ts.mdx b/docs/snippets/vue/button-group-story.ts-3.ts.mdx
index 91b68cc272f6..c6bb2b46420e 100644
--- a/docs/snippets/vue/button-group-story.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-group-story.ts-3.ts.mdx
@@ -3,31 +3,31 @@
import ButtonGroup from './ButtonGroup.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
//π Imports the Button stories
import * as ButtonStories from './Button.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'ButtonGroup',
component: ButtonGroup,
} as Meta;
-const Template: StoryFn = (args) => ({
- components: { ButtonGroup },
- setup() {
- return { args };
+export const Pair: Story = {
+ render: (args) => ({
+ components: { ButtonGroup },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
+ orientation: 'horizontal',
},
- template: '',
-});
-
-export const Pair = Template.bind({});
-Pair.args = {
- buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
- orientation: 'horizontal',
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-click-handler-args.2.js.mdx b/docs/snippets/vue/button-story-click-handler-args.2.js.mdx
index 703274ec5570..ee3c22d82d28 100644
--- a/docs/snippets/vue/button-story-click-handler-args.2.js.mdx
+++ b/docs/snippets/vue/button-story-click-handler-args.2.js.mdx
@@ -7,21 +7,22 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Button },
- template: ''
-});
-
-Text.args = {
- label: 'Hello',
- onClick: action('clicked'),
+export const Text = {
+ render: (args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Button },
+ template: '',
+ }),
+ args: {
+ label: 'Hello',
+ onClick: action('clicked'),
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-click-handler-args.3.js.mdx b/docs/snippets/vue/button-story-click-handler-args.3.js.mdx
index b192f70be997..fcb25d64724f 100644
--- a/docs/snippets/vue/button-story-click-handler-args.3.js.mdx
+++ b/docs/snippets/vue/button-story-click-handler-args.3.js.mdx
@@ -7,26 +7,26 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = ({ label, onClick }) => ({
- components: { Button },
- setup() {
- return {
- label,
- onClick,
- };
+export const Text = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return {
+ ...args,
+ onClick: action('clicked'),
+ };
+ },
+ template: '',
+ }),
+ args: {
+ label: 'Hello',
},
- template: '',
-});
-
-Text.args = {
- label: 'Hello',
- onClick: action('clicked'),
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-click-handler-simplificated.js.mdx b/docs/snippets/vue/button-story-click-handler-simplificated.js.mdx
index 7fffcdbcab4e..9f1c4bd3bc40 100644
--- a/docs/snippets/vue/button-story-click-handler-simplificated.js.mdx
+++ b/docs/snippets/vue/button-story-click-handler-simplificated.js.mdx
@@ -5,13 +5,13 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
/*
- * See https://storybook.js.org/docs/vue/essentials/actions#action-argtype-annotation
+ * See https://storybook.js.org/docs/7.0/vue/essentials/actions#action-argtype-annotation
* to learn how to set up argTypes for actions
*/
argTypes: {
@@ -19,11 +19,13 @@ export default {
},
};
-export const Text = (args) => ({
- components: { Button },
- setup() {
- return { args };
- },
- template: '',
-});
+export const Text = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-click-handler.2.js.mdx b/docs/snippets/vue/button-story-click-handler.2.js.mdx
index 78a35e008a9a..cdd298f8ac38 100644
--- a/docs/snippets/vue/button-story-click-handler.2.js.mdx
+++ b/docs/snippets/vue/button-story-click-handler.2.js.mdx
@@ -7,18 +7,20 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = () => ({
- components: { Button },
- template: '',
- methods: {
- onClick: action('clicked'),
- },
-});
+export const Text = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ methods: {
+ onClick: action('clicked'),
+ },
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-click-handler.3.js.mdx b/docs/snippets/vue/button-story-click-handler.3.js.mdx
index 7c1ad200ae7f..5d0c507c271c 100644
--- a/docs/snippets/vue/button-story-click-handler.3.js.mdx
+++ b/docs/snippets/vue/button-story-click-handler.3.js.mdx
@@ -7,20 +7,22 @@ import { action } from '@storybook/addon-actions';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Text = () => ({
- components: { Button },
- template: '',
- setup(){
- return {
- onClick: action('clicked'),
- };
- },
-});
+export const Text = {
+ render: () => ({
+ components: { Button },
+ setup() {
+ return {
+ onClick: action('clicked'),
+ };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-component-args-primary.js.mdx b/docs/snippets/vue/button-story-component-args-primary.js.mdx
index 525fc0d27571..8612d8a608a5 100644
--- a/docs/snippets/vue/button-story-component-args-primary.js.mdx
+++ b/docs/snippets/vue/button-story-component-args-primary.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-component-decorator.js.mdx b/docs/snippets/vue/button-story-component-decorator.js.mdx
index 0c505d3b8c0e..497c9e6c298d 100644
--- a/docs/snippets/vue/button-story-component-decorator.js.mdx
+++ b/docs/snippets/vue/button-story-component-decorator.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-component-decorator.ts-2.ts.mdx b/docs/snippets/vue/button-story-component-decorator.ts-2.ts.mdx
index 37a6ec4b52f0..75a646696fa5 100644
--- a/docs/snippets/vue/button-story-component-decorator.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story-component-decorator.ts-2.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue';
+import type { Meta } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-component-decorator.ts-3.ts.mdx b/docs/snippets/vue/button-story-component-decorator.ts-3.ts.mdx
index bc4678319e93..95ae0184fdb3 100644
--- a/docs/snippets/vue/button-story-component-decorator.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story-component-decorator.ts-3.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue3';
+import type { Meta } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-decorator.js.mdx b/docs/snippets/vue/button-story-decorator.js.mdx
index 80d1d3caf4c2..0f2c85b0d1b9 100644
--- a/docs/snippets/vue/button-story-decorator.js.mdx
+++ b/docs/snippets/vue/button-story-decorator.js.mdx
@@ -5,16 +5,23 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- components: { Button },
- template: '',
-});
-Primary.decorators = [() => ({ 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+ decorators: [() => ({ template: '
' })],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-decorator.mdx.mdx b/docs/snippets/vue/button-story-decorator.mdx.mdx
index 613fa80690f2..058c6520dfb7 100644
--- a/docs/snippets/vue/button-story-decorator.mdx.mdx
+++ b/docs/snippets/vue/button-story-decorator.mdx.mdx
@@ -7,19 +7,20 @@ import Button from './Button.vue';
-export const Template = () => ({
- components: { Button },
- template: '',
-});
-
-
+
({
template: '
',
}),
- ]}>
- {Template.bind({})}
-
+ ]}
+ render={() => ({
+ components: { Button },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-default-docs-code.3.js.mdx b/docs/snippets/vue/button-story-default-docs-code.3.js.mdx
deleted file mode 100644
index 12c57c90a59d..000000000000
--- a/docs/snippets/vue/button-story-default-docs-code.3.js.mdx
+++ /dev/null
@@ -1,47 +0,0 @@
-```js
-// Button.stories.js
-
-import Button from './Button.vue';
-
-export default {
- /* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'Button',
- component: Button,
- //π Creates specific argTypes
- argTypes: {
- backgroundColor: { control: 'color' },
- },
-};
-
-//π Some function to demonstrate the behavior
-const someFunction = (someValue) => {
- return `i am a ${someValue}`;
-};
-
-export const ExampleStory = (args) => {
- //π Assigns the function result to a variable
- const functionResult = someFunction(args.label);
- return {
- components: { Button },
- setup() {
- //π The args will now be passed down to the template
- return {
- args: {
- ...args,
- //π Replaces arg variable with the override (without the need of mutation)
- label: functionResult,
- },
- };
- },
- template: '',
- };
-};
-ExampleStory.args = {
- primary: true,
- size: 'small',
- label: 'button',
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-default-docs-code.mdx-3.mdx.mdx b/docs/snippets/vue/button-story-default-docs-code.mdx-3.mdx.mdx
deleted file mode 100644
index 1491648a2ccf..000000000000
--- a/docs/snippets/vue/button-story-default-docs-code.mdx-3.mdx.mdx
+++ /dev/null
@@ -1,49 +0,0 @@
-```md
-
-
-import { Meta, Story } from '@storybook/addon-docs';
-
-import Button from './Button.vue';
-
-
-
-
-
-export const someFunction = (someValue) => {
- return `i am a ${someValue}`;
-};
-
-
-
-
- {(args) => {
- const functionResult = someFunction(args.label);
- return {
- components: { Button },
- setup() {
- return {
- args: {
- ...args,
- label: functionResult,
- },
- };
- },
- template: '',
- };
- }}
-
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-default-export-with-component.js.mdx b/docs/snippets/vue/button-story-default-export-with-component.js.mdx
index c0a453a77ecd..4f5b035e16d1 100644
--- a/docs/snippets/vue/button-story-default-export-with-component.js.mdx
+++ b/docs/snippets/vue/button-story-default-export-with-component.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-default-export-with-component.ts-2.ts.mdx b/docs/snippets/vue/button-story-default-export-with-component.ts-2.ts.mdx
index 3203b13bc70a..02326201d4aa 100644
--- a/docs/snippets/vue/button-story-default-export-with-component.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story-default-export-with-component.ts-2.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue';
+import type { Meta } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-default-export-with-component.ts-3.ts.mdx b/docs/snippets/vue/button-story-default-export-with-component.ts-3.ts.mdx
index afc5e65c7954..d034f021fcb8 100644
--- a/docs/snippets/vue/button-story-default-export-with-component.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story-default-export-with-component.ts-3.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue3';
+import type { Meta } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-rename-story.js.mdx b/docs/snippets/vue/button-story-rename-story.js.mdx
index 95750d3d6c82..2cbbe957335d 100644
--- a/docs/snippets/vue/button-story-rename-story.js.mdx
+++ b/docs/snippets/vue/button-story-rename-story.js.mdx
@@ -5,16 +5,23 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- components: { Button },
- template: '',
-});
-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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ name: 'I am the primary',
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-rename-story.ts-2.ts.mdx b/docs/snippets/vue/button-story-rename-story.ts-2.ts.mdx
deleted file mode 100644
index 14dfc01e1fc2..000000000000
--- a/docs/snippets/vue/button-story-rename-story.ts-2.ts.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
-```ts
-// Button.stories.ts
-
-import Button from './Button.vue';
-
-import { Meta, StoryFn } from '@storybook/vue';
-
-export default {
- /* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'Button',
- component: Button,
-} as Meta;
-
-export const Primary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
-Primary.storyName = 'I am the primary';
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-rename-story.ts-3.ts.mdx b/docs/snippets/vue/button-story-rename-story.ts-3.ts.mdx
deleted file mode 100644
index 8925512e6961..000000000000
--- a/docs/snippets/vue/button-story-rename-story.ts-3.ts.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
-```ts
-// Button.stories.ts
-
-import Button from './Button.vue';
-
-import { Meta, StoryFn } from '@storybook/vue3';
-
-export default {
- /* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'Button',
- component: Button,
-} as Meta;
-
-export const Primary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
-Primary.storyName = 'I am the primary';
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-rename-story.ts.mdx b/docs/snippets/vue/button-story-rename-story.ts.mdx
new file mode 100644
index 000000000000..196941dad0c2
--- /dev/null
+++ b/docs/snippets/vue/button-story-rename-story.ts.mdx
@@ -0,0 +1,29 @@
+```ts
+// Button.stories.ts
+
+import Button from './Button.vue';
+
+import type { Meta, Story } from '@storybook/vue3';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+ component: Button,
+} 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ name:'I am the primary',
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-using-args.2.js.mdx b/docs/snippets/vue/button-story-using-args.2.js.mdx
index 1cce963c293f..4883a73fbbcd 100644
--- a/docs/snippets/vue/button-story-using-args.2.js.mdx
+++ b/docs/snippets/vue/button-story-using-args.2.js.mdx
@@ -5,27 +5,51 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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, { argTypes }) => ({
- components: { Button },
- props: Object.keys(argTypes),
- template: '',
-});
-
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ backgroundColor: '#ff0',
+ label: 'Button',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-using-args.3.js.mdx b/docs/snippets/vue/button-story-using-args.3.js.mdx
index c681a3c25ead..0a99803e1d16 100644
--- a/docs/snippets/vue/button-story-using-args.3.js.mdx
+++ b/docs/snippets/vue/button-story-using-args.3.js.mdx
@@ -5,28 +5,57 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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) => ({
- components: { Button },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ args: {
+ backgroundColor: '#ff0',
+ label: 'Button',
},
- template: '',
-});
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', label: 'Button' };
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary = {
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-using-args.ts-2.ts.mdx b/docs/snippets/vue/button-story-using-args.ts-2.ts.mdx
index 4bfe62dd1183..95ddfe52c24d 100644
--- a/docs/snippets/vue/button-story-using-args.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story-using-args.ts-2.ts.mdx
@@ -3,31 +3,55 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/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: StoryFn = (args, { argTypes }) => ({
- components: { Button },
- props: Object.keys(argTypes),
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ background: '#ff0',
+ label: 'Button',
+ },
+};
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', label: 'Button' };
+export const Secondary: Story = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
-
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary: Story = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-using-args.ts-3.ts.mdx b/docs/snippets/vue/button-story-using-args.ts-3.ts.mdx
index b081e49bbe23..e28b61419145 100644
--- a/docs/snippets/vue/button-story-using-args.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story-using-args.ts-3.ts.mdx
@@ -3,33 +3,62 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/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: StoryFn = (args) => ({
- components: { Button },
- setup() {
- return { args };
- },
- template: '',
-});
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ background: '#ff0',
+ label: 'Button',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary: Story = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary: Story = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-addon-example.js.mdx b/docs/snippets/vue/button-story-with-addon-example.js.mdx
index d07029c32d4e..2416e1432620 100644
--- a/docs/snippets/vue/button-story-with-addon-example.js.mdx
+++ b/docs/snippets/vue/button-story-with-addon-example.js.mdx
@@ -5,9 +5,9 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
//π Creates specific parameters for the story
parameters: {
@@ -17,8 +17,10 @@ export default {
},
};
-export const Basic = () => ({
- components: { Button },
+export const Basic = {
+ render: () => ({
+ components: { Button },
template: '',
-});
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-args.2.js.mdx b/docs/snippets/vue/button-story-with-args.2.js.mdx
index b7cfcaee9515..17611ee114ec 100644
--- a/docs/snippets/vue/button-story-with-args.2.js.mdx
+++ b/docs/snippets/vue/button-story-with-args.2.js.mdx
@@ -5,24 +5,27 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Button },
-});
-
-//π 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ primary: true,
+ label: 'Button',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-args.3.js.mdx b/docs/snippets/vue/button-story-with-args.3.js.mdx
index bd54da03cfb1..20f44a3250a3 100644
--- a/docs/snippets/vue/button-story-with-args.3.js.mdx
+++ b/docs/snippets/vue/button-story-with-args.3.js.mdx
@@ -5,28 +5,29 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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) => ({
- components: { Button },
- setup() {
- //π The args will now be passed down to the template
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ primary: true,
+ label: 'Button',
},
- template: '',
-});
-
-
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = {
- primary: true,
- label: 'Button',
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-args.mdx-2.mdx.mdx b/docs/snippets/vue/button-story-with-args.mdx-2.mdx.mdx
index 0fe61e09fbb8..66dc1204cb95 100644
--- a/docs/snippets/vue/button-story-with-args.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/button-story-with-args.mdx-2.mdx.mdx
@@ -7,21 +7,20 @@ import Button from './Button.vue';
-
-
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Button },
- template: ``,
-});
-
-
+
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Button },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-args.mdx-3.mdx.mdx b/docs/snippets/vue/button-story-with-args.mdx-3.mdx.mdx
index 252647df8f9c..49f7073f6211 100644
--- a/docs/snippets/vue/button-story-with-args.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/button-story-with-args.mdx-3.mdx.mdx
@@ -7,22 +7,22 @@ import Button from './Button.vue';
-
-
-export const Template = (args) => ({
- components: { Button },
- setup() {
- return { args };
- },
- template: '',
-});
-
+
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-blue-args.js.mdx b/docs/snippets/vue/button-story-with-blue-args.js.mdx
index b4a9ad989654..2c546313794b 100644
--- a/docs/snippets/vue/button-story-with-blue-args.js.mdx
+++ b/docs/snippets/vue/button-story-with-blue-args.js.mdx
@@ -5,7 +5,7 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-with-blue-args.ts-2.ts.mdx b/docs/snippets/vue/button-story-with-blue-args.ts-2.ts.mdx
index c55b57c2ccc5..25a0b18c0b4c 100644
--- a/docs/snippets/vue/button-story-with-blue-args.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story-with-blue-args.ts-2.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue';
+import type { Meta } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-with-blue-args.ts-3.ts.mdx b/docs/snippets/vue/button-story-with-blue-args.ts-3.ts.mdx
index 00cd50dc5c04..42c5b8729df9 100644
--- a/docs/snippets/vue/button-story-with-blue-args.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story-with-blue-args.ts-3.ts.mdx
@@ -3,11 +3,11 @@
import Button from './Button.vue';
-import { Meta } from '@storybook/vue3';
+import type { Meta } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
diff --git a/docs/snippets/vue/button-story-with-emojis.js.mdx b/docs/snippets/vue/button-story-with-emojis.js.mdx
index 7e4a668ce3e3..a1298fb5308e 100644
--- a/docs/snippets/vue/button-story-with-emojis.js.mdx
+++ b/docs/snippets/vue/button-story-with-emojis.js.mdx
@@ -5,25 +5,35 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
-export const Secondary = () => ({
- components: { Button },
- template: '',
-});
+export const Secondary = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
-export const Tertiary = () => ({
- components: { Button },
- template: '',
-});
+export const Tertiary = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-emojis.mdx.mdx b/docs/snippets/vue/button-story-with-emojis.mdx.mdx
index c9d44de65917..f0acba6330b7 100644
--- a/docs/snippets/vue/button-story-with-emojis.mdx.mdx
+++ b/docs/snippets/vue/button-story-with-emojis.mdx.mdx
@@ -7,32 +7,27 @@ import Button from './Button.vue';
-
- {() => {
- return {
- components: { Button },
- template: ``,
- };
- }}
-
-
+
+ ({
+ components: { Button },
+ template: ``,
+ })} />
- {() => {
- return {
- components: { Button },
- template: ``,
- };
- }}
-
-
+ name="Secondary"
+ render={() => ({
+ components: { Button },
+ template: ``,
+ })} />
- {() => {
- return {
- components: { Button },
- template: ``,
- };
- }}
-
+ name="Tertiary"
+ render={() => ({
+ components: { Button },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-emojis.ts-2.ts.mdx b/docs/snippets/vue/button-story-with-emojis.ts-2.ts.mdx
index cf8c9ca28e53..1b0551fb3d80 100644
--- a/docs/snippets/vue/button-story-with-emojis.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story-with-emojis.ts-2.ts.mdx
@@ -3,29 +3,41 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
} as Meta;
-export const Primary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
-export const Secondary: StoryFn = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
-export const Tertiary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
+export const Secondary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
+
+export const Tertiary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story-with-emojis.ts-3.ts.mdx b/docs/snippets/vue/button-story-with-emojis.ts-3.ts.mdx
index b292bb311fff..09b47b82b287 100644
--- a/docs/snippets/vue/button-story-with-emojis.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story-with-emojis.ts-3.ts.mdx
@@ -3,29 +3,41 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, StoryFn } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
} as Meta;
-export const Primary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
-export const Secondary: StoryFn = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
-export const Tertiary: StoryFn = () => ({
- components: { Button },
- template: '',
-});
+export const Secondary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
+
+export const Tertiary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story.js.mdx b/docs/snippets/vue/button-story.js.mdx
index 15514fefa403..1034da9bcf0d 100644
--- a/docs/snippets/vue/button-story.js.mdx
+++ b/docs/snippets/vue/button-story.js.mdx
@@ -5,15 +5,22 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
component: Button,
};
-export const Primary = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story.mdx.mdx b/docs/snippets/vue/button-story.mdx.mdx
index 7e5db63593b4..329d84014677 100644
--- a/docs/snippets/vue/button-story.mdx.mdx
+++ b/docs/snippets/vue/button-story.mdx.mdx
@@ -7,14 +7,18 @@ import Button from './Button.vue';
+
+
# Button
-
- {() => {
- return {
- components: { Button },
- template: ``,
- };
- }}
-
+ ({
+ components: { Button },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story.ts-2.ts.mdx b/docs/snippets/vue/button-story.ts-2.ts.mdx
index 38643023a710..f57eaff84b6d 100644
--- a/docs/snippets/vue/button-story.ts-2.ts.mdx
+++ b/docs/snippets/vue/button-story.ts-2.ts.mdx
@@ -3,19 +3,26 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
} as Meta;
-export const Primary: StoryFn = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/button-story.ts-3.ts.mdx b/docs/snippets/vue/button-story.ts-3.ts.mdx
index 813792649c3d..29286788861a 100644
--- a/docs/snippets/vue/button-story.ts-3.ts.mdx
+++ b/docs/snippets/vue/button-story.ts-3.ts.mdx
@@ -3,19 +3,26 @@
import Button from './Button.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
} as Meta;
-export const Primary: StoryFn = () => ({
- components: { Button },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary: Story = {
+ render: () => ({
+ components: { Button },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/checkbox-story-csf.js.mdx b/docs/snippets/vue/checkbox-story-csf.js.mdx
index 8047f0e4d5da..6d8bedac7379 100644
--- a/docs/snippets/vue/checkbox-story-csf.js.mdx
+++ b/docs/snippets/vue/checkbox-story-csf.js.mdx
@@ -5,20 +5,27 @@ import Checkbox from './Checkbox.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'Checkbox',
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Checkbox',
component: Checkbox,
};
-export const allCheckboxes = () => ({
- components: { Checkbox },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const allCheckboxes = () => {
+ render: () => ({
+ components: { Checkbox },
+ template: `
+ `,
+ });
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/checkbox-story-starter-example.mdx.mdx b/docs/snippets/vue/checkbox-story-starter-example.mdx.mdx
index b2a23ae68bab..9f76a0ab3e24 100644
--- a/docs/snippets/vue/checkbox-story-starter-example.mdx.mdx
+++ b/docs/snippets/vue/checkbox-story-starter-example.mdx.mdx
@@ -7,23 +7,27 @@ import Checkbox from './Checkbox.vue';
+
+
# Checkbox
With `MDX`, we can define a story for `Checkbox` right in the middle of our Markdown documentation.
-
- {() => {
- return {
- components: { Checkbox },
- template: `
- `,
- };
- }}
-
+ ({
+ components: { Checkbox },
+ template: `
+ `,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/checkbox-story.mdx-2.mdx.mdx b/docs/snippets/vue/checkbox-story.mdx-2.mdx.mdx
index 1175e202dc0d..0950503fee8d 100644
--- a/docs/snippets/vue/checkbox-story.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/checkbox-story.mdx-2.mdx.mdx
@@ -7,11 +7,11 @@ import Checkbox from './Checkbox.vue';
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Checkbox },
- template: '',
-});
+
# Checkbox
@@ -23,27 +23,34 @@ Markdown documentation.
name="Unchecked"
args={{
label: 'Unchecked',
- }}>
- {Template.bind({})}
-
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Checkbox },
+ template: '',
+ })} />
- {Template.bind({})}
-
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Checkbox },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Checkbox },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/checkbox-story.mdx-3.mdx.mdx b/docs/snippets/vue/checkbox-story.mdx-3.mdx.mdx
index d72e2856ea16..a721a22ab8bb 100644
--- a/docs/snippets/vue/checkbox-story.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/checkbox-story.mdx-3.mdx.mdx
@@ -7,13 +7,12 @@ import Checkbox from './Checkbox.vue';
-export const Template = (args) => ({
- components: { Checkbox },
- setup() {
- return { args };
- },
- template: '',
-});
+
+
# Checkbox
With `MDX`, we can define a story for `Checkbox` right in the middle of our
@@ -24,27 +23,40 @@ Markdown documentation.
name="Unchecked"
args={{
label: 'Unchecked',
- }}>
- {Template.bind({})}
-
-
+ }}
+ render={(args) => ({
+ components: { Checkbox },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
-
+ }}
+ render={(args) => ({
+ components: { Checkbox },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Checkbox },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-custom-args-complex.3.js.mdx b/docs/snippets/vue/component-story-custom-args-complex.3.js.mdx
index 1beee880c504..69d5024a98f1 100644
--- a/docs/snippets/vue/component-story-custom-args-complex.3.js.mdx
+++ b/docs/snippets/vue/component-story-custom-args-complex.3.js.mdx
@@ -5,9 +5,9 @@ import YourComponent from './YourComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
//π Creates specific argTypes with options
@@ -27,28 +27,27 @@ const someFunction = (valuePropertyA, valuePropertyB) => {
// Makes some computations and returns something
};
-const Template = (args) => {
- //π Assigns the function result to a variable
- const functionResult = someFunction(args.propertyA, args.propertyB);
- return {
- components: { YourComponent },
- setup() {
- //π The args will now be passed down to the template
- return {
- args: {
+export const ExampleStory = {
+ render: ({ args }) => {
+ const { propertyA, propertyB } = args;
+ //π Assigns the function result to a variable
+ const functionResult = someFunction(propertyA, propertyB);
+ return {
+ components: { YourComponent },
+ setup() {
+ return {
...args,
//π Replaces arg variable with the override (without the need of mutation)
someProperty: functionResult,
- },
- };
- },
- template: '',
- };
-};
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args= {
- propertyA: 'Item One',
- propertyB: 'Another Item One',
+ };
+ },
+ template:
+ '',
+ };
+ },
+ args: {
+ propertyA: 'Item One',
+ propertyB: 'Another Item One',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-custom-args-complex.mdx-3.mdx.mdx b/docs/snippets/vue/component-story-custom-args-complex.mdx-3.mdx.mdx
index 3f98a721667c..595367af8dda 100644
--- a/docs/snippets/vue/component-story-custom-args-complex.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/component-story-custom-args-complex.mdx-3.mdx.mdx
@@ -15,25 +15,11 @@ export const someFunction = (valuePropertyA, valuePropertyB) => {
};
-export const Template = (args) => {
- //π Assigns the function result to a variable
- const functionResult = someFunction(args.propertyA, args.propertyB);
- return {
- components: { YourComponent },
- setup() {
- //π The args will now be passed down to the template
- return {
- args: {
- ...args,
- //π Replaces arg variable with the override (without the need of mutation)
- someProperty: functionResult,
- },
- };
- },
- template: '',
- };
-};
-
+
{
args={{
propertyA: 'Item One',
propertyB: 'Another Item One',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => {
+ const { propertyA, propertyB } = args;
+ const functionResult = someFunction(propertyA, propertyB);
+ return {
+ components: { YourComponent },
+ setup() {
+ return {
+ args: {
+ ...args,
+ someProperty: functionResult,
+ },
+ };
+ },
+ template: '',
+ };
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-custom-args-icons.2.js.mdx b/docs/snippets/vue/component-story-custom-args-icons.2.js.mdx
deleted file mode 100644
index 59af2057e054..000000000000
--- a/docs/snippets/vue/component-story-custom-args-icons.2.js.mdx
+++ /dev/null
@@ -1,39 +0,0 @@
-```js
-// YourComponent.stories.js
-
-import YourComponent from './YourComponent.vue';
-
-import { IconA, IconB, IconC, IconD, IconE } from './icons';
-
-//π Maps the icons to a JSON serializable object to be safely used with the argTypes
-const iconMap = { IconA, IconB, IconC, IconD, IconE };
-
-export default {
- title: 'My Story with Icons',
- component: YourComponent,
- //π Creates specific argTypes with options
- argTypes: {
- icon: {
- options: Object.keys(iconMap),
- },
- },
-};
-
-const Template = (args, { argTypes }) => {
- //π Retrieves the appropriate icon passes it as a component prop
- const oldArgs = args;
- const { icon } = oldArgs;
-
- //π Sets the new icon
- const selectedIcon = iconMap[icon];
-
- //π Updates the args with the new icon
- args.icon = selectedIcon;
-
- return {
- props: Object.keys(argTypes),
- components: { YourComponent },
- template: '',
- };
-};
-```
diff --git a/docs/snippets/vue/component-story-custom-args-icons.3.js.mdx b/docs/snippets/vue/component-story-custom-args-icons.3.js.mdx
deleted file mode 100644
index 8da0ef8d9bb5..000000000000
--- a/docs/snippets/vue/component-story-custom-args-icons.3.js.mdx
+++ /dev/null
@@ -1,38 +0,0 @@
-```js
-// YourComponent.stories.js
-
-import YourComponent from './YourComponent.vue';
-
-import { IconA, IconB, IconC, IconD, IconE } from './icons';
-
-//π Maps the icons to a JSON serializable object to be safely used with the argTypes
-const iconMap = { IconA, IconB, IconC, IconD, IconE };
-
-export default {
- title: 'My Story with Icons',
- component: YourComponent,
- //π Creates specific argTypes with options
- argTypes: {
- icon: {
- options: Object.keys(iconMap),
- },
- },
-};
-
-const Template = (args) => {
- return {
- components: { YourComponent },
- setup() {
- //π The args will now be passed down to the template
- return {
- args: {
- ...args,
- //π Replaces the local variable with the override (without mutating it)
- icon: iconMap[args.icon],
- },
- };
- },
- template: '',
- };
-};
-```
diff --git a/docs/snippets/vue/component-story-figma-integration.js.mdx b/docs/snippets/vue/component-story-figma-integration.js.mdx
index c11f6fc3654b..113030fabe16 100644
--- a/docs/snippets/vue/component-story-figma-integration.js.mdx
+++ b/docs/snippets/vue/component-story-figma-integration.js.mdx
@@ -5,24 +5,28 @@ import { withDesign } from 'storybook-addon-designs';
import MyComponent from './MyComponent.vue';
-// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
+// More on default export: https://storybook.js.org/docs/7.0/vue/writing-stories/introduction#default-export
export default {
title: 'FigmaExample',
component: MyComponent,
decorators: [withDesign],
};
-// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
-const Template = () => ({
- components: { MyComponent },
- template: '',
-});
-
-export const Example = Template.bind({});
-Example.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/Sample-File',
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Example = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/Sample-File',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-figma-integration.mdx.mdx b/docs/snippets/vue/component-story-figma-integration.mdx.mdx
index a75e89528830..3012f1cfd244 100644
--- a/docs/snippets/vue/component-story-figma-integration.mdx.mdx
+++ b/docs/snippets/vue/component-story-figma-integration.mdx.mdx
@@ -9,23 +9,24 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- // Components used in your story `template` are defined in the `components` object
- components: { MyComponent },
- template: 'MyComponent />',
-});
+
- {Template.bind({})}
-
+ render={() => ({
+ components: { MyComponent },
+ template: 'MyComponent />',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-figma-integration.ts.mdx b/docs/snippets/vue/component-story-figma-integration.ts.mdx
index 0bacfcc5b3b3..b308b60e3c04 100644
--- a/docs/snippets/vue/component-story-figma-integration.ts.mdx
+++ b/docs/snippets/vue/component-story-figma-integration.ts.mdx
@@ -1,30 +1,40 @@
```ts
// MyComponent.stories.ts
-import { Meta, StoryFn } from '@storybook/vue'; // For Vue 3 use import { Meta, Story } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue'; // For Vue 3 use import { Meta, Story } from '@storybook/vue3';
import { withDesign } from 'storybook-addon-designs';
import MyComponent from './MyComponent.vue';
-// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
+// More on default export: https://storybook.js.org/docs/7.0/vue/writing-stories/introduction#default-export
export default {
title: 'FigmaExample',
component: MyComponent,
decorators: [withDesign],
} as Meta;
-// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
+// More on component templates: https://storybook.js.org/docs/7.0/vue/writing-stories/introduction#using-args
const Template: StoryFn = () => ({
components: { MyComponent },
template: '',
});
-export const Example = Template.bind({});
-Example.parameters = {
- design: {
- type: 'figma',
- url: 'https://www.figma.com/file/Sample-File',
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Example: Story = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/Sample-File',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-mdx-story-by-name.mdx-2.mdx.mdx b/docs/snippets/vue/component-story-mdx-story-by-name.mdx-2.mdx.mdx
index c03e760d90e2..32d8fd989ff8 100644
--- a/docs/snippets/vue/component-story-mdx-story-by-name.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/component-story-mdx-story-by-name.mdx-2.mdx.mdx
@@ -7,13 +7,18 @@ import Button from './Button.vue';
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Button },
- template: '',
-});
+
-
- {Template.bind({})}
-
+ ({
+ props: Object.keys(argTypes),
+ components: { Button },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-mdx-story-by-name.mdx-3.mdx.mdx b/docs/snippets/vue/component-story-mdx-story-by-name.mdx-3.mdx.mdx
index 80895d40a79c..deca29ac4103 100644
--- a/docs/snippets/vue/component-story-mdx-story-by-name.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/component-story-mdx-story-by-name.mdx-3.mdx.mdx
@@ -7,15 +7,20 @@ import Button from './Button.vue';
-export const Template = (args) => ({
- components: { Button },
- setup() {
- return { args };
- },
- template: '',
-});
+
-
- {Template.bind({})}
-
+ ({
+components: { Button },
+setup() {
+return { args };
+},
+template: '',
+})} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-cdn.js.mdx b/docs/snippets/vue/component-story-static-asset-cdn.js.mdx
index 20e6e9101918..c54b2d1b1ba7 100644
--- a/docs/snippets/vue/component-story-static-asset-cdn.js.mdx
+++ b/docs/snippets/vue/component-story-static-asset-cdn.js.mdx
@@ -3,13 +3,20 @@
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
};
-export const WithAnImage = () => ({
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-cdn.mdx.mdx b/docs/snippets/vue/component-story-static-asset-cdn.mdx.mdx
index 25f91e1caf3c..2508d192beaf 100644
--- a/docs/snippets/vue/component-story-static-asset-cdn.mdx.mdx
+++ b/docs/snippets/vue/component-story-static-asset-cdn.mdx.mdx
@@ -7,12 +7,15 @@ import MyComponent from './MyComponent.vue';
+
+
- {() => {
- return {
- template: ``,
- };
- }}
-
+ name="withAnImage"
+ render={() => ({
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-with-import.2.js.mdx b/docs/snippets/vue/component-story-static-asset-with-import.2.js.mdx
index 72e8ea79e836..25433007805c 100644
--- a/docs/snippets/vue/component-story-static-asset-with-import.2.js.mdx
+++ b/docs/snippets/vue/component-story-static-asset-with-import.2.js.mdx
@@ -5,9 +5,9 @@ import imageFile from './static/image.png';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
};
@@ -16,15 +16,22 @@ const image = {
alt: 'my image',
};
-export const WithAnImage = () => ({
- props: {
- src: {
- default: () => image.src,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
+ props: {
+ src: {
+ default: () => image.src,
+ },
+ alt: {
+ default: () => image.alt,
+ },
},
- alt: {
- default: () => image.alt,
- },
- },
- template: ``,
-});
+ template: ``,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-with-import.3.js.mdx b/docs/snippets/vue/component-story-static-asset-with-import.3.js.mdx
index 19c181a8e1f6..7c429a2e1743 100644
--- a/docs/snippets/vue/component-story-static-asset-with-import.3.js.mdx
+++ b/docs/snippets/vue/component-story-static-asset-with-import.3.js.mdx
@@ -5,9 +5,9 @@ import imageFile from './static/image.png';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
};
@@ -16,13 +16,18 @@ const image = {
alt: 'my image',
};
-export const WithAnImage = () => {
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const WithAnImage = {
+ render: () => ({
setup() {
- //π Returns the content of the image object create above.
+ //π Returns the content of the image object create above.
return { image };
},
template: ``,
- };
+ }),
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-with-import.mdx-2.mdx.mdx b/docs/snippets/vue/component-story-static-asset-with-import.mdx-2.mdx.mdx
index 555aa9a3d332..765535ee17a9 100644
--- a/docs/snippets/vue/component-story-static-asset-with-import.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/component-story-static-asset-with-import.mdx-2.mdx.mdx
@@ -12,20 +12,23 @@ export const image = {
alt: 'my image',
};
+
+
- {() => {
- return {
- props: {
- src: {
- default: () => image.src,
- },
- alt: {
- default: () => image.alt,
- },
+ name="withAnImage"
+ render={() => ({
+ props: {
+ src: {
+ default: () => image.src,
+ },
+ alt: {
+ default: () => image.alt,
},
- template: ``,
- };
- }}
-
+ },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-with-import.mdx-3.mdx.mdx b/docs/snippets/vue/component-story-static-asset-with-import.mdx-3.mdx.mdx
index 0c248e8c6177..3511fbffee53 100644
--- a/docs/snippets/vue/component-story-static-asset-with-import.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/component-story-static-asset-with-import.mdx-3.mdx.mdx
@@ -12,15 +12,18 @@ export const image = {
alt: 'my image',
};
+
+
- {() => {
- return {
- setup() {
- return { image };
- },
- template: ``,
- };
- }}
-
+ name="WithAnImage"
+ render={() => ({
+ setup() {
+ return { image };
+ },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-without-import.js.mdx b/docs/snippets/vue/component-story-static-asset-without-import.js.mdx
index 37352927b9a5..4ef7585553a8 100644
--- a/docs/snippets/vue/component-story-static-asset-without-import.js.mdx
+++ b/docs/snippets/vue/component-story-static-asset-without-import.js.mdx
@@ -3,14 +3,16 @@
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'img',
};
// Assume image.png is located in the "public" directory.
-export const WithAnImage = () => ({
- template: '',
-});
+export const WithAnImage = {
+ render: () => ({
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-static-asset-without-import.mdx.mdx b/docs/snippets/vue/component-story-static-asset-without-import.mdx.mdx
index d793002a15c6..f4875eccfdec 100644
--- a/docs/snippets/vue/component-story-static-asset-without-import.mdx.mdx
+++ b/docs/snippets/vue/component-story-static-asset-without-import.mdx.mdx
@@ -5,16 +5,10 @@ import { Meta, Story } from '@storybook/addon-docs';
-
+
- {() => {
- return {
- setup() {
- return { image };
- },
- template: ``,
- };
- }}
-
+ name="WithAnImage"
+ render={() => ({
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-accessibility.2.js.mdx b/docs/snippets/vue/component-story-with-accessibility.2.js.mdx
index 1559c5bf5238..0e0876e15954 100644
--- a/docs/snippets/vue/component-story-with-accessibility.2.js.mdx
+++ b/docs/snippets/vue/component-story-with-accessibility.2.js.mdx
@@ -5,9 +5,9 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Accessibility testing',
component: Button,
argTypes: {
@@ -15,23 +15,29 @@ export default {
},
};
-const Template = (args, { argTypes }) => ({
- components: { Button },
- props: Object.keys(argTypes),
- template: '',
-});
-
// This is an accessible story
-export const Accessible = Template.bind({});
-Accessible.args = {
- primary: false,
- label: 'Button',
+export const Accessible = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ primary: false,
+ label: 'Button',
+ },
};
// This is not
-export const Inaccessible = Template.bind({});
-Inaccessible.args = {
- ...Accessible.args,
- backgroundColor: 'red',
+export const Inaccessible = {
+ render: (args, { argTypes }) => ({
+ components: { Button },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ ...Accessible.args,
+ backgroundColor: 'red',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-accessibility.3.js.mdx b/docs/snippets/vue/component-story-with-accessibility.3.js.mdx
index 82f3717d0cf9..f006abce95b7 100644
--- a/docs/snippets/vue/component-story-with-accessibility.3.js.mdx
+++ b/docs/snippets/vue/component-story-with-accessibility.3.js.mdx
@@ -5,9 +5,9 @@ import Button from './Button.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Accessibility testing',
component: Button,
argTypes: {
@@ -24,16 +24,32 @@ const Template = (args) => ({
});
// This is an accessible story
-export const Accessible = Template.bind({});
-Accessible.args = {
- primary: false,
- label: 'Button',
+export const Accessible = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ primary: false,
+ label: 'Button',
+ },
};
// This is not
-export const Inaccessible = Template.bind({});
-Inaccessible.args = {
- ...Accessible.args,
- backgroundColor: 'red',
+export const Inaccessible = {
+ render: (args) => ({
+ components: { Button },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ ...Accessible.args,
+ backgroundColor: 'red',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-accessibility.mdx-2.mdx.mdx b/docs/snippets/vue/component-story-with-accessibility.mdx-2.mdx.mdx
index 8d2b797e331b..a236ad94897b 100644
--- a/docs/snippets/vue/component-story-with-accessibility.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/component-story-with-accessibility.mdx-2.mdx.mdx
@@ -16,11 +16,11 @@ import Button from './Button.vue';
}
}} />
-export const Template = (args, { argTypes }) => ({
- components: { Button },
- props: Object.keys(argTypes),
- template: '',
-});
+
## This is an accessible story
@@ -29,9 +29,12 @@ export const Template = (args, { argTypes }) => ({
args={{
primary: false,
label: 'Button'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Button },
+ template: '',
+ })} />
## This is not
@@ -41,7 +44,10 @@ export const Template = (args, { argTypes }) => ({
primary: false,
label: 'Button',
backgroundColor: 'red'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Button },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-accessibility.mdx-3.mdx.mdx b/docs/snippets/vue/component-story-with-accessibility.mdx-3.mdx.mdx
index 2b891162b950..221cd63ecc60 100644
--- a/docs/snippets/vue/component-story-with-accessibility.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/component-story-with-accessibility.mdx-3.mdx.mdx
@@ -16,13 +16,11 @@ import Button from './Button.vue';
}
}} />
-export const Template = (args) => ({
- components: { Button },
- setup() {
- return { args };
- },
- template: '',
-});
+
## This is an accessible story
@@ -31,9 +29,14 @@ export const Template = (args) => ({
args={{
primary: false,
label: 'Button'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { MyButton },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
## This is not
@@ -43,7 +46,12 @@ export const Template = (args) => ({
primary: false,
label: 'Button',
backgroundColor: 'red'
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { MyButton },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-custom-render-function.js.mdx b/docs/snippets/vue/component-story-with-custom-render-function.js.mdx
new file mode 100644
index 000000000000..b2226c9ebf7a
--- /dev/null
+++ b/docs/snippets/vue/component-story-with-custom-render-function.js.mdx
@@ -0,0 +1,33 @@
+```js
+// MyComponent.stories.js
+
+import Layout from './Layout.vue';
+
+import MyComponent from './MyComponent.vue';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'MyComponent',
+ component: MyComponent,
+};
+
+// This story uses a render function to fully control how the component renders.
+export const Example = {
+ render: () => ({
+ components: { Layout, MyComponent },
+ template: `
+
+
+
Example
+
+
+
+
+
+ `,
+ }),
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/vue/component-story-with-custom-render-function.ts.mdx b/docs/snippets/vue/component-story-with-custom-render-function.ts.mdx
new file mode 100644
index 000000000000..5e7e56c8a5b7
--- /dev/null
+++ b/docs/snippets/vue/component-story-with-custom-render-function.ts.mdx
@@ -0,0 +1,35 @@
+```ts
+// MyComponent.stories.js
+
+import type { Meta, Story } from '@storybook/vue'; // Replace with '@storybook/vue3' if you're working with Vue3 project
+
+import Layout from './Layout.vue';
+
+import MyComponent from './MyComponent.vue';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'MyComponent',
+ component: MyComponent,
+};
+
+// This story uses a render function to fully control how the component renders.
+export const Example: Story = {
+ render: () => ({
+ components: { Layout, MyComponent },
+ template: `
+
+
+
Example
+
+
+
+
+
+ `,
+ }),
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/vue/documentscreen-story-msw-graphql-query.3.js.mdx b/docs/snippets/vue/documentscreen-story-msw-graphql-query.3.js.mdx
index 94dba8191196..185a5df817b1 100644
--- a/docs/snippets/vue/documentscreen-story-msw-graphql-query.3.js.mdx
+++ b/docs/snippets/vue/documentscreen-story-msw-graphql-query.3.js.mdx
@@ -9,9 +9,9 @@ import { graphql } from 'msw';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
@@ -65,37 +65,43 @@ const TestData = {
],
};
-const PageTemplate = () => ({
- components: { DocumentScreen, WrapperComponent },
- template: `
-
-
-
- `,
-});
-
-export const MockedSuccess = PageTemplate.bind({});
-MockedSuccess.parameters = {
- msw: [
- graphql.query('AllInfoQuery', (req, res, ctx) => {
- return res(ctx.data(TestData));
- }),
- ],
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const MockedSuccess = {
+ render: () => ({
+ components: { DocumentScreen, WrapperComponent },
+ template: '',
+ }),
+ 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 = {
+ render: () => ({
+ components: { DocumentScreen, WrapperComponent },
+ template: '',
+ }),
+ 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/vue/documentscreen-story-msw-rest-request.3.js.mdx b/docs/snippets/vue/documentscreen-story-msw-rest-request.3.js.mdx
index eaf1c5396b89..f09309eee49f 100644
--- a/docs/snippets/vue/documentscreen-story-msw-rest-request.3.js.mdx
+++ b/docs/snippets/vue/documentscreen-story-msw-rest-request.3.js.mdx
@@ -7,9 +7,9 @@ import DocumentScreen from './YourPage.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
@@ -63,26 +63,36 @@ const TestData = {
],
};
-const PageTemplate = () => ({
- components: { DocumentScreen },
- template: '',
-});
-
-export const MockedSuccess = PageTemplate.bind({});
-MockedSuccess.parameters = {
- msw: [
- rest.get('https://your-restful-endpoint/', (_req, res, ctx) => {
- return res(ctx.json(TestData));
- }),
- ],
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const MockedSuccess = {
+ render: () => ({
+ components: { DocumentScreen },
+ template: '',
+ }),
+ 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 = {
+ render: () => ({
+ components: { DocumentScreen },
+ template: '',
+ }),
+ 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/vue/form-story-component-with-play-function.2.js.mdx b/docs/snippets/vue/form-story-component-with-play-function.2.js.mdx
deleted file mode 100644
index d79f1d5905f7..000000000000
--- a/docs/snippets/vue/form-story-component-with-play-function.2.js.mdx
+++ /dev/null
@@ -1,29 +0,0 @@
-```js
-// Form.stories.js
-
-import { userEvent, within } from '@storybook/testing-library';
-
-import LoginForm from './LoginForm.vue';
-
-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/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('button'));
- },
- render: (args, { argTypes }) => ({
- components: { LoginForm },
- props: Object.keys(argTypes),
- template: '',
- }),
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/form-story-component-with-play-function.3.js.mdx b/docs/snippets/vue/form-story-component-with-play-function.3.js.mdx
deleted file mode 100644
index 96d612cee7d0..000000000000
--- a/docs/snippets/vue/form-story-component-with-play-function.3.js.mdx
+++ /dev/null
@@ -1,30 +0,0 @@
-```js
-// Form.stories.js
-
-import { userEvent, within } from '@storybook/testing-library';
-
-import LoginForm from './LoginForm.vue';
-
-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/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('button'));
- },
- render: (args) => ({
- components: { LoginForm },
- setup() {
- return { args };
- },
- template: '',
- }),
-};
-```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-expanded.2.js.mdx b/docs/snippets/vue/list-story-expanded.2.js.mdx
index b81948be649a..0283f679873c 100644
--- a/docs/snippets/vue/list-story-expanded.2.js.mdx
+++ b/docs/snippets/vue/list-story-expanded.2.js.mdx
@@ -6,34 +6,47 @@ import ListItem from './ListItem.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-export const Empty = (args, { argTypes }) => ({
- components: { List },
- props: Object.keys(argTypes),
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty = {
+ render: (args, { argTypes }) => ({
+ components: { List },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+};
-export const OneItem = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- template: '',
-});
+export const OneItem = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+ `,
+ }),
+};
-export const ManyItems = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- template: `
-
-
-
-
-
- `,
-});
+export const ManyItems = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+ `,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-expanded.3.js.mdx b/docs/snippets/vue/list-story-expanded.3.js.mdx
index e74b9d9705d6..30d8fb53c459 100644
--- a/docs/snippets/vue/list-story-expanded.3.js.mdx
+++ b/docs/snippets/vue/list-story-expanded.3.js.mdx
@@ -6,40 +6,53 @@ import ListItem from './ListItem.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-export const Empty = (args) => ({
- components: { List },
- setup() {
- return { args };
- },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty = {
+ render: (args) => ({
+ components: { List },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
-export const OneItem = (args) => ({
- components: { List, ListItem },
- setup() {
- return { args };
- },
- template: '',
-});
+export const OneItem = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { args };
+ },
+ template: `
+
+
+ `,
+ }),
+};
-export const ManyItems = (args) => ({
- components: { List, ListItem },
- setup() {
- return { args };
- },
- template: `
-
-
-
-
-
- `,
-});
-```
\ No newline at end of file
+export const ManyItems = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { ...args };
+ },
+ template: `
+
+
+
+
+ `,
+ }),
+};
+```
diff --git a/docs/snippets/vue/list-story-expanded.ts-2.ts.mdx b/docs/snippets/vue/list-story-expanded.ts-2.ts.mdx
index 429fe6f3fb76..ad2be5eae619 100644
--- a/docs/snippets/vue/list-story-expanded.ts-2.ts.mdx
+++ b/docs/snippets/vue/list-story-expanded.ts-2.ts.mdx
@@ -4,38 +4,51 @@
import List from './ListComponent.vue';
import ListItem from './ListItem.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
} as Meta;
-export const Empty: StoryFn = (args, { argTypes }) => ({
- components: { List },
- props: Object.keys(argTypes),
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty: Story = {
+ render: (args, { argTypes }) => ({
+ components: { List },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+};
-export const OneItem: StoryFn = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- template: '',
-});
+export const OneItem: Story = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+ `,
+ }),
+};
-export const ManyItems: StoryFn = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- template: `
-
-
-
-
-
- `,
-});
+export const ManyItems: Story = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+ `,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-expanded.ts-3.ts.mdx b/docs/snippets/vue/list-story-expanded.ts-3.ts.mdx
index 74c9ea1a72b4..3034a470efcd 100644
--- a/docs/snippets/vue/list-story-expanded.ts-3.ts.mdx
+++ b/docs/snippets/vue/list-story-expanded.ts-3.ts.mdx
@@ -4,44 +4,57 @@
import List from './ListComponent.vue';
import ListItem from './ListItem.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
} as Meta;
-export const Empty: StoryFn = (args) => ({
- components: { List },
- setup() {
- return { args };
- },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty: Story = {
+ render: (args) => ({
+ components: { List },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
-export const OneItem: StoryFn = (args) => ({
- components: { List, ListItem },
- setup() {
- return { args };
- },
- template: '',
-});
+export const OneItem: Story = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { args };
+ },
+ template: `
+
+
+ `,
+ }),
+};
-export const ManyItems: StoryFn = (args) => ({
- components: { List, ListItem },
- setup() {
- return { args };
- },
- template: `
-
-
-
-
-
- `,
-});
+export const ManyItems: Story = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { ...args };
+ },
+ template: `
+
+
+
+
+ `,
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-reuse-data.2.js.mdx b/docs/snippets/vue/list-story-reuse-data.2.js.mdx
index 3f017761fae0..c85a025b01d1 100644
--- a/docs/snippets/vue/list-story-reuse-data.2.js.mdx
+++ b/docs/snippets/vue/list-story-reuse-data.2.js.mdx
@@ -9,26 +9,32 @@ import { Selected, Unselected } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-export const ManyItems = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ManyItems = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+ `,
+ }),
+ args: {
+ Selected: Selected.args.isSelected,
+ Unselected: Unselected.args.isSelected,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-reuse-data.3.js.mdx b/docs/snippets/vue/list-story-reuse-data.3.js.mdx
index f4eb4c0f3836..5f0ee1cd7a32 100644
--- a/docs/snippets/vue/list-story-reuse-data.3.js.mdx
+++ b/docs/snippets/vue/list-story-reuse-data.3.js.mdx
@@ -9,29 +9,34 @@ import { Selected, Unselected } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-
-export const ManyItems = (args) => ({
- components: { List, ListItem },
- setup() {
- return { ...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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ManyItems = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { ...args };
+ },
+ template: `
+
+
+
+
+ `,
+ }),
+ args: {
+ Selected: Selected.args.isSelected,
+ Unselected: Unselected.args.isSelected,
},
- template: `
-
-
-
-
- `,
-});
-
-ManyItems.args={
- Selected: Selected.args.isSelected,
- Unselected: Unselected.args.isSelected,
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-reuse-data.ts-2.ts.mdx b/docs/snippets/vue/list-story-reuse-data.ts-2.ts.mdx
index 225252c1575b..d0093f915537 100644
--- a/docs/snippets/vue/list-story-reuse-data.ts-2.ts.mdx
+++ b/docs/snippets/vue/list-story-reuse-data.ts-2.ts.mdx
@@ -4,33 +4,39 @@
import List from './ListComponent.vue';
import ListItem from './ListItem.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
//π We're importing the necessary stories from ListItem
import { Selected, Unselected } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
} as Meta;
-export const ManyItems: StoryFn = (args, { argTypes }) => ({
- components: { List, ListItem },
- props: Object.keys(argTypes),
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ManyItems: Story = {
+ render: (args, { argTypes }) => ({
+ components: { List, ListItem },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+ `,
+ }),
+ args: {
+ Selected: Selected.args.isSelected,
+ Unselected: Unselected.args.isSelected,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-reuse-data.ts-3.ts.mdx b/docs/snippets/vue/list-story-reuse-data.ts-3.ts.mdx
index ff0fe53148d8..7633181840a7 100644
--- a/docs/snippets/vue/list-story-reuse-data.ts-3.ts.mdx
+++ b/docs/snippets/vue/list-story-reuse-data.ts-3.ts.mdx
@@ -4,35 +4,41 @@
import List from './ListComponent.vue';
import ListItem from './ListItem.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
//π We're importing the necessary stories from ListItem
import { Selected, Unselected } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
} as Meta;
-export const ManyItems: StoryFn = (args) => ({
- components: { List, ListItem },
- setup() {
- return { ...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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ManyItems: Story = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ return { ...args };
+ },
+ template: `
+
+
+
+
+ `,
+ }),
+ args: {
+ Selected: Selected.args.isSelected,
+ Unselected: Unselected.args.isSelected,
},
- template: `
-
-
-
-
- `,
-});
-
-ManyItems.args = {
- Selected: Selected.args.isSelected,
- Unselected: Unselected.args.isSelected,
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-starter.2.js.mdx b/docs/snippets/vue/list-story-starter.2.js.mdx
index 52914eb835c2..7132fc1ce3e1 100644
--- a/docs/snippets/vue/list-story-starter.2.js.mdx
+++ b/docs/snippets/vue/list-story-starter.2.js.mdx
@@ -5,17 +5,19 @@ import List from './ListComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
// Always an empty list, not super interesting
-const Template = (args, { argTypes }) => ({
- components: { List },
- props: Object.keys(argTypes),
- template: '',
-});
+export const Empty = {
+ render: (args, { argTypes }) => ({
+ components: { List },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-starter.3.js.mdx b/docs/snippets/vue/list-story-starter.3.js.mdx
index c986f99ff11b..4eb68fcdf087 100644
--- a/docs/snippets/vue/list-story-starter.3.js.mdx
+++ b/docs/snippets/vue/list-story-starter.3.js.mdx
@@ -5,19 +5,21 @@ import List from './ListComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
// Always an empty list, not super interesting
-const Template = (args) => ({
- components: { List },
- setup() {
- return { args };
- },
- template: '',
-});
+export const Empty = {
+ render: (args) => ({
+ components: { List },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-starter.ts-2.ts.mdx b/docs/snippets/vue/list-story-starter.ts-2.ts.mdx
index ff6266df96ac..3da1ee182503 100644
--- a/docs/snippets/vue/list-story-starter.ts-2.ts.mdx
+++ b/docs/snippets/vue/list-story-starter.ts-2.ts.mdx
@@ -3,11 +3,11 @@
import List from './ListComponent.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
@@ -15,9 +15,11 @@ export default {
} as Meta;
// Always an empty list, not super interesting
-const Template: StoryFn = (args, { argTypes }) => ({
- components: { List },
- props: Object.keys(argTypes),
- template: '',
-});
+export const Empty: Story = {
+ render: (args, { argTypes }) => ({
+ components: { List },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-starter.ts-3.ts.mdx b/docs/snippets/vue/list-story-starter.ts-3.ts.mdx
index c70cddcd7b08..58231b976371 100644
--- a/docs/snippets/vue/list-story-starter.ts-3.ts.mdx
+++ b/docs/snippets/vue/list-story-starter.ts-3.ts.mdx
@@ -3,11 +3,11 @@
import List from './ListComponent.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
@@ -15,11 +15,13 @@ export default {
} as Meta;
// Always an empty list, not super interesting
-const Template: StoryFn = (args) => ({
- components: { List },
- setup() {
- return { args };
- },
- template: '',
-});
+export const Empty: Story = {
+ render: (args) => ({
+ components: { List },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-template.2.js.mdx b/docs/snippets/vue/list-story-template.2.js.mdx
index 6cbc57b20b4a..f2ceb52f1e71 100644
--- a/docs/snippets/vue/list-story-template.2.js.mdx
+++ b/docs/snippets/vue/list-story-template.2.js.mdx
@@ -9,13 +9,14 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
+//π The ListTemplate construct will be spread to the existing stories.
const ListTemplate = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { List, ListItem },
@@ -25,20 +26,24 @@ const ListTemplate = (args, { argTypes }) => ({
- `,
+ `,
});
-export const Empty = ListTemplate.bind({});
-EmptyListTemplate.args = {
- items: [],
+export const Empty = {
+ ...ListTemplate,
+ args: {
+ items: [],
+ },
};
-export const OneItem = ListTemplate.bind({});
-OneItem.args = {
- items: [
- {
- ...Unchecked.args,
- },
- ],
+export const OneItem = {
+ ...ListTemplate,
+ args: {
+ items: [
+ {
+ ...Unchecked.args,
+ },
+ ],
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-template.3.js.mdx b/docs/snippets/vue/list-story-template.3.js.mdx
index 76587aabeca3..20d9e6a66fde 100644
--- a/docs/snippets/vue/list-story-template.3.js.mdx
+++ b/docs/snippets/vue/list-story-template.3.js.mdx
@@ -9,38 +9,44 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-const ListTemplate = (args) => ({
- components: { List, ListItem },
- setup() {
- return { args };
- },
- template: `
-
-
+
+ `,
+ }),
};
-export const OneItem = ListTemplate.bind({});
-OneItem.args = {
- items: [
- {
- ...Unchecked.args,
- },
- ],
+export const Empty = {
+ ...ListTemplate,
+ args: {
+ items: [],
+ },
+};
+export const OneItem = {
+ ...ListTemplate,
+ args: {
+ items: [
+ {
+ ...Unchecked.args,
+ },
+ ],
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-unchecked.2.js.mdx b/docs/snippets/vue/list-story-unchecked.2.js.mdx
index cd4e5cecec46..9efb6d802874 100644
--- a/docs/snippets/vue/list-story-unchecked.2.js.mdx
+++ b/docs/snippets/vue/list-story-unchecked.2.js.mdx
@@ -9,23 +9,25 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-
-export const OneItem = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { List, ListItem },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const OneItem = {
+ render: (args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { List, ListItem },
+ template: '',
+ }),
+ args: {
+ ...Unchecked.args,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-unchecked.3.js.mdx b/docs/snippets/vue/list-story-unchecked.3.js.mdx
index 5b7da6194f00..f29e1f9c91ce 100644
--- a/docs/snippets/vue/list-story-unchecked.3.js.mdx
+++ b/docs/snippets/vue/list-story-unchecked.3.js.mdx
@@ -9,26 +9,29 @@ import { Unchecked } from './ListItem.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
component: List,
};
-export const OneItem = (args) => ({
- components: { List, ListItem },
- setup() {
- //π The args will now be passed down to the template
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const OneItem = {
+ args: {
+ ...Unchecked.args,
},
- template: `
-
-
-
- `,
-});
-OneItem.args = {
- ...Unchecked.args,
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ //π The args will now be passed down to the template
+ return { args };
+ },
+ template: '',
+ }),
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-with-sub-components.2.js.mdx b/docs/snippets/vue/list-story-with-sub-components.2.js.mdx
index 46b574b44665..67ef97d43b0c 100644
--- a/docs/snippets/vue/list-story-with-sub-components.2.js.mdx
+++ b/docs/snippets/vue/list-story-with-sub-components.2.js.mdx
@@ -6,23 +6,32 @@ import ListItem from './ListItem.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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
};
-export const Empty = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { List },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty = {
+ render: (args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { List },
+ template: '',
+ }),
+};
-export const OneItem = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { List, ListItem },
- template: '',
-});
+export const OneItem = {
+ render: (args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { List, ListItem },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/list-story-with-sub-components.3.js.mdx b/docs/snippets/vue/list-story-with-sub-components.3.js.mdx
index 0ffa0b326f6e..8230ff8d08fc 100644
--- a/docs/snippets/vue/list-story-with-sub-components.3.js.mdx
+++ b/docs/snippets/vue/list-story-with-sub-components.3.js.mdx
@@ -6,29 +6,37 @@ import ListItem from './ListItem.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/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
};
-export const Empty = (args) => ({
- components: { List },
- setup() {
- //π The args will now be passed down to the template
- return { args };
- }
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty = {
+ render: (args) => ({
+ components: { List },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+};
-export const OneItem = (args) => ({
- components: { List, ListItem },
- setup() {
- //π The args will now be passed down to the template
- return { args };
- }
- template: '',
-});
+export const OneItem = {
+ render: (args) => ({
+ components: { List, ListItem },
+ setup() {
+ //π The args will now be passed down to the template
+ return { args };
+ },
+ template: '',
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/loader-story.3.js.mdx b/docs/snippets/vue/loader-story.3.js.mdx
index b99ff7360963..68009a29747e 100644
--- a/docs/snippets/vue/loader-story.3.js.mdx
+++ b/docs/snippets/vue/loader-story.3.js.mdx
@@ -7,26 +7,25 @@ import fetch from 'node-fetch';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Examples/Loader',
component: TodoItem,
};
-export const Primary = (args, { loaded: { todo } }) => {
- return {
+export const Primary = {
+ render: (args, { loaded: { todo } }) => ({
components: { TodoItem },
setup() {
return { args, todo: todo };
},
- template: ``,
- };
-};
-
-Primary.loaders = [
- async () => ({
- todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
+ template: '',
}),
-];
+ loaders: [
+ async () => ({
+ todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
+ }),
+ ],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/loader-story.mdx.mdx b/docs/snippets/vue/loader-story.mdx.mdx
index 493be08e80c6..976c57f594ec 100644
--- a/docs/snippets/vue/loader-story.mdx.mdx
+++ b/docs/snippets/vue/loader-story.mdx.mdx
@@ -9,21 +9,25 @@ import fetch from 'node-fetch';
+
({
todo: await (
- await fetch("https://jsonplaceholder.typicode.com/todos/1")
+ await fetch('https://jsonplaceholder.typicode.com/todos/1')
).json(),
}),
]}>
- {(args, { loaded: { todo } }) => ({
+ render={(args, { loaded: { todo } }) => ({
components: { TodoItem },
setup() {
return { args, todo: todo };
},
- template: ``,
- })}
-
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.2.js.mdx b/docs/snippets/vue/login-form-with-play-function.2.js.mdx
index e82613674972..125d8e607521 100644
--- a/docs/snippets/vue/login-form-with-play-function.2.js.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.2.js.mdx
@@ -9,39 +9,50 @@ import LoginForm from './LoginForm.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Form',
component: LoginForm,
};
-const Template = (args, { argTypes }) => ({
- components: { LoginForm },
- props: Object.keys(argTypes),
- template: ``,
-});
-
-export const EmptyForm = Template.bind({});
-
-export const FilledForm = Template.bind({});
-FilledForm.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');
-
- await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
-
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const EmptyForm = {
+ render: (args, { argTypes }) => ({
+ components: { LoginForm },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+};
- // π Assert DOM structure
- await expect(
- canvas.getByText(
- 'Everything is perfect. Your account is ready and we should probably get you started!'
- )
- ).toBeInTheDocument();
+export const FilledForm = {
+ render: (args, { argTypes }) => ({
+ components: { LoginForm },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+ 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');
+
+ await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
+
+ // See https://storybook.js.org/docs/7.0/vue/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();
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.3.js.mdx b/docs/snippets/vue/login-form-with-play-function.3.js.mdx
index 19c529bd529a..60c4bb89d983 100644
--- a/docs/snippets/vue/login-form-with-play-function.3.js.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.3.js.mdx
@@ -9,41 +9,54 @@ import LoginForm from './LoginForm.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Form',
component: LoginForm,
};
-const Template = (args) => ({
- components: { LoginForm },
- setup() {
- return args;
- },
- template: '',
-});
-
-export const EmptyForm = Template.bind({});
-
-export const FilledForm = Template.bind({});
-FilledForm.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');
-
- await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
-
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const EmptyForm = {
+ render: (args) => ({
+ components: { LoginForm },
+ setup() {
+ return args;
+ },
+ template: '',
+ }),
+};
- // π Assert DOM structure
- await expect(
- canvas.getByText(
- 'Everything is perfect. Your account is ready and we should probably get you started!'
- )
- ).toBeInTheDocument();
+export const FilledForm = {
+ render: (args) => ({
+ components: { LoginForm },
+ setup() {
+ return args;
+ },
+ template: '',
+ }),
+ 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');
+
+ await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
+
+ // See https://storybook.js.org/docs/7.0/vue/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();
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.mdx-2.mdx b/docs/snippets/vue/login-form-with-play-function.mdx-2.mdx
index c1e887057671..a6e449bc4f20 100644
--- a/docs/snippets/vue/login-form-with-play-function.mdx-2.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.mdx-2.mdx
@@ -11,20 +11,23 @@ import LoginForm from './LoginForm.vue';
-export const Template = (args, { argTypes }) => ({
- components: { LoginForm },
- props: Object.keys(argTypes),
- template: ``,
-});
+
-
- {Template.bind({})}
-
-
+ ({
+ props: Object.keys(argTypes),
+ components: { LoginForm },
+ template: ``,
+ })} />
{
+ play={ async ({ canvasElement }) => {
// Starts querying the component from its root element
const canvas = within(canvasElement);
@@ -33,7 +36,7 @@ export const Template = (args, { argTypes }) => ({
await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await userEvent.click(canvas.getByRole('button'));
// π Assert DOM structure
@@ -42,8 +45,11 @@ export const Template = (args, { argTypes }) => ({
'Everything is perfect. Your account is ready and we should probably get you started!'
)
).toBeInTheDocument();
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { LoginForm },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.mdx-3.mdx b/docs/snippets/vue/login-form-with-play-function.mdx-3.mdx
index ea842adea3c6..cc79337b989d 100644
--- a/docs/snippets/vue/login-form-with-play-function.mdx-3.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.mdx-3.mdx
@@ -11,19 +11,22 @@ import LoginForm from './LoginForm.vue';
-export const Template = (args) => ({
- components: { LoginForm },
- setup() {
- return { args };
- },
- template: '',
-});
+
-
- {Template.bind({})}
-
-
+ ({
+ components: { LoginForm },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
{
@@ -35,7 +38,7 @@ export const Template = (args) => ({
await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await userEvent.click(canvas.getByRole('button'));
// π Assert DOM structure
@@ -44,8 +47,13 @@ export const Template = (args) => ({
'Everything is perfect. Your account is ready and we should probably get you started!'
)
).toBeInTheDocument();
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { LoginForm },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.ts-2.ts.mdx b/docs/snippets/vue/login-form-with-play-function.ts-2.ts.mdx
index 656daf2ec4e5..f40a38b1b6d4 100644
--- a/docs/snippets/vue/login-form-with-play-function.ts-2.ts.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.ts-2.ts.mdx
@@ -7,43 +7,54 @@ import { expect } from '@storybook/jest';
import LoginForm from './LoginForm.vue';
-import { Meta, StoryFn } from '@storybook/vue';
+import type { Meta, Story } from '@storybook/vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Form',
component: LoginForm,
} as Meta;
-const Template: StoryFn = (args, { argTypes }) => ({
- components: { LoginForm },
- props: Object.keys(argTypes),
- template: ``,
-});
-
-export const EmptyForm = Template.bind({});
-
-export const FilledForm = Template.bind({});
-FilledForm.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');
-
- await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
-
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(canvas.getByRole('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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const EmptyForm: Story = {
+ render: (args, { argTypes }) => ({
+ components: { LoginForm },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+};
- // π Assert DOM structure
- await expect(
- canvas.getByText(
- 'Everything is perfect. Your account is ready and we should probably get you started!'
- )
- ).toBeInTheDocument();
+export const FilledForm: Story = {
+ render: (args, { argTypes }) => ({
+ components: { LoginForm },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+ 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');
+
+ await userEvent.type(canvas.getByTestId('password'), 'a-random-password');
+
+ // See https://storybook.js.org/docs/7.0/vue/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();
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/login-form-with-play-function.ts-3.ts.mdx b/docs/snippets/vue/login-form-with-play-function.ts-3.ts.mdx
index 1b676ae48dbc..39ab085cff4f 100644
--- a/docs/snippets/vue/login-form-with-play-function.ts-3.ts.mdx
+++ b/docs/snippets/vue/login-form-with-play-function.ts-3.ts.mdx
@@ -1,4 +1,4 @@
-```js
+```ts
// LoginForm.stories.ts
import { userEvent, within } from '@storybook/testing-library';
@@ -7,45 +7,58 @@ import { expect } from '@storybook/jest';
import LoginForm from './LoginForm.vue';
-import { Meta, StoryFn } from '@storybook/vue3';
+import type { Meta, Story } from '@storybook/vue3';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Form',
component: LoginForm,
} as Meta;
-const Template: StoryFn = (args) => ({
- components: { LoginForm },
- setup() {
- return args;
- },
- template: '',
-});
-
-export const EmptyForm = Template.bind({});
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const EmptyForm: Story = {
+ render: (args) => ({
+ components: { LoginForm },
+ setup() {
+ return args;
+ },
+ template: '',
+ }),
+};
-export const FilledForm = Template.bind({});
-FilledForm.play = async ({ canvasElement }) => {
- // Starts querying the component from its root element
- const canvas = within(canvasElement);
+export const FilledForm: Story = {
+ render: (args) => ({
+ components: { LoginForm },
+ setup() {
+ return args;
+ },
+ template: '',
+ }),
+ 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/vue/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/vue/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/vue/mdx-canvas-multiple-stories.mdx-2.mdx.mdx b/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-2.mdx.mdx
index 32349dcf0594..3770bc3373f1 100644
--- a/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-2.mdx.mdx
@@ -7,11 +7,11 @@ import Badge from './Badge.vue';
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { Badge },
- template: '',
-});
+
({
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { Badge },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-3.mdx.mdx b/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-3.mdx.mdx
index 9acb775a0b80..49945de46736 100644
--- a/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/mdx-canvas-multiple-stories.mdx-3.mdx.mdx
@@ -7,13 +7,11 @@ import Badge from './Badge.vue';
-export const Template = (args) => ({
- components: { Badge },
- setup() {
- return { args };
- },
- template: '',
-});
+
({
args={{
status: 'warning',
label: 'Warning',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Badge },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-alt-queries.js.mdx b/docs/snippets/vue/my-component-play-function-alt-queries.js.mdx
index 511ad5034d8b..e08ee1f538e0 100644
--- a/docs/snippets/vue/my-component-play-function-alt-queries.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-alt-queries.js.mdx
@@ -7,27 +7,37 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'QueryMethods',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
-
-export const ExampleWithRole = Template.bind({});
-ExampleWithRole.play = async () => {
- // See https://storybook.js.org/docs/vue/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 }));
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleWithRole = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/vue/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 = 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 = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ 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/vue/my-component-play-function-alt-queries.mdx.mdx b/docs/snippets/vue/my-component-play-function-alt-queries.mdx.mdx
index e7cfac89bcfc..eb46c3de5a75 100644
--- a/docs/snippets/vue/my-component-play-function-alt-queries.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-alt-queries.mdx.mdx
@@ -9,26 +9,29 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
+
- {
- // See https://storybook.js.org/docs/vue/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({})}
-
-
- {
- // The play function interacts with the component and looks for the text
+ play={ async () => {
+ // See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ await userEvent.click(screen.getByRole('button'));
+ }}
+ render={() => ({
+ components: { MyComponent },
+ template: '',
+ })} />
+ {
await screen.findByText('example string');
- }}>
- {Template.bind({})}
-
+ }}
+ render={() => ({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-composition.js.mdx b/docs/snippets/vue/my-component-play-function-composition.js.mdx
index 3f98c21f192c..f8476bdb8e60 100644
--- a/docs/snippets/vue/my-component-play-function-composition.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-composition.js.mdx
@@ -7,33 +7,48 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
-
-export const FirstStory = Template.bind({});
-FirstStory.play = async () => {
- userEvent.type(screen.getByTestId('an-element'), 'example-value');
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const FirstStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ userEvent.type(screen.getByTestId('an-element'), 'example-value');
+ },
};
-export const SecondStory = Template.bind({});
-SecondStory.play = async () => {
- await userEvent.type(screen.getByTestId('other-element'), 'another value');
+export const SecondStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ await userEvent.type(screen.getByTestId('other-element'), 'another value');
+ },
};
-export const CombinedStories = 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 = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ 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/vue/my-component-play-function-waitfor.js.mdx b/docs/snippets/vue/my-component-play-function-waitfor.js.mdx
index dcc1bbba2447..afe123c71c7e 100644
--- a/docs/snippets/vue/my-component-play-function-waitfor.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-waitfor.js.mdx
@@ -7,34 +7,39 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithAsync',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
-
-export const ExampleAsyncStory = Template.bind({});
-ExampleAsyncStory.play = async () => {
- const Input = screen.getByLabelText('Username', {
- selector: 'input',
- });
-
- await userEvent.type(Input, 'WrongInput', {
- delay: 100,
- });
-
- // See https://storybook.js.org/docs/vue/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'));
- });
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleAsyncStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ const exampleElement = screen.getByLabelText('example-element', {
+ selector: 'input',
+ });
+
+ // The delay option set the ammount of milliseconds between characters being typed
+ await userEvent.type(exampleElement, 'WrongInput', {
+ delay: 100,
+ });
+ // See https://storybook.js.org/docs/7.0/vue/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'));
+ });
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-waitfor.mdx.mdx b/docs/snippets/vue/my-component-play-function-waitfor.mdx.mdx
index 2767f7a0285c..b1622949bd40 100644
--- a/docs/snippets/vue/my-component-play-function-waitfor.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-waitfor.mdx.mdx
@@ -9,14 +9,10 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
{
+ play={ async () => {
const Input = screen.getByLabelText('Username', {
selector: 'input',
});
@@ -25,14 +21,16 @@ export const Template = (args) => ({
delay: 100,
});
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/vue/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={() => ({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-canvas.js.mdx b/docs/snippets/vue/my-component-play-function-with-canvas.js.mdx
index af3918404fc9..c1ecae5aabfa 100644
--- a/docs/snippets/vue/my-component-play-function-with-canvas.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-canvas.js.mdx
@@ -7,25 +7,30 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithCanvasElement',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async ({ canvasElement }) => {
+ // Assigns canvas to the component root element
+ const canvas = within(canvasElement);
-export const ExampleStory = 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.type(canvas.getByTestId('another-element'), 'something else');
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-canvas.mdx.mdx b/docs/snippets/vue/my-component-play-function-with-canvas.mdx.mdx
index 4d2c1d9b0bfd..75e9c8b2c73c 100644
--- a/docs/snippets/vue/my-component-play-function-with-canvas.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-canvas.mdx.mdx
@@ -9,21 +9,24 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
+
{
+ 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'));
- }}>
- {Template.bind({})}
-
+ }}
+ render={() => ({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-clickevent.js.mdx b/docs/snippets/vue/my-component-play-function-with-clickevent.js.mdx
index c51f1e86af46..c187bad1f38a 100644
--- a/docs/snippets/vue/my-component-play-function-with-clickevent.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-clickevent.js.mdx
@@ -7,27 +7,37 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ClickExamples',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
-
-export const ClickExample = Template.bind({});
-ClickExample.play = async () => {
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
- await userEvent.click(screen.getByRole('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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ClickExample = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ await userEvent.click(screen.getByRole('button'));
+ },
};
-export const FireEventExample = Template.bind({});
-FireEventExample.play = async () => {
- // See https://storybook.js.org/docs/vue/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 = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ // See https://storybook.js.org/docs/7.0/vue/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/vue/my-component-play-function-with-clickevent.mdx.mdx b/docs/snippets/vue/my-component-play-function-with-clickevent.mdx.mdx
index 15f8de3cb0fa..f0139a13bc10 100644
--- a/docs/snippets/vue/my-component-play-function-with-clickevent.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-clickevent.mdx.mdx
@@ -9,26 +9,31 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
+
{
- // See https://storybook.js.org/docs/vue/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/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
await userEvent.click(screen.getByRole('button'));
- }}>
- {Template.bind({})}
-
+ }}
+ render={()=>({
+ components: { MyComponent },
+ template: '',
+ })} />
{
- // See https://storybook.js.org/docs/vue/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/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={()=>({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-delay.js.mdx b/docs/snippets/vue/my-component-play-function-with-delay.js.mdx
index 2d1c49c9ac7f..f653741346ee 100644
--- a/docs/snippets/vue/my-component-play-function-with-delay.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-delay.js.mdx
@@ -7,30 +7,35 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithDelay',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const DelayedStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ const exampleElement = screen.getByLabelText('example-element');
-export const DelayedStory = Template.bind({});
-DelayedStory.play = async () => {
- const exampleElement= screen.getByLabelText('example-element');
+ // The delay option set the ammount of milliseconds between characters being typed
+ await userEvent.type(exampleElement, 'random string', {
+ delay: 100,
+ });
- // The delay option set the amount 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,
+ });
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-delay.mdx.mdx b/docs/snippets/vue/my-component-play-function-with-delay.mdx.mdx
index 162a4e518842..b48c3eb4a727 100644
--- a/docs/snippets/vue/my-component-play-function-with-delay.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-delay.mdx.mdx
@@ -9,14 +9,15 @@ import MyComponent from './MyComponent.vue';
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
+
{
+ play={ async () => {
const exampleElement= screen.getByLabelText('example-element');
// The delay option set the amount of milliseconds between characters being typed
@@ -28,7 +29,9 @@ const Template = (args) => ({
await userEvent.type(AnotherExampleElement, 'another random string', {
delay: 100,
});
- }}>
- {Template.bind({})}
-
+ }}
+ render={()=>({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-selectevent.js.mdx b/docs/snippets/vue/my-component-play-function-with-selectevent.js.mdx
index a72f05e4fed6..f62f6b8b2058 100644
--- a/docs/snippets/vue/my-component-play-function-with-selectevent.js.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-selectevent.js.mdx
@@ -7,12 +7,11 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'WithSelectEvent',
component: MyComponent,
-
};
// Custom function to emulate a pause
@@ -20,21 +19,26 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
-const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
-
-export const ExampleChangeEvent = Template.bind({});
-ExampleChangeEvent.play = async () => {
- const select = screen.getByRole('listbox');
-
- await userEvent.selectOptions(select, ['One Item']);
- await sleep(2000);
-
- await userEvent.selectOptions(select, ['Another Item']);
- await sleep(2000);
-
- await userEvent.selectOptions(select, ['Yet another item']);
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleChangeEvent = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ play: async () => {
+ const select = screen.getByRole('listbox');
+
+ await userEvent.selectOptions(select, ['One Item']);
+ await sleep(2000);
+
+ await userEvent.selectOptions(select, ['Another Item']);
+ await sleep(2000);
+
+ await userEvent.selectOptions(select, ['Yet another item']);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-play-function-with-selectevent.mdx.mdx b/docs/snippets/vue/my-component-play-function-with-selectevent.mdx.mdx
index 60154d1ad9c7..edac1d7cd7cb 100644
--- a/docs/snippets/vue/my-component-play-function-with-selectevent.mdx.mdx
+++ b/docs/snippets/vue/my-component-play-function-with-selectevent.mdx.mdx
@@ -15,10 +15,11 @@ export const sleep= (ms) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
-export const Template = (args) => ({
- components: { MyComponent },
- template: '',
-});
+
({
await userEvent.selectOptions(select, ['Yet another item']);
- }}>
- {Template.bind({})}
-
+ }}
+ render={()=>({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-basic-and-props.js.mdx b/docs/snippets/vue/my-component-story-basic-and-props.js.mdx
index 0f0d9b9ac2d5..0ae747854f0e 100644
--- a/docs/snippets/vue/my-component-story-basic-and-props.js.mdx
+++ b/docs/snippets/vue/my-component-story-basic-and-props.js.mdx
@@ -5,20 +5,24 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Path/To/MyComponent',
component: MyComponent,
};
-export const Basic = () => ({
- components: { MyComponent },
- template: '',
-});
+export const Basic = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+};
-export const WithProp = () => ({
- components: { MyComponent },
+export const WithProp = {
+ render: () => ({
+ components: { MyComponent },
template: '',
-});
+ }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-configure-viewports.js.mdx b/docs/snippets/vue/my-component-story-configure-viewports.js.mdx
index c356aaf70e3d..4d5538c3552d 100644
--- a/docs/snippets/vue/my-component-story-configure-viewports.js.mdx
+++ b/docs/snippets/vue/my-component-story-configure-viewports.js.mdx
@@ -7,9 +7,9 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
parameters: {
@@ -24,13 +24,20 @@ export default {
},
};
-export const MyStory = () => ({
- components: { MyComponent },
- template: '',
-});
-MyStory.parameters = {
- viewport: {
- defaultViewport: 'iphonex'
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const MyStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ parameters: {
+ viewport: {
+ defaultViewport: 'iphonex',
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-configure-viewports.mdx.mdx b/docs/snippets/vue/my-component-story-configure-viewports.mdx.mdx
index 9dbf1c2c759e..b87b7c293fdd 100644
--- a/docs/snippets/vue/my-component-story-configure-viewports.mdx.mdx
+++ b/docs/snippets/vue/my-component-story-configure-viewports.mdx.mdx
@@ -18,17 +18,21 @@ import MyComponent from './MyComponent.vue';
component={MyComponent}
/>
+
+
- {() => {
- return {
- template: ``,
- };
}}
-
+ render={()=>({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-use-globaltype.js.mdx b/docs/snippets/vue/my-component-story-use-globaltype.js.mdx
index c40b18ea44b5..d7dc941bface 100644
--- a/docs/snippets/vue/my-component-story-use-globaltype.js.mdx
+++ b/docs/snippets/vue/my-component-story-use-globaltype.js.mdx
@@ -5,9 +5,9 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
@@ -27,10 +27,17 @@ const getCaptionForLocale = (locale) => {
}
};
-export const StoryWithLocale = (args, { globals: { locale } }) => {
- const caption = getCaptionForLocale(locale);
- return {
- template: `
${caption}
`,
- };
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const StoryWithLocale = {
+ render: (args, { globals: { locale } }) => {
+ const caption = getCaptionForLocale(locale);
+ return {
+ template: `
`,
};
- }}
-
+ }} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-with-nonstory.2.js.mdx b/docs/snippets/vue/my-component-story-with-nonstory.2.js.mdx
index 4627965fe1ac..1c756ffc7701 100644
--- a/docs/snippets/vue/my-component-story-with-nonstory.2.js.mdx
+++ b/docs/snippets/vue/my-component-story-with-nonstory.2.js.mdx
@@ -7,10 +7,10 @@ import someData from './data.json';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'MyComponent',
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'MyComponent',
component: MyComponent,
includeStories: ['SimpleStory', 'ComplexStory'],
excludeStories: /.*Data$/, // π Storybook ignores anything that contains Data
@@ -19,21 +19,30 @@ export default {
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
-
-const Template = (args, { argTypes }) => ({
- components: { MyComponent },
- props: Object.keys(argTypes),
- template: ``,
-});
-
-
-export const SimpleStory = Template.bind({});
-SimpleStory,args = {
- data: simpleData,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const SimpleStory = {
+ render: (args, { argTypes }) => ({
+ components: { MyComponent },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+ args: {
+ data: simpleData,
+ },
};
-export const ComplexStory = Template.bind({});
-ComplexStory,args = {
- data: complexData,
+export const ComplexStory = {
+ render: (args, { argTypes }) => ({
+ components: { MyComponent },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+ args: {
+ data: complexData,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-story-with-nonstory.3.js.mdx b/docs/snippets/vue/my-component-story-with-nonstory.3.js.mdx
index 25ea9cf96b39..539600f2ee9a 100644
--- a/docs/snippets/vue/my-component-story-with-nonstory.3.js.mdx
+++ b/docs/snippets/vue/my-component-story-with-nonstory.3.js.mdx
@@ -7,10 +7,10 @@ import someData from './data.json';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
- title: 'MyComponent',
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'MyComponent',
component: MyComponent,
includeStories: ['SimpleStory', 'ComplexStory'],
excludeStories: /.*Data$/, // π Storybook ignores anything that contains Data
@@ -19,21 +19,34 @@ export default {
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
-const Template = (args) => ({
- components: { MyComponent },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const SimpleStory = {
+ render: (args) => ({
+ components: { MyComponent },
+ setup() {
+ return { args };
+ },
+ template: ``,
+ }),
+ args: {
+ data: simpleData,
},
- template: ``,
-});
-
-export const SimpleStory = Template.bind({});
-SimpleStory.args = {
- data: simpleData,
};
-export const ComplexStory = Template.bind({});
-ComplexStory.args = {
- data: complexData,
+export const ComplexStory = {
+ render: (args) => ({
+ components: { MyComponent },
+ setup() {
+ return { args };
+ },
+ template: ``,
+ }),
+ args: {
+ data: complexData,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-with-env-variables.2.js.mdx b/docs/snippets/vue/my-component-with-env-variables.2.js.mdx
index e52e2a3bf63b..8186f3f7ee3b 100644
--- a/docs/snippets/vue/my-component-with-env-variables.2.js.mdx
+++ b/docs/snippets/vue/my-component-with-env-variables.2.js.mdx
@@ -5,21 +5,26 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
-const Template = (args, { argTypes }) => ({
- components: { MyComponent },
- props: Object.keys(argTypes),
- template: '',
-});
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: (args, { argTypes }) => ({
+ components: { MyComponent },
+ props: Object.keys(argTypes),
+ template: ``,
+ }),
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-with-env-variables.3.js.mdx b/docs/snippets/vue/my-component-with-env-variables.3.js.mdx
index e910c0d8e448..85f983d25af2 100644
--- a/docs/snippets/vue/my-component-with-env-variables.3.js.mdx
+++ b/docs/snippets/vue/my-component-with-env-variables.3.js.mdx
@@ -5,23 +5,28 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
component: MyComponent,
};
-const Template = (args) => ({
- components: { MyComponent },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: (args) => ({
+ components: { MyComponent },
+ setup() {
+ return { args };
+ },
+ template: ``,
+ }),
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
},
- template: '',
-});
-
-export const ExampleStory = Template.bind({});
-ExampleStory.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY,
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-with-env-variables.mdx-2.mdx.mdx b/docs/snippets/vue/my-component-with-env-variables.mdx-2.mdx.mdx
index e0521529431e..b86d8d38b61d 100644
--- a/docs/snippets/vue/my-component-with-env-variables.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/my-component-with-env-variables.mdx-2.mdx.mdx
@@ -7,19 +7,22 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args, { argTypes }) => ({
- components: { MyComponent },
- props: Object.keys(argTypes),
- template: '',
-});
+
- {Template.bind({})}
-
+ }}
+ render={(args, { argTypes }) => ({
+ components: { MyComponent },
+ props: Object.keys(argTypes),
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/my-component-with-env-variables.mdx-3.mdx.mdx b/docs/snippets/vue/my-component-with-env-variables.mdx-3.mdx.mdx
index 0f3c843518d3..90a944178731 100644
--- a/docs/snippets/vue/my-component-with-env-variables.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/my-component-with-env-variables.mdx-3.mdx.mdx
@@ -7,21 +7,24 @@ import MyComponent from './MyComponent.vue';
-export const Template = (args) => ({
- components: { MyComponent },
- setup() {
- return { args };
- },
- template: '',
-});
+
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { MyComponent },
+ setup() {
+ return { args };
+ },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-slots.2.js.mdx b/docs/snippets/vue/page-story-slots.2.js.mdx
index ff119043c287..bea8a0bc4711 100644
--- a/docs/snippets/vue/page-story-slots.2.js.mdx
+++ b/docs/snippets/vue/page-story-slots.2.js.mdx
@@ -5,27 +5,32 @@ import Page from './Page.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Page',
component: Page,
};
-const Template = (args, { argTypes }) => ({
- components: { Page },
- props: Object.keys(argTypes),
- template: `
-
-
-
-
-
- `,
-});
-
-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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const CustomFooter = {
+ render: (args, { argTypes }) => ({
+ components: { Page },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+
+ `,
+ }),
+ args: {
+ footer: 'Built with Storybook',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-slots.3.js.mdx b/docs/snippets/vue/page-story-slots.3.js.mdx
index cf8b6b6106a3..42c640d6d786 100644
--- a/docs/snippets/vue/page-story-slots.3.js.mdx
+++ b/docs/snippets/vue/page-story-slots.3.js.mdx
@@ -5,29 +5,34 @@ import Page from './Page.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Page',
component: Page,
};
-const Template = (args) => ({
- components: { Page },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const CustomFooter = {
+ render: (args) => ({
+ components: { Page },
+ setup() {
+ return { args };
+ },
+ template: `
+
+
+
+
+
+ `,
+ }),
+ args: {
+ footer: 'Built with Storybook',
},
- template: `
-
-
-
-
-
- `,
-});
-
-export const CustomFooter = Template.bind({});
-CustomFooter.args = {
- footer: 'Built with Storybook',
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-slots.mdx-2.mdx.mdx b/docs/snippets/vue/page-story-slots.mdx-2.mdx.mdx
index b6ce77d8a2f6..20150162787a 100644
--- a/docs/snippets/vue/page-story-slots.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/page-story-slots.mdx-2.mdx.mdx
@@ -7,23 +7,26 @@ import Page from './Page.vue';
-export const Template = (args, { argTypes }) => ({
- components: { Page },
- props: Object.keys(argTypes),
- template: `
-
-
-
-
-
- `,
-});
+
Built with Storybook`,
- }}>
- {Template.bind({})}
-
+ footer: `Built with Storybook`,
+ }}
+ render={(args, { argTypes }) => ({
+ components: { Page },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+
+
+ `,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-slots.mdx-3.mdx.mdx b/docs/snippets/vue/page-story-slots.mdx-3.mdx.mdx
index 3567c4b8a6e0..dc304d091cd7 100644
--- a/docs/snippets/vue/page-story-slots.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/page-story-slots.mdx-3.mdx.mdx
@@ -7,25 +7,28 @@ import Page from './Page.vue';
-export const Template = (args) => ({
- components: { Page },
- setup() {
- return { args };
- },
- template: `
-
-
-
-
-
- `,
-});
+
Built with Storybook',
- }}>
- {Template.bind({})}
-
+ }}
+ render={(args) => ({
+ components: { Page },
+ setup() {
+ return { args };
+ },
+ template: `
+
+
+
+
+
+ `,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-with-args-composition.2.js.mdx b/docs/snippets/vue/page-story-with-args-composition.2.js.mdx
index 090392985479..3a3b6c22a700 100644
--- a/docs/snippets/vue/page-story-with-args-composition.2.js.mdx
+++ b/docs/snippets/vue/page-story-with-args-composition.2.js.mdx
@@ -10,23 +10,28 @@ import * as DocumentListStories from './DocumentList.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
-const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { DocumentScreen },
- template: '',
-});
-
-export const Simple = Template.bind({});
-Simple.args = {
- user: PageLayoutStories.Simple.args.user,
- document: DocumentHeaderStories.Simple.args.document,
- subdocuments: DocumentListStories.Simple.args.documents,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Simple = {
+ render: (args, { argTypes }) => ({
+ components: { DocumentScreen },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ user: PageLayoutStories.Simple.args.user,
+ document: DocumentHeaderStories.Simple.args.document,
+ subdocuments: DocumentListStories.Simple.args.documents,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story-with-args-composition.3.js.mdx b/docs/snippets/vue/page-story-with-args-composition.3.js.mdx
index bd47190804e4..d247267a9121 100644
--- a/docs/snippets/vue/page-story-with-args-composition.3.js.mdx
+++ b/docs/snippets/vue/page-story-with-args-composition.3.js.mdx
@@ -10,25 +10,30 @@ import * as DocumentListStories from './DocumentList.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'DocumentScreen',
component: DocumentScreen,
};
-const Template = (args) => ({
- components: { DocumentScreen },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const Simple = {
+ render: (args) => ({
+ components: { DocumentScreen },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ user: PageLayoutStories.Simple.args.user,
+ document: DocumentHeaderStories.Simple.args.document,
+ subdocuments: DocumentListStories.Simple.args.documents,
},
- template: '',
-});
-
-export const Simple = Template.bind({});
-Simple.args = {
- user: PageLayoutStories.Simple.args.user,
- document: DocumentHeaderStories.Simple.args.document,
- subdocuments: DocumentListStories.Simple.args.documents,
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story.2.js.mdx b/docs/snippets/vue/page-story.2.js.mdx
index 59f260eed46e..04352638586d 100644
--- a/docs/snippets/vue/page-story.2.js.mdx
+++ b/docs/snippets/vue/page-story.2.js.mdx
@@ -8,22 +8,26 @@ import * as HeaderStories from './Header.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Page',
component: Page,
};
-
-const Template = (args, { argTypes }) => ({
- components: { Page },
- props: Object.keys(argTypes),
- template: '',
-});
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- ...HeaderStories.LoggedIn.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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const LoggedIn = {
+ render: (args, { argTypes }) => ({
+ components: { Page },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ ...HeaderStories.LoggedIn.args,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/page-story.3.js.mdx b/docs/snippets/vue/page-story.3.js.mdx
index 30b6cb0cb5b8..07368d3cbad9 100644
--- a/docs/snippets/vue/page-story.3.js.mdx
+++ b/docs/snippets/vue/page-story.3.js.mdx
@@ -8,23 +8,28 @@ import * as HeaderStories from './Header.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Page',
component: Page,
};
-const Template = (args) => ({
- components: { Page },
- setup() {
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const LoggedIn = {
+ render: (args) => ({
+ components: { Page },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ ...HeaderStories.LoggedIn.args,
},
- template: '',
-});
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- ...HeaderStories.LoggedIn.args,
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/register-component-with-play-function.js.mdx b/docs/snippets/vue/register-component-with-play-function.js.mdx
index c898c389ff0a..9dc018d2ad58 100644
--- a/docs/snippets/vue/register-component-with-play-function.js.mdx
+++ b/docs/snippets/vue/register-component-with-play-function.js.mdx
@@ -7,28 +7,32 @@ import RegistrationForm from './RegistrationForm.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'RegistrationForm',
component: RegistrationForm,
};
-const Template = (args) => ({
- components: { RegistrationForm },
- template: '',
-});
-
-export const FilledForm = Template.bind({});
-FilledForm.play = async () => {
- const emailInput = screen.getByLabelText('email', {
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const FilledForm = {
+ render: () => ({
+ components: { RegistrationForm },
+ template: '',
+ }),
+ play: async () => {
+ const emailInput = screen.getByLabelText('email', {
selector: 'input',
});
await userEvent.type(emailInput, 'example-email@email.com', {
delay: 100,
});
-
+
const passwordInput = screen.getByLabelText('password', {
selector: 'input',
});
@@ -36,9 +40,11 @@ FilledForm.play = async () => {
await userEvent.type(passwordInput, 'ExamplePassword', {
delay: 100,
});
-
- // See https://storybook.js.org/docs/vue/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/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ const submitButton = screen.getByRole('button');
+
+ await userEvent.click(submitButton);
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/register-component-with-play-function.mdx.mdx b/docs/snippets/vue/register-component-with-play-function.mdx.mdx
index f85c8b1afa87..d133cc0e8fbd 100644
--- a/docs/snippets/vue/register-component-with-play-function.mdx.mdx
+++ b/docs/snippets/vue/register-component-with-play-function.mdx.mdx
@@ -9,14 +9,15 @@ import RegistrationForm from './RegistrationForm.vue';
-export const Template = (args) => ({
- components: { RegistrationForm },
- template: '',
-});
+
{
+ play={ async () => {
const emailInput = screen.getByLabelText('email', {
selector: 'input',
});
@@ -33,10 +34,12 @@ export const Template = (args) => ({
delay: 100,
});
- // See https://storybook.js.org/docs/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
+ // See https://storybook.js.org/docs/7.0/vue/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={() => ({
+ components: { RegistrationForm },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/storybook-addon-a11y-disable.js.mdx b/docs/snippets/vue/storybook-addon-a11y-disable.js.mdx
index 7be7ee2c227c..0fde60b15579 100644
--- a/docs/snippets/vue/storybook-addon-a11y-disable.js.mdx
+++ b/docs/snippets/vue/storybook-addon-a11y-disable.js.mdx
@@ -5,23 +5,28 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Disable a11y addon',
component: MyComponent,
};
-const Template = () => ({
- components: { MyComponent },
- template: '',
-});
-
-export const NonA11yStory = Template.bind({});
-NonA11yStory.parameters = {
- a11y: {
- // This option disables all a11y checks on this story
- disable: 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const NonA11yStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ parameters: {
+ a11y: {
+ // This option disables all a11y checks on this story
+ disable: true,
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/storybook-addon-a11y-story-config.js.mdx b/docs/snippets/vue/storybook-addon-a11y-story-config.js.mdx
index 9e9addbb4ac7..76609c6f8423 100644
--- a/docs/snippets/vue/storybook-addon-a11y-story-config.js.mdx
+++ b/docs/snippets/vue/storybook-addon-a11y-story-config.js.mdx
@@ -5,38 +5,43 @@ import MyComponent from './MyComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Configure a11y addon',
component: MyComponent,
};
-const Template = () => ({
- components: { MyComponent },
- template: '',
-});
-
-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,
- },
- ],
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: () => ({
+ components: { MyComponent },
+ template: '',
+ }),
+ 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/vue/storybook-addon-a11y-story-config.mdx.mdx b/docs/snippets/vue/storybook-addon-a11y-story-config.mdx.mdx
index e76f552f1d4e..e41bc9806563 100644
--- a/docs/snippets/vue/storybook-addon-a11y-story-config.mdx.mdx
+++ b/docs/snippets/vue/storybook-addon-a11y-story-config.mdx.mdx
@@ -9,10 +9,11 @@ import MyComponent from './MyComponent.vue';
title="Configure a11y addon"
component={MyComponent} />
-export const Template = () => ({
- components: { MyComponent },
- template: '',
-});
+
({
options: {},
manual: true,
},
- }}>
- {Template.bind({})}
-
+ }}
+ render={() => ({
+ components: { MyComponent },
+ template: '',
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/table-story-fully-customize-controls.2.js.mdx b/docs/snippets/vue/table-story-fully-customize-controls.2.js.mdx
index ade9b4a326ca..b15cca26de0d 100644
--- a/docs/snippets/vue/table-story-fully-customize-controls.2.js.mdx
+++ b/docs/snippets/vue/table-story-fully-customize-controls.2.js.mdx
@@ -5,34 +5,40 @@ import Table from './Table.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Custom Table',
component: Table,
};
-const TableStory = (args, { argTypes }) => ({
- components: { Table },
- props: Object.keys(argTypes),
- template: `
-
-
-
- {{ data[idx1][idx2] }}
-
-
-
`,
-});
-
-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',
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const TableStory = {
+ render: (args, { argTypes }) => ({
+ components: { Table },
+ props: Object.keys(argTypes),
+ template: `
+
+
+
+ {{ data[idx1][idx2] }}
+
+
+
+ `,
+ }),
+ 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',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/table-story-fully-customize-controls.3.js.mdx b/docs/snippets/vue/table-story-fully-customize-controls.3.js.mdx
index 0623762a7da3..c80f5663c165 100644
--- a/docs/snippets/vue/table-story-fully-customize-controls.3.js.mdx
+++ b/docs/snippets/vue/table-story-fully-customize-controls.3.js.mdx
@@ -5,37 +5,42 @@ import Table from './Table.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Custom Table',
component: Table,
};
-const TableStory = (args) => ({
- components: { Table },
- setup() {
- return { args };
- },
- template: `
-
-
-
- {{ data[idx1][idx2] }}
-
-
-
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const TableStory = {
+ render: (args) => ({
+ components: { Table },
+ setup() {
+ return { args };
+ },
+ template: `
+
+
+
+ {{ data[idx1][idx2] }}
+
+
+
`,
-});
-
-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: {
+ //π 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',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/table-story-fully-customize-controls.mdx-2.mdx.mdx b/docs/snippets/vue/table-story-fully-customize-controls.mdx-2.mdx.mdx
index ed39b60e5e4e..fc432b4e13ad 100644
--- a/docs/snippets/vue/table-story-fully-customize-controls.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/table-story-fully-customize-controls.mdx-2.mdx.mdx
@@ -7,18 +7,11 @@ import Table from './Table.vue';
-export const TableStory = (args, { argTypes }) => ({
- components: { Table },
- props: Object.keys(argTypes),
- template: `
-
`,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/your-component-with-decorator.js.mdx b/docs/snippets/vue/your-component-with-decorator.js.mdx
index 15f560e26f4a..d6bd32c0d686 100644
--- a/docs/snippets/vue/your-component-with-decorator.js.mdx
+++ b/docs/snippets/vue/your-component-with-decorator.js.mdx
@@ -5,7 +5,7 @@ import YourComponent from './YourComponent.vue';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'YourComponent',
diff --git a/docs/snippets/vue/your-component.2.js.mdx b/docs/snippets/vue/your-component.2.js.mdx
index 4e31094af482..faf3cd115f9c 100644
--- a/docs/snippets/vue/your-component.2.js.mdx
+++ b/docs/snippets/vue/your-component.2.js.mdx
@@ -6,22 +6,26 @@ import YourComponent from './YourComponent.vue';
//π 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/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = (args, { argTypes }) => ({
- components: { YourComponent },
- props: Object.keys(argTypes),
- template: '',
-});
-
-export const FirstStory = Template.bind({});
-FirstStory.args = {
- //π The args you need here will depend on your component
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const FirstStory = {
+ render: (args, { argTypes }) => ({
+ components: { YourComponent },
+ props: Object.keys(argTypes),
+ template: '',
+ }),
+ args: {
+ //π The args you need here will depend on your component
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/your-component.3.js.mdx b/docs/snippets/vue/your-component.3.js.mdx
index 9acd73d1c783..02dfb7653b4d 100644
--- a/docs/snippets/vue/your-component.3.js.mdx
+++ b/docs/snippets/vue/your-component.3.js.mdx
@@ -6,26 +6,28 @@ import YourComponent from './YourComponent.vue';
//π 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/vue/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
component: YourComponent,
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = (args) => ({
- components: { YourComponent },
- setup() {
- //π The args will now be passed down to the template
- return { 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/vue/api/csf
+ * to learn how to use render functions.
+ */
+export const FirstStory = {
+ render: (args) => ({
+ components: { YourComponent },
+ setup() {
+ return { args };
+ },
+ template: '',
+ }),
+ args: {
+ //π The args you need here will depend on your component
},
- template: '',
-});
-
-export const FirstStory = Template.bind({});
-
-FirstStory.args = {
- /* π The args you need here will depend on your component */
};
```
\ No newline at end of file
diff --git a/docs/snippets/vue/your-component.mdx-2.mdx.mdx b/docs/snippets/vue/your-component.mdx-2.mdx.mdx
index 8250437df8f8..e2f2af44bb57 100644
--- a/docs/snippets/vue/your-component.mdx-2.mdx.mdx
+++ b/docs/snippets/vue/your-component.mdx-2.mdx.mdx
@@ -8,17 +8,14 @@ import YourComponent from './YourComponent.vue';
-
-export const Template = (args, { argTypes }) => ({
- props: Object.keys(argTypes),
- components: { YourComponent },
- template: ``,
-});
- {Template.bind({})}
-
+ args={{}}
+ render={(args, { argTypes }) => ({
+ props: Object.keys(argTypes),
+ components: { YourComponent },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/vue/your-component.mdx-3.mdx.mdx b/docs/snippets/vue/your-component.mdx-3.mdx.mdx
index f5c6d9d6f784..40643976fa13 100644
--- a/docs/snippets/vue/your-component.mdx-3.mdx.mdx
+++ b/docs/snippets/vue/your-component.mdx-3.mdx.mdx
@@ -8,19 +8,15 @@ import YourComponent from './YourComponent.vue';
-
-export const Template = (args) => ({
- components: { YourComponent },
- setup() {
- return { args };
- },
- template: ``,
-});
-
- {Template.bind({})}
-
+ args={{}}
+ render={(args) => ({
+ components: { YourComponent },
+ setup() {
+ return { args };
+ },
+ template: ``,
+ })} />
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-group-story.js.mdx b/docs/snippets/web-components/button-group-story.js.mdx
index a73c25d09706..be5be5ad4afc 100644
--- a/docs/snippets/web-components/button-group-story.js.mdx
+++ b/docs/snippets/web-components/button-group-story.js.mdx
@@ -1,26 +1,30 @@
```js
// demo-button-group.stories.js
-import { html } from 'lit-html';
-
-import './demo-button-group';
+import { ButtonGroup } from './demo-button-group';
//π Imports the Button stories
import * as ButtonStories from './demo-button.stories';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'ButtonGroup',
};
-const Template = ({ buttons, orientation }) => {
- return html`
-
- `;
-};
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
-export const Pair = Template.bind({});
-Pair.args = {
- buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
- orientation: 'horizontal',
+export const Pair = {
+ render: (args) => ButtonGroup(args),
+ args: {
+ buttons: [{ ...ButtonStories.Primary.args }, { ...ButtonStories.Secondary.args }],
+ orientation: 'horizontal',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-component-args-primary.js.mdx b/docs/snippets/web-components/button-story-component-args-primary.js.mdx
index 58a22394f3be..00f18b087cc2 100644
--- a/docs/snippets/web-components/button-story-component-args-primary.js.mdx
+++ b/docs/snippets/web-components/button-story-component-args-primary.js.mdx
@@ -1,11 +1,13 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
-
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
//π Creates specific argTypes
argTypes: {
@@ -17,5 +19,12 @@ export default {
},
};
-export const Primary = ({ primary }) => html``;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: ({ primary }) => Button({ primary }),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-component-decorator.js.mdx b/docs/snippets/web-components/button-story-component-decorator.js.mdx
index 7d1de7f44e5b..d48c3b57a715 100644
--- a/docs/snippets/web-components/button-story-component-decorator.js.mdx
+++ b/docs/snippets/web-components/button-story-component-decorator.js.mdx
@@ -6,9 +6,20 @@ import { html } from 'lit-html';
import './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
decorators: [(story) => html`
${story()}
`],
};
-export const Primary = () => html``;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => html``,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-decorator.js.mdx b/docs/snippets/web-components/button-story-decorator.js.mdx
index bba7d7bf7539..affc293914c9 100644
--- a/docs/snippets/web-components/button-story-decorator.js.mdx
+++ b/docs/snippets/web-components/button-story-decorator.js.mdx
@@ -1,15 +1,26 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
+import { Button } from './demo-button';
-import './demo-button';
+import { html } from 'lit-html';
export default {
- title: 'Button',
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
};
-export const Primary = () => html`Hello World`;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
-Primary.decorators = [(story) => html`
`],
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-default-export-with-component.js.mdx b/docs/snippets/web-components/button-story-default-export-with-component.js.mdx
index 9c5daceab5fd..d0319e8ce8a3 100644
--- a/docs/snippets/web-components/button-story-default-export-with-component.js.mdx
+++ b/docs/snippets/web-components/button-story-default-export-with-component.js.mdx
@@ -1,9 +1,13 @@
```js
// demo-button.stories.js
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
};
-```
+```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-rename-story.js.mdx b/docs/snippets/web-components/button-story-rename-story.js.mdx
index bf448006efa3..02576065c63b 100644
--- a/docs/snippets/web-components/button-story-rename-story.js.mdx
+++ b/docs/snippets/web-components/button-story-rename-story.js.mdx
@@ -1,15 +1,23 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
-
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
};
-export const Primary = () => html``;
-
-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/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ name: 'I am the primary',
+ render: (args) => Button(args),
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-using-args.js.mdx b/docs/snippets/web-components/button-story-using-args.js.mdx
index a76dcb9266fd..ef689a882c1f 100644
--- a/docs/snippets/web-components/button-story-using-args.js.mdx
+++ b/docs/snippets/web-components/button-story-using-args.js.mdx
@@ -1,25 +1,43 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
-
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = ({ background, label }) =>
- html``;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
-//π Each story then reuses that template
-export const Primary = Template.bind({});
-Primary.args = { background: '#ff0', label: 'Button' };
+export const Primary = {
+ render: (args) => Button(args),
+ args: {
+ background: '#ff0',
+ label: 'Button',
+ },
+};
-export const Secondary = Template.bind({});
-Secondary.args = { ...Primary.args, label: 'ππππ―' };
+export const Secondary = {
+ render: (args) => Button(args),
+ args: {
+ ...Primary.args,
+ label: 'ππππ―',
+ },
+};
-export const Tertiary = Template.bind({});
-Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+export const Tertiary = {
+ render: (args) => Button(args),
+ args: {
+ ...Primary.args,
+ label: 'ππππ€',
+ },
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-with-args.js.mdx b/docs/snippets/web-components/button-story-with-args.js.mdx
index 0ab143262f91..deed847c6c3b 100644
--- a/docs/snippets/web-components/button-story-with-args.js.mdx
+++ b/docs/snippets/web-components/button-story-with-args.js.mdx
@@ -1,23 +1,26 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
-
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
};
-//π We create a βtemplateβ of how args map to rendering
-const Template = ({ primary, label }) =>
- html``;
-
-//π 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/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: (args) => Button(args),
+ args: {
+ primary: true,
+ label: 'Button',
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story-with-blue-args.js.mdx b/docs/snippets/web-components/button-story-with-blue-args.js.mdx
index 25ae55d76e7f..3c9621d38cf8 100644
--- a/docs/snippets/web-components/button-story-with-blue-args.js.mdx
+++ b/docs/snippets/web-components/button-story-with-blue-args.js.mdx
@@ -1,11 +1,13 @@
```js
// demo-button.stories.js
-import { html } from 'lit-html';
-
-import './demo-button';
+import { Button } from './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
//π Creates specific parameters for the story
parameters: {
diff --git a/docs/snippets/web-components/button-story-with-emojis.js.mdx b/docs/snippets/web-components/button-story-with-emojis.js.mdx
index b02251d5283b..1d2cd87784b8 100644
--- a/docs/snippets/web-components/button-story-with-emojis.js.mdx
+++ b/docs/snippets/web-components/button-story-with-emojis.js.mdx
@@ -1,4 +1,4 @@
-```ts
+```js
// demo-button.stories.js
import { html } from 'lit-html';
@@ -6,9 +6,27 @@ import { html } from 'lit-html';
import './demo-button';
export default {
- title: 'Button',
-}
-export const Primary = () => html``;
-export const Secondary = () => html``;
-export const Tertiary = () => html``;
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: '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/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => html``,
+};
+
+export const Secondary = {
+ render: () => html``,
+};
+
+export const Tertiary = {
+ render: () => html``,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/button-story.js.mdx b/docs/snippets/web-components/button-story.js.mdx
index 85b6bb491f9d..e3ccba0a62e4 100644
--- a/docs/snippets/web-components/button-story.js.mdx
+++ b/docs/snippets/web-components/button-story.js.mdx
@@ -6,8 +6,19 @@ import { html } from 'lit-html';
import './demo-button';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'Button',
};
-export const Primary = () => html``;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Primary = {
+ render: () => html``,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/component-story-with-custom-render-function.js.mdx b/docs/snippets/web-components/component-story-with-custom-render-function.js.mdx
new file mode 100644
index 000000000000..9893084eb937
--- /dev/null
+++ b/docs/snippets/web-components/component-story-with-custom-render-function.js.mdx
@@ -0,0 +1,30 @@
+```js
+// MyComponent.stories.js
+
+import { html } from 'lit-html';
+
+import './Layout';
+import './MyComponent';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'MyComponent',
+};
+
+// This story uses a render function to fully control how the component renders.
+export const Example = {
+ render: () => html`
+
+
+
Example
+
+
+
+
+
+ `,
+};
+```
\ No newline at end of file
diff --git a/docs/snippets/web-components/list-story-expanded.js.mdx b/docs/snippets/web-components/list-story-expanded.js.mdx
index 88a988979f20..2d34e8cb48d9 100644
--- a/docs/snippets/web-components/list-story-expanded.js.mdx
+++ b/docs/snippets/web-components/list-story-expanded.js.mdx
@@ -7,26 +7,35 @@ import './demo-list';
import './demo-list-item';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
};
-export const Empty = (args) => html``;
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const Empty = {
+ render: () => html``,
+};
-export const OneItem = (args) => {
- return html`
+export const OneItem = {
+ render: () => html`
- `;
+ `,
};
-export const ManyItems = (args) => {
- return html`
-
-
-
-
-
- `;
+export const ManyItems = {
+ render: () => html`
+
+
+
+ `,
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/list-story-reuse-data.js.mdx b/docs/snippets/web-components/list-story-reuse-data.js.mdx
index 90b453e02fb2..e46cd323079b 100644
--- a/docs/snippets/web-components/list-story-reuse-data.js.mdx
+++ b/docs/snippets/web-components/list-story-reuse-data.js.mdx
@@ -7,19 +7,28 @@ import './demo-list';
import './demo-list-item';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
};
//π We're importing the necessary stories from ListItem
import { Selected, Unselected } from './demo-list-item.stories';
-export const ManyItems = (args) => {
- return html`
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const ManyItems = {
+ render: (args) => html`
- ${Selected({ ...args, ...Selected.args })}
- ${Unselected({ ...args, ...Unselected.args })}
- ${Unselected({ ...args, ...Unselected.args })}
+ ${Selected({ ...args, ...Selected.args })} ${Unselected({ ...args, ...Unselected.args })} ${Unselected(
+ { ...args, ...Unselected.args }
+ )}
- `;
+ `,
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/list-story-starter.js.mdx b/docs/snippets/web-components/list-story-starter.js.mdx
index 58a7a4b1d691..174406588fef 100644
--- a/docs/snippets/web-components/list-story-starter.js.mdx
+++ b/docs/snippets/web-components/list-story-starter.js.mdx
@@ -6,9 +6,15 @@ import { html } from 'lit-html';
import './demo-list';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'List',
};
// Always an empty list, not super interesting
-const Template = (args) => html``
+export const Empty = {
+ render: () => html``,
+};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/list-story-unchecked.js.mdx b/docs/snippets/web-components/list-story-unchecked.js.mdx
index 79946a547334..cd4d7bf3fb9a 100644
--- a/docs/snippets/web-components/list-story-unchecked.js.mdx
+++ b/docs/snippets/web-components/list-story-unchecked.js.mdx
@@ -10,15 +10,22 @@ import { Unchecked } from './my-list-item.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/web-components/configure/overview#configure-story-loading
- * to learn how to generate automatic titles
- */
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'my-list',
};
-export const OneItem = () => html`
-
- ${Unchecked({ ...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/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const OneItem = {
+ render: () => html`
+
+ ${Unchecked({ ...Unchecked.args })}
+
+ `,
+};
```
diff --git a/docs/snippets/web-components/list-story-unchecked.ts.mdx b/docs/snippets/web-components/list-story-unchecked.ts.mdx
index e491afd8c265..11843216e964 100644
--- a/docs/snippets/web-components/list-story-unchecked.ts.mdx
+++ b/docs/snippets/web-components/list-story-unchecked.ts.mdx
@@ -12,7 +12,7 @@ import { Unchecked } from './my-list-item.stories';
export default {
/* π The title prop is optional.
- * See https://storybook.js.org/docs/web-components/configure/overview#configure-story-loading
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'my-list',
diff --git a/docs/snippets/web-components/my-component-story-configure-viewports.js.mdx b/docs/snippets/web-components/my-component-story-configure-viewports.js.mdx
index 4a8b594dc42d..1a12e9d642ea 100644
--- a/docs/snippets/web-components/my-component-story-configure-viewports.js.mdx
+++ b/docs/snippets/web-components/my-component-story-configure-viewports.js.mdx
@@ -1,13 +1,15 @@
```js
// my-component.stories.js
-import { html } from 'lit-html';
-
-import './my-component';
+import { MyComponent } from'./my-component';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
parameters: {
//π The viewports object from the Essentials addon
@@ -20,10 +22,17 @@ export default {
};
};
-export const MyStory = () => html``;
-MyStory.parameters = {
- viewport: {
- defaultViewport: 'iphonex'
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const InitialButton = {
+ render: () => MyComponent(),
+ parameters: {
+ viewport: {
+ defaultViewport: 'iphonex'
+ },
},
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/my-component-story-use-globaltype-backwards-compat.js.mdx b/docs/snippets/web-components/my-component-story-use-globaltype-backwards-compat.js.mdx
index 00291479a6b4..a659bd8a7fc5 100644
--- a/docs/snippets/web-components/my-component-story-use-globaltype-backwards-compat.js.mdx
+++ b/docs/snippets/web-components/my-component-story-use-globaltype-backwards-compat.js.mdx
@@ -3,8 +3,10 @@
import { html } from 'lit-html';
-export const StoryWithLocale = ({ globals: { locale } }) => {
- const caption = getCaptionForLocale(locale);
- return html`
`;
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/my-component-with-env-variables.js.mdx b/docs/snippets/web-components/my-component-with-env-variables.js.mdx
index 5fd5ff24bcb6..b19ba2898945 100644
--- a/docs/snippets/web-components/my-component-with-env-variables.js.mdx
+++ b/docs/snippets/web-components/my-component-with-env-variables.js.mdx
@@ -1,19 +1,25 @@
```js
// my-component.stories.js
-import { html } from 'lit-html';
-
-import './my-component';
+import { MyComponent } from './my-component';
export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'MyComponent',
};
-const Template = ({ propertyA }) => html``;
-
-export const Default = Template.bind({});
-
-Default.args = {
- propertyA: process.env.STORYBOOK_DATA_KEY,
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const ExampleStory = {
+ render: (args) => MyComponent({ propertyA }),
+ args: {
+ propertyA: process.env.STORYBOOK_DATA_KEY,
+ },
};
```
\ No newline at end of file
diff --git a/docs/snippets/web-components/your-component.js.mdx b/docs/snippets/web-components/your-component.js.mdx
index c8461f952f49..cbb4c9c76ca2 100644
--- a/docs/snippets/web-components/your-component.js.mdx
+++ b/docs/snippets/web-components/your-component.js.mdx
@@ -1,22 +1,26 @@
```js
// your-component.stories.js
-import { html } from 'lit-html';
-
-import './your-component';
+import { MyComponent } 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/7.0/web-components/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'YourComponent',
};
-// π We create a βtemplateβ of how args map to rendering
-const Template = ({ aProperty }) => html``;
-
-export const FirstStory = Template.bind({});
-
-FirstStory.args = {
- /* π The args you need here will depend on your component */
- aProperty: 'aProperty'
+/*
+ *π Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/7.0/web-components/api/csf
+ * to learn how to use render functions.
+ */
+export const FirstStory = {
+ render: (args) => MyComponent(args),
+ args: {
+ //π The args you need here will depend on your component
+ },
};
-```
\ No newline at end of file
+```
diff --git a/docs/writing-stories/args.md b/docs/writing-stories/args.md
index 6d10a8faab72..2ee7027d196b 100644
--- a/docs/writing-stories/args.md
+++ b/docs/writing-stories/args.md
@@ -30,7 +30,6 @@ To define the args of a single story, use the `args` CSF story key:
'angular/button-story-with-args.ts.mdx',
'angular/button-story-with-args.mdx.mdx',
'svelte/button-story-with-args.js.mdx',
- 'svelte/button-story-with-args.native-format.mdx',
'svelte/button-story-with-args.mdx.mdx',
'web-components/button-story-with-args.js.mdx',
'html/button-story-with-args.ts.mdx',
@@ -70,7 +69,6 @@ You can also define args at the component level; they will apply to all the comp
'angular/button-story-component-args-primary.ts.mdx',
'angular/button-story-component-args-primary.mdx.mdx',
'svelte/button-story-component-args-primary.js.mdx',
- 'svelte/button-story-component-args-primary.native-format.mdx',
'svelte/button-story-component-args-primary.mdx.mdx',
'web-components/button-story-component-args-primary.js.mdx',
]}
@@ -146,7 +144,6 @@ You can use args in your stories to configure the component's appearance, simila
'vue/page-story-slots.mdx-3.mdx.mdx',
'angular/page-story-slots.ts.mdx',
'angular/page-story-slots.mdx.mdx',
- 'svelte/page-story-slots.native-format.mdx',
]}
/>
diff --git a/docs/writing-stories/decorators.md b/docs/writing-stories/decorators.md
index bc8509b7c2d8..717514e6502b 100644
--- a/docs/writing-stories/decorators.md
+++ b/docs/writing-stories/decorators.md
@@ -26,7 +26,6 @@ Some components require a βharnessβ to render in a useful way. For instance,
'angular/your-component-with-decorator.ts.mdx',
'angular/your-component-with-decorator.mdx.mdx',
'svelte/your-component-with-decorator.js.mdx',
- 'svelte/your-component-with-decorator.native-format.mdx',
'svelte/your-component-with-decorator.mdx.mdx',
'web-components/your-component-with-decorator.js.mdx',
]}
@@ -121,7 +120,6 @@ To define a decorator for all stories of a component, use the `decorators` key o
'angular/button-story-component-decorator.ts.mdx',
'angular/button-story-component-decorator.mdx.mdx',
'svelte/button-story-component-decorator.js.mdx',
- 'svelte/button-story-component-decorator.native-format.mdx',
'svelte/button-story-component-decorator.mdx.mdx',
'web-components/button-story-component-decorator.js.mdx',
]}
diff --git a/docs/writing-stories/introduction.md b/docs/writing-stories/introduction.md
index 15e4c456516b..8ac21987ca01 100644
--- a/docs/writing-stories/introduction.md
+++ b/docs/writing-stories/introduction.md
@@ -59,7 +59,6 @@ Use the _named_ exports of a CSF file to define your componentβs stories. We r
'vue/button-story.ts-3.ts.mdx',
'angular/button-story.ts.mdx',
'svelte/button-story.js.mdx',
- 'svelte/button-story.native-format.mdx',
'web-components/button-story.js.mdx',
'html/button-story.js.mdx',
'html/button-story.ts.mdx',
@@ -98,8 +97,7 @@ You can rename any particular story you need. For instance, to give it a more ac
'react/button-story-rename-story.js.mdx',
'react/button-story-rename-story.ts.mdx',
'vue/button-story-rename-story.js.mdx',
- 'vue/button-story-rename-story.ts-2.ts.mdx',
- 'vue/button-story-rename-story.ts-3.ts.mdx',
+ 'vue/button-story-rename-story.ts.mdx',
'angular/button-story-rename-story.ts.mdx',
'svelte/button-story-rename-story.js.mdx',
'web-components/button-story-rename-story.js.mdx',
@@ -130,7 +128,6 @@ A story is a function that describes how to render a component. You can have mul
'angular/button-story-with-emojis.ts.mdx',
'angular/button-story-with-emojis.mdx.mdx',
'svelte/button-story-with-emojis.js.mdx',
- 'svelte/button-story-with-emojis.native-format.mdx',
'svelte/button-story-with-emojis.mdx.mdx',
'web-components/button-story-with-emojis.js.mdx',
'html/button-story-with-emojis.js.mdx',
@@ -158,7 +155,6 @@ Refine this pattern by introducing `args` for your component's stories. It reduc
'vue/button-story-using-args.ts-3.ts.mdx',
'angular/button-story-using-args.ts.mdx',
'svelte/button-story-using-args.js.mdx',
- 'svelte/button-story-using-args.native-format.mdx',
'web-components/button-story-using-args.js.mdx',
'html/button-story-using-args.js.mdx',
'html/button-story-using-args.ts.mdx',
@@ -167,11 +163,6 @@ Refine this pattern by introducing `args` for your component's stories. It reduc
-
-
-π‘ `Template.bind({})` is a [standard JavaScript technique](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) for making a copy of a function. We copy the `Template` so each exported story can set its own properties on it.
-
-
By introducing args into your component's stories, you're not only reducing the amount of code you need to write, but you're also decreasing data duplication, as shown by spreading the `Primary` story's args into the other stories.
@@ -261,7 +252,6 @@ For instance, suppose you wanted to test your Button component against a differe
'angular/button-story-with-blue-args.ts.mdx',
'angular/button-story-with-blue-args.mdx.mdx',
'svelte/button-story-with-blue-args.js.mdx',
- 'svelte/button-story-with-blue-args.native-format.mdx',
'svelte/button-story-with-blue-args.mdx.mdx',
'web-components/button-story-with-blue-args.js.mdx',
'html/button-story-with-blue-args.js.mdx',
@@ -295,7 +285,6 @@ A simple example is adding padding to a componentβs stories. Accomplish this u
'angular/button-story-component-decorator.ts.mdx',
'angular/button-story-component-decorator.mdx.mdx',
'svelte/button-story-component-decorator.js.mdx',
- 'svelte/button-story-component-decorator.native-format.mdx',
'svelte/button-story-component-decorator.mdx.mdx',
'web-components/button-story-component-decorator.js.mdx',
'html/button-story-component-decorator.js.mdx',
@@ -322,7 +311,6 @@ When building design systems or component libraries, you may have two or more co
'vue/list-story-starter.ts-2.ts.mdx',
'vue/list-story-starter.3.js.mdx',
'vue/list-story-starter.ts-3.ts.mdx',
- 'svelte/list-story-starter.native-format.mdx',
'web-components/list-story-starter.js.mdx',
'html/list-story-starter.js.mdx',
'html/list-story-starter.ts.mdx',
@@ -344,7 +332,6 @@ In such cases, it makes sense to render a different function for each story:
'vue/list-story-expanded.ts-2.ts.mdx',
'vue/list-story-expanded.3.js.mdx',
'vue/list-story-expanded.ts-3.ts.mdx',
- 'svelte/list-story-expanded.native-format.mdx',
'web-components/list-story-expanded.js.mdx',
'html/list-story-expanded.js.mdx',
'html/list-story-expanded.ts.mdx',
diff --git a/docs/writing-stories/parameters.md b/docs/writing-stories/parameters.md
index f7093ef0289c..7758681099dd 100644
--- a/docs/writing-stories/parameters.md
+++ b/docs/writing-stories/parameters.md
@@ -38,7 +38,6 @@ We can set the parameters for all stories of a component using the `parameters`
'angular/button-story-with-blue-args.ts.mdx',
'angular/button-story-with-blue-args.mdx.mdx',
'svelte/button-story-with-blue-args.js.mdx',
- 'svelte/button-story-with-blue-args.native-format.mdx',
'svelte/button-story-with-blue-args.mdx.mdx',
'web-components/button-story-with-blue-args.js.mdx',
]}
diff --git a/docs/writing-stories/play-function.md b/docs/writing-stories/play-function.md
index 0923ee57a2c3..b95c7514ff0f 100644
--- a/docs/writing-stories/play-function.md
+++ b/docs/writing-stories/play-function.md
@@ -55,6 +55,12 @@ Storybook's `play` functions are small code snippets that run once the story fin
+
+
+π‘ See the [Interaction testing documentation](../writing-tests/interaction-testing.md#api-for-user-events) for an overview of the available API events.
+
+
+
When Storybook finishes rendering the story, it executes the steps defined within the `play` function, interacting with the component and filling the form's information. All of this without the need for user intervention. If you check your `Interactions` panel, you'll see the step-by-step flow.
## Composing stories