storybook/docs/snippets/vue/list-story-template.2.js.mdx
2021-09-03 23:31:04 +01:00

45 lines
798 B
Plaintext

```js
// List.stories.js
import List from './List.vue';
import ListItem from './ListItem.vue';
//👇 Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';
export default {
component: List,
};
//👇 The ListTemplate construct will be spread to the existing stories.
const ListTemplate = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { List, ListItem },
template: `
<List v-bind="$props">
<div v-for="item in items" :key="item.title">
<ListItem :item="item" />
</div>
</List>
`,
});
export const Empty = {
...ListTemplate,
args: {
items: [],
},
};
export const OneItem = {
...ListTemplate,
args: {
items: [
{
...Unchecked.args,
},
],
},
};
```