mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 07:31:19 +08:00
38 lines
934 B
Plaintext
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,
|
|
};
|
|
``` |