@aleph-alpha/ui-library 7.0.0 → 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 (118) hide show
  1. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +1 -1
  2. package/dist/system/icons/story-sidebar-icons.json +74 -17
  3. package/dist/system/lib.js +1167 -1162
  4. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  5. package/dist/system/story-sidebar-icons.json +74 -17
  6. package/package.json +8 -3
  7. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  8. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  9. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  10. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  11. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  12. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  13. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  14. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  15. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  16. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  17. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  18. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  19. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  20. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  21. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  22. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  23. package/src/components/UiButton/UiButton.stories.ts +5 -2
  24. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  25. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  26. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  27. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  28. package/src/components/UiCard/UiCard.guidance.md +65 -0
  29. package/src/components/UiCard/UiCard.stories.ts +393 -0
  30. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  31. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  32. package/src/components/UiChip/UiChip.guidance.md +64 -0
  33. package/src/components/UiChip/UiChip.stories.ts +162 -138
  34. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  35. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  36. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  37. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  38. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  39. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  40. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  41. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  42. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +332 -85
  43. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +134 -0
  44. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +23 -2
  45. package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
  46. package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
  47. package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
  48. package/src/components/UiField/UiField.guidance.md +63 -0
  49. package/src/components/UiField/UiField.stories.ts +90 -113
  50. package/src/components/UiFileType/UiFileType.stories.ts +254 -0
  51. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
  52. package/src/components/UiIcon/UiIcon.stories.ts +256 -1
  53. package/src/components/UiInput/UiInput.guidance.md +64 -0
  54. package/src/components/UiInput/UiInput.stories.ts +132 -80
  55. package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
  56. package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
  57. package/src/components/UiItem/UiItem.guidance.md +66 -0
  58. package/src/components/UiItem/UiItem.stories.ts +81 -28
  59. package/src/components/UiKbd/UiKbd.guidance.md +65 -0
  60. package/src/components/UiKbd/UiKbd.stories.ts +373 -3
  61. package/src/components/UiLabel/UiLabel.guidance.md +65 -0
  62. package/src/components/UiLabel/UiLabel.stories.ts +163 -139
  63. package/src/components/UiListbox/UiListbox.stories.ts +197 -195
  64. package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
  65. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
  66. package/src/components/UiPopover/UiPopover.guidance.md +65 -0
  67. package/src/components/UiPopover/UiPopover.stories.ts +115 -91
  68. package/src/components/UiProgress/UiProgress.guidance.md +65 -0
  69. package/src/components/UiProgress/UiProgress.stories.ts +300 -0
  70. package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
  71. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
  72. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
  73. package/src/components/UiResizable/UiResizable.guidance.md +65 -0
  74. package/src/components/UiResizable/UiResizable.stories.ts +176 -152
  75. package/src/components/UiSelect/UiSelect.guidance.md +66 -0
  76. package/src/components/UiSelect/UiSelect.stories.ts +150 -126
  77. package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
  78. package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
  79. package/src/components/UiSheet/UiSheet.guidance.md +66 -0
  80. package/src/components/UiSheet/UiSheet.stories.ts +194 -170
  81. package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
  82. package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
  83. package/src/components/UiSlider/UiSlider.guidance.md +66 -0
  84. package/src/components/UiSlider/UiSlider.stories.ts +150 -126
  85. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  86. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  87. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  88. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  89. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  90. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  91. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  92. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  93. package/src/components/UiTable/UiTable.guidance.md +66 -0
  94. package/src/components/UiTable/UiTable.stories.ts +530 -12
  95. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  96. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  97. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  98. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  99. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  100. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  101. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  102. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  103. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  104. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  105. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  106. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  107. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  108. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  109. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  110. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  111. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  112. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  113. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  114. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  115. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  116. package/src/patterns/UiPlaceholder/types.ts +1 -0
  117. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
  118. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -1,5 +1,15 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, userEvent, within } from 'storybook/test';
2
3
  import UiSkeleton from './UiSkeleton.vue';
4
+ import {
5
+ accessibilityStory,
6
+ designNotesStory,
7
+ guidanceLinks,
8
+ parseGuidance,
9
+ } from '../../../.storybook/guidance';
10
+ import guidanceMarkdown from './UiSkeleton.guidance.md?raw';
11
+
12
+ const guidance = parseGuidance(guidanceMarkdown);
3
13
 
4
14
  /**
5
15
  * UiSkeleton is a neutral placeholder shape that mimics the size of incoming content while it is loading.
@@ -26,6 +36,9 @@ const meta: Meta<typeof UiSkeleton> = {
26
36
  args: {
27
37
  rounded: false,
28
38
  },
39
+ parameters: {
40
+ docs: { links: guidanceLinks(guidance) },
41
+ },
29
42
  };
30
43
 
31
44
  export default meta;
@@ -70,6 +83,58 @@ export const Default: Story = {
70
83
  },
71
84
  },
72
85
  },
86
+ play: async ({ canvasElement, step }) => {
87
+ // Scenario (UiSkeleton): the placeholders hold the layout while loading
88
+ // but carry no content, role, or focus of their own.
89
+ const skeletons = canvasElement.querySelectorAll<HTMLElement>(
90
+ '[data-slot="skeleton"]',
91
+ );
92
+
93
+ await step('interaction: renders one placeholder per block', async () => {
94
+ await expect(skeletons).toHaveLength(3);
95
+ });
96
+
97
+ await step(
98
+ 'interaction: placeholders are empty and not focusable',
99
+ async () => {
100
+ for (const skeleton of skeletons) {
101
+ await expect(skeleton).toBeEmptyDOMElement();
102
+ await expect(skeleton).not.toHaveAttribute('tabindex');
103
+ }
104
+ },
105
+ );
106
+ },
107
+ };
108
+
109
+ /**
110
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
111
+ */
112
+ export const DesignNotes: Story = {
113
+ ...designNotesStory(guidance),
114
+ tags: ['!autodocs'],
115
+ };
116
+
117
+ /**
118
+ * Accessibility guidance from the Figma documentation, with the component in
119
+ * the default and accessible themes.
120
+ */
121
+ export const Accessibility: Story = {
122
+ ...accessibilityStory({
123
+ requirements: guidance.accessibility,
124
+ example: {
125
+ components: { UiSkeleton },
126
+ template: `
127
+ <div class="flex items-center gap-3">
128
+ <UiSkeleton class="h-10 w-10 rounded-full" />
129
+ <div class="flex flex-col gap-2">
130
+ <UiSkeleton class="h-4 w-32" />
131
+ <UiSkeleton class="h-4 w-24" />
132
+ </div>
133
+ </div>
134
+ `,
135
+ },
136
+ }),
137
+ tags: ['!autodocs'],
73
138
  };
74
139
 
75
140
  const cardTemplateSource = `<script setup lang="ts">
@@ -249,3 +314,191 @@ export const Table: Story = {
249
314
  },
250
315
  },
251
316
  };
317
+
318
+ const renderTestSkeleton = () => ({
319
+ components: { UiSkeleton },
320
+ template: `
321
+ <div role="status" aria-busy="true" class="flex w-full max-w-sm items-center gap-x-4">
322
+ <span class="sr-only">Loading profile</span>
323
+ <UiSkeleton class="h-12 w-12 shrink-0" rounded />
324
+ <div class="flex min-w-0 flex-1 flex-col gap-y-2">
325
+ <UiSkeleton class="h-4 w-full" />
326
+ <UiSkeleton class="h-4 w-3/4" />
327
+ </div>
328
+ </div>
329
+ `,
330
+ });
331
+
332
+ const getSkeletons = (canvasElement: HTMLElement) =>
333
+ canvasElement.querySelectorAll<HTMLElement>('[data-slot="skeleton"]');
334
+
335
+ /**
336
+ * Skeletons are decorative placeholders, so there is nothing to focus: the
337
+ * keyboard check asserts they stay out of the tab order. Hidden test-only
338
+ * story.
339
+ */
340
+ export const KeyboardNavigation: Story = {
341
+ name: 'test - Keyboard Navigation',
342
+ tags: ['!dev', '!autodocs'],
343
+ parameters: {
344
+ // Focus moves during the play function.
345
+ chromatic: { disableSnapshot: true },
346
+ docs: {
347
+ description: {
348
+ story: 'Press `Tab`: focus skips the skeleton, which is decorative.',
349
+ },
350
+ },
351
+ },
352
+ render: renderTestSkeleton,
353
+ play: async ({ canvasElement, step }) => {
354
+ // Scenario (UiSkeleton): a keyboard user tabs through a loading page and
355
+ // never lands on a placeholder.
356
+ await step('keyboard: skeletons have no focusable target', async () => {
357
+ await userEvent.tab();
358
+ await expect(canvasElement.contains(document.activeElement)).toBe(false);
359
+ });
360
+
361
+ await step('keyboard: no skeleton carries a tabindex', async () => {
362
+ for (const skeleton of getSkeletons(canvasElement)) {
363
+ await expect(skeleton).not.toHaveAttribute('tabindex');
364
+ }
365
+ });
366
+ },
367
+ };
368
+
369
+ /**
370
+ * Skeletons are silent; the loading state is announced by a status message
371
+ * instead. Hidden test-only story.
372
+ */
373
+ export const ScreenReader: Story = {
374
+ name: 'test - Screen Reader',
375
+ tags: ['!dev', '!autodocs'],
376
+ parameters: {
377
+ docs: {
378
+ description: {
379
+ story:
380
+ 'Verifies that the skeletons are not announced as content and the wait is announced in text.',
381
+ },
382
+ },
383
+ },
384
+ render: renderTestSkeleton,
385
+ play: async ({ canvasElement, step }) => {
386
+ // Scenario (UiSkeleton): a screen-reader user hears "Loading profile",
387
+ // not a run of empty blocks mistaken for real content.
388
+ const canvas = within(canvasElement);
389
+
390
+ await step(
391
+ 'screen-reader: skeletons are not announced as real content',
392
+ async () => {
393
+ for (const skeleton of getSkeletons(canvasElement)) {
394
+ await expect(skeleton).toBeEmptyDOMElement();
395
+ await expect(skeleton).not.toHaveAttribute('role');
396
+ await expect(skeleton).not.toHaveAttribute('aria-label');
397
+ await expect(skeleton).toHaveAccessibleName('');
398
+ }
399
+ },
400
+ );
401
+
402
+ await step(
403
+ 'screen-reader: the wait is announced in text by a status region',
404
+ async () => {
405
+ const status = canvas.getByRole('status');
406
+ await expect(status).toHaveAttribute('aria-busy', 'true');
407
+ await expect(status).toHaveTextContent('Loading profile');
408
+ },
409
+ );
410
+ },
411
+ };
412
+
413
+ /**
414
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
415
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
416
+ */
417
+ export const ZoomMagnification: Story = {
418
+ name: 'test - Zoom Magnification',
419
+ tags: ['!dev', '!autodocs'],
420
+ globals: { zoom: '200' },
421
+ parameters: {
422
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
423
+ // already covers magnified snapshots, so skip this one.
424
+ chromatic: { disableSnapshot: true },
425
+ docs: {
426
+ description: {
427
+ story:
428
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
429
+ },
430
+ },
431
+ },
432
+ render: renderTestSkeleton,
433
+ play: async ({ canvasElement, step }) => {
434
+ // Scenario (UiSkeleton): at 200% page zoom the placeholders stay inside
435
+ // the viewport, so the page doesn't scroll sideways while loading.
436
+ await step(
437
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
438
+ async () => {
439
+ await expect(document.documentElement.style.zoom).toBe('200%');
440
+ },
441
+ );
442
+
443
+ await step('zoom: skeletons stay inside the viewport', async () => {
444
+ const skeletons = getSkeletons(canvasElement);
445
+ await expect(skeletons.length).toBeGreaterThan(0);
446
+ for (const skeleton of skeletons) {
447
+ const { left, right } = skeleton.getBoundingClientRect();
448
+ await expect(left).toBeGreaterThanOrEqual(0);
449
+ await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
450
+ }
451
+ });
452
+ },
453
+ };
454
+
455
+ /**
456
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
457
+ * toolbar. Hidden test-only story.
458
+ */
459
+ export const MobileBreakpoint: Story = {
460
+ name: 'test - Mobile Breakpoint',
461
+ tags: ['!dev', '!autodocs'],
462
+ globals: { mediaBreakpoint: 'reflow' },
463
+ parameters: {
464
+ // Reflow snapshots are already covered by the accessible-reflow mode.
465
+ chromatic: { disableSnapshot: true },
466
+ docs: {
467
+ description: {
468
+ story:
469
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
470
+ },
471
+ },
472
+ },
473
+ render: renderTestSkeleton,
474
+ play: async ({ canvasElement, step }) => {
475
+ // Scenario (UiSkeleton): at the 320px mobile breakpoint the placeholders
476
+ // fit without sideways scrolling.
477
+ const canvas = within(canvasElement);
478
+
479
+ await step(
480
+ 'mobile: the loading state renders at the 320px breakpoint',
481
+ async () => {
482
+ await expect(canvas.getByRole('status')).toBeInTheDocument();
483
+ await expect(getSkeletons(canvasElement)).toHaveLength(3);
484
+ },
485
+ );
486
+
487
+ await step(
488
+ 'mobile: the layout fits without sideways scrolling (WCAG 1.4.10 Reflow)',
489
+ async () => {
490
+ const { scrollWidth, clientWidth } = document.documentElement;
491
+ await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
492
+ },
493
+ );
494
+
495
+ await step(
496
+ 'mobile: skeletons add no touch targets of their own',
497
+ async () => {
498
+ // Placeholders take no input, so 2.5.8 doesn't apply to them.
499
+ await expect(canvas.queryAllByRole('button')).toHaveLength(0);
500
+ await expect(canvas.queryAllByRole('link')).toHaveLength(0);
501
+ },
502
+ );
503
+ },
504
+ };
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29207:71402'
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 Slider component sets a value by position within a range. The user gains a sense of where the value sits relative to the whole, and loses precision — which is the right trade only sometimes.
10
+
11
+ Use it when the approximate value matters more than the exact one: volume, brightness, a price band. When the user has an exact number in mind, an input is faster and kinder.
12
+
13
+ ### Position has to be readable
14
+
15
+ A slider is read before it is dragged:
16
+
17
+ - The filled portion shows how far along the value is
18
+ - The handle is clearly the part that moves
19
+ - The current value is shown in text wherever precision matters at all
20
+ - The ends of the range are labelled where their meaning is not obvious
21
+
22
+ ### Ranges need two handles
23
+
24
+ A range is one value made of two, so treat it as one:
25
+
26
+ 1. Both handles are visibly the same kind of control
27
+ 2. The span between them is filled, showing what is selected
28
+ 3. Handles cannot cross, and stop rather than swapping
29
+ 4. Both ends of the range are shown in text together
30
+
31
+ ### Consistency
32
+
33
+ Every slider is built from the same parts:
34
+
35
+ - Slider, single value or range
36
+ - Track, with a filled portion
37
+ - Handle, with default, hover and focus states
38
+ - A value in text, where precision matters
39
+ - One track height and handle size per context
40
+
41
+ ## Do
42
+
43
+ - Show the current value in text wherever precision matters at all
44
+ - Label the ends of the range where their meaning is not obvious
45
+ - Fill the track up to the value, so position reads at a glance
46
+ - Keep both handles identical in a range slider
47
+ - Stop handles at each other rather than letting them swap
48
+ - Offer an input alongside where the user may know the exact number
49
+
50
+ ## Don't
51
+
52
+ - Use a slider where an exact value is required
53
+ - Hide the current value entirely
54
+ - Make the handle smaller than it can comfortably be grabbed
55
+ - Let range handles cross each other
56
+ - Use a slider for a range with only a few possible values
57
+ - Rely on the fill colour alone to distinguish the filled track from the rest
58
+
59
+ ## Accessibility
60
+
61
+ - Filled and unfilled track differ in more than colour, so the value reads in greyscale
62
+ - The handle is a comfortable target on touch as well as pointer, larger than the track is tall
63
+ - The handle carries a visible focus state, distinct from hover
64
+ - The current value appears in text, so position is not the only way to read it
65
+ - In a range slider the two handles stay distinguishable at the ends of the track
66
+ - The track is tall enough that a value near either end is still visible
@@ -9,6 +9,16 @@ import {
9
9
  } from 'storybook/test';
10
10
  import { ref, watch } from 'vue';
11
11
  import { UiSlider } from '.';
12
+ import {
13
+ accessibilityRequirementsTemplate,
14
+ designNotesStory,
15
+ guidanceLinks,
16
+ guidanceSectionClass,
17
+ parseGuidance,
18
+ } from '../../../.storybook/guidance';
19
+ import guidanceMarkdown from './UiSlider.guidance.md?raw';
20
+
21
+ const guidance = parseGuidance(guidanceMarkdown);
12
22
 
13
23
  /**
14
24
  * UiSlider lets users pick a numeric value (single thumb) or a range (multiple thumbs) by dragging.
@@ -60,6 +70,9 @@ const meta: Meta<typeof UiSlider> = {
60
70
  orientation: 'horizontal',
61
71
  inverted: false,
62
72
  },
73
+ parameters: {
74
+ docs: { links: guidanceLinks(guidance) },
75
+ },
63
76
  };
64
77
 
65
78
  export default meta;
@@ -155,6 +168,143 @@ export const Default: Story = {
155
168
  },
156
169
  };
157
170
 
171
+ /**
172
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
173
+ */
174
+ export const DesignNotes: Story = {
175
+ ...designNotesStory(guidance),
176
+ tags: ['!autodocs'],
177
+ };
178
+
179
+ /**
180
+ * Accessibility guidance for labelling the slider, exposing its value as text,
181
+ * and keeping it operable from the keyboard.
182
+ */
183
+ export const Accessibility: Story = {
184
+ render: () => ({
185
+ components: { UiSlider },
186
+ setup() {
187
+ const defaultValue = ref([60]);
188
+ const accessibleValue = ref([60]);
189
+ return { defaultValue, accessibleValue };
190
+ },
191
+ template: `
192
+ <section class="${guidanceSectionClass}">
193
+ <div>
194
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
195
+ Accessibility
196
+ </h2>
197
+ </div>
198
+
199
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
200
+
201
+ <div class="flex flex-col gap-6">
202
+ <div class="flex flex-col gap-2">
203
+ <h3 class="body-m-medium text-content-on-surface-primary">
204
+ Label what the slider controls
205
+ </h3>
206
+ <p class="body-m-regular text-content-on-surface-primary">
207
+ Each handle is announced as a slider named <code>Value</code>
208
+ (<code>Value 1</code> / <code>Value 2</code> for a range), which
209
+ says nothing about what is being adjusted. Put a visible heading
210
+ or <code>label</code> next to the slider so the surrounding
211
+ context supplies the meaning.
212
+ </p>
213
+ </div>
214
+
215
+ <div class="flex flex-col gap-2">
216
+ <h3 class="body-m-medium text-content-on-surface-primary">
217
+ Show the current value as text
218
+ </h3>
219
+ <p class="body-m-regular text-content-on-surface-primary">
220
+ Handle position alone is not perceivable for everyone. Render the
221
+ value next to the slider so it can be read, magnified, and
222
+ translated — the same number assistive technology gets from
223
+ <code>aria-valuenow</code>.
224
+ </p>
225
+ </div>
226
+
227
+ <div class="flex flex-col gap-2">
228
+ <h3 class="body-m-medium text-content-on-surface-primary">
229
+ Keep it keyboard operable
230
+ </h3>
231
+ <p class="body-m-regular text-content-on-surface-primary">
232
+ Every handle is a Tab stop and moves with the arrow keys.
233
+ <code>Home</code> and <code>End</code> jump to the minimum and
234
+ maximum, and <code>Page Up</code> / <code>Page Down</code> (or
235
+ <code>Shift</code> + arrow) move in larger jumps — so a long
236
+ range never needs hundreds of key presses.
237
+ </p>
238
+ </div>
239
+
240
+ <div class="flex flex-col gap-2">
241
+ <h3 class="body-m-medium text-content-on-surface-primary">
242
+ Give small handles room
243
+ </h3>
244
+ <p class="body-m-regular text-content-on-surface-primary">
245
+ The handle is smaller than the 24px minimum target size, so it
246
+ relies on the WCAG 2.5.8 spacing exception: keep other controls
247
+ at least 24px away, and don't crowd several sliders together.
248
+ </p>
249
+ </div>
250
+
251
+ <div class="flex flex-col gap-2">
252
+ <h3 class="body-m-medium text-content-on-surface-primary">
253
+ Enable accessibility theme
254
+ </h3>
255
+ <p class="body-m-regular text-content-on-surface-primary">
256
+ When accessibility is required, enable our accessibility theme.
257
+ This increases contrast and makes sure there are no color
258
+ contrast issues.
259
+ </p>
260
+ </div>
261
+ </div>
262
+
263
+ <div class="grid gap-4 md:grid-cols-2">
264
+ <div class="flex flex-col gap-3">
265
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
266
+ Default
267
+ </h3>
268
+ <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
269
+ <p class="label-s-medium text-content-on-surface-primary">Volume</p>
270
+ <div class="my-3">
271
+ <UiSlider v-model="defaultValue" />
272
+ </div>
273
+ <p class="body-s-regular text-content-on-surface-muted">Value: {{ defaultValue[0] }}</p>
274
+ </div>
275
+ </div>
276
+
277
+ <div class="accessible-theme flex flex-col gap-3">
278
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
279
+ Accessible
280
+ </h3>
281
+ <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
282
+ <p class="label-s-medium text-content-on-surface-primary">Volume</p>
283
+ <div class="my-3">
284
+ <UiSlider v-model="accessibleValue" />
285
+ </div>
286
+ <p class="body-s-regular text-content-on-surface-muted">Value: {{ accessibleValue[0] }}</p>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ </section>
291
+ `,
292
+ }),
293
+ tags: ['!autodocs'],
294
+ parameters: {
295
+ surface: 'primary',
296
+ a11y: { test: 'off' },
297
+ chromatic: {
298
+ disableSnapshot: true,
299
+ },
300
+ docs: {
301
+ canvas: {
302
+ sourceState: 'none',
303
+ },
304
+ },
305
+ },
306
+ };
307
+
158
308
  const rangeTemplateSource = `<script setup lang="ts">
159
309
  import { ref } from 'vue'
160
310
  import { UiSlider } from '@aleph-alpha/ui-library'
@@ -347,132 +497,6 @@ export const Disabled: Story = {
347
497
  },
348
498
  };
349
499
 
350
- /**
351
- * Accessibility guidance for labelling the slider, exposing its value as text,
352
- * and keeping it operable from the keyboard.
353
- */
354
- export const Accessibility: Story = {
355
- render: () => ({
356
- components: { UiSlider },
357
- setup() {
358
- const defaultValue = ref([60]);
359
- const accessibleValue = ref([60]);
360
- return { defaultValue, accessibleValue };
361
- },
362
- template: `
363
- <section class="flex flex-col gap-6 p-4">
364
- <div>
365
- <h2 class="heading-m font-bold text-content-on-surface-primary">
366
- Accessibility
367
- </h2>
368
- </div>
369
-
370
- <div class="flex flex-col gap-6">
371
- <div class="flex flex-col gap-2">
372
- <h3 class="body-m-medium text-content-on-surface-primary">
373
- Label what the slider controls
374
- </h3>
375
- <p class="body-m-regular text-content-on-surface-primary">
376
- Each handle is announced as a slider named <code>Value</code>
377
- (<code>Value 1</code> / <code>Value 2</code> for a range), which
378
- says nothing about what is being adjusted. Put a visible heading
379
- or <code>label</code> next to the slider so the surrounding
380
- context supplies the meaning.
381
- </p>
382
- </div>
383
-
384
- <div class="flex flex-col gap-2">
385
- <h3 class="body-m-medium text-content-on-surface-primary">
386
- Show the current value as text
387
- </h3>
388
- <p class="body-m-regular text-content-on-surface-primary">
389
- Handle position alone is not perceivable for everyone. Render the
390
- value next to the slider so it can be read, magnified, and
391
- translated — the same number assistive technology gets from
392
- <code>aria-valuenow</code>.
393
- </p>
394
- </div>
395
-
396
- <div class="flex flex-col gap-2">
397
- <h3 class="body-m-medium text-content-on-surface-primary">
398
- Keep it keyboard operable
399
- </h3>
400
- <p class="body-m-regular text-content-on-surface-primary">
401
- Every handle is a Tab stop and moves with the arrow keys.
402
- <code>Home</code> and <code>End</code> jump to the minimum and
403
- maximum, and <code>Page Up</code> / <code>Page Down</code> (or
404
- <code>Shift</code> + arrow) move in larger jumps — so a long
405
- range never needs hundreds of key presses.
406
- </p>
407
- </div>
408
-
409
- <div class="flex flex-col gap-2">
410
- <h3 class="body-m-medium text-content-on-surface-primary">
411
- Give small handles room
412
- </h3>
413
- <p class="body-m-regular text-content-on-surface-primary">
414
- The handle is smaller than the 24px minimum target size, so it
415
- relies on the WCAG 2.5.8 spacing exception: keep other controls
416
- at least 24px away, and don't crowd several sliders together.
417
- </p>
418
- </div>
419
-
420
- <div class="flex flex-col gap-2">
421
- <h3 class="body-m-medium text-content-on-surface-primary">
422
- Enable accessibility theme
423
- </h3>
424
- <p class="body-m-regular text-content-on-surface-primary">
425
- When accessibility is required, enable our accessibility theme.
426
- This increases contrast and makes sure there are no color
427
- contrast issues.
428
- </p>
429
- </div>
430
- </div>
431
-
432
- <div class="grid gap-4 md:grid-cols-2">
433
- <div class="flex flex-col gap-3">
434
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
435
- Default
436
- </h3>
437
- <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
438
- <p class="label-s-medium text-content-on-surface-primary">Volume</p>
439
- <div class="my-3">
440
- <UiSlider v-model="defaultValue" />
441
- </div>
442
- <p class="body-s-regular text-content-on-surface-muted">Value: {{ defaultValue[0] }}</p>
443
- </div>
444
- </div>
445
-
446
- <div class="accessible-theme flex flex-col gap-3">
447
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
448
- Accessible
449
- </h3>
450
- <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
451
- <p class="label-s-medium text-content-on-surface-primary">Volume</p>
452
- <div class="my-3">
453
- <UiSlider v-model="accessibleValue" />
454
- </div>
455
- <p class="body-s-regular text-content-on-surface-muted">Value: {{ accessibleValue[0] }}</p>
456
- </div>
457
- </div>
458
- </div>
459
- </section>
460
- `,
461
- }),
462
- tags: ['!autodocs'],
463
- parameters: {
464
- a11y: { test: 'off' },
465
- chromatic: {
466
- disableSnapshot: true,
467
- },
468
- docs: {
469
- canvas: {
470
- sourceState: 'none',
471
- },
472
- },
473
- },
474
- };
475
-
476
500
  /*
477
501
  * ─────────────────────────────────────────────────────────────────────────────
478
502
  * Interaction & accessibility tests (play functions)