storybook/docs/snippets/angular/my-component-story-with-nonstory.ts.mdx
2021-11-09 01:41:54 +00:00

37 lines
980 B
Plaintext

```ts
// MyComponent.stories.ts
import { Meta, Story } from '@storybook/angular';
import { MyComponent } from './MyComponent.component';
import someData from './data.json';
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: 'MyComponent',
component: MyComponent,
includeStories: ['SimpleStory', 'ComplexStory'], // 👈 Storybook loads these stories
excludeStories: /.*Data$/, // 👈 Storybook ignores anything that contains Data
} as Meta;
const Template: Story = (args) => ({
props: args,
});
export const simpleData = { foo: 1, bar: 'baz' };
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
export const SimpleStory = Template.bind({});
SimpleStory.args = {
data: simpleData,
};
export const ComplexStory = Template.bind({});
ComplexStory.args = {
data: complexData,
};
```