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

41 lines
904 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';
//👇 We're importing the necessary stories from ListItem
import { Selected, Unselected } from './ListItem.stories';
export default {
component: List,
decorators: [
moduleMetadata({
declarations: [List, ListItem],
imports: [CommonModule],
}),
],
};
export const ManyItems = {
args: {
Selected: Selected.args.isSelected,
Unselected: Unselected.args.isSelected,
},
render: (args) => ({
props: args,
template: `
<list>
<list-item [isSelected]="Selected"></list-item>
<list-item [isSelected]="Unselected"></list-item>
<list-item [isSelected]="Unselected"></list-item>
</app-list>
`,
}),
};
```