storybook/docs/snippets/react/badge-story-starter-example.mdx.mdx

55 lines
1.2 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 -->
# Badge
Let's define a story for our `Badge` component:
<Story
name="positive"
render={() => <Badge status="positive">Positive</Badge>} />
We can drop it in a `Canvas` to get a code snippet:
<Canvas>
<Story
name="negative"
render={() => <Badge status="negative">Negative</Badge>} />
</Canvas>
We can even preview multiple stories in a block. This
gets rendered as a group, but defines individual stories
with unique URLs and isolated snapshot tests.
<Canvas>
<Story
name="warning"
render={() => <Badge status="warning">Warning</Badge> } />
<Story
name="neutral"
render={() => <Badge status="neutral">Neutral</Badge>} />
<Story
name="error"
render={() => <Badge status="error">Error</Badge>} />
<Story
name="with icon"
render={() => (
<Badge status="warning">
<Icon icon="check" inline />
with icon
</Badge>
)} />
</Canvas>
```