storybook/docs/snippets/react/badge-story.mdx.mdx
2022-07-07 19:47:29 +01:00

76 lines
1.6 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} />
<!--
👇 Render functions are a framework specific feature to allow you control on how the component renders.
See https://storybook.js.org/docs/7.0/react/api/csf
to learn how to use render functions.
-->
# Badge
Let's define a story for our `Badge` component:
<Story
name="positive"
args={{
status: 'positive',
label: 'Positive'
}}
render={(args) => <Badge {...args } />} />
We can drop it in a `Canvas` to get a code snippet:
<Canvas>
<Story
name="negative"
args={{
status: 'negative',
label: 'Negative'
}}
render={(args) => <Badge {...args } />} />
</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'
}}
render={(args) => <Badge {...args } />} />
<Story
name="neutral"
args={{
status: 'neutral',
label: 'Neutral'
}}
render={(args) => <Badge {...args } />} />
<Story
name="error"
args={{
status: 'error',
label: 'Error'
}}
render={(args) => <Badge {...args } />} />
<Story
name="with icon"
args={{
status: 'warning',
label: (<Icon icon="check" inline /> with icon)
}}
render={(args) => <Badge {...args } />} />
</Canvas>
```