mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
67 lines
1.4 KiB
Plaintext
67 lines
1.4 KiB
Plaintext
```md
|
|
<!---Badge.stories.mdx --->
|
|
|
|
import { Meta, Story, Canvas } from '@storybook/addon-docs';
|
|
|
|
import { Badge } from './Badge';
|
|
import { Icon } from './Icon';
|
|
|
|
<Meta title="MDX/Badge" component={Badge} />
|
|
|
|
<!--- This is your Story template function, shown here in React -->
|
|
|
|
export const Template = (args) => <Badge {...args } />
|
|
|
|
# Badge
|
|
|
|
Let's define a story for our `Badge` component:
|
|
|
|
<Story name="positive" args={{
|
|
status: 'positive',
|
|
label: 'Positive'
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
|
|
We can drop it in a `Canvas` to get a code snippet:
|
|
|
|
<Canvas>
|
|
<Story name="negative" args={{
|
|
status: 'negative',
|
|
label: 'Negative'
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
</Canvas>
|
|
|
|
We can even preview multiple Stories in a block. This
|
|
gets rendered as a group but defines individual stories
|
|
with unique URLs, which is great for review and testing.
|
|
|
|
<Canvas>
|
|
<Story name="warning" args={{
|
|
status: 'warning',
|
|
label: 'Warning'
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
<Story name="neutral" args={{
|
|
status: 'neutral',
|
|
label: 'Neutral'
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
<Story name="error" args={{
|
|
status: 'error',
|
|
label: 'Error'
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
<Story name="with icon" args={{
|
|
status: 'warning',
|
|
label: (<Icon icon="check" inline /> with icon)
|
|
)}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
</Canvas>
|
|
``` |