mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 02:11:49 +08:00
43 lines
955 B
Plaintext
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;
|
|
},
|
|
};
|
|
```
|