-
Notifications
You must be signed in to change notification settings - Fork 46
/
Button.stories.js
194 lines (170 loc) · 4.72 KB
/
Button.stories.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import AgnosticButton from './Button.vue';
import ButtonsDisabled from './ButtonsDisabled.vue';
import { action } from '@storybook/addon-actions';
export default {
title: 'Button',
component: AgnosticButton,
argTypes: {
label: { control: 'text' },
mode: { control: 'text' },
isBordered: { control: 'boolean' },
isBlock: { control: 'boolean' },
isDisabled: { control: 'boolean' },
isRaised: { control: 'boolean' },
isRounded: { control: 'boolean' },
isSkinned: { control: 'boolean' },
size: {
control: { type: 'select', options: ['small', 'large'] },
},
},
};
// Storybook does not appear to render code snippets for Vue/Svelte automagically
// as well as it does for React. I've logged: https://github.com/storybookjs/storybook/issues/12495
// but it seems in React, the fact that we can have JSX within foo.stories.js helps
// that cause; but in Vue/Svelte, we don't have .vue or .svelte files and I don't see
// some sort of Storybook custom vue loader. So, my closest success has been to use the
// `docs.source.code` mechanism you see below. It's not ideal since it requires duplication
// of code which could likely diverge, but it's the best comprimise I've found so far.
export const ButtonsDisabledAll = () => ({
title: 'Buttons Disabled',
components: { ButtonsDisabled },
template: `<buttons-disabled />`,
});
ButtonsDisabledAll.parameters = {
docs: {
source: {
code: `
<AgnosticButton label="Default Disabled" isDisabled />
<AgnosticButton mode="primary" label="Primary Disabled" isDisabled />
<AgnosticButton mode="secondary" label="Secondary Disabled" isDisabled />
<AgnosticButton mode="secondary" label="Secondary Bordered Disabled" isBordered isDisabled />
`
}
},
}
const Template = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { AgnosticButton },
template: '<agnostic-button @click="onClick" v-bind="$props" />',
methods: {
onClick: action('onClick'),
},
});
export const Primary = Template.bind({});
Primary.args = {
label: 'Primary',
mode: 'primary',
};
export const PrimaryBordered = Template.bind({});
PrimaryBordered.args = {
label: 'Primary Bordered',
mode: 'primary',
isBordered: true,
};
export const PrimaryBlock = Template.bind({});
PrimaryBlock.args = {
mode: 'primary',
label: 'Block (aka Stacked)',
isBlock: true,
};
export const PrimaryRounded = Template.bind({});
PrimaryRounded.args = {
label: 'Primary Rounded',
mode: 'primary',
isRounded: true,
};
export const PrimaryRoundedRaised = Template.bind({});
PrimaryRoundedRaised.args = {
label: 'Primary Rounded',
mode: 'primary',
isRounded: true,
isRaised: true,
};
export const PrimaryBorderedRounded = Template.bind({});
PrimaryBorderedRounded.args = {
label: 'Primary Borded Rounded',
mode: 'primary',
isBordered: true,
isRounded: true,
};
export const Secondary = Template.bind({});
Secondary.args = {
label: 'Secondary',
mode: 'secondary',
};
export const SecondaryBordered = Template.bind({});
SecondaryBordered.args = {
label: 'Secondary Bordered',
mode: 'secondary',
isBordered: true,
};
export const SecondaryRounded = Template.bind({});
SecondaryRounded.args = {
label: 'Secondary Rounded',
mode: 'secondary',
isRounded: true,
};
export const SecondaryRoundedRaised = Template.bind({});
SecondaryRoundedRaised.args = {
label: 'Secondary Rounded',
mode: 'secondary',
isRounded: true,
isRaised: true,
};
export const SecondaryBorderedRounded = Template.bind({});
SecondaryBorderedRounded.args = {
label: 'Secondary Borded Rounded',
mode: 'secondary',
isBordered: true,
isRounded: true,
};
export const Default = Template.bind({});
Default.args = {
label: 'Default',
};
export const DefaultRaised = Template.bind({});
DefaultRaised.args = {
label: 'Default Raised',
isRaised: true,
};
export const DefaultBordered = Template.bind({});
DefaultBordered.args = {
label: 'Default Bordered',
isBordered: true,
};
export const DefaultRounded = Template.bind({});
DefaultRounded.args = {
label: 'Default Rounded',
isRounded: true,
};
export const DefaultBorderedRounded = Template.bind({});
DefaultBorderedRounded.args = {
label: 'Default Bordered Rounded',
isBordered: true,
isRounded: true,
};
export const Disabled = Template.bind({});
Disabled.args = {
label: 'Disabled',
isDisabled: true,
};
export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Large',
};
export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Small',
};
export const ButtonBlank = Template.bind({});
ButtonBlank.args = {
label: 'Cancel',
isBlank: true,
};
export const ButtonBase = Template.bind({});
ButtonBase.args = {
label: 'Button Base Only (no skin)',
isSkinned: false,
};