storybook/docs/snippets/vue/my-component-story-with-nonstory.2.js.mdx
2021-11-04 23:51:08 +00:00

39 lines
977 B
Plaintext

```js
// MyComponent.stories.js
import MyComponent from './MyComponent.vue';
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',
component: MyComponent,
includeStories: ['SimpleStory', 'ComplexStory'],
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, { argTypes }) => ({
components: { MyComponent },
props: Object.keys(argTypes),
template: `<MyComponent v-bind="$props"/>`,
});
export const SimpleStory = Template.bind({});
SimpleStory,args = {
data: simpleData,
};
export const ComplexStory = Template.bind({});
ComplexStory,args = {
data: complexData,
};
```