storybook/docs/snippets/html/list-story-expanded.ts.mdx
2022-11-17 16:33:22 +01:00

43 lines
955 B
Plaintext

```ts
// List.stories.ts
import type { Meta, StoryObj } from '@storybook/html';
import { createList, ListArgs } from './List';
import { createListItem } from './ListItem';
const meta: Meta<ListArgs> = {
title: 'List',
};
export default meta;
type Story = StoryObj<ListArgs>;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/html/api/csf
* to learn how to use render functions.
*/
export const Empty: Story = {
render: () => createList(args),
};
export const OneItem: Story = {
render: (args) => {
const list = createList(args);
list.appendChild(createListItem());
return list;
},
};
export const ManyItems: Story = {
render: (args) => {
const list = createList(args);
list.appendChild(createListItem());
list.appendChild(createListItem());
list.appendChild(createListItem());
return list;
},
};
```