mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 02:31:05 +08:00
34 lines
683 B
Plaintext
34 lines
683 B
Plaintext
```md
|
|
import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
|
|
|
|
import Icon from './Icon';
|
|
import { IconA, IconB, IconC, IconD, IconE } from './icons';
|
|
|
|
const iconMap = {IconA, IconB, IconC, IconD, IconE };
|
|
|
|
<Meta title='Storybook with MDX and icons'/>
|
|
|
|
export const Template = ({ icon, ...rest }) => {
|
|
const selectedIcon = iconMap[icon];
|
|
return <Icon icon={selectedIcon} />;
|
|
};
|
|
|
|
<Canvas>
|
|
<Story
|
|
name="My Story with MDX with Icons"
|
|
argTypes={{
|
|
icon: {
|
|
control: {
|
|
type: 'select',
|
|
options: Object.keys(iconMap)
|
|
},
|
|
},
|
|
}}
|
|
args={{
|
|
icon: IconA,
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
</Canvas>
|
|
|
|
``` |