generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathButton.stories.svelte
55 lines (45 loc) · 1.29 KB
/
Button.stories.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script module lang="ts">
import {
defineMeta,
setTemplate,
type Args,
type StoryContext,
} from '@storybook/addon-svelte-csf';
import { fn } from '@storybook/test';
import Button from './components/Button.svelte';
const onclickFn = fn().mockName('onclick');
/**
* These are the stories for the `Button` component.
* It's the default button we use throughout our application.
*/
const { Story } = defineMeta({
component: Button,
tags: ['autodocs'],
args: {
onclick: onclickFn,
},
argTypes: {
backgroundColor: { control: 'color' },
size: {
control: { type: 'select' },
options: ['small', 'medium', 'large'],
},
children: { control: 'text' },
},
});
</script>
<script lang="ts">
setTemplate(template);
</script>
{#snippet template(args: Args<typeof Story>, context: StoryContext<typeof Story>)}
<Button {...args}>{'Click me'}</Button>
{/snippet}
<!-- Only use this sparingly as the main CTA. -->
<Story name="Primary" args={{ primary: true }} />
<Story name="Secondary" />
<Story name="Large" args={{ size: 'large' }} />
<!-- This is _tiny_ 🤏 -->
<Story name="Small" args={{ size: 'small' }} />
<Story name="Long content">
<Button onclick={onclickFn}>The very long content</Button>
</Story>