storybook/docs/snippets/svelte/badge-story.mdx.mdx
2022-07-07 19:15:02 +01:00

77 lines
1.3 KiB
Plaintext

```md
<!-- Badge.stories.mdx -->
import { Canvas, Meta, Story } from '@storybook/addon-docs';
import Badge from './Badge.svelte';
<Meta title="MDX/Badge" component={Badge} />
# Badge
Let's define a story for our `Badge` component:
<Story
name="positive"
args={{
status: 'positive',
label: 'Positive'
}}
render={(args) => ({
Component: Badge,
props: args,
})} />
We can drop it in a `Canvas` to get a code snippet:
<Canvas>
<Story
name="negative"
args={{
status: 'negative',
label: 'Negative'
}}
render={(args) => ({
Component: Badge,
props: 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) => ({
Component: Badge,
props: args,
})} />
<Story
name="neutral"
args={{
status: 'neutral',
label: 'Neutral'
}}
render={(args) => ({
Component: Badge,
props: args,
})} />
<Story
name="error"
args={{
status: 'error',
label: 'Error'
}}
render={(args) => ({
Component: Badge,
props: args,
})} />
</Canvas>
```