@citizenplane/pimp 16.0.3 → 16.1.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.
Files changed (61) hide show
  1. package/dist/pimp.es.js +313 -285
  2. package/dist/pimp.umd.js +21 -21
  3. package/dist/style.css +1 -1
  4. package/package.json +2 -1
  5. package/src/components/CpHeading.vue +4 -5
  6. package/src/components/CpText.vue +141 -0
  7. package/src/components/index.ts +2 -0
  8. package/src/stories/BaseInputLabel.stories.ts +36 -9
  9. package/src/stories/Colors.mdx +9 -0
  10. package/src/stories/Colors.stories.ts +177 -0
  11. package/src/stories/CpAccordion.stories.ts +187 -158
  12. package/src/stories/CpAccordionGroup.stories.ts +50 -94
  13. package/src/stories/CpAirlineLogo.stories.ts +49 -28
  14. package/src/stories/CpAlert.stories.ts +195 -158
  15. package/src/stories/CpBadge.stories.ts +259 -193
  16. package/src/stories/CpButton.stories.ts +257 -426
  17. package/src/stories/CpCheckbox.stories.ts +101 -29
  18. package/src/stories/CpContextualMenu.stories.ts +9 -8
  19. package/src/stories/CpDate.stories.ts +52 -25
  20. package/src/stories/CpDatepicker.stories.ts +57 -88
  21. package/src/stories/CpDialog.stories.ts +22 -1
  22. package/src/stories/CpHeading.stories.ts +59 -20
  23. package/src/stories/CpIcon.stories.ts +98 -31
  24. package/src/stories/CpInput.stories.ts +142 -67
  25. package/src/stories/CpItemActions.stories.ts +22 -27
  26. package/src/stories/CpLoader.stories.ts +54 -6
  27. package/src/stories/CpMenuItem.stories.ts +52 -26
  28. package/src/stories/CpMultiselect.stories.ts +52 -71
  29. package/src/stories/CpPartnerBadge.stories.ts +53 -74
  30. package/src/stories/CpRadio.stories.ts +44 -48
  31. package/src/stories/CpRadioGroup.stories.ts +46 -39
  32. package/src/stories/CpSelect.stories.ts +98 -39
  33. package/src/stories/CpSelectMenu.stories.ts +49 -57
  34. package/src/stories/CpSelectableButton.stories.ts +170 -81
  35. package/src/stories/CpSwitch.stories.ts +135 -133
  36. package/src/stories/CpTable.stories.ts +54 -1
  37. package/src/stories/CpTableEmptyState.stories.ts +11 -7
  38. package/src/stories/CpTabs.stories.ts +22 -4
  39. package/src/stories/CpTelInput.stories.ts +25 -23
  40. package/src/stories/CpText.stories.ts +131 -0
  41. package/src/stories/CpTextarea.stories.ts +59 -23
  42. package/src/stories/CpToast.stories.ts +53 -103
  43. package/src/stories/CpTooltip.stories.ts +82 -77
  44. package/src/stories/CpTransitionCounter.stories.ts +4 -0
  45. package/src/stories/CpTransitionExpand.stories.ts +11 -6
  46. package/src/stories/CpTransitionListItems.stories.ts +5 -0
  47. package/src/stories/CpTransitionSize.stories.ts +8 -0
  48. package/src/stories/CpTransitionSlide.stories.ts +4 -0
  49. package/src/stories/CpTransitionTabContent.stories.ts +4 -0
  50. package/src/stories/Dimensions.mdx +9 -0
  51. package/src/stories/Dimensions.stories.ts +119 -0
  52. package/src/stories/Easings.mdx +9 -0
  53. package/src/stories/Easings.stories.ts +101 -0
  54. package/src/stories/FocusRings.mdx +9 -0
  55. package/src/stories/FocusRings.stories.ts +74 -0
  56. package/src/stories/Shadows.mdx +9 -0
  57. package/src/stories/Shadows.stories.ts +100 -0
  58. package/src/stories/Typography.mdx +9 -0
  59. package/src/stories/Typography.stories.ts +181 -0
  60. package/src/stories/documentationStyles.ts +2 -10
  61. package/src/stories/tokenUtils.ts +259 -0
@@ -2,32 +2,44 @@ import type { Args, Meta, StoryObj } from '@storybook/vue3'
2
2
 
3
3
  import CpBadge from '@/components/CpBadge.vue'
4
4
 
5
- import {
6
- docCellStyle,
7
- docLabelStyle,
8
- docPageStyle,
9
- docRowWrapStyle,
10
- docSectionStyle,
11
- docTitleStyle,
12
- } from '@/stories/documentationStyles'
5
+ import { docCellStyle, docLabelStyle, docRowWrapStyle } from '@/stories/documentationStyles'
6
+
7
+ const badgeColors = [
8
+ 'neutral',
9
+ 'accent',
10
+ 'error',
11
+ 'warning',
12
+ 'success',
13
+ 'blue',
14
+ 'pink',
15
+ 'magenta',
16
+ 'yellow',
17
+ 'white',
18
+ ] as const
19
+
20
+ const badgeSizes = ['2xs', 'xs', 'sm', 'md'] as const
21
+
22
+ const badgeVariants = ['outline', 'soft', 'solid'] as const
23
+
24
+ const badgeIcons = ['', 'check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down', 'plus'] as const
13
25
 
14
26
  const meta = {
15
- title: 'Visual/CpBadge',
27
+ title: 'Atoms/CpBadge',
16
28
  component: CpBadge,
17
29
  argTypes: {
18
30
  color: {
19
31
  control: 'select',
20
- options: ['neutral', 'accent', 'error', 'warning', 'success', 'blue', 'pink', 'magenta', 'yellow', 'white'],
32
+ options: badgeColors,
21
33
  description: 'The color variant of the badge',
22
34
  },
23
35
  size: {
24
36
  control: 'select',
25
- options: ['2xs', 'xs', 'sm', 'md'],
37
+ options: badgeSizes,
26
38
  description: 'The size of the badge',
27
39
  },
28
40
  variant: {
29
41
  control: 'select',
30
- options: ['outline', 'soft', 'solid'],
42
+ options: badgeVariants,
31
43
  description: 'The variant of the badge',
32
44
  },
33
45
  disabled: {
@@ -40,12 +52,12 @@ const meta = {
40
52
  },
41
53
  leadingIcon: {
42
54
  control: 'select',
43
- options: ['', 'check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down', 'plus'],
55
+ options: badgeIcons,
44
56
  description: 'Type of leading icon (if any)',
45
57
  },
46
58
  trailingIcon: {
47
59
  control: 'select',
48
- options: ['', 'check', 'arrow-right', 'arrow-left', 'arrow-up', 'arrow-down', 'plus'],
60
+ options: badgeIcons,
49
61
  description: 'Type of trailing icon (if any)',
50
62
  },
51
63
  label: {
@@ -72,204 +84,258 @@ const defaultRender = (args: Args) => ({
72
84
  template: defaultTemplate,
73
85
  })
74
86
 
75
- export const Documentation: Story = {
76
- args: {},
87
+ /**
88
+ * Default badge: neutral color, outline variant, medium size. Use the controls
89
+ * to experiment with each prop in isolation.
90
+ */
91
+ export const Default: Story = {
92
+ args: {
93
+ color: 'neutral',
94
+ size: 'md',
95
+ variant: 'outline',
96
+ isSquare: false,
97
+ disabled: false,
98
+ leadingIcon: '',
99
+ trailingIcon: '',
100
+ label: 'Badge',
101
+ isClearable: false,
102
+ },
103
+ render: defaultRender,
104
+ }
105
+
106
+ /* -------------------------------------------------------------------------- */
107
+ /* Sizes */
108
+ /* -------------------------------------------------------------------------- */
109
+
110
+ /**
111
+ * All sizes rendered side by side, from `2xs` to `md`.
112
+ */
113
+ export const Sizes: Story = {
114
+ parameters: { controls: { disable: true } },
77
115
  render: () => ({
78
116
  components: { CpBadge },
79
- setup: () => ({}),
117
+ setup() {
118
+ return { badgeSizes, docCellStyle, docLabelStyle, docRowWrapStyle }
119
+ },
80
120
  template: `
81
- <div>
82
- <div style="${docPageStyle}">
83
- <h1 style="margin: 0 0 32px 0; font-size: 28px; font-weight: 700; color: #111;">CpBadge</h1>
84
-
85
- <section style="${docSectionStyle}">
86
- <h2 style="${docTitleStyle}">Size</h2>
87
- <div style="${docRowWrapStyle}">
88
- <div style="${docCellStyle}">
89
- <span style="${docLabelStyle}">2xs</span>
90
- <CpBadge color="accent" size="2xs" label="Badge" />
91
- </div>
92
- <div style="${docCellStyle}">
93
- <span style="${docLabelStyle}">xs</span>
94
- <CpBadge color="accent" size="xs" label="Badge" />
95
- </div>
96
- <div style="${docCellStyle}">
97
- <span style="${docLabelStyle}">sm</span>
98
- <CpBadge color="accent" size="sm" label="Badge" />
99
- </div>
100
- <div style="${docCellStyle}">
101
- <span style="${docLabelStyle}">md</span>
102
- <CpBadge color="accent" size="md" label="Badge" />
103
- </div>
104
- </div>
105
- </section>
121
+ <div :style="docRowWrapStyle">
122
+ <div v-for="size in badgeSizes" :key="size" :style="docCellStyle">
123
+ <span :style="docLabelStyle">{{ size }}</span>
124
+ <CpBadge color="accent" :size="size" label="Badge" />
125
+ </div>
126
+ </div>
127
+ `,
128
+ }),
129
+ }
106
130
 
107
- <section style="${docSectionStyle}">
108
- <h2 style="${docTitleStyle}">Color</h2>
109
- <div style="${docRowWrapStyle}">
110
- <div style="${docCellStyle}">
111
- <span style="${docLabelStyle}">neutral</span>
112
- <CpBadge color="neutral" label="Badge" />
113
- </div>
114
- <div style="${docCellStyle}">
115
- <span style="${docLabelStyle}">accent</span>
116
- <CpBadge color="accent" label="Badge" />
117
- </div>
118
- <div style="${docCellStyle}">
119
- <span style="${docLabelStyle}">error</span>
120
- <CpBadge color="error" label="Badge" />
121
- </div>
122
- <div style="${docCellStyle}">
123
- <span style="${docLabelStyle}">warning</span>
124
- <CpBadge color="warning" label="Badge" />
125
- </div>
126
- <div style="${docCellStyle}">
127
- <span style="${docLabelStyle}">success</span>
128
- <CpBadge color="success" label="Badge" />
129
- </div>
130
- <div style="${docCellStyle}">
131
- <span style="${docLabelStyle}">blue</span>
132
- <CpBadge color="blue" label="Badge" />
133
- </div>
134
- <div style="${docCellStyle}">
135
- <span style="${docLabelStyle}">pink</span>
136
- <CpBadge color="pink" label="Badge" />
137
- </div>
138
- <div style="${docCellStyle}">
139
- <span style="${docLabelStyle}">magenta</span>
140
- <CpBadge color="magenta" label="Badge" />
141
- </div>
142
- <div style="${docCellStyle}">
143
- <span style="${docLabelStyle}">yellow</span>
144
- <CpBadge color="yellow" label="Badge" />
145
- </div>
146
- <div style="${docCellStyle}">
147
- <span style="${docLabelStyle}">white</span>
148
- <CpBadge color="white" label="Badge" />
149
- </div>
150
- </div>
151
- </section>
131
+ /* -------------------------------------------------------------------------- */
132
+ /* Colors */
133
+ /* -------------------------------------------------------------------------- */
152
134
 
153
- <section style="${docSectionStyle}">
154
- <h2 style="${docTitleStyle}">Variant</h2>
155
- <table style="border-collapse: collapse; width: 100%;">
156
- <thead>
157
- <tr>
158
- <th style="text-align: left; padding: 8px 12px; font-size: 12px; color: #666; font-weight: 500;"></th>
159
- <th v-for="color in ['neutral', 'accent', 'error', 'warning', 'success', 'blue', 'pink', 'magenta', 'yellow', 'white']" :key="color" style="text-align: center; padding: 8px 12px; font-size: 12px; color: #666; font-weight: 500;">{{ color }}</th>
160
- </tr>
161
- </thead>
162
- <tbody>
163
- <tr v-for="variant in ['outline', 'soft', 'solid']" :key="variant">
164
- <td style="padding: 8px 12px; font-size: 12px; color: #666;">{{ variant }}</td>
165
- <td v-for="color in ['neutral', 'accent', 'error', 'warning', 'success', 'blue', 'pink', 'magenta', 'yellow', 'white']" :key="color" style="padding: 8px 12px; text-align: center;">
166
- <CpBadge :color="color" :variant label="Badge" />
167
- </td>
168
- </tr>
169
- </tbody>
170
- </table>
171
- </section>
135
+ /**
136
+ * Every semantic and utility color available for the badge.
137
+ */
138
+ export const Colors: Story = {
139
+ parameters: { controls: { disable: true } },
140
+ render: () => ({
141
+ components: { CpBadge },
142
+ setup() {
143
+ return { badgeColors, docCellStyle, docLabelStyle, docRowWrapStyle }
144
+ },
145
+ template: `
146
+ <div :style="docRowWrapStyle">
147
+ <div v-for="color in badgeColors" :key="color" :style="docCellStyle">
148
+ <span :style="docLabelStyle">{{ color }}</span>
149
+ <CpBadge :color="color" label="Badge" />
150
+ </div>
151
+ </div>
152
+ `,
153
+ }),
154
+ }
172
155
 
173
- <section style="${docSectionStyle}">
174
- <h2 style="${docTitleStyle}">disabled</h2>
175
- <div style="${docRowWrapStyle}">
176
- <div style="${docCellStyle}">
177
- <span style="${docLabelStyle}">false</span>
178
- <CpBadge color="accent" label="Badge" />
179
- </div>
180
- <div style="${docCellStyle}">
181
- <span style="${docLabelStyle}">true</span>
182
- <CpBadge color="accent" :disabled="true" label="Badge" />
183
- </div>
184
- </div>
185
- </section>
156
+ /* -------------------------------------------------------------------------- */
157
+ /* Variants */
158
+ /* -------------------------------------------------------------------------- */
186
159
 
187
- <section style="${docSectionStyle}">
188
- <h2 style="${docTitleStyle}">is-square</h2>
189
- <div style="${docRowWrapStyle}">
190
- <div style="${docCellStyle}">
191
- <span style="${docLabelStyle}">false</span>
192
- <CpBadge color="accent" :is-square="false" label="Badge" />
193
- </div>
194
- <div style="${docCellStyle}">
195
- <span style="${docLabelStyle}">true</span>
196
- <CpBadge color="accent" :is-square="true" label="Badge" />
197
- </div>
198
- </div>
199
- </section>
160
+ /**
161
+ * Variant × color matrix, showing how each variant renders across every color.
162
+ */
163
+ export const Variants: Story = {
164
+ parameters: { controls: { disable: true } },
165
+ render: () => ({
166
+ components: { CpBadge },
167
+ setup() {
168
+ return { badgeColors, badgeVariants }
169
+ },
170
+ template: `
171
+ <table style="border-collapse: collapse; width: 100%;">
172
+ <thead>
173
+ <tr>
174
+ <th style="text-align: left; padding: 8px 12px; font-size: 12px; color: #666; font-weight: 500;"></th>
175
+ <th
176
+ v-for="color in badgeColors"
177
+ :key="color"
178
+ style="text-align: center; padding: 8px 12px; font-size: 12px; color: #666; font-weight: 500; text-transform: capitalize;"
179
+ >
180
+ {{ color }}
181
+ </th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr v-for="variant in badgeVariants" :key="variant">
186
+ <td style="padding: 8px 12px; font-size: 12px; color: #666; text-transform: capitalize;">{{ variant }}</td>
187
+ <td
188
+ v-for="color in badgeColors"
189
+ :key="color"
190
+ style="padding: 8px 12px; text-align: center;"
191
+ >
192
+ <CpBadge :color="color" :variant="variant" label="Badge" />
193
+ </td>
194
+ </tr>
195
+ </tbody>
196
+ </table>
197
+ `,
198
+ }),
199
+ }
200
200
 
201
- <section style="${docSectionStyle}">
202
- <h2 style="${docTitleStyle}">leading-icon & trailing-icon</h2>
203
- <div style="${docRowWrapStyle}">
204
- <div style="${docCellStyle}">
205
- <span style="${docLabelStyle}">default</span>
206
- <CpBadge color="accent" label="Badge" />
207
- </div>
208
- <div style="${docCellStyle}">
209
- <span style="${docLabelStyle}">leading</span>
210
- <CpBadge color="accent" leading-icon="check" label="Badge" />
211
- </div>
212
- <div style="${docCellStyle}">
213
- <span style="${docLabelStyle}">leading + trailing</span>
214
- <CpBadge color="accent" leading-icon="check" trailing-icon="arrow-right" label="Badge" />
215
- </div>
216
- <div style="${docCellStyle}">
217
- <span style="${docLabelStyle}">trailing</span>
218
- <CpBadge color="accent" trailing-icon="arrow-right" label="Badge" />
219
- </div>
220
- <div style="${docCellStyle}">
221
- <span style="${docLabelStyle}">without label</span>
222
- <CpBadge color="accent" leading-icon="check" />
223
- </div>
224
- </div>
225
- </section>
201
+ /* -------------------------------------------------------------------------- */
202
+ /* Disabled */
203
+ /* -------------------------------------------------------------------------- */
226
204
 
227
- <section style="${docSectionStyle}">
228
- <h2 style="${docTitleStyle}">is-clearable</h2>
229
- <div style="${docRowWrapStyle}">
230
- <div style="${docCellStyle}">
231
- <span style="${docLabelStyle}">without event</span>
232
- <CpBadge color="accent" label="Badge" />
233
- </div>
234
- <div style="${docCellStyle}">
235
- <span style="${docLabelStyle}">with event</span>
236
- <CpBadge color="accent" @on-clear="console.log('clear')" is-clearable label="Badge" />
237
- </div>
238
- <div style="${docCellStyle}">
239
- <span style="${docLabelStyle}">with disabled clear</span>
240
- <CpBadge color="accent" @on-clear="console.log('clear')" is-clearable disabled label="Badge" />
241
- </div>
242
- </div>
243
- </section>
205
+ /**
206
+ * Enabled and disabled states compared side by side.
207
+ */
208
+ export const Disabled: Story = {
209
+ parameters: { controls: { disable: true } },
210
+ render: () => ({
211
+ components: { CpBadge },
212
+ setup() {
213
+ return { docCellStyle, docLabelStyle, docRowWrapStyle }
214
+ },
215
+ template: `
216
+ <div :style="docRowWrapStyle">
217
+ <div :style="docCellStyle">
218
+ <span :style="docLabelStyle">Enabled</span>
219
+ <CpBadge color="accent" label="Badge" />
220
+ </div>
221
+ <div :style="docCellStyle">
222
+ <span :style="docLabelStyle">Disabled</span>
223
+ <CpBadge color="accent" :disabled="true" label="Badge" />
244
224
  </div>
245
225
  </div>
246
226
  `,
247
227
  }),
248
- parameters: {
249
- controls: { disable: true },
250
- docs: {
251
- source: {
252
- code: null,
253
- },
228
+ }
229
+
230
+ /* -------------------------------------------------------------------------- */
231
+ /* Square vs rounded */
232
+ /* -------------------------------------------------------------------------- */
233
+
234
+ /**
235
+ * Fully rounded (default) compared with the square variant.
236
+ */
237
+ export const Squared: Story = {
238
+ parameters: { controls: { disable: true } },
239
+ render: () => ({
240
+ components: { CpBadge },
241
+ setup() {
242
+ return { docCellStyle, docLabelStyle, docRowWrapStyle }
254
243
  },
255
- },
244
+ template: `
245
+ <div :style="docRowWrapStyle">
246
+ <div :style="docCellStyle">
247
+ <span :style="docLabelStyle">Rounded</span>
248
+ <CpBadge color="accent" :is-square="false" label="Badge" />
249
+ </div>
250
+ <div :style="docCellStyle">
251
+ <span :style="docLabelStyle">Square</span>
252
+ <CpBadge color="accent" :is-square="true" label="Badge" />
253
+ </div>
254
+ </div>
255
+ `,
256
+ }),
256
257
  }
257
258
 
258
- export const Default: Story = {
259
- args: {
260
- color: 'neutral',
261
- size: 'md',
262
- variant: 'outline',
263
- isSquare: false,
264
- disabled: false,
265
- leadingIcon: '',
266
- trailingIcon: '',
267
- label: 'Badge',
268
- isClearable: false,
269
- },
259
+ /* -------------------------------------------------------------------------- */
260
+ /* Icons */
261
+ /* -------------------------------------------------------------------------- */
262
+
263
+ /**
264
+ * Badge with a leading icon.
265
+ */
266
+ export const WithLeadingIcon: Story = {
267
+ args: { ...Default.args, color: 'accent', leadingIcon: 'check' },
268
+ render: defaultRender,
269
+ }
270
+
271
+ /**
272
+ * Badge with a trailing icon.
273
+ */
274
+ export const WithTrailingIcon: Story = {
275
+ args: { ...Default.args, color: 'accent', trailingIcon: 'arrow-right' },
276
+ render: defaultRender,
277
+ }
278
+
279
+ /**
280
+ * Badge with both a leading and a trailing icon.
281
+ */
282
+ export const WithBothIcons: Story = {
283
+ args: { ...Default.args, color: 'accent', leadingIcon: 'check', trailingIcon: 'arrow-right' },
270
284
  render: defaultRender,
271
285
  }
272
286
 
287
+ /**
288
+ * Badge without a label, acting as an icon-only indicator.
289
+ */
290
+ export const WithoutLabel: Story = {
291
+ args: { ...Default.args, color: 'accent', leadingIcon: 'check', label: '' },
292
+ render: defaultRender,
293
+ }
294
+
295
+ /* -------------------------------------------------------------------------- */
296
+ /* Clearable */
297
+ /* -------------------------------------------------------------------------- */
298
+
299
+ /**
300
+ * The clearable affordance shows up when `isClearable` is `true` and an
301
+ * `onClear` listener is provided. The clear button follows the badge disabled
302
+ * state.
303
+ */
304
+ export const Clearable: Story = {
305
+ parameters: { controls: { disable: true } },
306
+ render: () => ({
307
+ components: { CpBadge },
308
+ setup() {
309
+ const onClear = () => console.log('clear')
310
+ return { docCellStyle, docLabelStyle, docRowWrapStyle, onClear }
311
+ },
312
+ template: `
313
+ <div :style="docRowWrapStyle">
314
+ <div :style="docCellStyle">
315
+ <span :style="docLabelStyle">Not clearable</span>
316
+ <CpBadge color="accent" label="Badge" />
317
+ </div>
318
+ <div :style="docCellStyle">
319
+ <span :style="docLabelStyle">Clearable</span>
320
+ <CpBadge color="accent" :is-clearable="true" label="Badge" @on-clear="onClear" />
321
+ </div>
322
+ <div :style="docCellStyle">
323
+ <span :style="docLabelStyle">Clearable (disabled)</span>
324
+ <CpBadge color="accent" :is-clearable="true" :disabled="true" label="Badge" @on-clear="onClear" />
325
+ </div>
326
+ </div>
327
+ `,
328
+ }),
329
+ }
330
+
331
+ /* -------------------------------------------------------------------------- */
332
+ /* Slots */
333
+ /* -------------------------------------------------------------------------- */
334
+
335
+ /**
336
+ * Customize the icons and the label through `#leading-icon`, `#trailing-icon`
337
+ * and the default slot.
338
+ */
273
339
  export const WithSlot: Story = {
274
340
  render: (args: Args) => ({
275
341
  components: { CpBadge },