storybook/docs/snippets/angular/list-story-template.ts.mdx
2021-11-04 23:10:45 +00:00

54 lines
1.1 KiB
Plaintext

```ts
// List.stories.ts
import { Meta, moduleMetadata, Story } 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 {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
decorators: [
moduleMetadata({
declarations: [List, ListItem],
imports: [CommonModule],
}),
],
} as Meta;
const ListTemplate: Story = (args) => ({
props: args,
template: `
<app-list>
<div *ngFor="let item of items">
<app-list-item [item]="item"></app-list-item>
</div>
</app-list>
`,
});
export const Empty = ListTemplate.bind({});
EmptyListTemplate.args = {
items: [],
};
export const OneItem = ListTemplate.bind({});
OneItem.args = {
items: [
{
...Unchecked.args,
},
],
};
```