storybook/docs/snippets/svelte/my-component-story-with-nonstory.js.mdx
2021-11-09 01:41:54 +00:00

38 lines
934 B
Plaintext

```js
// MyComponent.stories.js
import MyComponent from './MyComponent.svelte';
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',
component: MyComponent,
includeStories: ['SimpleStory', 'ComplexStory'], // 👈 Storybook loads these stories
excludeStories: /.*Data$/, // 👈 Storybook ignores anything that contains Data
};
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,
};
export const ComplexStory = Template.bind({});
ComplexStory.args = {
data: complexData,
};
```