@citizenplane/pimp 11.0.5 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pimp.es.js +3573 -3573
- package/dist/pimp.umd.js +44 -44
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CpBadge.vue +1 -1
- package/src/components/CpButton.vue +193 -179
- package/src/components/CpCheckbox.vue +2 -2
- package/src/components/CpLoader.vue +1 -1
- package/src/components/CpRadio.vue +2 -2
- package/src/components/CpSwitch.vue +2 -2
- package/src/components/CpTooltip.vue +2 -2
- package/src/constants/Button.ts +3 -14
- package/src/constants/colors/Colors.ts +16 -20
- package/src/constants/colors/ToggleColors.ts +2 -5
- package/src/constants/index.ts +2 -2
- package/src/stories/CpBadge.stories.ts +3 -3
- package/src/stories/CpButton.stories.ts +421 -72
- package/src/stories/CpLoader.stories.ts +1 -3
package/src/constants/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Colors } from './colors/Colors'
|
|
1
|
+
export type { Colors } from './colors/Colors'
|
|
2
2
|
export { Position } from './Position'
|
|
3
|
-
export { ToggleColors } from './colors/ToggleColors'
|
|
3
|
+
export type { ToggleColors } from './colors/ToggleColors'
|
|
4
4
|
export { HeadingLevels } from './Heading'
|
|
5
5
|
export { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from './CpTableConfig'
|
|
6
6
|
export { Sizes } from './Sizes'
|
|
@@ -2,7 +2,7 @@ import type { Args, Meta, StoryObj } from '@storybook/vue3'
|
|
|
2
2
|
|
|
3
3
|
import CpBadge from '@/components/CpBadge.vue'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Sizes } from '@/constants'
|
|
6
6
|
|
|
7
7
|
const meta = {
|
|
8
8
|
title: 'CpBadge',
|
|
@@ -62,7 +62,7 @@ const defaultRender = (args: Args) => ({
|
|
|
62
62
|
|
|
63
63
|
export const Default: Story = {
|
|
64
64
|
args: {
|
|
65
|
-
color:
|
|
65
|
+
color: 'neutral',
|
|
66
66
|
size: Sizes.MD,
|
|
67
67
|
isStroked: false,
|
|
68
68
|
isSquare: false,
|
|
@@ -214,7 +214,7 @@ export const IsDisabledWithIcon: Story = {
|
|
|
214
214
|
...Default.args,
|
|
215
215
|
isDisabled: true,
|
|
216
216
|
label: 'Disabled',
|
|
217
|
-
color:
|
|
217
|
+
color: 'red',
|
|
218
218
|
leadingIcon: 'check',
|
|
219
219
|
trailingIcon: 'arrow-right',
|
|
220
220
|
},
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
2
|
|
|
3
|
+
import { ButtonAppearances } from '@/constants/Button'
|
|
4
|
+
import { Sizes } from '@/constants/Sizes'
|
|
5
|
+
|
|
3
6
|
import CpButton from '@/components/CpButton.vue'
|
|
7
|
+
import CpIcon from '@/components/CpIcon.vue'
|
|
4
8
|
|
|
5
9
|
const meta = {
|
|
6
10
|
title: 'CpButton',
|
|
@@ -8,7 +12,7 @@ const meta = {
|
|
|
8
12
|
argTypes: {
|
|
9
13
|
appearance: {
|
|
10
14
|
control: 'select',
|
|
11
|
-
options: ['
|
|
15
|
+
options: ['primary', 'secondary', 'tertiary'],
|
|
12
16
|
description: 'The visual style of the button',
|
|
13
17
|
},
|
|
14
18
|
size: {
|
|
@@ -18,7 +22,7 @@ const meta = {
|
|
|
18
22
|
},
|
|
19
23
|
color: {
|
|
20
24
|
control: 'select',
|
|
21
|
-
options: ['
|
|
25
|
+
options: ['Neutral', 'Accent', 'Success', 'Warning', 'Error'],
|
|
22
26
|
description: 'The color variant of the button',
|
|
23
27
|
},
|
|
24
28
|
disabled: {
|
|
@@ -43,7 +47,6 @@ const meta = {
|
|
|
43
47
|
control: 'boolean',
|
|
44
48
|
description: 'Whether the button has square corners',
|
|
45
49
|
},
|
|
46
|
-
onClick: { action: 'clicked' },
|
|
47
50
|
},
|
|
48
51
|
} satisfies Meta<typeof CpButton>
|
|
49
52
|
|
|
@@ -51,7 +54,8 @@ export default meta
|
|
|
51
54
|
type Story = StoryObj<typeof meta>
|
|
52
55
|
|
|
53
56
|
const defaultTemplate = '<CpButton v-bind="args">Button</CpButton>'
|
|
54
|
-
|
|
57
|
+
|
|
58
|
+
const defaultRender = (args: (typeof CpButton)['props']) => ({
|
|
55
59
|
components: { CpButton },
|
|
56
60
|
setup() {
|
|
57
61
|
return { args }
|
|
@@ -59,67 +63,334 @@ const defaultRender = (args) => ({
|
|
|
59
63
|
template: defaultTemplate,
|
|
60
64
|
})
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const docSectionStyle =
|
|
67
|
+
'background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);'
|
|
68
|
+
const docTitleStyle =
|
|
69
|
+
'margin: 0 0 16px 0; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em;'
|
|
70
|
+
const docRowStyle = 'display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-end;'
|
|
71
|
+
const docCellStyle = 'display: flex; flex-direction: column; gap: 8px; align-items: flex-start;'
|
|
72
|
+
const docLabelStyle = 'font-size: 12px; color: #6b7280;'
|
|
73
|
+
|
|
74
|
+
export const Documentation: Story = {
|
|
75
|
+
args: {},
|
|
76
|
+
render: () => ({
|
|
77
|
+
components: { CpButton, CpIcon },
|
|
78
|
+
setup: () => ({}),
|
|
79
|
+
template: `
|
|
80
|
+
<div>
|
|
81
|
+
<div style="padding: 24px; background: #f3f4f6; min-height: 100vh;">
|
|
82
|
+
<h1 style="margin: 0 0 32px 0; font-size: 28px; font-weight: 700; color: #111;">Button</h1>
|
|
83
|
+
|
|
84
|
+
<section style="${docSectionStyle}">
|
|
85
|
+
<h2 style="${docTitleStyle}">Size</h2>
|
|
86
|
+
<div style="${docRowStyle}">
|
|
87
|
+
<div style="${docCellStyle}">
|
|
88
|
+
<span style="${docLabelStyle}">2xs</span>
|
|
89
|
+
<CpButton color="accent" size="${Sizes.XXS}">Default button</CpButton>
|
|
90
|
+
</div>
|
|
91
|
+
<div style="${docCellStyle}">
|
|
92
|
+
<span style="${docLabelStyle}">xs</span>
|
|
93
|
+
<CpButton color="accent" size="${Sizes.XS}">Default button</CpButton>
|
|
94
|
+
</div>
|
|
95
|
+
<div style="${docCellStyle}">
|
|
96
|
+
<span style="${docLabelStyle}">sm</span>
|
|
97
|
+
<CpButton color="accent" size="${Sizes.SM}">Default button</CpButton>
|
|
98
|
+
</div>
|
|
99
|
+
<div style="${docCellStyle}">
|
|
100
|
+
<span style="${docLabelStyle}">md</span>
|
|
101
|
+
<CpButton color="accent" size="${Sizes.MD}">Default button</CpButton>
|
|
102
|
+
</div>
|
|
103
|
+
<div style="${docCellStyle}">
|
|
104
|
+
<span style="${docLabelStyle}">lg</span>
|
|
105
|
+
<CpButton color="accent" size="${Sizes.LG}">Default button</CpButton>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</section>
|
|
109
|
+
|
|
110
|
+
<section style="${docSectionStyle}">
|
|
111
|
+
<h2 style="${docTitleStyle}">Color</h2>
|
|
112
|
+
<div style="${docRowStyle}">
|
|
113
|
+
<div style="${docCellStyle}">
|
|
114
|
+
<span style="${docLabelStyle}">neutral</span>
|
|
115
|
+
<CpButton color="neutral">Default button</CpButton>
|
|
116
|
+
</div>
|
|
117
|
+
<div style="${docCellStyle}">
|
|
118
|
+
<span style="${docLabelStyle}">accent</span>
|
|
119
|
+
<CpButton color="accent">Default button</CpButton>
|
|
120
|
+
</div>
|
|
121
|
+
<div style="${docCellStyle}">
|
|
122
|
+
<span style="${docLabelStyle}">error</span>
|
|
123
|
+
<CpButton color="error">Default button</CpButton>
|
|
124
|
+
</div>
|
|
125
|
+
<div style="${docCellStyle}">
|
|
126
|
+
<span style="${docLabelStyle}">warning</span>
|
|
127
|
+
<CpButton color="warning">Default button</CpButton>
|
|
128
|
+
</div>
|
|
129
|
+
<div style="${docCellStyle}">
|
|
130
|
+
<span style="${docLabelStyle}">success</span>
|
|
131
|
+
<CpButton color="success">Default button</CpButton>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</section>
|
|
135
|
+
|
|
136
|
+
<section style="${docSectionStyle}">
|
|
137
|
+
<h2 style="${docTitleStyle}">State</h2>
|
|
138
|
+
<div style="${docRowStyle}">
|
|
139
|
+
<div style="${docCellStyle}">
|
|
140
|
+
<span style="${docLabelStyle}">default</span>
|
|
141
|
+
<CpButton color="accent">Default button</CpButton>
|
|
142
|
+
</div>
|
|
143
|
+
<div style="${docCellStyle}">
|
|
144
|
+
<span style="${docLabelStyle}">disabled</span>
|
|
145
|
+
<CpButton color="accent" :disabled="true">Default button</CpButton>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</section>
|
|
149
|
+
|
|
150
|
+
<section style="${docSectionStyle}">
|
|
151
|
+
<h2 style="${docTitleStyle}">Squared</h2>
|
|
152
|
+
<div style="${docRowStyle}">
|
|
153
|
+
<div style="${docCellStyle}">
|
|
154
|
+
<span style="${docLabelStyle}">false</span>
|
|
155
|
+
<CpButton color="accent" :is-square="false">Default button</CpButton>
|
|
156
|
+
</div>
|
|
157
|
+
<div style="${docCellStyle}">
|
|
158
|
+
<span style="${docLabelStyle}">true</span>
|
|
159
|
+
<CpButton color="accent" :is-square="true">Default button</CpButton>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</section>
|
|
163
|
+
|
|
164
|
+
<section style="${docSectionStyle}">
|
|
165
|
+
<h2 style="${docTitleStyle}">Style</h2>
|
|
166
|
+
<div style="${docRowStyle}">
|
|
167
|
+
<div style="${docCellStyle}">
|
|
168
|
+
<span style="${docLabelStyle}">primary</span>
|
|
169
|
+
<CpButton color="accent">Default button</CpButton>
|
|
170
|
+
</div>
|
|
171
|
+
<div style="${docCellStyle}">
|
|
172
|
+
<span style="${docLabelStyle}">secondary</span>
|
|
173
|
+
<CpButton appearance="secondary" color="accent">Default button</CpButton>
|
|
174
|
+
</div>
|
|
175
|
+
<div style="${docCellStyle}">
|
|
176
|
+
<span style="${docLabelStyle}">tertiary</span>
|
|
177
|
+
<CpButton appearance="tertiary" color="accent">Default button</CpButton>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</section>
|
|
181
|
+
|
|
182
|
+
<section style="${docSectionStyle}">
|
|
183
|
+
<h2 style="${docTitleStyle}">Icon</h2>
|
|
184
|
+
<div style="${docRowStyle}">
|
|
185
|
+
<div style="${docCellStyle}">
|
|
186
|
+
<span style="${docLabelStyle}">—</span>
|
|
187
|
+
<CpButton color="accent">Default button</CpButton>
|
|
188
|
+
</div>
|
|
189
|
+
<div style="${docCellStyle}">
|
|
190
|
+
<span style="${docLabelStyle}">leading</span>
|
|
191
|
+
<CpButton color="accent">
|
|
192
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
193
|
+
Default button
|
|
194
|
+
</CpButton>
|
|
195
|
+
</div>
|
|
196
|
+
<div style="${docCellStyle}">
|
|
197
|
+
<span style="${docLabelStyle}">leading + trailing</span>
|
|
198
|
+
<CpButton color="accent">
|
|
199
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
200
|
+
Default button
|
|
201
|
+
<template #trailing-icon><CpIcon type="plus" /></template>
|
|
202
|
+
</CpButton>
|
|
203
|
+
</div>
|
|
204
|
+
<div style="${docCellStyle}">
|
|
205
|
+
<span style="${docLabelStyle}">trailing</span>
|
|
206
|
+
<CpButton color="accent">
|
|
207
|
+
Default button
|
|
208
|
+
<template #trailing-icon><CpIcon type="plus" /></template>
|
|
209
|
+
</CpButton>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</section>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
`,
|
|
216
|
+
}),
|
|
217
|
+
parameters: {
|
|
218
|
+
docs: {
|
|
219
|
+
source: {
|
|
220
|
+
code: null,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
70
223
|
},
|
|
71
|
-
render: defaultRender,
|
|
72
224
|
}
|
|
73
225
|
|
|
74
|
-
export const
|
|
75
|
-
args: {
|
|
76
|
-
...Default.args,
|
|
77
|
-
appearance: 'primary',
|
|
78
|
-
color: 'Purple',
|
|
79
|
-
},
|
|
226
|
+
export const Default: Story = {
|
|
227
|
+
args: {},
|
|
80
228
|
render: defaultRender,
|
|
81
229
|
}
|
|
82
230
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
231
|
+
/** Semantic colors shown in appearance variant stories (primary, secondary, etc.). */
|
|
232
|
+
const semanticButtonColors = [
|
|
233
|
+
{ value: 'neutral', label: 'neutral' },
|
|
234
|
+
{ value: 'accent', label: 'accent' },
|
|
235
|
+
{ value: 'error', label: 'error' },
|
|
236
|
+
{ value: 'warning', label: 'warning' },
|
|
237
|
+
{ value: 'success', label: 'success' },
|
|
238
|
+
] as const
|
|
239
|
+
|
|
240
|
+
const appearanceVariantsStoryParameters = {
|
|
241
|
+
docs: {
|
|
242
|
+
source: {
|
|
243
|
+
code: null,
|
|
244
|
+
},
|
|
88
245
|
},
|
|
89
|
-
|
|
246
|
+
} as const
|
|
247
|
+
|
|
248
|
+
function createAppearanceVariantsStory(appearance: ButtonAppearances): Story {
|
|
249
|
+
return {
|
|
250
|
+
args: {
|
|
251
|
+
...Default.args,
|
|
252
|
+
appearance,
|
|
253
|
+
},
|
|
254
|
+
render: (args) => ({
|
|
255
|
+
components: { CpButton },
|
|
256
|
+
setup: () => ({
|
|
257
|
+
args,
|
|
258
|
+
semanticButtonColors,
|
|
259
|
+
storyAppearance: appearance,
|
|
260
|
+
}),
|
|
261
|
+
template: `
|
|
262
|
+
<div style="display: flex; flex-direction: column; gap: 32px; padding: 24px;">
|
|
263
|
+
<div
|
|
264
|
+
v-for="c in semanticButtonColors"
|
|
265
|
+
:key="c.value"
|
|
266
|
+
style="display: flex; flex-direction: column; gap: 12px; padding: 16px; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);"
|
|
267
|
+
>
|
|
268
|
+
<h4 style="margin: 0; font-size: 14px; font-weight: 600; color: #333; text-transform: capitalize;">{{ c.label }}</h4>
|
|
269
|
+
<div style="display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-end;">
|
|
270
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
271
|
+
<span style="font-size: 12px; color: #6b7280; font-weight: 500;">Square</span>
|
|
272
|
+
<div style="display: flex; gap: 16px; align-items: flex-end;">
|
|
273
|
+
<div style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;">
|
|
274
|
+
<span style="font-size: 12px; color: #9ca3af;">Normal</span>
|
|
275
|
+
<CpButton
|
|
276
|
+
v-bind="args"
|
|
277
|
+
:appearance="storyAppearance"
|
|
278
|
+
:color="c.value"
|
|
279
|
+
:is-square="true"
|
|
280
|
+
:disabled="false"
|
|
281
|
+
>
|
|
282
|
+
Default button
|
|
283
|
+
</CpButton>
|
|
284
|
+
</div>
|
|
285
|
+
<div style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;">
|
|
286
|
+
<span style="font-size: 12px; color: #9ca3af;">Disabled</span>
|
|
287
|
+
<CpButton
|
|
288
|
+
v-bind="args"
|
|
289
|
+
:appearance="storyAppearance"
|
|
290
|
+
:color="c.value"
|
|
291
|
+
:is-square="true"
|
|
292
|
+
:disabled="true"
|
|
293
|
+
>
|
|
294
|
+
Default button
|
|
295
|
+
</CpButton>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
300
|
+
<span style="font-size: 12px; color: #6b7280; font-weight: 500;">Not square</span>
|
|
301
|
+
<div style="display: flex; gap: 16px; align-items: flex-end;">
|
|
302
|
+
<div style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;">
|
|
303
|
+
<span style="font-size: 12px; color: #9ca3af;">Normal</span>
|
|
304
|
+
<CpButton
|
|
305
|
+
v-bind="args"
|
|
306
|
+
:appearance="storyAppearance"
|
|
307
|
+
:color="c.value"
|
|
308
|
+
:is-square="false"
|
|
309
|
+
:disabled="false"
|
|
310
|
+
>
|
|
311
|
+
Default button
|
|
312
|
+
</CpButton>
|
|
313
|
+
</div>
|
|
314
|
+
<div style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;">
|
|
315
|
+
<span style="font-size: 12px; color: #9ca3af;">Disabled</span>
|
|
316
|
+
<CpButton
|
|
317
|
+
v-bind="args"
|
|
318
|
+
:appearance="storyAppearance"
|
|
319
|
+
:color="c.value"
|
|
320
|
+
:is-square="false"
|
|
321
|
+
:disabled="true"
|
|
322
|
+
>
|
|
323
|
+
Default button
|
|
324
|
+
</CpButton>
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
`,
|
|
332
|
+
}),
|
|
333
|
+
parameters: appearanceVariantsStoryParameters,
|
|
334
|
+
}
|
|
90
335
|
}
|
|
91
336
|
|
|
337
|
+
export const Primary = createAppearanceVariantsStory('primary')
|
|
338
|
+
export const Secondary = createAppearanceVariantsStory('secondary')
|
|
339
|
+
export const Tertiary = createAppearanceVariantsStory('tertiary')
|
|
340
|
+
|
|
341
|
+
const withIconsSizes = [
|
|
342
|
+
{ value: Sizes.XXS, label: '2xs' },
|
|
343
|
+
{ value: Sizes.XS, label: 'xs' },
|
|
344
|
+
{ value: Sizes.SM, label: 'sm' },
|
|
345
|
+
{ value: Sizes.MD, label: 'md' },
|
|
346
|
+
{ value: Sizes.LG, label: 'lg' },
|
|
347
|
+
] as const
|
|
348
|
+
|
|
92
349
|
export const WithIcons: Story = {
|
|
93
350
|
args: {
|
|
94
351
|
...Default.args,
|
|
95
352
|
appearance: 'primary',
|
|
96
|
-
color: '
|
|
353
|
+
color: 'accent',
|
|
97
354
|
},
|
|
98
355
|
render: (args) => ({
|
|
99
|
-
components: { CpButton },
|
|
100
|
-
setup: () => ({ args }),
|
|
356
|
+
components: { CpButton, CpIcon },
|
|
357
|
+
setup: () => ({ args, withIconsSizes }),
|
|
101
358
|
template: `
|
|
102
|
-
<
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
359
|
+
<div style="display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-end; padding: 24px;">
|
|
360
|
+
<div
|
|
361
|
+
v-for="s in withIconsSizes"
|
|
362
|
+
:key="s.value"
|
|
363
|
+
style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;"
|
|
364
|
+
>
|
|
365
|
+
<span style="font-size: 12px; color: #6b7280;">{{ s.label }}</span>
|
|
366
|
+
<CpButton v-bind="args" :size="s.value">
|
|
367
|
+
<template #leading-icon>
|
|
368
|
+
<CpIcon type="arrow-left" />
|
|
369
|
+
</template>
|
|
370
|
+
Button with Icon
|
|
371
|
+
<template #trailing-icon>
|
|
372
|
+
<CpIcon type="arrow-right" />
|
|
373
|
+
</template>
|
|
374
|
+
</CpButton>
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
111
377
|
`,
|
|
112
378
|
}),
|
|
113
379
|
}
|
|
114
380
|
|
|
115
381
|
export const WithHaptics: Story = {
|
|
116
|
-
args: {
|
|
382
|
+
args: {
|
|
383
|
+
...Default.args,
|
|
384
|
+
enableHaptics: true,
|
|
385
|
+
color: 'accent',
|
|
386
|
+
},
|
|
117
387
|
render: (args) => ({
|
|
118
388
|
components: { CpButton },
|
|
119
389
|
setup() {
|
|
120
390
|
const onClick = () => {
|
|
121
391
|
console.log('Button clicked')
|
|
122
392
|
}
|
|
393
|
+
|
|
123
394
|
return { args, onClick }
|
|
124
395
|
},
|
|
125
396
|
template: `
|
|
@@ -131,48 +402,126 @@ export const WithHaptics: Story = {
|
|
|
131
402
|
}
|
|
132
403
|
|
|
133
404
|
export const Loading: Story = {
|
|
134
|
-
args: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
args: { ...Default.args, disabled: true },
|
|
405
|
+
args: {
|
|
406
|
+
...Default.args,
|
|
407
|
+
isLoading: true,
|
|
408
|
+
color: 'accent',
|
|
409
|
+
},
|
|
140
410
|
render: defaultRender,
|
|
141
411
|
}
|
|
142
412
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<CpButton v-bind="args" color="purple" size="2xs">Extra Extra Small</CpButton>
|
|
151
|
-
<CpButton v-bind="args" color="blue" size="xs">Extra Small</CpButton>
|
|
152
|
-
<CpButton v-bind="args" color="green" size="sm">Small</CpButton>
|
|
153
|
-
<CpButton v-bind="args" color="orange" size="md">Medium</CpButton>
|
|
154
|
-
<CpButton v-bind="args" color="red" size="lg">Large</CpButton>
|
|
155
|
-
</div>
|
|
156
|
-
`,
|
|
157
|
-
}),
|
|
158
|
-
}
|
|
413
|
+
const iconOnlySizes = [
|
|
414
|
+
{ value: Sizes.XXS, label: '2xs' },
|
|
415
|
+
{ value: Sizes.XS, label: 'xs' },
|
|
416
|
+
{ value: Sizes.SM, label: 'sm' },
|
|
417
|
+
{ value: Sizes.MD, label: 'md' },
|
|
418
|
+
{ value: Sizes.LG, label: 'lg' },
|
|
419
|
+
] as const
|
|
159
420
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
421
|
+
/** Icon-only appearances (inverse excluded for this story). */
|
|
422
|
+
const iconOnlyAppearances = [
|
|
423
|
+
{ value: 'primary', label: 'primary' },
|
|
424
|
+
{ value: 'secondary', label: 'secondary' },
|
|
425
|
+
{ value: 'tertiary', label: 'tertiary' },
|
|
426
|
+
] as const
|
|
164
427
|
|
|
165
428
|
export const IconOnly: Story = {
|
|
166
|
-
args: {
|
|
429
|
+
args: {
|
|
430
|
+
...Default.args,
|
|
431
|
+
appearance: 'primary',
|
|
432
|
+
color: 'accent',
|
|
433
|
+
isSquare: true,
|
|
434
|
+
},
|
|
167
435
|
render: (args) => ({
|
|
168
|
-
components: { CpButton },
|
|
169
|
-
setup: () => ({
|
|
436
|
+
components: { CpButton, CpIcon },
|
|
437
|
+
setup: () => ({
|
|
438
|
+
args,
|
|
439
|
+
iconOnlySizes,
|
|
440
|
+
iconOnlyAppearances,
|
|
441
|
+
semanticButtonColors,
|
|
442
|
+
docSectionStyle,
|
|
443
|
+
docTitleStyle,
|
|
444
|
+
docRowStyle,
|
|
445
|
+
docCellStyle,
|
|
446
|
+
docLabelStyle,
|
|
447
|
+
}),
|
|
170
448
|
template: `
|
|
171
|
-
<
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
449
|
+
<div style="padding: 24px; background: #f3f4f6; min-height: 100vh;">
|
|
450
|
+
<h1 style="margin: 0 0 32px 0; font-size: 28px; font-weight: 700; color: #111;">Icon Button</h1>
|
|
451
|
+
|
|
452
|
+
<section style="${docSectionStyle}">
|
|
453
|
+
<h2 style="${docTitleStyle}">Size</h2>
|
|
454
|
+
<div style="${docRowStyle}">
|
|
455
|
+
<div
|
|
456
|
+
v-for="s in iconOnlySizes"
|
|
457
|
+
:key="s.value"
|
|
458
|
+
style="${docCellStyle}"
|
|
459
|
+
>
|
|
460
|
+
<span style="${docLabelStyle}">{{ s.label }}</span>
|
|
461
|
+
<CpButton v-bind="args" :size="s.value">
|
|
462
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
463
|
+
</CpButton>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
</section>
|
|
467
|
+
|
|
468
|
+
<section style="${docSectionStyle}">
|
|
469
|
+
<h2 style="${docTitleStyle}">Color</h2>
|
|
470
|
+
<div style="${docRowStyle}">
|
|
471
|
+
<div
|
|
472
|
+
v-for="c in semanticButtonColors"
|
|
473
|
+
:key="c.value"
|
|
474
|
+
style="${docCellStyle}"
|
|
475
|
+
>
|
|
476
|
+
<span style="${docLabelStyle}">{{ c.label }}</span>
|
|
477
|
+
<CpButton v-bind="args" :color="c.value">
|
|
478
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
479
|
+
</CpButton>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
</section>
|
|
483
|
+
|
|
484
|
+
<section style="${docSectionStyle}">
|
|
485
|
+
<h2 style="${docTitleStyle}">Squared</h2>
|
|
486
|
+
<div style="${docRowStyle}">
|
|
487
|
+
<div style="${docCellStyle}">
|
|
488
|
+
<span style="${docLabelStyle}">false</span>
|
|
489
|
+
<CpButton v-bind="args" :is-square="false">
|
|
490
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
491
|
+
</CpButton>
|
|
492
|
+
</div>
|
|
493
|
+
<div style="${docCellStyle}">
|
|
494
|
+
<span style="${docLabelStyle}">true</span>
|
|
495
|
+
<CpButton v-bind="args" :is-square="true">
|
|
496
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
497
|
+
</CpButton>
|
|
498
|
+
</div>
|
|
499
|
+
</div>
|
|
500
|
+
</section>
|
|
501
|
+
|
|
502
|
+
<section style="${docSectionStyle}">
|
|
503
|
+
<h2 style="${docTitleStyle}">Style</h2>
|
|
504
|
+
<div style="${docRowStyle}">
|
|
505
|
+
<div
|
|
506
|
+
v-for="a in iconOnlyAppearances"
|
|
507
|
+
:key="a.value"
|
|
508
|
+
style="${docCellStyle}"
|
|
509
|
+
>
|
|
510
|
+
<span style="${docLabelStyle}">{{ a.label }}</span>
|
|
511
|
+
<CpButton v-bind="args" :appearance="a.value">
|
|
512
|
+
<template #leading-icon><CpIcon type="plus" /></template>
|
|
513
|
+
</CpButton>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
</section>
|
|
517
|
+
</div>
|
|
176
518
|
`,
|
|
177
519
|
}),
|
|
520
|
+
parameters: {
|
|
521
|
+
docs: {
|
|
522
|
+
source: {
|
|
523
|
+
code: null,
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
},
|
|
178
527
|
}
|
|
@@ -2,8 +2,6 @@ import type { Meta, StoryObj } from '@storybook/vue3'
|
|
|
2
2
|
|
|
3
3
|
import CpLoader from '@/components/CpLoader.vue'
|
|
4
4
|
|
|
5
|
-
import { Colors } from '@/constants'
|
|
6
|
-
|
|
7
5
|
const meta = {
|
|
8
6
|
title: 'CpLoader',
|
|
9
7
|
component: CpLoader,
|
|
@@ -25,6 +23,6 @@ type Story = StoryObj<typeof meta>
|
|
|
25
23
|
|
|
26
24
|
export const Default: Story = {
|
|
27
25
|
args: {
|
|
28
|
-
color:
|
|
26
|
+
color: 'neutral',
|
|
29
27
|
},
|
|
30
28
|
}
|