@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
@@ -19,6 +19,16 @@ import { UiLabel } from '../UiLabel';
19
19
  import { UiSeparator } from '../UiSeparator';
20
20
  import { UiSpinner } from '../UiSpinner';
21
21
  import { UiTooltip } from '../UiTooltip';
22
+ import {
23
+ accessibilityRequirementsTemplate,
24
+ designNotesStory,
25
+ guidanceLinks,
26
+ guidanceSectionClass,
27
+ parseGuidance,
28
+ } from '../../../.storybook/guidance';
29
+ import guidanceMarkdown from './UiInputGroup.guidance.md?raw';
30
+
31
+ const guidance = parseGuidance(guidanceMarkdown);
22
32
 
23
33
  /**
24
34
  * `UiInputGroup` attaches addons — icons, text affixes, keyboard shortcuts,
@@ -38,6 +48,9 @@ const meta: Meta<typeof UiInputGroup> = {
38
48
  "The kind of control the group hosts. `'textarea'` lets the group grow with its content instead of staying a fixed-height row.",
39
49
  },
40
50
  },
51
+ parameters: {
52
+ docs: { links: guidanceLinks(guidance) },
53
+ },
41
54
  };
42
55
 
43
56
  export default meta;
@@ -244,6 +257,120 @@ export const Default: Story = {
244
257
  },
245
258
  };
246
259
 
260
+ /**
261
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
262
+ */
263
+ export const DesignNotes: Story = {
264
+ ...designNotesStory(guidance),
265
+ tags: ['!autodocs'],
266
+ };
267
+
268
+ /**
269
+ * Accessibility guidance for labelling, focus, error states, and contrast.
270
+ */
271
+ export const Accessibility: Story = {
272
+ render: () => ({
273
+ components: {
274
+ UiInputGroup,
275
+ UiInputGroupAddon,
276
+ UiInputGroupButton,
277
+ UiInputGroupInput,
278
+ UiIcon,
279
+ },
280
+ template: `
281
+ <section class="${guidanceSectionClass}">
282
+ <div>
283
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
284
+ Accessibility
285
+ </h2>
286
+ </div>
287
+
288
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
289
+
290
+ <div class="flex flex-col gap-6">
291
+ <div class="flex flex-col gap-2">
292
+ <h3 class="body-m-medium text-content-on-surface-primary">
293
+ In code
294
+ </h3>
295
+ <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
296
+ <li>The whole group shows focus as one boundary, so it is clear the field is active.</li>
297
+ <li>Every control needs an accessible name — an associated <code>UiLabel</code> or an <code>aria-label</code>.</li>
298
+ <li>Icon-only addon buttons must set <code>ariaLabel</code>; a tooltip alone is not an accessible name.</li>
299
+ <li>Error states belong on the control (<code>aria-invalid</code>) with text beneath the field, not only on the addon.</li>
300
+ <li>Text addons keep enough contrast against the field background and are not the only explanation of the expected format.</li>
301
+ <li>Place addons after the control in the markup so the control keeps the first tab stop.</li>
302
+ </ul>
303
+ </div>
304
+
305
+ <div class="flex flex-col gap-2">
306
+ <h3 class="body-m-medium text-content-on-surface-primary">
307
+ Enable accessibility theme
308
+ </h3>
309
+ <p class="body-m-regular text-content-on-surface-primary">
310
+ When accessibility is required, enable our accessibility theme.
311
+ This increases contrast and ensures there are no color contrast
312
+ issues.
313
+ </p>
314
+ </div>
315
+ </div>
316
+
317
+ <div class="grid gap-4 md:grid-cols-2">
318
+ <div class="flex flex-col gap-3">
319
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
320
+ Default
321
+ </h3>
322
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
323
+ <UiInputGroup class="max-w-xs">
324
+ <UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
325
+ <UiInputGroupAddon>
326
+ <UiIcon :name="SearchIcon" :size="16" />
327
+ </UiInputGroupAddon>
328
+ <UiInputGroupAddon align="inline-end">
329
+ <UiInputGroupButton size="icon-xs" aria-label="Search by voice">
330
+ <UiIcon :name="MicIcon" :size="14" />
331
+ </UiInputGroupButton>
332
+ </UiInputGroupAddon>
333
+ </UiInputGroup>
334
+ </div>
335
+ </div>
336
+
337
+ <div class="accessible-theme flex flex-col gap-3">
338
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
339
+ Accessible
340
+ </h3>
341
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
342
+ <UiInputGroup class="max-w-xs">
343
+ <UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
344
+ <UiInputGroupAddon>
345
+ <UiIcon :name="SearchIcon" :size="16" />
346
+ </UiInputGroupAddon>
347
+ <UiInputGroupAddon align="inline-end">
348
+ <UiInputGroupButton size="icon-xs" aria-label="Search by voice">
349
+ <UiIcon :name="MicIcon" :size="14" />
350
+ </UiInputGroupButton>
351
+ </UiInputGroupAddon>
352
+ </UiInputGroup>
353
+ </div>
354
+ </div>
355
+ </div>
356
+ </section>
357
+ `,
358
+ }),
359
+ tags: ['!autodocs'],
360
+ parameters: {
361
+ surface: 'primary',
362
+ a11y: { test: 'off' },
363
+ chromatic: {
364
+ disableSnapshot: true,
365
+ },
366
+ docs: {
367
+ canvas: {
368
+ sourceState: 'none',
369
+ },
370
+ },
371
+ },
372
+ };
373
+
247
374
  const iconTemplateSource = `<script setup lang="ts">
248
375
  import { UiInputGroup, UiInputGroupAddon, UiInputGroupInput, UiIcon } from '@aleph-alpha/ui-library'
249
376
  import { CheckIcon, CreditCardIcon, InfoIcon, MailIcon, SearchIcon, StarIcon } from '@aleph-alpha/ui-library/icons'
@@ -1621,109 +1748,6 @@ export const CustomInput: Story = {
1621
1748
  },
1622
1749
  };
1623
1750
 
1624
- /**
1625
- * Accessibility guidance for labelling, focus, error states, and contrast.
1626
- */
1627
- export const Accessibility: Story = {
1628
- render: () => ({
1629
- components: {
1630
- UiInputGroup,
1631
- UiInputGroupAddon,
1632
- UiInputGroupButton,
1633
- UiInputGroupInput,
1634
- UiIcon,
1635
- },
1636
- template: `
1637
- <section class="flex flex-col gap-6 p-4">
1638
- <div>
1639
- <h2 class="heading-m font-bold text-content-on-surface-primary">
1640
- Accessibility
1641
- </h2>
1642
- </div>
1643
-
1644
- <div class="flex flex-col gap-6">
1645
- <div class="flex flex-col gap-2">
1646
- <h3 class="body-m-medium text-content-on-surface-primary">
1647
- Requirements
1648
- </h3>
1649
- <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
1650
- <li>The whole group shows focus as one boundary, so it is clear the field is active.</li>
1651
- <li>Every control needs an accessible name — an associated <code>UiLabel</code> or an <code>aria-label</code>.</li>
1652
- <li>Icon-only addon buttons must set <code>ariaLabel</code>; a tooltip alone is not an accessible name.</li>
1653
- <li>Error states belong on the control (<code>aria-invalid</code>) with text beneath the field, not only on the addon.</li>
1654
- <li>Text addons keep enough contrast against the field background and are not the only explanation of the expected format.</li>
1655
- <li>Place addons after the control in the markup so the control keeps the first tab stop.</li>
1656
- </ul>
1657
- </div>
1658
-
1659
- <div class="flex flex-col gap-2">
1660
- <h3 class="body-m-medium text-content-on-surface-primary">
1661
- Enable accessibility theme
1662
- </h3>
1663
- <p class="body-m-regular text-content-on-surface-primary">
1664
- When accessibility is required, enable our accessibility theme.
1665
- This increases contrast and ensures there are no color contrast
1666
- issues.
1667
- </p>
1668
- </div>
1669
- </div>
1670
-
1671
- <div class="grid gap-4 md:grid-cols-2">
1672
- <div class="flex flex-col gap-3">
1673
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1674
- Default
1675
- </h3>
1676
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1677
- <UiInputGroup class="max-w-xs">
1678
- <UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
1679
- <UiInputGroupAddon>
1680
- <UiIcon :name="SearchIcon" :size="16" />
1681
- </UiInputGroupAddon>
1682
- <UiInputGroupAddon align="inline-end">
1683
- <UiInputGroupButton size="icon-xs" aria-label="Search by voice">
1684
- <UiIcon :name="MicIcon" :size="14" />
1685
- </UiInputGroupButton>
1686
- </UiInputGroupAddon>
1687
- </UiInputGroup>
1688
- </div>
1689
- </div>
1690
-
1691
- <div class="accessible-theme flex flex-col gap-3">
1692
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1693
- Accessible
1694
- </h3>
1695
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1696
- <UiInputGroup class="max-w-xs">
1697
- <UiInputGroupInput placeholder="Placeholder" aria-label="Search" />
1698
- <UiInputGroupAddon>
1699
- <UiIcon :name="SearchIcon" :size="16" />
1700
- </UiInputGroupAddon>
1701
- <UiInputGroupAddon align="inline-end">
1702
- <UiInputGroupButton size="icon-xs" aria-label="Search by voice">
1703
- <UiIcon :name="MicIcon" :size="14" />
1704
- </UiInputGroupButton>
1705
- </UiInputGroupAddon>
1706
- </UiInputGroup>
1707
- </div>
1708
- </div>
1709
- </div>
1710
- </section>
1711
- `,
1712
- }),
1713
- tags: ['!autodocs'],
1714
- parameters: {
1715
- a11y: { test: 'off' },
1716
- chromatic: {
1717
- disableSnapshot: true,
1718
- },
1719
- docs: {
1720
- canvas: {
1721
- sourceState: 'none',
1722
- },
1723
- },
1724
- },
1725
- };
1726
-
1727
1751
  /**
1728
1752
  * Clicking a non-interactive addon focuses the control, and typing updates
1729
1753
  * the value via `update:modelValue`. Hidden test-only story.
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '27085:10701'
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 Item component can house nearly any type of content. Use it to display a title, description, and actions. Group it with the ItemGroup component to create a list of items.
10
+
11
+ Please refer to the stories for examples of different configurations.
12
+
13
+ ### One row, one thing
14
+
15
+ An item is a row about a single subject:
16
+
17
+ - Media identifies it, the title names it, the description qualifies it
18
+ - Actions act on that subject only
19
+ - Any part may be dropped, but the order never changes
20
+ - Items in a group carry the same parts in the same places
21
+
22
+ ### Size follows density
23
+
24
+ Pick the size from how much the row has to carry:
25
+
26
+ 1. Minimal for dense lists where only the title matters
27
+ 2. Small for rows with a title and a short description
28
+ 3. Default for rows with media, description and actions
29
+ 4. One size per list, never mixed
30
+
31
+ ### Consistency
32
+
33
+ Every item is built from the same parts:
34
+
35
+ - Item, in default, outline, hover, hover-action or selected variants
36
+ - Item media: icon, simple icon, image, avatar or avatar group
37
+ - Title and description
38
+ - Item actions: buttons, text with a button, or an icon
39
+ - Item group, with or without separators
40
+
41
+ ## Do
42
+
43
+ - Keep media, title, description and actions in the same order on every row
44
+ - Use one size and one variant throughout a list
45
+ - Reserve the selected variant for actual selection, not for hover
46
+ - Show actions in the same position on every row
47
+ - Use an item group with separators when the rows form one list
48
+ - Let the description truncate before the title does
49
+
50
+ ## Don't
51
+
52
+ - Mix item sizes within one list
53
+ - Put actions belonging to the page inside a row
54
+ - Use the hover variant on rows that are not interactive
55
+ - Vary which parts appear from row to row in the same list
56
+ - Nest an item inside another item
57
+ - Let a long title push the actions out of alignment
58
+
59
+ ## Accessibility
60
+
61
+ - The whole row is a comfortable target where the row itself is interactive
62
+ - Selected and hover states are distinguishable from each other and from the resting state
63
+ - Focus is visible on the row, and separately on each action inside it
64
+ - Media never carries meaning on its own; the title always states the subject
65
+ - Title and description hold their contrast against the row's own surface in every variant
66
+ - Rows keep a stable height as content changes, so a list does not shift under the reader
@@ -20,6 +20,16 @@ import {
20
20
  UiAvatarGroup,
21
21
  UiAvatarImage,
22
22
  } from '../UiAvatar';
23
+ import {
24
+ accessibilityRequirementsTemplate,
25
+ designNotesStory,
26
+ guidanceLinks,
27
+ guidanceSectionClass,
28
+ parseGuidance,
29
+ } from '../../../.storybook/guidance';
30
+ import guidanceMarkdown from './UiItem.guidance.md?raw';
31
+
32
+ const guidance = parseGuidance(guidanceMarkdown);
23
33
 
24
34
  /**
25
35
  * A versatile component that you can use to display any content.
@@ -82,6 +92,9 @@ const meta: Meta<typeof UiItem> = {
82
92
  asChild: false,
83
93
  withListSemantics: false,
84
94
  },
95
+ parameters: {
96
+ docs: { links: guidanceLinks(guidance) },
97
+ },
85
98
  };
86
99
 
87
100
  export default meta;
@@ -461,36 +474,11 @@ export const Basic: Story = {
461
474
  };
462
475
 
463
476
  /**
464
- * Design guidance for choosing item variants, density, and composition.
477
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
465
478
  */
466
479
  export const DesignNotes: Story = {
467
- render: () => ({
468
- components: { UiButton },
469
- template: `
470
- <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
471
- <div>
472
- <h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
473
- <p class="body-m-regular mt-2 text-content-on-surface-primary">
474
- The Item component can house nearly any type of content. Use it to display a title,
475
- description, and actions. Group it with the ItemGroup component to create a list of items.
476
- Please refer to the stories for examples of different configurations.
477
- </p>
478
- </div>
479
- </section>
480
- `,
481
- }),
480
+ ...designNotesStory(guidance),
482
481
  tags: ['!autodocs'],
483
- parameters: {
484
- a11y: { test: 'off' },
485
- chromatic: {
486
- disableSnapshot: true,
487
- },
488
- docs: {
489
- canvas: {
490
- sourceState: 'none',
491
- },
492
- },
493
- },
494
482
  };
495
483
 
496
484
  /**
@@ -500,13 +488,15 @@ export const Accessibility: Story = {
500
488
  render: () => ({
501
489
  components: { UiItem, UiIcon },
502
490
  template: `
503
- <section class="flex flex-col gap-6 p-4">
491
+ <section class="${guidanceSectionClass}">
504
492
  <div>
505
493
  <h2 class="heading-m font-bold text-content-on-surface-primary">
506
494
  Accessibility
507
495
  </h2>
508
496
  </div>
509
497
 
498
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
499
+
510
500
  <div class="flex flex-col gap-6">
511
501
  <div class="flex flex-col gap-2">
512
502
  <h3 class="body-m-medium text-content-on-surface-primary">
@@ -550,6 +540,7 @@ export const Accessibility: Story = {
550
540
  }),
551
541
  tags: ['!autodocs'],
552
542
  parameters: {
543
+ surface: 'primary',
553
544
  a11y: { test: 'off' },
554
545
  chromatic: {
555
546
  disableSnapshot: true,
@@ -987,6 +978,68 @@ export const AllVariants: Story = {
987
978
  },
988
979
  };
989
980
 
981
+ /**
982
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
983
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
984
+ */
985
+ export const ZoomMagnification: Story = {
986
+ name: 'test - Zoom Magnification',
987
+ tags: ['!dev', '!autodocs'],
988
+ globals: { zoom: '200' },
989
+ render: () => ({
990
+ components: { UiItem },
991
+ setup() {
992
+ return { onAction };
993
+ },
994
+ template: `
995
+ <div class="w-full max-w-md">
996
+ <UiItem title="Weekly report" description="Summary of this week's activity" @action="onAction" />
997
+ </div>
998
+ `,
999
+ }),
1000
+ parameters: {
1001
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
1002
+ // already covers magnified snapshots, so skip this one.
1003
+ chromatic: { disableSnapshot: true },
1004
+ docs: {
1005
+ description: {
1006
+ story:
1007
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
1008
+ },
1009
+ },
1010
+ },
1011
+ play: async ({ canvasElement, step }) => {
1012
+ // Scenario (UiItem): at 200% page zoom the title, description and trailing
1013
+ // action stay readable, and the action still works.
1014
+ onAction.mockClear();
1015
+ const canvas = within(canvasElement);
1016
+ const action = canvas.getByRole('button', { name: 'More actions' });
1017
+
1018
+ await step(
1019
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
1020
+ async () => {
1021
+ await expect(document.documentElement.style.zoom).toBe('200%');
1022
+ },
1023
+ );
1024
+
1025
+ await step('zoom: title and description stay readable', async () => {
1026
+ await expect(canvas.getByText('Weekly report')).toBeVisible();
1027
+ await expect(
1028
+ canvas.getByText("Summary of this week's activity"),
1029
+ ).toBeVisible();
1030
+ });
1031
+
1032
+ await step(
1033
+ 'zoom: the trailing action stays visible and operable',
1034
+ async () => {
1035
+ await expect(action).toBeVisible();
1036
+ await userEvent.click(action);
1037
+ await expect(onAction).toHaveBeenCalledTimes(1);
1038
+ },
1039
+ );
1040
+ },
1041
+ };
1042
+
990
1043
  const mobileBreakpointTemplate = `
991
1044
  <div class="w-full max-w-md">
992
1045
  <UiItem
@@ -0,0 +1,65 @@
1
+ ---
2
+ figma: '29199:70605'
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 Kbd component shows a key, or a combination of keys, as the user would press them. It is a label for a shortcut, printed in the shape of a key so it is recognised before it is read.
10
+
11
+ Use it beside the action the shortcut performs — in a menu row, a tooltip, a search field, a help page. It is never a control: pressing it on screen does nothing.
12
+
13
+ ### Print the key, not the concept
14
+
15
+ A shortcut only helps if it matches the keyboard in front of the user:
16
+
17
+ - Keys are written as they appear on the key itself
18
+ - Modifier symbols follow the platform the user is on
19
+ - The order matches the order the keys are held
20
+ - The same shortcut is written the same way everywhere in the product
21
+
22
+ ### Combinations read left to right
23
+
24
+ A group is one shortcut, so build it in pressing order:
25
+
26
+ 1. Modifiers first, in a fixed order
27
+ 2. The action key last
28
+ 3. Plus-separated form where the combination needs to be explicit
29
+ 4. Default form where the keys sit close enough to read as one
30
+
31
+ ### Consistency
32
+
33
+ Every shortcut is built from the same parts:
34
+
35
+ - Kbd, on the default or primary background
36
+ - Optional leading and trailing icon, for symbol keys
37
+ - Kbd group, holding up to four keys
38
+ - Group type: default, or plus-separated
39
+
40
+ ## Do
41
+
42
+ - Write keys as they are printed on the keyboard
43
+ - Use the modifier symbols of the platform the user is on
44
+ - Keep modifier order fixed across the product
45
+ - Put the shortcut next to the action it triggers
46
+ - Use the plus-separated group when the combination could be misread
47
+ - Use the primary background only on surfaces where the default disappears
48
+
49
+ ## Don't
50
+
51
+ - Use Kbd as a button
52
+ - Spell out keys where the symbol is what the user sees
53
+ - Show a shortcut for an action that has none
54
+ - Vary the way one shortcut is written between screens
55
+ - Put more than four keys in one group
56
+ - Use Kbd for on-screen instructions unrelated to a key
57
+
58
+ ## Accessibility
59
+
60
+ - Key text holds its contrast against the key's own fill, on both backgrounds
61
+ - Keys stay legible at their smallest size, since Kbd sits inside dense rows
62
+ - The key shape is not the only signal: a shortcut appears beside the action it belongs to
63
+ - The shortcut never reads as interactive, so it is not mistaken for a button
64
+ - Symbol-only keys are recognisable at small size, and paired with a written form where they are not
65
+ - A shortcut is an addition, never the only route to an action