mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
```ts
|
|
// Button.stories.ts|tsx
|
|
|
|
import { Button } from './Button';
|
|
|
|
// Replace your-framework with the name of your framework
|
|
import type { Meta } from '@storybook/your-framework';
|
|
|
|
import { ArrowUp, ArrowDown, ArrowLeft, ArrowRight } from './icons';
|
|
|
|
const arrows = { ArrowUp, ArrowDown, ArrowLeft, ArrowRight };
|
|
|
|
const meta: Meta<typeof Button> = {
|
|
/* 👇 The title prop is optional.
|
|
* See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
|
|
* to learn how to generate automatic titles
|
|
*/
|
|
title: 'Button',
|
|
component: Button,
|
|
argTypes: {
|
|
arrow: {
|
|
options: Object.keys(arrows), // An array of serializable values
|
|
mapping: arrows, // Maps serializable option values to complex arg values
|
|
control: {
|
|
type: 'select', // Type 'select' is automatically inferred when 'options' is defined
|
|
labels: {
|
|
// 'labels' maps option values to string labels
|
|
ArrowUp: 'Up',
|
|
ArrowDown: 'Down',
|
|
ArrowLeft: 'Left',
|
|
ArrowRight: 'Right',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
```
|