storybook/docs/snippets/html/list-story-reuse-data.ts.mdx

33 lines
828 B
Plaintext

```ts
// List.stories.ts
import { Meta, StoryFn } from '@storybook/html';
import { createList, ListArgs } from './List';
import { createListItem } from './ListItem';
// 👇 We're importing the necessary stories from ListItem
import { Selected, Unselected } from './ListItem.stories';
export default {
title: 'List',
} as Meta<ListArgs>;
export const Empty: StoryFn<ListArgs> = (args) => createList(args);
export const OneItem: StoryFn<ListArgs> = (args) => {
const list = createList(args);
list.appendChild(createListItem());
return list;
};
export const ManyItems: StoryFn<ListArgs> = (args) => {
const list = createList(args);
list.appendChild(createListItem(Selected.args));
list.appendChild(createListItem(Unselected.args));
list.appendChild(createListItem(Unselected.args));
return list;
};
```