fbredius/storybook

View on GitHub
docs/snippets/vue/list-story-with-sub-components.2.js.mdx

Summary

Maintainability
Test Coverage
```js
// List.stories.js

import List from './List.vue';
import ListItem from './ListItem.vue';

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: 'List',
  component: List,
  subcomponents: { ListItem }, //👈 Adds the ListItem component as a subcomponent
};

export const Empty = (args, { argTypes }) => ({
  props: Object.keys(argTypes),
  components: { List },
  template: '<List v-bind="$props"/>',
});

export const OneItem = (args, { argTypes }) => ({
  props: Object.keys(argTypes),
  components: { List, ListItem },
  template: '<List v-bind="$props"><ListItem /></List>',
});
```