@aleph-alpha/ui-library 7.0.1 → 7.0.2

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 (115) hide show
  1. package/dist/system/icons/story-sidebar-icons.json +74 -17
  2. package/dist/system/lib.js +8 -5
  3. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  4. package/dist/system/story-sidebar-icons.json +74 -17
  5. package/package.json +8 -3
  6. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  7. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  8. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  9. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  10. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  11. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  12. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  13. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  14. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  15. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  16. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  17. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  18. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  19. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  20. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  21. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  22. package/src/components/UiButton/UiButton.stories.ts +5 -2
  23. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  24. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  25. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  26. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  27. package/src/components/UiCard/UiCard.guidance.md +65 -0
  28. package/src/components/UiCard/UiCard.stories.ts +393 -0
  29. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  30. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  31. package/src/components/UiChip/UiChip.guidance.md +64 -0
  32. package/src/components/UiChip/UiChip.stories.ts +162 -138
  33. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  34. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  35. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  36. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  37. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  38. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  39. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  40. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  41. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
  42. package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
  43. package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
  44. package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
  45. package/src/components/UiField/UiField.guidance.md +63 -0
  46. package/src/components/UiField/UiField.stories.ts +90 -113
  47. package/src/components/UiFileType/UiFileType.stories.ts +254 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
  49. package/src/components/UiIcon/UiIcon.stories.ts +256 -1
  50. package/src/components/UiInput/UiInput.guidance.md +64 -0
  51. package/src/components/UiInput/UiInput.stories.ts +132 -80
  52. package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
  53. package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
  54. package/src/components/UiItem/UiItem.guidance.md +66 -0
  55. package/src/components/UiItem/UiItem.stories.ts +81 -28
  56. package/src/components/UiKbd/UiKbd.guidance.md +65 -0
  57. package/src/components/UiKbd/UiKbd.stories.ts +373 -3
  58. package/src/components/UiLabel/UiLabel.guidance.md +65 -0
  59. package/src/components/UiLabel/UiLabel.stories.ts +163 -139
  60. package/src/components/UiListbox/UiListbox.stories.ts +197 -195
  61. package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
  62. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
  63. package/src/components/UiPopover/UiPopover.guidance.md +65 -0
  64. package/src/components/UiPopover/UiPopover.stories.ts +115 -91
  65. package/src/components/UiProgress/UiProgress.guidance.md +65 -0
  66. package/src/components/UiProgress/UiProgress.stories.ts +300 -0
  67. package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
  68. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
  69. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
  70. package/src/components/UiResizable/UiResizable.guidance.md +65 -0
  71. package/src/components/UiResizable/UiResizable.stories.ts +176 -152
  72. package/src/components/UiSelect/UiSelect.guidance.md +66 -0
  73. package/src/components/UiSelect/UiSelect.stories.ts +150 -126
  74. package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
  75. package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
  76. package/src/components/UiSheet/UiSheet.guidance.md +66 -0
  77. package/src/components/UiSheet/UiSheet.stories.ts +194 -170
  78. package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
  79. package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
  80. package/src/components/UiSlider/UiSlider.guidance.md +66 -0
  81. package/src/components/UiSlider/UiSlider.stories.ts +150 -126
  82. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  83. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  84. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  85. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  86. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  87. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  88. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  89. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  90. package/src/components/UiTable/UiTable.guidance.md +66 -0
  91. package/src/components/UiTable/UiTable.stories.ts +530 -12
  92. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  93. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  94. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  95. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  96. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  97. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  98. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  99. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  100. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  101. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  102. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  103. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  104. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  105. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  106. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  107. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  108. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  109. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  110. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  111. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  112. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  113. package/src/patterns/UiPlaceholder/types.ts +1 -0
  114. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
  115. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -13,6 +13,16 @@ import {
13
13
  import type { UiStepperItemProps, UiStepperProps } from './types';
14
14
  import { UiIcon } from '../UiIcon';
15
15
  import { BookUserIcon, CreditCardIcon, TruckIcon } from '@/icons/lucide';
16
+ import {
17
+ accessibilityRequirementsTemplate,
18
+ designNotesStory,
19
+ guidanceLinks,
20
+ guidanceSectionClass,
21
+ parseGuidance,
22
+ } from '../../../.storybook/guidance';
23
+ import guidanceMarkdown from './UiStepper.guidance.md?raw';
24
+
25
+ const guidance = parseGuidance(guidanceMarkdown);
16
26
 
17
27
  /**
18
28
  * Story args: the UiStepper props plus the UiStepperItem props that are
@@ -64,6 +74,9 @@ const meta: Meta<StepperStoryArgs> = {
64
74
  disabled: false,
65
75
  completed: false,
66
76
  },
77
+ parameters: {
78
+ docs: { links: guidanceLinks(guidance) },
79
+ },
67
80
  };
68
81
 
69
82
  export default meta;
@@ -212,6 +225,135 @@ export const Default: Story = {
212
225
  },
213
226
  };
214
227
 
228
+ /**
229
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
230
+ */
231
+ export const DesignNotes: Story = {
232
+ ...designNotesStory(guidance),
233
+ tags: ['!autodocs'],
234
+ };
235
+
236
+ /**
237
+ * Accessibility guidance for distinguishing step states without colour,
238
+ * comfortable targets, reading order, and the accessible theme.
239
+ */
240
+ export const Accessibility: Story = {
241
+ render: () => ({
242
+ components: {
243
+ UiStepper,
244
+ UiStepperItem,
245
+ UiStepperTrigger,
246
+ UiStepperIndicator,
247
+ UiStepperTitle,
248
+ UiStepperDescription,
249
+ UiStepperSeparator,
250
+ },
251
+ setup() {
252
+ const steps = [1, 2, 3];
253
+ return { steps };
254
+ },
255
+ template: `
256
+ <section class="${guidanceSectionClass}">
257
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
258
+ Accessibility
259
+ </h2>
260
+
261
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
262
+
263
+ <div class="flex flex-col gap-2">
264
+ <h3 class="body-m-medium text-content-on-surface-primary">
265
+ In code
266
+ </h3>
267
+ <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
268
+ <li>Give every trigger an accessible title or name; never use an icon alone as its name</li>
269
+ <li>Keyboard users can Tab into the stepper, move with arrow keys, and activate with Enter or Space</li>
270
+ </ul>
271
+ </div>
272
+
273
+ <div class="flex flex-col gap-2">
274
+ <h3 class="body-m-medium text-content-on-surface-primary">
275
+ Enable accessibility theme
276
+ </h3>
277
+ <p class="body-m-regular text-content-on-surface-primary">
278
+ When accessibility is required, enable our accessibility theme.
279
+ This increases contrast and ensures there are no color contrast
280
+ issues.
281
+ </p>
282
+ </div>
283
+
284
+ <div class="grid gap-4 md:grid-cols-2">
285
+ <div class="flex flex-col gap-3">
286
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
287
+ Default
288
+ </h3>
289
+ <div class="flex justify-center border border-border-surface-default p-6">
290
+ <UiStepper :default-value="2" class="flex w-full items-start gap-2">
291
+ <UiStepperItem
292
+ v-for="step in steps"
293
+ :key="step"
294
+ :step="step"
295
+ class="relative flex w-full flex-col items-center justify-center"
296
+ >
297
+ <UiStepperTrigger>
298
+ <UiStepperIndicator>
299
+ <span>{{ step }}</span>
300
+ </UiStepperIndicator>
301
+ </UiStepperTrigger>
302
+ <UiStepperSeparator v-if="step !== steps.length" />
303
+ <div class="flex flex-col items-center">
304
+ <UiStepperTitle>Address</UiStepperTitle>
305
+ <UiStepperDescription>Add your address</UiStepperDescription>
306
+ </div>
307
+ </UiStepperItem>
308
+ </UiStepper>
309
+ </div>
310
+ </div>
311
+
312
+ <div class="accessible-theme flex flex-col gap-3">
313
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
314
+ Accessible
315
+ </h3>
316
+ <div class="flex justify-center border border-border-surface-default p-6">
317
+ <UiStepper :default-value="2" class="flex w-full items-start gap-2">
318
+ <UiStepperItem
319
+ v-for="step in steps"
320
+ :key="step"
321
+ :step="step"
322
+ class="relative flex w-full flex-col items-center justify-center"
323
+ >
324
+ <UiStepperTrigger>
325
+ <UiStepperIndicator>
326
+ <span>{{ step }}</span>
327
+ </UiStepperIndicator>
328
+ </UiStepperTrigger>
329
+ <UiStepperSeparator v-if="step !== steps.length" />
330
+ <div class="flex flex-col items-center">
331
+ <UiStepperTitle>Address</UiStepperTitle>
332
+ <UiStepperDescription>Add your address</UiStepperDescription>
333
+ </div>
334
+ </UiStepperItem>
335
+ </UiStepper>
336
+ </div>
337
+ </div>
338
+ </div>
339
+ </section>
340
+ `,
341
+ }),
342
+ tags: ['!autodocs'],
343
+ parameters: {
344
+ surface: 'primary',
345
+ a11y: { test: 'off' },
346
+ chromatic: {
347
+ disableSnapshot: true,
348
+ },
349
+ docs: {
350
+ canvas: {
351
+ sourceState: 'none',
352
+ },
353
+ },
354
+ },
355
+ };
356
+
215
357
  const horizontalTemplateSource = `<script setup lang="ts">
216
358
  import { ref } from 'vue'
217
359
  import {
@@ -479,130 +621,6 @@ export const Vertical: Story = {
479
621
  },
480
622
  };
481
623
 
482
- /**
483
- * Accessibility guidance for distinguishing step states without colour,
484
- * comfortable targets, reading order, and the accessible theme.
485
- */
486
- export const Accessibility: Story = {
487
- render: () => ({
488
- components: {
489
- UiStepper,
490
- UiStepperItem,
491
- UiStepperTrigger,
492
- UiStepperIndicator,
493
- UiStepperTitle,
494
- UiStepperDescription,
495
- UiStepperSeparator,
496
- },
497
- setup() {
498
- const steps = [1, 2, 3];
499
- return { steps };
500
- },
501
- template: `
502
- <section class="flex w-full flex-col gap-6 p-4">
503
- <h2 class="heading-m font-bold text-content-on-surface-primary">
504
- Accessibility
505
- </h2>
506
-
507
- <div class="flex flex-col gap-2">
508
- <h3 class="body-m-medium text-content-on-surface-primary">
509
- Requirements
510
- </h3>
511
- <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
512
- <li>Complete, active and pending differ in shape and weight, not colour alone</li>
513
- <li>The complete state carries a mark, such as a tick, rather than only a fill change</li>
514
- <li>Labels stay legible at the sm size and when they wrap</li>
515
- <li>The active step is identifiable without relying on the connector's colour</li>
516
- <li>Triggers and labels are comfortable targets where steps can be revisited</li>
517
- <li>Reading order follows the step order, horizontally or vertically as laid out</li>
518
- <li>Give every trigger an accessible title or name; never use an icon alone as its name</li>
519
- <li>Keyboard users can Tab into the stepper, move with arrow keys, and activate with Enter or Space</li>
520
- </ul>
521
- </div>
522
-
523
- <div class="flex flex-col gap-2">
524
- <h3 class="body-m-medium text-content-on-surface-primary">
525
- Enable accessibility theme
526
- </h3>
527
- <p class="body-m-regular text-content-on-surface-primary">
528
- When accessibility is required, enable our accessibility theme.
529
- This increases contrast and ensures there are no color contrast
530
- issues.
531
- </p>
532
- </div>
533
-
534
- <div class="grid gap-4 md:grid-cols-2">
535
- <div class="flex flex-col gap-3">
536
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
537
- Default
538
- </h3>
539
- <div class="flex justify-center border border-border-surface-default p-6">
540
- <UiStepper :default-value="2" class="flex w-full items-start gap-2">
541
- <UiStepperItem
542
- v-for="step in steps"
543
- :key="step"
544
- :step="step"
545
- class="relative flex w-full flex-col items-center justify-center"
546
- >
547
- <UiStepperTrigger>
548
- <UiStepperIndicator>
549
- <span>{{ step }}</span>
550
- </UiStepperIndicator>
551
- </UiStepperTrigger>
552
- <UiStepperSeparator v-if="step !== steps.length" />
553
- <div class="flex flex-col items-center">
554
- <UiStepperTitle>Address</UiStepperTitle>
555
- <UiStepperDescription>Add your address</UiStepperDescription>
556
- </div>
557
- </UiStepperItem>
558
- </UiStepper>
559
- </div>
560
- </div>
561
-
562
- <div class="accessible-theme flex flex-col gap-3">
563
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
564
- Accessible
565
- </h3>
566
- <div class="flex justify-center border border-border-surface-default p-6">
567
- <UiStepper :default-value="2" class="flex w-full items-start gap-2">
568
- <UiStepperItem
569
- v-for="step in steps"
570
- :key="step"
571
- :step="step"
572
- class="relative flex w-full flex-col items-center justify-center"
573
- >
574
- <UiStepperTrigger>
575
- <UiStepperIndicator>
576
- <span>{{ step }}</span>
577
- </UiStepperIndicator>
578
- </UiStepperTrigger>
579
- <UiStepperSeparator v-if="step !== steps.length" />
580
- <div class="flex flex-col items-center">
581
- <UiStepperTitle>Address</UiStepperTitle>
582
- <UiStepperDescription>Add your address</UiStepperDescription>
583
- </div>
584
- </UiStepperItem>
585
- </UiStepper>
586
- </div>
587
- </div>
588
- </div>
589
- </section>
590
- `,
591
- }),
592
- tags: ['!autodocs'],
593
- parameters: {
594
- a11y: { test: 'off' },
595
- chromatic: {
596
- disableSnapshot: true,
597
- },
598
- docs: {
599
- canvas: {
600
- sourceState: 'none',
601
- },
602
- },
603
- },
604
- };
605
-
606
624
  /*
607
625
  * ─────────────────────────────────────────────────────────────────────────────
608
626
  * Interaction & accessibility tests (play functions)
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29209:71413'
3
+ ---
4
+
5
+ <!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
6
+
7
+ ## Usage
8
+
9
+ The Switch component turns a single setting on or off, and the change takes effect as soon as it is made. There is no save step, which is exactly what separates it from a checkbox.
10
+
11
+ Use it for settings that apply immediately. When the choice is part of a form and only takes effect on submit, Checkbox is the honest control.
12
+
13
+ ### Immediate, and reversible
14
+
15
+ A switch promises that something just happened:
16
+
17
+ - The change applies at once, with no confirm step
18
+ - The new state is visible on the switch itself
19
+ - Turning it back off is as easy as turning it on
20
+ - Nothing destructive hides behind a switch
21
+
22
+ ### Label the setting, not the state
23
+
24
+ The label stays the same whichever way the switch is set:
25
+
26
+ 1. Label names the setting, phrased so that on means on
27
+ 2. Description adds the consequence of turning it on
28
+ 3. Control placement puts the switch at the start, or the end for settings rows
29
+ 4. The whole row is the target, label included
30
+
31
+ ### Consistency
32
+
33
+ Every switch is built from the same parts:
34
+
35
+ - Switch, default or box type, at default or small size
36
+ - Control placement, at the start or the end
37
+ - Label, always present; description, where it helps
38
+ - States: default and focus, active on or off
39
+ - Switch group, for related settings
40
+
41
+ ## Do
42
+
43
+ - Use a switch only where the change applies immediately
44
+ - Phrase the label so that on means the thing is on
45
+ - Keep the label the same whichever way the switch is set
46
+ - Make the whole row the target
47
+ - Use one control placement throughout a settings screen
48
+ - Group related settings with a switch group
49
+
50
+ ## Don't
51
+
52
+ - Use a switch inside a form that is submitted — use Checkbox
53
+ - Change the label depending on the state
54
+ - Put a destructive action behind a switch
55
+ - Ask the user to confirm a switch
56
+ - Mix control placement within one screen
57
+ - Rely on the track colour alone to show which way the switch is set
58
+
59
+ ## Accessibility
60
+
61
+ - On and off differ by the handle's position as well as its fill, so the state survives without colour
62
+ - Focus is visible on the switch and distinguishable from the on state
63
+ - The whole row is a comfortable target, including on touch
64
+ - The label names the setting, so it reads correctly whichever way the switch is set
65
+ - The small size keeps a target big enough to hit, even where the visual is reduced
66
+ - Descriptions stay visually attached to their own switch, not to the next one