mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 04:21:07 +08:00
22 lines
653 B
Plaintext
22 lines
653 B
Plaintext
```js
|
|
// MyComponent.stories.js
|
|
|
|
import React from 'react';
|
|
|
|
import MyComponent from './MyComponent';
|
|
|
|
import someData from './data.json';
|
|
|
|
export default {
|
|
title: 'MyComponent',
|
|
component: MyComponent,
|
|
includeStories: ['SimpleStory', 'ComplexStory'], // 👈 Storybook loads these stories
|
|
excludeStories: /.*Data$/, // 👈 Storybook ignores anything that contains Data
|
|
};
|
|
|
|
export const simpleData = { foo: 1, bar: 'baz' };
|
|
export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
|
|
|
|
export const SimpleStory = () => <MyComponent data={simpleData} />;
|
|
export const ComplexStory = () => <MyComponent data={complexData} />;
|
|
``` |