@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
@@ -28,6 +28,16 @@ import {
28
28
  UiDrawerTitle,
29
29
  UiDrawerTrigger,
30
30
  } from '../UiDrawer';
31
+ import {
32
+ accessibilityRequirementsTemplate,
33
+ designNotesStory,
34
+ guidanceLinks,
35
+ guidanceSectionClass,
36
+ parseGuidance,
37
+ } from '../../../.storybook/guidance';
38
+ import guidanceMarkdown from './UiBreadcrumb.guidance.md?raw';
39
+
40
+ const guidance = parseGuidance(guidanceMarkdown);
31
41
 
32
42
  // Crumbs render native anchors and declare no `onClick` prop, so plays assert
33
43
  // against these module-level spies bound via `@click`. Each `play` clears them
@@ -44,6 +54,9 @@ const meta: Meta<typeof UiBreadcrumb> = {
44
54
  title: 'Components/UiBreadcrumb',
45
55
  component: UiBreadcrumb,
46
56
  tags: ['autodocs'],
57
+ parameters: {
58
+ docs: { links: guidanceLinks(guidance) },
59
+ },
47
60
  };
48
61
 
49
62
  export default meta;
@@ -187,6 +200,158 @@ export const Default: Story = {
187
200
  },
188
201
  };
189
202
 
203
+ /**
204
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
205
+ */
206
+ export const DesignNotes: Story = {
207
+ ...designNotesStory(guidance),
208
+ tags: ['!autodocs'],
209
+ };
210
+
211
+ /**
212
+ * Accessibility guidance for the breadcrumb: a named landmark, a clearly marked
213
+ * current page, and decorative parts kept out of the accessibility tree — shown
214
+ * side by side in the default and accessible themes.
215
+ */
216
+ export const Accessibility: Story = {
217
+ tags: ['!autodocs'],
218
+ parameters: {
219
+ surface: 'primary',
220
+ a11y: { test: 'off' },
221
+ chromatic: { disableSnapshot: true },
222
+ docs: {
223
+ canvas: {
224
+ sourceState: 'none',
225
+ },
226
+ },
227
+ },
228
+ render: () => ({
229
+ components,
230
+ template: `
231
+ <section class="${guidanceSectionClass}">
232
+ <div>
233
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
234
+ Accessibility
235
+ </h2>
236
+ </div>
237
+
238
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
239
+
240
+ <div class="flex flex-col gap-6">
241
+ <div class="flex flex-col gap-2">
242
+ <h3 class="body-m-medium text-content-on-surface-primary">
243
+ The trail is already a named landmark
244
+ </h3>
245
+ <p class="body-m-regular text-content-on-surface-primary">
246
+ <code>UiBreadcrumb</code> renders a <code>nav</code> labelled
247
+ "breadcrumb" around an ordered list, so screen-reader users can jump
248
+ straight to it. You do not need to add your own
249
+ <code>aria-label</code>, and there should only be one breadcrumb
250
+ trail per page.
251
+ </p>
252
+ </div>
253
+
254
+ <div class="flex flex-col gap-2">
255
+ <h3 class="body-m-medium text-content-on-surface-primary">
256
+ Mark the current page
257
+ </h3>
258
+ <p class="body-m-regular text-content-on-surface-primary">
259
+ End the trail with <code>UiBreadcrumbPage</code> instead of
260
+ <code>UiBreadcrumbLink</code>. It sets
261
+ <code>aria-current="page"</code> and is not a link, so
262
+ <code>Tab</code> skips it — a link that navigates nowhere is
263
+ confusing (WCAG 4.1.2).
264
+ </p>
265
+ </div>
266
+
267
+ <div class="flex flex-col gap-2">
268
+ <h3 class="body-m-medium text-content-on-surface-primary">
269
+ Label the collapsed-crumbs trigger
270
+ </h3>
271
+ <p class="body-m-regular text-content-on-surface-primary">
272
+ <code>UiBreadcrumbEllipsis</code> is hidden from assistive
273
+ technology, so it contributes no accessible name. When you wrap it in
274
+ a menu trigger, give that trigger an <code>aria-label</code> such as
275
+ "Show hidden pages", and keep its target at least 24×24px
276
+ (WCAG 2.5.8).
277
+ </p>
278
+ </div>
279
+
280
+ <div class="flex flex-col gap-2">
281
+ <h3 class="body-m-medium text-content-on-surface-primary">
282
+ Keep separators decorative
283
+ </h3>
284
+ <p class="body-m-regular text-content-on-surface-primary">
285
+ <code>UiBreadcrumbSeparator</code> is presentational and excluded
286
+ from the list, so screen readers announce the crumbs without a
287
+ "slash" between each one. Never put meaningful text in it.
288
+ </p>
289
+ </div>
290
+
291
+ <div class="flex flex-col gap-2">
292
+ <h3 class="body-m-medium text-content-on-surface-primary">
293
+ Enable accessibility theme
294
+ </h3>
295
+ <p class="body-m-regular text-content-on-surface-primary">
296
+ When accessibility is required, enable our accessibility theme.
297
+ This increases contrast and makes sure there are no color
298
+ contrast issues.
299
+ </p>
300
+ </div>
301
+ </div>
302
+
303
+ <div class="grid gap-4 md:grid-cols-2">
304
+ <div class="flex flex-col gap-3">
305
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
306
+ Default
307
+ </h3>
308
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
309
+ <UiBreadcrumb>
310
+ <UiBreadcrumbList>
311
+ <UiBreadcrumbItem>
312
+ <UiBreadcrumbLink href="/">Home</UiBreadcrumbLink>
313
+ </UiBreadcrumbItem>
314
+ <UiBreadcrumbSeparator />
315
+ <UiBreadcrumbItem>
316
+ <UiBreadcrumbLink href="/components">Components</UiBreadcrumbLink>
317
+ </UiBreadcrumbItem>
318
+ <UiBreadcrumbSeparator />
319
+ <UiBreadcrumbItem>
320
+ <UiBreadcrumbPage>Breadcrumb</UiBreadcrumbPage>
321
+ </UiBreadcrumbItem>
322
+ </UiBreadcrumbList>
323
+ </UiBreadcrumb>
324
+ </div>
325
+ </div>
326
+
327
+ <div class="accessible-theme flex flex-col gap-3">
328
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
329
+ Accessible
330
+ </h3>
331
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
332
+ <UiBreadcrumb>
333
+ <UiBreadcrumbList>
334
+ <UiBreadcrumbItem>
335
+ <UiBreadcrumbLink href="/">Home</UiBreadcrumbLink>
336
+ </UiBreadcrumbItem>
337
+ <UiBreadcrumbSeparator />
338
+ <UiBreadcrumbItem>
339
+ <UiBreadcrumbLink href="/components">Components</UiBreadcrumbLink>
340
+ </UiBreadcrumbItem>
341
+ <UiBreadcrumbSeparator />
342
+ <UiBreadcrumbItem>
343
+ <UiBreadcrumbPage>Breadcrumb</UiBreadcrumbPage>
344
+ </UiBreadcrumbItem>
345
+ </UiBreadcrumbList>
346
+ </UiBreadcrumb>
347
+ </div>
348
+ </div>
349
+ </div>
350
+ </section>
351
+ `,
352
+ }),
353
+ };
354
+
190
355
  const customSeparatorTemplateSource = `<script setup lang="ts">
191
356
  import {
192
357
  UiBreadcrumb,
@@ -1114,147 +1279,6 @@ export const ScreenReader: Story = {
1114
1279
  },
1115
1280
  };
1116
1281
 
1117
- /**
1118
- * Accessibility guidance for the breadcrumb: a named landmark, a clearly marked
1119
- * current page, and decorative parts kept out of the accessibility tree — shown
1120
- * side by side in the default and accessible themes.
1121
- */
1122
- export const Accessibility: Story = {
1123
- tags: ['!autodocs'],
1124
- parameters: {
1125
- a11y: { test: 'off' },
1126
- chromatic: { disableSnapshot: true },
1127
- docs: {
1128
- canvas: {
1129
- sourceState: 'none',
1130
- },
1131
- },
1132
- },
1133
- render: () => ({
1134
- components,
1135
- template: `
1136
- <section class="flex flex-col gap-6 p-4">
1137
- <div>
1138
- <h2 class="heading-m font-bold text-content-on-surface-primary">
1139
- Accessibility
1140
- </h2>
1141
- </div>
1142
-
1143
- <div class="flex flex-col gap-6">
1144
- <div class="flex flex-col gap-2">
1145
- <h3 class="body-m-medium text-content-on-surface-primary">
1146
- The trail is already a named landmark
1147
- </h3>
1148
- <p class="body-m-regular text-content-on-surface-primary">
1149
- <code>UiBreadcrumb</code> renders a <code>nav</code> labelled
1150
- "breadcrumb" around an ordered list, so screen-reader users can jump
1151
- straight to it. You do not need to add your own
1152
- <code>aria-label</code>, and there should only be one breadcrumb
1153
- trail per page.
1154
- </p>
1155
- </div>
1156
-
1157
- <div class="flex flex-col gap-2">
1158
- <h3 class="body-m-medium text-content-on-surface-primary">
1159
- Mark the current page
1160
- </h3>
1161
- <p class="body-m-regular text-content-on-surface-primary">
1162
- End the trail with <code>UiBreadcrumbPage</code> instead of
1163
- <code>UiBreadcrumbLink</code>. It sets
1164
- <code>aria-current="page"</code> and is not a link, so
1165
- <code>Tab</code> skips it — a link that navigates nowhere is
1166
- confusing (WCAG 4.1.2).
1167
- </p>
1168
- </div>
1169
-
1170
- <div class="flex flex-col gap-2">
1171
- <h3 class="body-m-medium text-content-on-surface-primary">
1172
- Label the collapsed-crumbs trigger
1173
- </h3>
1174
- <p class="body-m-regular text-content-on-surface-primary">
1175
- <code>UiBreadcrumbEllipsis</code> is hidden from assistive
1176
- technology, so it contributes no accessible name. When you wrap it in
1177
- a menu trigger, give that trigger an <code>aria-label</code> such as
1178
- "Show hidden pages", and keep its target at least 24×24px
1179
- (WCAG 2.5.8).
1180
- </p>
1181
- </div>
1182
-
1183
- <div class="flex flex-col gap-2">
1184
- <h3 class="body-m-medium text-content-on-surface-primary">
1185
- Keep separators decorative
1186
- </h3>
1187
- <p class="body-m-regular text-content-on-surface-primary">
1188
- <code>UiBreadcrumbSeparator</code> is presentational and excluded
1189
- from the list, so screen readers announce the crumbs without a
1190
- "slash" between each one. Never put meaningful text in it.
1191
- </p>
1192
- </div>
1193
-
1194
- <div class="flex flex-col gap-2">
1195
- <h3 class="body-m-medium text-content-on-surface-primary">
1196
- Enable accessibility theme
1197
- </h3>
1198
- <p class="body-m-regular text-content-on-surface-primary">
1199
- When accessibility is required, enable our accessibility theme.
1200
- This increases contrast and makes sure there are no color
1201
- contrast issues.
1202
- </p>
1203
- </div>
1204
- </div>
1205
-
1206
- <div class="grid gap-4 md:grid-cols-2">
1207
- <div class="flex flex-col gap-3">
1208
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1209
- Default
1210
- </h3>
1211
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1212
- <UiBreadcrumb>
1213
- <UiBreadcrumbList>
1214
- <UiBreadcrumbItem>
1215
- <UiBreadcrumbLink href="/">Home</UiBreadcrumbLink>
1216
- </UiBreadcrumbItem>
1217
- <UiBreadcrumbSeparator />
1218
- <UiBreadcrumbItem>
1219
- <UiBreadcrumbLink href="/components">Components</UiBreadcrumbLink>
1220
- </UiBreadcrumbItem>
1221
- <UiBreadcrumbSeparator />
1222
- <UiBreadcrumbItem>
1223
- <UiBreadcrumbPage>Breadcrumb</UiBreadcrumbPage>
1224
- </UiBreadcrumbItem>
1225
- </UiBreadcrumbList>
1226
- </UiBreadcrumb>
1227
- </div>
1228
- </div>
1229
-
1230
- <div class="accessible-theme flex flex-col gap-3">
1231
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1232
- Accessible
1233
- </h3>
1234
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1235
- <UiBreadcrumb>
1236
- <UiBreadcrumbList>
1237
- <UiBreadcrumbItem>
1238
- <UiBreadcrumbLink href="/">Home</UiBreadcrumbLink>
1239
- </UiBreadcrumbItem>
1240
- <UiBreadcrumbSeparator />
1241
- <UiBreadcrumbItem>
1242
- <UiBreadcrumbLink href="/components">Components</UiBreadcrumbLink>
1243
- </UiBreadcrumbItem>
1244
- <UiBreadcrumbSeparator />
1245
- <UiBreadcrumbItem>
1246
- <UiBreadcrumbPage>Breadcrumb</UiBreadcrumbPage>
1247
- </UiBreadcrumbItem>
1248
- </UiBreadcrumbList>
1249
- </UiBreadcrumb>
1250
- </div>
1251
- </div>
1252
- </div>
1253
- </section>
1254
- `,
1255
- }),
1256
- };
1257
-
1258
1282
  /**
1259
1283
  * The collapsing trail above 768px, where `useMediaQuery` selects the dropdown menu.
1260
1284
  * Pairs with `test - Mobile Breakpoint`, which asserts the drawer is used instead at
@@ -4,6 +4,7 @@ import { ref } from 'vue';
4
4
  import UiButton from './UiButton.vue';
5
5
  import { UiIcon } from '../UiIcon';
6
6
  import { ChevronLeftIcon, ChevronRightIcon, MailIcon } from '@/icons/lucide';
7
+ import { guidanceSectionClass } from '../../../.storybook/guidance';
7
8
 
8
9
  // `UiButton` emits a native click (it declares no `onClick` prop), so play
9
10
  // functions assert against this module-level spy bound via `@click` rather
@@ -115,7 +116,7 @@ export const DesignNotes: Story = {
115
116
  render: () => ({
116
117
  components: { UiButton },
117
118
  template: `
118
- <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
119
+ <section class="${guidanceSectionClass}">
119
120
  <div>
120
121
  <h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
121
122
  <p class="body-m-regular mt-2 text-content-on-surface-primary">
@@ -180,6 +181,7 @@ export const DesignNotes: Story = {
180
181
  }),
181
182
  tags: ['!autodocs'],
182
183
  parameters: {
184
+ surface: 'primary',
183
185
  a11y: { test: 'off' },
184
186
  chromatic: {
185
187
  disableSnapshot: true,
@@ -199,7 +201,7 @@ export const Accessibility: Story = {
199
201
  render: () => ({
200
202
  components: { UiButton },
201
203
  template: `
202
- <section class="flex flex-col gap-6 p-4">
204
+ <section class="${guidanceSectionClass}">
203
205
  <div>
204
206
  <h2 class="heading-m font-bold text-content-on-surface-primary">
205
207
  Accessibility
@@ -278,6 +280,7 @@ export const Accessibility: Story = {
278
280
  }),
279
281
  tags: ['!autodocs'],
280
282
  parameters: {
283
+ surface: 'primary',
281
284
  a11y: { test: 'off' },
282
285
  chromatic: {
283
286
  disableSnapshot: true,
@@ -0,0 +1,63 @@
1
+ ---
2
+ figma: '29187:69045'
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 Button Group component joins related buttons into a single control. The shared edge tells the user these actions belong to one subject, and the grouping makes the set easier to scan than the same buttons spaced apart.
10
+
11
+ Use it when every button in the group acts on the same thing. Actions with nothing in common should stay separate buttons at normal spacing.
12
+
13
+ ### Group only what belongs together
14
+
15
+ The shared edge is a claim about the buttons, so make it true:
16
+
17
+ - Every button in the group acts on the same object
18
+ - The buttons sit at the same level of importance
19
+ - One variant across the whole group: default, secondary or outline
20
+ - Groups stay small enough to read as a single control
21
+
22
+ ### Orientation follows the layout
23
+
24
+ Orientation is a layout decision rather than a stylistic one:
25
+
26
+ 1. Horizontal wherever the row has width to spare
27
+ 2. Vertical when the group sits in a narrow column or a menu
28
+ 3. Attached to an input at the start, the end, or both sides
29
+ 4. One orientation per group, never mixed within it
30
+
31
+ ### Consistency
32
+
33
+ Every group is built from the same parts:
34
+
35
+ - Button group, horizontal or vertical, holding up to six buttons
36
+ - Variants: default, secondary and outline
37
+ - Button group with input, attached at start, end or both sides
38
+ - Buttons of a single variant and size within one group
39
+
40
+ ## Do
41
+
42
+ - Keep every button in a group acting on the same object
43
+ - Use one variant and one size across the whole group
44
+ - Cap a group at a handful of buttons before splitting it
45
+ - Switch to vertical when the row runs out of width
46
+ - Attach a group to an input when it modifies that input's value
47
+
48
+ ## Don't
49
+
50
+ - Group unrelated actions just to save space
51
+ - Mix variants or sizes inside one group
52
+ - Put a destructive action in a group with ordinary ones
53
+ - Use a group where one option is picked and stays picked — use Toggle Group
54
+ - Let a horizontal group overflow its container instead of going vertical
55
+
56
+ ## Accessibility
57
+
58
+ - Each button stays separately identifiable, by its own label and its own boundary
59
+ - Focus is visible on the individual button and never clipped by a neighbour's shared edge
60
+ - Every button keeps a comfortable target size where the shared edge tightens the spacing
61
+ - Icon-only buttons in a group carry a visible label or tooltip, so the set can be read
62
+ - Disabled buttons are distinguishable by more than reduced opacity
63
+ - The group reads left to right, or top to bottom, in the order the actions should be considered
@@ -5,6 +5,16 @@ import { UiButton } from '../UiButton';
5
5
  import { UiIcon } from '../UiIcon';
6
6
  import { UiInput } from '../UiInput';
7
7
  import { ImageIcon } from '@/icons/lucide';
8
+ import {
9
+ accessibilityRequirementsTemplate,
10
+ designNotesStory,
11
+ guidanceLinks,
12
+ guidanceSectionClass,
13
+ parseGuidance,
14
+ } from '../../../.storybook/guidance';
15
+ import guidanceMarkdown from './UiButtonGroup.guidance.md?raw';
16
+
17
+ const guidance = parseGuidance(guidanceMarkdown);
8
18
 
9
19
  const onClick = fn();
10
20
 
@@ -27,6 +37,9 @@ const meta: Meta<typeof UiButtonGroup> = {
27
37
  args: {
28
38
  orientation: 'horizontal',
29
39
  },
40
+ parameters: {
41
+ docs: { links: guidanceLinks(guidance) },
42
+ },
30
43
  };
31
44
 
32
45
  export default meta;
@@ -71,6 +84,84 @@ export const Default: Story = {
71
84
  },
72
85
  };
73
86
 
87
+ /**
88
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
89
+ */
90
+ export const DesignNotes: Story = {
91
+ ...designNotesStory(guidance),
92
+ tags: ['!autodocs'],
93
+ };
94
+
95
+ /**
96
+ * Accessibility guidance for labelling groups and keyboard use.
97
+ */
98
+ export const Accessibility: Story = {
99
+ render: () => ({
100
+ components: { UiButtonGroup, UiButton, UiIcon },
101
+ template: `
102
+ <section class="${guidanceSectionClass}">
103
+ <div>
104
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
105
+ Accessibility
106
+ </h2>
107
+ </div>
108
+
109
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
110
+
111
+ <div class="flex flex-col gap-6">
112
+ <div class="flex flex-col gap-2">
113
+ <h3 class="body-m-medium text-content-on-surface-primary">
114
+ Give the group an accessible name
115
+ </h3>
116
+ <p class="body-m-regular text-content-on-surface-primary">
117
+ <code>UiButtonGroup</code> renders a <code>role="group"</code>.
118
+ For toolbars or segmented controls, add an <code>aria-label</code>
119
+ so screen-reader users know what the buttons share. Icon-only
120
+ buttons still need their own <code>aria-label</code>.
121
+ </p>
122
+ </div>
123
+
124
+ <div class="flex flex-col gap-2">
125
+ <h3 class="body-m-medium text-content-on-surface-primary">
126
+ Keyboard operability
127
+ </h3>
128
+ <p class="body-m-regular text-content-on-surface-primary">
129
+ Each button is a normal tab stop: <code>Tab</code> moves between
130
+ them in DOM order and <code>Enter</code>/<code>Space</code>
131
+ activates the focused one.
132
+ </p>
133
+ </div>
134
+ </div>
135
+
136
+ <UiButtonGroup aria-label="Text alignment">
137
+ <UiButton variant="outline" size="icon-sm" aria-label="Align left">
138
+ <UiIcon :name="AlignLeftIcon" :size="16" />
139
+ </UiButton>
140
+ <UiButton variant="outline" size="icon-sm" aria-label="Align center">
141
+ <UiIcon :name="AlignCenterIcon" :size="16" />
142
+ </UiButton>
143
+ <UiButton variant="outline" size="icon-sm" aria-label="Align right">
144
+ <UiIcon :name="AlignRightIcon" :size="16" />
145
+ </UiButton>
146
+ </UiButtonGroup>
147
+ </section>
148
+ `,
149
+ }),
150
+ tags: ['!autodocs'],
151
+ parameters: {
152
+ surface: 'primary',
153
+ a11y: { test: 'off' },
154
+ chromatic: {
155
+ disableSnapshot: true,
156
+ },
157
+ docs: {
158
+ canvas: {
159
+ sourceState: 'none',
160
+ },
161
+ },
162
+ },
163
+ };
164
+
74
165
  const verticalTemplateSource = `<script setup lang="ts">
75
166
  import { UiButtonGroup, UiButton } from '@aleph-alpha/ui-library'
76
167
  </script>
@@ -310,73 +401,6 @@ export const Sizes: Story = {
310
401
  },
311
402
  };
312
403
 
313
- /**
314
- * Accessibility guidance for labelling groups and keyboard use.
315
- */
316
- export const Accessibility: Story = {
317
- render: () => ({
318
- components: { UiButtonGroup, UiButton, UiIcon },
319
- template: `
320
- <section class="flex flex-col gap-6 p-4">
321
- <div>
322
- <h2 class="heading-m font-bold text-content-on-surface-primary">
323
- Accessibility
324
- </h2>
325
- </div>
326
-
327
- <div class="flex flex-col gap-6">
328
- <div class="flex flex-col gap-2">
329
- <h3 class="body-m-medium text-content-on-surface-primary">
330
- Give the group an accessible name
331
- </h3>
332
- <p class="body-m-regular text-content-on-surface-primary">
333
- <code>UiButtonGroup</code> renders a <code>role="group"</code>.
334
- For toolbars or segmented controls, add an <code>aria-label</code>
335
- so screen-reader users know what the buttons share. Icon-only
336
- buttons still need their own <code>aria-label</code>.
337
- </p>
338
- </div>
339
-
340
- <div class="flex flex-col gap-2">
341
- <h3 class="body-m-medium text-content-on-surface-primary">
342
- Keyboard operability
343
- </h3>
344
- <p class="body-m-regular text-content-on-surface-primary">
345
- Each button is a normal tab stop: <code>Tab</code> moves between
346
- them in DOM order and <code>Enter</code>/<code>Space</code>
347
- activates the focused one.
348
- </p>
349
- </div>
350
- </div>
351
-
352
- <UiButtonGroup aria-label="Text alignment">
353
- <UiButton variant="outline" size="icon-sm" aria-label="Align left">
354
- <UiIcon :name="AlignLeftIcon" :size="16" />
355
- </UiButton>
356
- <UiButton variant="outline" size="icon-sm" aria-label="Align center">
357
- <UiIcon :name="AlignCenterIcon" :size="16" />
358
- </UiButton>
359
- <UiButton variant="outline" size="icon-sm" aria-label="Align right">
360
- <UiIcon :name="AlignRightIcon" :size="16" />
361
- </UiButton>
362
- </UiButtonGroup>
363
- </section>
364
- `,
365
- }),
366
- tags: ['!autodocs'],
367
- parameters: {
368
- a11y: { test: 'off' },
369
- chromatic: {
370
- disableSnapshot: true,
371
- },
372
- docs: {
373
- canvas: {
374
- sourceState: 'none',
375
- },
376
- },
377
- },
378
- };
379
-
380
404
  const keyboardNavigationTemplateSource = `<script setup lang="ts">
381
405
  import { UiButtonGroup, UiButton } from '@aleph-alpha/ui-library'
382
406
  </script>
@@ -0,0 +1,65 @@
1
+ ---
2
+ figma: '29187:69172'
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 Calendar component lays out a month so the user can choose a date, or a range, by looking rather than typing. The grid carries the information: which day is today, which are selected, which are unavailable.
10
+
11
+ Use it when the shape of the month matters — weekends, spans, availability. When the user already knows the date, a date input is faster, and Date Picker pairs the two.
12
+
13
+ ### Keep the grid legible
14
+
15
+ Everything the user needs is in the grid, so it has to stay readable:
16
+
17
+ - Today is marked distinctly from the selected day
18
+ - Days outside the current month recede but stay in place
19
+ - Unavailable days read as unavailable, not merely dim
20
+ - The week starts on the day the user's locale expects
21
+
22
+ ### Ranges read as one selection
23
+
24
+ A range is a single choice made in two steps:
25
+
26
+ 1. The first date is chosen and shown as an endpoint
27
+ 2. The span fills in as the user moves toward the second
28
+ 3. Both endpoints stay distinct from the days between them
29
+ 4. Multi-column layouts keep the span continuous across months
30
+
31
+ ### Consistency
32
+
33
+ Every calendar is built from the same parts:
34
+
35
+ - Calendar: basic, with month and year selector, or as a range in one to three columns
36
+ - Day header, naming the days of the week
37
+ - Day button: default, current, outside, range and unavailable
38
+ - Arrow buttons, previous and next, default or outline
39
+ - Week number, where the product counts weeks
40
+ - Custom day button, when a day carries an extra value such as a price
41
+
42
+ ## Do
43
+
44
+ - Mark today and the selected day differently, so both can be seen at once
45
+ - Keep outside days in place, so the grid never reflows
46
+ - Use the md size on touch and the default size in dense desktop layouts
47
+ - Show two or three columns when the user picks a range across months
48
+ - Keep the month and year controls in the same position at every size
49
+
50
+ ## Don't
51
+
52
+ - Show unavailable days as merely faded, with no other signal
53
+ - Let the grid change height as the user moves between months
54
+ - Hide the current month name behind an interaction
55
+ - Use a calendar where a single known date is being entered — use a date input
56
+ - Mark today and the selection the same way
57
+
58
+ ## Accessibility
59
+
60
+ - Today and the selected day differ in shape as well as fill, so both survive without colour
61
+ - Selected, hover and focus are three distinguishable treatments, not variations of one
62
+ - Focus stays visible on a day even when that day is selected or inside a range
63
+ - Day buttons are a comfortable target at the size chosen, including the smallest one used
64
+ - Unavailable days carry a visible treatment beyond low contrast
65
+ - The grid keeps a stable size between months, so the page does not shift under the reader