storybook/docs/snippets/vue/list-story-template.2.js.mdx
2022-07-07 18:50:21 +01:00

49 lines
995 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 {
/* 👇 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: 'List',
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,
},
],
},
};
```