storybook/docs/snippets/angular/list-story-template.ts.mdx
2021-09-06 22:03:15 +01:00

49 lines
875 B
Plaintext

```ts
// List.stories.ts
import { moduleMetadata } from '@storybook/angular';
import { CommonModule } from '@angular/common';
import { List } from './list.component';
import { ListItem } from './list-item.component';
//👇 Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';
export default {
component: List,
decorators: [
moduleMetadata({
declarations: [ListItem],
imports: [CommonModule],
}),
],
};
const ListTemplate = {
render: (args) => ({
props: args,
template: `
<list>
<div *ngFor="let item of items">
<list-item [item]="item"></list-item>
</div>
</list>
`,
}),
};
export const Empty = {
...ListTemplate,
args: { items: [] },
};
export const OneItem = {
...ListTemplate,
args: {
items: [{ ...Unchecked.args }],
},
};
```