storybook/docs/snippets/web-components/list-story-template.js.mdx
2023-02-16 09:13:06 +08:00

42 lines
710 B
Plaintext

```js
// List.stories.js
import { html } from 'lit';
import { repeat } from 'lit/directives/repeat.js';
import { Unchecked } from './ListItem.stories';
export default {
title: 'List',
component: 'demo-list',
};
//👇 The ListTemplate construct will be spread to the existing stories.
const ListTemplate = {
render: ({ items, ...args }) => {
return html`
<demo-list>
${repeat(items, (item) => html`<demo-list-item>${item}</demo-list-item>`)}
</demo-list>
`;
},
};
export const Empty = {
...ListTemplate,
args: {
items: [],
},
};
export const OneItem = {
...ListTemplate,
args: {
items: [
{
...Unchecked.args,
},
],
},
};
```