@aleph-alpha/ui-library 7.0.1 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/system/components/UiSlider/step-marks.d.ts +45 -0
  2. package/dist/system/components/UiSlider/types.d.ts +28 -0
  3. package/dist/system/components/core/slider/Slider.vue.d.ts +21 -1
  4. package/dist/system/icons/story-sidebar-icons.json +74 -17
  5. package/dist/system/lib.js +2026 -1912
  6. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  7. package/dist/system/story-sidebar-icons.json +74 -17
  8. package/package.json +15 -10
  9. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  10. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  11. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  12. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  13. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  14. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  15. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  16. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  17. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  18. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  19. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  20. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  21. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  22. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  23. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  24. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  25. package/src/components/UiButton/UiButton.stories.ts +5 -2
  26. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  27. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  28. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  29. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  30. package/src/components/UiCard/UiCard.guidance.md +65 -0
  31. package/src/components/UiCard/UiCard.stories.ts +393 -0
  32. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  33. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  34. package/src/components/UiChip/UiChip.guidance.md +64 -0
  35. package/src/components/UiChip/UiChip.stories.ts +162 -138
  36. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  37. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  38. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  39. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  40. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  41. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  42. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  43. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  44. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
  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 +885 -153
  85. package/src/components/UiSlider/UiSlider.vue +109 -1
  86. package/src/components/UiSlider/__tests__/UiSliderValueAndSteps.test.ts +210 -0
  87. package/src/components/UiSlider/__tests__/step-marks.test.ts +94 -0
  88. package/src/components/UiSlider/step-marks.ts +96 -0
  89. package/src/components/UiSlider/types.ts +32 -0
  90. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  91. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  92. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  93. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  94. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  95. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  96. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  97. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  98. package/src/components/UiTable/UiTable.guidance.md +66 -0
  99. package/src/components/UiTable/UiTable.stories.ts +530 -12
  100. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  101. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  102. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  103. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  104. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  105. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  106. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  107. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  108. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  109. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  110. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  111. package/src/components/core/slider/Slider.vue +16 -6
  112. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  113. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  114. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  115. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  116. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  117. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  118. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  119. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  120. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  121. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  122. package/src/patterns/UiPlaceholder/types.ts +1 -0
  123. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +86 -84
  124. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -4,6 +4,16 @@ import { ref } from 'vue';
4
4
  import { UiAlert, UiAlertDescription, UiAlertTitle } from './index';
5
5
  import { UiButton } from '../UiButton';
6
6
  import { AlertVariants } from './constants';
7
+ import {
8
+ accessibilityRequirementsTemplate,
9
+ designNotesStory,
10
+ guidanceLinks,
11
+ guidanceSectionClass,
12
+ parseGuidance,
13
+ } from '../../../.storybook/guidance';
14
+ import guidanceMarkdown from './UiAlert.guidance.md?raw';
15
+
16
+ const guidance = parseGuidance(guidanceMarkdown);
7
17
 
8
18
  /**
9
19
  * UiAlert is a static, contextual message that calls attention to status information (info, success, warning, destructive).
@@ -24,6 +34,9 @@ const meta: Meta<typeof UiAlert> = {
24
34
  args: {
25
35
  variant: 'default',
26
36
  },
37
+ parameters: {
38
+ docs: { links: guidanceLinks(guidance) },
39
+ },
27
40
  };
28
41
 
29
42
  export default meta;
@@ -118,6 +131,160 @@ export const Default: Story = {
118
131
  },
119
132
  };
120
133
 
134
+ /**
135
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
136
+ */
137
+ export const DesignNotes: Story = {
138
+ ...designNotesStory(guidance),
139
+ tags: ['!autodocs'],
140
+ };
141
+
142
+ /**
143
+ * Accessibility guidance for announcing alerts, conveying severity without
144
+ * relying on colour, composing a dismiss control, and contrast.
145
+ */
146
+ export const Accessibility: Story = {
147
+ render: () => ({
148
+ components: {
149
+ UiAlert,
150
+ UiAlertDescription,
151
+ UiAlertTitle,
152
+ },
153
+ template: `
154
+ <section class="${guidanceSectionClass}">
155
+ <div>
156
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
157
+ Accessibility
158
+ </h2>
159
+ </div>
160
+
161
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
162
+
163
+ <div class="flex flex-col gap-6">
164
+ <div class="flex flex-col gap-2">
165
+ <h3 class="body-m-medium text-content-on-surface-primary">
166
+ Mount the alert to announce it
167
+ </h3>
168
+ <p class="body-m-regular text-content-on-surface-primary">
169
+ <code>UiAlert</code> renders <code>role="alert"</code>, which is
170
+ an assertive live region. Screen readers announce it when it
171
+ enters the page, so render it in response to the event it reports
172
+ rather than leaving it mounted and swapping its text. An alert
173
+ that is already on screen at page load is read as ordinary
174
+ content, not announced.
175
+ </p>
176
+ </div>
177
+
178
+ <div class="flex flex-col gap-2">
179
+ <h3 class="body-m-medium text-content-on-surface-primary">
180
+ Don't rely on colour or the icon
181
+ </h3>
182
+ <p class="body-m-regular text-content-on-surface-primary">
183
+ The variant icon is decorative — <code>UiIcon</code> marks it
184
+ <code>aria-hidden</code> unless you give it an
185
+ <code>ariaLabel</code> — and the destructive styling is colour
186
+ only. Say what happened in the text so the severity survives
187
+ without either (WCAG 1.4.1).
188
+ </p>
189
+ </div>
190
+
191
+ <div class="flex flex-col gap-2">
192
+ <h3 class="body-m-medium text-content-on-surface-primary">
193
+ Keep announcements short
194
+ </h3>
195
+ <p class="body-m-regular text-content-on-surface-primary">
196
+ An alert is atomic: the whole region is read as one
197
+ announcement, including anything interactive inside it. Keep the
198
+ title and description tight, and don't pack an alert with several
199
+ controls.
200
+ </p>
201
+ </div>
202
+
203
+ <div class="flex flex-col gap-2">
204
+ <h3 class="body-m-medium text-content-on-surface-primary">
205
+ Compose dismissal with a labelled button
206
+ </h3>
207
+ <p class="body-m-regular text-content-on-surface-primary">
208
+ There is no built-in dismiss. Add your own control in the content
209
+ column and prefer visible text such as <code>Dismiss</code> over
210
+ an icon-only X: it names itself and it is reachable with
211
+ <code>Tab</code>. Note that <code>size="sm"</code> is exactly
212
+ 24px tall — the minimum touch-target size — so don't go smaller.
213
+ See the Dismissible story.
214
+ </p>
215
+ </div>
216
+
217
+ <div class="flex flex-col gap-2">
218
+ <h3 class="body-m-medium text-content-on-surface-primary">
219
+ Enable accessibility theme
220
+ </h3>
221
+ <p class="body-m-regular text-content-on-surface-primary">
222
+ When accessibility is required, enable our accessibility theme.
223
+ This increases contrast and makes sure there are no color
224
+ contrast issues.
225
+ </p>
226
+ </div>
227
+ </div>
228
+
229
+ <div class="grid gap-4 md:grid-cols-2">
230
+ <div class="flex flex-col gap-3">
231
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
232
+ Default
233
+ </h3>
234
+ <div class="flex flex-col gap-3 border border-border-surface-default p-6">
235
+ <UiAlert>
236
+ <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
237
+ <UiAlertDescription>
238
+ Your profile is now up to date.
239
+ </UiAlertDescription>
240
+ </UiAlert>
241
+ <UiAlert variant="destructive">
242
+ <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
243
+ <UiAlertDescription>
244
+ Please verify your billing information and try again.
245
+ </UiAlertDescription>
246
+ </UiAlert>
247
+ </div>
248
+ </div>
249
+
250
+ <div class="accessible-theme flex flex-col gap-3">
251
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
252
+ Accessible
253
+ </h3>
254
+ <div class="flex flex-col gap-3 border border-border-surface-default p-6">
255
+ <UiAlert>
256
+ <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
257
+ <UiAlertDescription>
258
+ Your profile is now up to date.
259
+ </UiAlertDescription>
260
+ </UiAlert>
261
+ <UiAlert variant="destructive">
262
+ <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
263
+ <UiAlertDescription>
264
+ Please verify your billing information and try again.
265
+ </UiAlertDescription>
266
+ </UiAlert>
267
+ </div>
268
+ </div>
269
+ </div>
270
+ </section>
271
+ `,
272
+ }),
273
+ tags: ['!autodocs'],
274
+ parameters: {
275
+ surface: 'primary',
276
+ a11y: { test: 'off' },
277
+ chromatic: {
278
+ disableSnapshot: true,
279
+ },
280
+ docs: {
281
+ canvas: {
282
+ sourceState: 'none',
283
+ },
284
+ },
285
+ },
286
+ };
287
+
121
288
  const destructiveTemplateSource = `<script setup lang="ts">
122
289
  import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
123
290
  </script>
@@ -371,149 +538,6 @@ export const Dismissible: Story = {
371
538
  },
372
539
  };
373
540
 
374
- /**
375
- * Accessibility guidance for announcing alerts, conveying severity without
376
- * relying on colour, composing a dismiss control, and contrast.
377
- */
378
- export const Accessibility: Story = {
379
- render: () => ({
380
- components: {
381
- UiAlert,
382
- UiAlertDescription,
383
- UiAlertTitle,
384
- },
385
- template: `
386
- <section class="flex flex-col gap-6 p-4">
387
- <div>
388
- <h2 class="heading-m font-bold text-content-on-surface-primary">
389
- Accessibility
390
- </h2>
391
- </div>
392
-
393
- <div class="flex flex-col gap-6">
394
- <div class="flex flex-col gap-2">
395
- <h3 class="body-m-medium text-content-on-surface-primary">
396
- Mount the alert to announce it
397
- </h3>
398
- <p class="body-m-regular text-content-on-surface-primary">
399
- <code>UiAlert</code> renders <code>role="alert"</code>, which is
400
- an assertive live region. Screen readers announce it when it
401
- enters the page, so render it in response to the event it reports
402
- rather than leaving it mounted and swapping its text. An alert
403
- that is already on screen at page load is read as ordinary
404
- content, not announced.
405
- </p>
406
- </div>
407
-
408
- <div class="flex flex-col gap-2">
409
- <h3 class="body-m-medium text-content-on-surface-primary">
410
- Don't rely on colour or the icon
411
- </h3>
412
- <p class="body-m-regular text-content-on-surface-primary">
413
- The variant icon is decorative — <code>UiIcon</code> marks it
414
- <code>aria-hidden</code> unless you give it an
415
- <code>ariaLabel</code> — and the destructive styling is colour
416
- only. Say what happened in the text so the severity survives
417
- without either (WCAG 1.4.1).
418
- </p>
419
- </div>
420
-
421
- <div class="flex flex-col gap-2">
422
- <h3 class="body-m-medium text-content-on-surface-primary">
423
- Keep announcements short
424
- </h3>
425
- <p class="body-m-regular text-content-on-surface-primary">
426
- An alert is atomic: the whole region is read as one
427
- announcement, including anything interactive inside it. Keep the
428
- title and description tight, and don't pack an alert with several
429
- controls.
430
- </p>
431
- </div>
432
-
433
- <div class="flex flex-col gap-2">
434
- <h3 class="body-m-medium text-content-on-surface-primary">
435
- Compose dismissal with a labelled button
436
- </h3>
437
- <p class="body-m-regular text-content-on-surface-primary">
438
- There is no built-in dismiss. Add your own control in the content
439
- column and prefer visible text such as <code>Dismiss</code> over
440
- an icon-only X: it names itself and it is reachable with
441
- <code>Tab</code>. Note that <code>size="sm"</code> is exactly
442
- 24px tall — the minimum touch-target size — so don't go smaller.
443
- See the Dismissible story.
444
- </p>
445
- </div>
446
-
447
- <div class="flex flex-col gap-2">
448
- <h3 class="body-m-medium text-content-on-surface-primary">
449
- Enable accessibility theme
450
- </h3>
451
- <p class="body-m-regular text-content-on-surface-primary">
452
- When accessibility is required, enable our accessibility theme.
453
- This increases contrast and makes sure there are no color
454
- contrast issues.
455
- </p>
456
- </div>
457
- </div>
458
-
459
- <div class="grid gap-4 md:grid-cols-2">
460
- <div class="flex flex-col gap-3">
461
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
462
- Default
463
- </h3>
464
- <div class="flex flex-col gap-3 border border-border-surface-default p-6">
465
- <UiAlert>
466
- <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
467
- <UiAlertDescription>
468
- Your profile is now up to date.
469
- </UiAlertDescription>
470
- </UiAlert>
471
- <UiAlert variant="destructive">
472
- <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
473
- <UiAlertDescription>
474
- Please verify your billing information and try again.
475
- </UiAlertDescription>
476
- </UiAlert>
477
- </div>
478
- </div>
479
-
480
- <div class="accessible-theme flex flex-col gap-3">
481
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
482
- Accessible
483
- </h3>
484
- <div class="flex flex-col gap-3 border border-border-surface-default p-6">
485
- <UiAlert>
486
- <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
487
- <UiAlertDescription>
488
- Your profile is now up to date.
489
- </UiAlertDescription>
490
- </UiAlert>
491
- <UiAlert variant="destructive">
492
- <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
493
- <UiAlertDescription>
494
- Please verify your billing information and try again.
495
- </UiAlertDescription>
496
- </UiAlert>
497
- </div>
498
- </div>
499
- </div>
500
- </section>
501
- `,
502
- }),
503
- tags: ['!autodocs'],
504
- parameters: {
505
- a11y: { test: 'off' },
506
- chromatic: {
507
- disableSnapshot: true,
508
- },
509
- docs: {
510
- canvas: {
511
- sourceState: 'none',
512
- },
513
- },
514
- },
515
- };
516
-
517
541
  /*
518
542
  * ─────────────────────────────────────────────────────────────────────────────
519
543
  * Interaction & accessibility tests (play functions)
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29184:68913'
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 Alert Dialog component stops the user, states a consequence, and waits for a decision. Nothing else on the screen can be used until they answer, which makes it the most expensive pattern in the system to spend.
10
+
11
+ Use it only when proceeding without a decision would cause loss or harm. For anything the user can undo, let the action happen and offer an undo in a Snackbar instead.
12
+
13
+ ### Earn the interruption
14
+
15
+ Before reaching for an alert dialog, check that:
16
+
17
+ - The consequence is real and hard to reverse
18
+ - The user cannot simply be told afterwards instead
19
+ - There are exactly two reasonable answers
20
+ - The question fits in one short sentence
21
+
22
+ ### Write the decision, not the warning
23
+
24
+ The user reads in this order, so write in this order:
25
+
26
+ 1. Title asks the question, or names the consequence
27
+ 2. Description adds only what would change the answer
28
+ 3. Confirm names the action it performs, rather than agreeing
29
+ 4. Cancel is the safe way out, and stays visually quieter
30
+
31
+ ### Consistency
32
+
33
+ Every alert dialog is built from the same parts:
34
+
35
+ - Dialog surface, at the md or sm breakpoint
36
+ - Title, carrying the decision
37
+ - Description, giving the consequence
38
+ - Confirm action, naming what will happen
39
+ - Cancel action, always present
40
+
41
+ ## Do
42
+
43
+ - Name the consequence in the title, so the dialog can be answered without reading further
44
+ - Label the confirm action with the verb it performs
45
+ - Keep the cancel action visually quieter but equally easy to hit
46
+ - Use the sm breakpoint on narrow surfaces rather than shrinking the md one
47
+ - Keep the whole dialog to a question, a consequence and two actions
48
+ - Return the user to exactly where they were after either answer
49
+
50
+ ## Don't
51
+
52
+ - Use an alert dialog for something the user can undo
53
+ - Ask twice about the same action
54
+ - Label the actions yes and no when the question is not a yes-or-no
55
+ - Bury the consequence in a long description
56
+ - Make cancel harder to find or hit than confirm
57
+ - Stack another dialog on top of an alert dialog
58
+
59
+ ## Accessibility
60
+
61
+ - The dialog separates from the page behind it by surface and elevation, not colour alone
62
+ - Title, description and actions follow one another in reading order, top to bottom
63
+ - Both actions are comfortable targets and both carry a visible focus state
64
+ - Confirm is distinguishable from cancel by shape and weight, not only by fill
65
+ - Text stays legible at the sm breakpoint, with the actions still wide enough to hit
66
+ - Nothing important is carried by the dimming behind the dialog alone
@@ -13,6 +13,16 @@ import {
13
13
  UiAlertDialogTrigger,
14
14
  } from './index';
15
15
  import { UiButton } from '../UiButton';
16
+ import {
17
+ accessibilityRequirementsTemplate,
18
+ designNotesStory,
19
+ guidanceLinks,
20
+ guidanceSectionClass,
21
+ parseGuidance,
22
+ } from '../../../.storybook/guidance';
23
+ import guidanceMarkdown from './UiAlertDialog.guidance.md?raw';
24
+
25
+ const guidance = parseGuidance(guidanceMarkdown);
16
26
 
17
27
  /**
18
28
  * UiAlertDialog is for confirmations that block the page (destructive actions, irreversible steps).
@@ -31,6 +41,9 @@ const meta: Meta<typeof UiAlertDialog> = {
31
41
  args: {
32
42
  model: false,
33
43
  },
44
+ parameters: {
45
+ docs: { links: guidanceLinks(guidance) },
46
+ },
34
47
  };
35
48
 
36
49
  export default meta;
@@ -148,6 +161,129 @@ export const Default: Story = {
148
161
  },
149
162
  };
150
163
 
164
+ /**
165
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
166
+ */
167
+ export const DesignNotes: Story = {
168
+ ...designNotesStory(guidance),
169
+ tags: ['!autodocs'],
170
+ };
171
+
172
+ /**
173
+ * Accessibility guidance for labelled triggers, alertdialog naming, and contrast.
174
+ */
175
+ export const Accessibility: Story = {
176
+ render: () => ({
177
+ components: {
178
+ UiAlertDialog,
179
+ UiAlertDialogAction,
180
+ UiAlertDialogCancel,
181
+ UiAlertDialogContent,
182
+ UiAlertDialogDescription,
183
+ UiAlertDialogFooter,
184
+ UiAlertDialogHeader,
185
+ UiAlertDialogTitle,
186
+ UiAlertDialogTrigger,
187
+ UiButton,
188
+ },
189
+ setup() {
190
+ const defaultModel = ref(false);
191
+ const accessibleModel = ref(false);
192
+ return { defaultModel, accessibleModel };
193
+ },
194
+ template: `
195
+ <section class="${guidanceSectionClass}">
196
+ <div>
197
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
198
+ Accessibility
199
+ </h2>
200
+ </div>
201
+
202
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
203
+
204
+ <div class="flex flex-col gap-6">
205
+ <div class="flex flex-col gap-2">
206
+ <h3 class="body-m-medium text-content-on-surface-primary">
207
+ Enable accessibility theme
208
+ </h3>
209
+ <p class="body-m-regular text-content-on-surface-primary">
210
+ When accessibility is required, enable our accessibility theme. This
211
+ increases contrast and ensures there are no color contrast issues.
212
+ </p>
213
+ </div>
214
+ </div>
215
+
216
+ <div class="grid gap-4 md:grid-cols-2">
217
+ <div class="flex flex-col gap-3">
218
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
219
+ Default
220
+ </h3>
221
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
222
+ <UiAlertDialog v-model:model="defaultModel">
223
+ <UiAlertDialogTrigger as-child>
224
+ <UiButton variant="outline">Show Dialog</UiButton>
225
+ </UiAlertDialogTrigger>
226
+ <UiAlertDialogContent max-width="max-w-lg">
227
+ <UiAlertDialogHeader>
228
+ <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
229
+ <UiAlertDialogDescription>
230
+ This action cannot be undone. This will permanently delete your
231
+ account and remove your data from our servers.
232
+ </UiAlertDialogDescription>
233
+ </UiAlertDialogHeader>
234
+ <UiAlertDialogFooter>
235
+ <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
236
+ <UiAlertDialogAction>Continue</UiAlertDialogAction>
237
+ </UiAlertDialogFooter>
238
+ </UiAlertDialogContent>
239
+ </UiAlertDialog>
240
+ </div>
241
+ </div>
242
+
243
+ <div class="accessible-theme flex flex-col gap-3">
244
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
245
+ Accessible
246
+ </h3>
247
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
248
+ <UiAlertDialog v-model:model="accessibleModel">
249
+ <UiAlertDialogTrigger as-child>
250
+ <UiButton variant="outline">Show Dialog</UiButton>
251
+ </UiAlertDialogTrigger>
252
+ <UiAlertDialogContent max-width="max-w-lg">
253
+ <UiAlertDialogHeader>
254
+ <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
255
+ <UiAlertDialogDescription>
256
+ This action cannot be undone. This will permanently delete your
257
+ account and remove your data from our servers.
258
+ </UiAlertDialogDescription>
259
+ </UiAlertDialogHeader>
260
+ <UiAlertDialogFooter>
261
+ <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
262
+ <UiAlertDialogAction>Continue</UiAlertDialogAction>
263
+ </UiAlertDialogFooter>
264
+ </UiAlertDialogContent>
265
+ </UiAlertDialog>
266
+ </div>
267
+ </div>
268
+ </div>
269
+ </section>
270
+ `,
271
+ }),
272
+ tags: ['!autodocs'],
273
+ parameters: {
274
+ surface: 'primary',
275
+ a11y: { test: 'off' },
276
+ chromatic: {
277
+ disableSnapshot: true,
278
+ },
279
+ docs: {
280
+ canvas: {
281
+ sourceState: 'none',
282
+ },
283
+ },
284
+ },
285
+ };
286
+
151
287
  const simpleTemplateSource = `<script setup lang="ts">
152
288
  import {
153
289
  UiAlertDialog,
@@ -339,118 +475,6 @@ export const FullWidthContent: Story = {
339
475
  },
340
476
  };
341
477
 
342
- /**
343
- * Accessibility guidance for labelled triggers, alertdialog naming, and contrast.
344
- */
345
- export const Accessibility: Story = {
346
- render: () => ({
347
- components: {
348
- UiAlertDialog,
349
- UiAlertDialogAction,
350
- UiAlertDialogCancel,
351
- UiAlertDialogContent,
352
- UiAlertDialogDescription,
353
- UiAlertDialogFooter,
354
- UiAlertDialogHeader,
355
- UiAlertDialogTitle,
356
- UiAlertDialogTrigger,
357
- UiButton,
358
- },
359
- setup() {
360
- const defaultModel = ref(false);
361
- const accessibleModel = ref(false);
362
- return { defaultModel, accessibleModel };
363
- },
364
- template: `
365
- <section class="flex flex-col gap-6 p-4">
366
- <div>
367
- <h2 class="heading-m font-bold text-content-on-surface-primary">
368
- Accessibility
369
- </h2>
370
- </div>
371
-
372
- <div class="flex flex-col gap-6">
373
- <div class="flex flex-col gap-2">
374
- <h3 class="body-m-medium text-content-on-surface-primary">
375
- Enable accessibility theme
376
- </h3>
377
- <p class="body-m-regular text-content-on-surface-primary">
378
- When accessibility is required, enable our accessibility theme. This
379
- increases contrast and ensures there are no color contrast issues.
380
- </p>
381
- </div>
382
- </div>
383
-
384
- <div class="grid gap-4 md:grid-cols-2">
385
- <div class="flex flex-col gap-3">
386
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
387
- Default
388
- </h3>
389
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
390
- <UiAlertDialog v-model:model="defaultModel">
391
- <UiAlertDialogTrigger as-child>
392
- <UiButton variant="outline">Show Dialog</UiButton>
393
- </UiAlertDialogTrigger>
394
- <UiAlertDialogContent max-width="max-w-lg">
395
- <UiAlertDialogHeader>
396
- <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
397
- <UiAlertDialogDescription>
398
- This action cannot be undone. This will permanently delete your
399
- account and remove your data from our servers.
400
- </UiAlertDialogDescription>
401
- </UiAlertDialogHeader>
402
- <UiAlertDialogFooter>
403
- <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
404
- <UiAlertDialogAction>Continue</UiAlertDialogAction>
405
- </UiAlertDialogFooter>
406
- </UiAlertDialogContent>
407
- </UiAlertDialog>
408
- </div>
409
- </div>
410
-
411
- <div class="accessible-theme flex flex-col gap-3">
412
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
413
- Accessible
414
- </h3>
415
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
416
- <UiAlertDialog v-model:model="accessibleModel">
417
- <UiAlertDialogTrigger as-child>
418
- <UiButton variant="outline">Show Dialog</UiButton>
419
- </UiAlertDialogTrigger>
420
- <UiAlertDialogContent max-width="max-w-lg">
421
- <UiAlertDialogHeader>
422
- <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
423
- <UiAlertDialogDescription>
424
- This action cannot be undone. This will permanently delete your
425
- account and remove your data from our servers.
426
- </UiAlertDialogDescription>
427
- </UiAlertDialogHeader>
428
- <UiAlertDialogFooter>
429
- <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
430
- <UiAlertDialogAction>Continue</UiAlertDialogAction>
431
- </UiAlertDialogFooter>
432
- </UiAlertDialogContent>
433
- </UiAlertDialog>
434
- </div>
435
- </div>
436
- </div>
437
- </section>
438
- `,
439
- }),
440
- tags: ['!autodocs'],
441
- parameters: {
442
- a11y: { test: 'off' },
443
- chromatic: {
444
- disableSnapshot: true,
445
- },
446
- docs: {
447
- canvas: {
448
- sourceState: 'none',
449
- },
450
- },
451
- },
452
- };
453
-
454
478
  /*
455
479
  * ─────────────────────────────────────────────────────────────────────────────
456
480
  * Interaction & accessibility tests (play functions)