@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
@@ -4,6 +4,16 @@ import type { DateRange, DateValue } from 'reka-ui';
4
4
  import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
5
5
  import { ref, watch } from 'vue';
6
6
  import UiDatePicker from './UiDatePicker.vue';
7
+ import {
8
+ accessibilityRequirementsTemplate,
9
+ designNotesStory,
10
+ guidanceLinks,
11
+ guidanceSectionClass,
12
+ parseGuidance,
13
+ } from '../../../.storybook/guidance';
14
+ import guidanceMarkdown from './UiDatePicker.guidance.md?raw';
15
+
16
+ const guidance = parseGuidance(guidanceMarkdown);
7
17
 
8
18
  // Module-level spy shared by every story with a play function; each play
9
19
  // clears it first so runs stay independent.
@@ -116,6 +126,9 @@ const meta: Meta<typeof UiDatePicker> = {
116
126
  preventDeselect: false,
117
127
  closeOnSelect: true,
118
128
  },
129
+ parameters: {
130
+ docs: { links: guidanceLinks(guidance) },
131
+ },
119
132
  };
120
133
 
121
134
  export default meta;
@@ -177,6 +190,129 @@ export const Default: Story = {
177
190
  },
178
191
  };
179
192
 
193
+ /**
194
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
195
+ */
196
+ export const DesignNotes: Story = {
197
+ ...designNotesStory(guidance),
198
+ tags: ['!autodocs'],
199
+ };
200
+
201
+ /**
202
+ * Accessibility guidance for the date-picker input and its popover calendar:
203
+ * day treatments that survive without colour, comfortable targets, and a
204
+ * stable grid — shown side by side in the default and accessible themes.
205
+ */
206
+ export const Accessibility: Story = {
207
+ tags: ['!autodocs'],
208
+ parameters: {
209
+ surface: 'primary',
210
+ a11y: { test: 'off' },
211
+ chromatic: { disableSnapshot: true },
212
+ docs: {
213
+ canvas: {
214
+ sourceState: 'none',
215
+ },
216
+ },
217
+ },
218
+ render: () => ({
219
+ components: { UiDatePicker },
220
+ setup() {
221
+ const date = new CalendarDate(2025, 1, 10);
222
+ return { date };
223
+ },
224
+ template: `
225
+ <section class="${guidanceSectionClass}">
226
+ <div>
227
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
228
+ Accessibility
229
+ </h2>
230
+ </div>
231
+
232
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
233
+
234
+ <div class="flex flex-col gap-6">
235
+ <div class="flex flex-col gap-2">
236
+ <h3 class="body-m-medium text-content-on-surface-primary">
237
+ In code
238
+ </h3>
239
+ <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
240
+ <li>
241
+ Today and the selected day differ in shape as well as fill, so
242
+ both survive without colour
243
+ </li>
244
+ <li>
245
+ Selected, hover and focus are three distinguishable treatments,
246
+ not variations of one
247
+ </li>
248
+ <li>
249
+ Focus stays visible on a day even when that day is selected or
250
+ inside a range
251
+ </li>
252
+ <li>
253
+ Day buttons are a comfortable target at the size chosen,
254
+ including the smallest one used
255
+ </li>
256
+ <li>
257
+ Unavailable days carry a visible treatment beyond low contrast
258
+ </li>
259
+ <li>
260
+ The grid keeps a stable size between months, so the page does
261
+ not shift under the reader
262
+ </li>
263
+ <li>
264
+ Give the trigger a meaningful name with aria-label (for example,
265
+ "Choose departure date") and name its calendar with calendar-label.
266
+ </li>
267
+ <li>
268
+ Tab to the trigger and press Enter or Space to open the calendar.
269
+ Use arrow keys to navigate dates and Enter or Space to select.
270
+ In range mode, select the start and then the end date.
271
+ </li>
272
+ <li>
273
+ Escape dismisses the calendar and returns focus to the trigger.
274
+ By default, selecting a date or completing a range also closes
275
+ the popover; setting close-on-select to false keeps it open.
276
+ </li>
277
+ </ul>
278
+ </div>
279
+
280
+ <div class="flex flex-col gap-2">
281
+ <h3 class="body-m-medium text-content-on-surface-primary">
282
+ Enable accessibility theme
283
+ </h3>
284
+ <p class="body-m-regular text-content-on-surface-primary">
285
+ When accessibility is required, enable our accessibility theme.
286
+ This increases contrast and ensures there are no color contrast
287
+ issues.
288
+ </p>
289
+ </div>
290
+ </div>
291
+
292
+ <div class="grid gap-4 md:grid-cols-2">
293
+ <div class="flex flex-col gap-3">
294
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
295
+ Default
296
+ </h3>
297
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
298
+ <UiDatePicker :default-value="date" aria-label="Choose date" />
299
+ </div>
300
+ </div>
301
+
302
+ <div class="accessible-theme flex flex-col gap-3">
303
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
304
+ Accessible
305
+ </h3>
306
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
307
+ <UiDatePicker :default-value="date" aria-label="Choose date" />
308
+ </div>
309
+ </div>
310
+ </div>
311
+ </section>
312
+ `,
313
+ }),
314
+ };
315
+
180
316
  const withPreselectedDateTemplateSource = `<script setup lang="ts">
181
317
  import { ref } from 'vue'
182
318
  import type { DateValue } from '@internationalized/date'
@@ -1691,115 +1827,3 @@ export const MobileBreakpoint: Story = {
1691
1827
  );
1692
1828
  },
1693
1829
  };
1694
-
1695
- /**
1696
- * Accessibility guidance for the date-picker input and its popover calendar:
1697
- * day treatments that survive without colour, comfortable targets, and a
1698
- * stable grid — shown side by side in the default and accessible themes.
1699
- */
1700
- export const Accessibility: Story = {
1701
- tags: ['!autodocs'],
1702
- parameters: {
1703
- a11y: { test: 'off' },
1704
- chromatic: { disableSnapshot: true },
1705
- docs: {
1706
- canvas: {
1707
- sourceState: 'none',
1708
- },
1709
- },
1710
- },
1711
- render: () => ({
1712
- components: { UiDatePicker },
1713
- setup() {
1714
- const date = new CalendarDate(2025, 1, 10);
1715
- return { date };
1716
- },
1717
- template: `
1718
- <section class="flex w-full flex-col gap-6 p-4">
1719
- <div>
1720
- <h2 class="heading-m font-bold text-content-on-surface-primary">
1721
- Accessibility
1722
- </h2>
1723
- </div>
1724
-
1725
- <div class="flex flex-col gap-6">
1726
- <div class="flex flex-col gap-2">
1727
- <h3 class="body-m-medium text-content-on-surface-primary">
1728
- Requirements
1729
- </h3>
1730
- <ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
1731
- <li>
1732
- Today and the selected day differ in shape as well as fill, so
1733
- both survive without colour
1734
- </li>
1735
- <li>
1736
- Selected, hover and focus are three distinguishable treatments,
1737
- not variations of one
1738
- </li>
1739
- <li>
1740
- Focus stays visible on a day even when that day is selected or
1741
- inside a range
1742
- </li>
1743
- <li>
1744
- Day buttons are a comfortable target at the size chosen,
1745
- including the smallest one used
1746
- </li>
1747
- <li>
1748
- Unavailable days carry a visible treatment beyond low contrast
1749
- </li>
1750
- <li>
1751
- The grid keeps a stable size between months, so the page does
1752
- not shift under the reader
1753
- </li>
1754
- <li>
1755
- Give the trigger a meaningful name with aria-label (for example,
1756
- "Choose departure date") and name its calendar with calendar-label.
1757
- </li>
1758
- <li>
1759
- Tab to the trigger and press Enter or Space to open the calendar.
1760
- Use arrow keys to navigate dates and Enter or Space to select.
1761
- In range mode, select the start and then the end date.
1762
- </li>
1763
- <li>
1764
- Escape dismisses the calendar and returns focus to the trigger.
1765
- By default, selecting a date or completing a range also closes
1766
- the popover; setting close-on-select to false keeps it open.
1767
- </li>
1768
- </ul>
1769
- </div>
1770
-
1771
- <div class="flex flex-col gap-2">
1772
- <h3 class="body-m-medium text-content-on-surface-primary">
1773
- Enable accessibility theme
1774
- </h3>
1775
- <p class="body-m-regular text-content-on-surface-primary">
1776
- When accessibility is required, enable our accessibility theme.
1777
- This increases contrast and ensures there are no color contrast
1778
- issues.
1779
- </p>
1780
- </div>
1781
- </div>
1782
-
1783
- <div class="grid gap-4 md:grid-cols-2">
1784
- <div class="flex flex-col gap-3">
1785
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1786
- Default
1787
- </h3>
1788
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1789
- <UiDatePicker :default-value="date" aria-label="Choose date" />
1790
- </div>
1791
- </div>
1792
-
1793
- <div class="accessible-theme flex flex-col gap-3">
1794
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1795
- Accessible
1796
- </h3>
1797
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
1798
- <UiDatePicker :default-value="date" aria-label="Choose date" />
1799
- </div>
1800
- </div>
1801
- </div>
1802
- </section>
1803
- `,
1804
- }),
1805
- };
@@ -7,6 +7,7 @@ import {
7
7
  ImagePlayIcon,
8
8
  Table2Icon,
9
9
  } from '@/icons/lucide';
10
+ import { guidanceSectionClass } from '../../../.storybook/guidance';
10
11
 
11
12
  const mediaIconOptions = {
12
13
  auto: undefined,
@@ -172,6 +173,82 @@ export const Default: Story = {
172
173
  },
173
174
  };
174
175
 
176
+ /**
177
+ * Accessibility guidance for file rows and accessible theme usage.
178
+ */
179
+ export const Accessibility: Story = {
180
+ render: () => ({
181
+ components: { UiFileItem },
182
+ setup() {
183
+ return { onRemove };
184
+ },
185
+ template: `
186
+ <section class="${guidanceSectionClass}">
187
+ <div>
188
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
189
+ Accessibility
190
+ </h2>
191
+ </div>
192
+
193
+ <div class="flex flex-col gap-6">
194
+ <div class="flex flex-col gap-2">
195
+ <h3 class="body-m-medium text-content-on-surface-primary">
196
+ Enable accessibility theme
197
+ </h3>
198
+ <p class="body-m-regular text-content-on-surface-primary">
199
+ When accessibility is required, enable our accessibility theme. This increases contrast and makes sure there are no color contrast issues.
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
+ Never rely on the media badge alone
206
+ </h3>
207
+ <p class="body-m-regular text-content-on-surface-primary">
208
+ The round media badge is decorative and hidden from assistive tech, so the file family must also be stated in text. In the accessibility theme the media badge for video resolves to the same yellow as tabular files, which is why every row keeps its type label and its own icon. Processing uses the same neutral badge as an upload in progress, so the status has to be the text “Processing…”, not the badge.
209
+ </p>
210
+ </div>
211
+ </div>
212
+
213
+ <div class="grid gap-4 md:grid-cols-2">
214
+ <div class="flex flex-col gap-3">
215
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
216
+ Default
217
+ </h3>
218
+ <div class="flex flex-col gap-3 border border-border-surface-default p-4">
219
+ <UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
220
+ <UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
221
+ </div>
222
+ </div>
223
+
224
+ <div class="accessible-theme flex flex-col gap-3">
225
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
226
+ Accessible
227
+ </h3>
228
+ <div class="flex flex-col gap-3 border border-border-surface-default p-4">
229
+ <UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
230
+ <UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
231
+ </div>
232
+ </div>
233
+ </div>
234
+ </section>
235
+ `,
236
+ }),
237
+ tags: ['!autodocs'],
238
+ parameters: {
239
+ surface: 'primary',
240
+ a11y: { test: 'off' },
241
+ chromatic: {
242
+ disableSnapshot: true,
243
+ },
244
+ docs: {
245
+ canvas: {
246
+ sourceState: 'none',
247
+ },
248
+ },
249
+ },
250
+ };
251
+
175
252
  const defaultWithProgressTemplateSource = `<script setup lang="ts">
176
253
  import { UiFileItem } from '@aleph-alpha/ui-library'
177
254
 
@@ -1225,81 +1302,6 @@ export const AllVariants: Story = {
1225
1302
  }),
1226
1303
  };
1227
1304
 
1228
- /**
1229
- * Accessibility guidance for file rows and accessible theme usage.
1230
- */
1231
- export const Accessibility: Story = {
1232
- render: () => ({
1233
- components: { UiFileItem },
1234
- setup() {
1235
- return { onRemove };
1236
- },
1237
- template: `
1238
- <section class="flex flex-col gap-6 p-4">
1239
- <div>
1240
- <h2 class="heading-m font-bold text-content-on-surface-primary">
1241
- Accessibility
1242
- </h2>
1243
- </div>
1244
-
1245
- <div class="flex flex-col gap-6">
1246
- <div class="flex flex-col gap-2">
1247
- <h3 class="body-m-medium text-content-on-surface-primary">
1248
- Enable accessibility theme
1249
- </h3>
1250
- <p class="body-m-regular text-content-on-surface-primary">
1251
- When accessibility is required, enable our accessibility theme. This increases contrast and makes sure there are no color contrast issues.
1252
- </p>
1253
- </div>
1254
-
1255
- <div class="flex flex-col gap-2">
1256
- <h3 class="body-m-medium text-content-on-surface-primary">
1257
- Never rely on the media badge alone
1258
- </h3>
1259
- <p class="body-m-regular text-content-on-surface-primary">
1260
- The round media badge is decorative and hidden from assistive tech, so the file family must also be stated in text. In the accessibility theme the media badge for video resolves to the same yellow as tabular files, which is why every row keeps its type label and its own icon. Processing uses the same neutral badge as an upload in progress, so the status has to be the text “Processing…”, not the badge.
1261
- </p>
1262
- </div>
1263
- </div>
1264
-
1265
- <div class="grid gap-4 md:grid-cols-2">
1266
- <div class="flex flex-col gap-3">
1267
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1268
- Default
1269
- </h3>
1270
- <div class="flex flex-col gap-3 border border-border-surface-default p-4">
1271
- <UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
1272
- <UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
1273
- </div>
1274
- </div>
1275
-
1276
- <div class="accessible-theme flex flex-col gap-3">
1277
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
1278
- Accessible
1279
- </h3>
1280
- <div class="flex flex-col gap-3 border border-border-surface-default p-4">
1281
- <UiFileItem filename="Quarterly report.csv" type-label="CSV" size-label="320 KB" @remove="onRemove" />
1282
- <UiFileItem filename="Product tour.mp4" type-label="MP4" size-label="18 MB" @remove="onRemove" />
1283
- </div>
1284
- </div>
1285
- </div>
1286
- </section>
1287
- `,
1288
- }),
1289
- tags: ['!autodocs'],
1290
- parameters: {
1291
- a11y: { test: 'off' },
1292
- chromatic: {
1293
- disableSnapshot: true,
1294
- },
1295
- docs: {
1296
- canvas: {
1297
- sourceState: 'none',
1298
- },
1299
- },
1300
- },
1301
- };
1302
-
1303
1305
  /*
1304
1306
  * ─────────────────────────────────────────────────────────────────────────────
1305
1307
  * Interaction & accessibility tests (play functions)
@@ -0,0 +1,68 @@
1
+ ---
2
+ figma: '29182:672'
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 File Upload component brings the whole act of adding files into one surface: an area to drop them, an explicit picker for people who do not drag, the constraints the files must satisfy, and a list that reports the outcome for every file.
10
+
11
+ Use it whenever a task depends on files the user provides. The component carries the upload; the form around it still owns saving and cancelling.
12
+
13
+ ### State the rules up front
14
+
15
+ A user should know what will be accepted before choosing a file:
16
+
17
+ - Supported file types are named beside the drop zone, not hidden in a tooltip
18
+ - The size limit is visible at the same moment
19
+ - The drop zone reads as a target, with the picker offered alongside it
20
+ - Any limit on how many files may be added is stated as well
21
+
22
+ ### Report every file
23
+
24
+ Each file moves through the same visible sequence:
25
+
26
+ 1. Added, showing name, type and size
27
+ 2. Uploading, with progress the user can watch
28
+ 3. Succeeded, or failed with the reason in plain words
29
+ 4. Removable at any point, one file at a time
30
+
31
+ ### Consistency
32
+
33
+ Every upload is built from the same parts:
34
+
35
+ - File upload surface, holding the drop zone and the actions
36
+ - Drop zone, at rest and while a file is dragged over it
37
+ - Constraint line: supported types and maximum size
38
+ - File item, at default or small size
39
+ - File item states: with progress, success, error, multiple
40
+ - Filetype icon: text, markdown, tabular, media
41
+ - File item menu, for actions on a single file
42
+
43
+ ## Do
44
+
45
+ - Name the accepted file types and the size limit before the user picks a file
46
+ - Offer a visible picker button as well as the drop zone
47
+ - Show progress per file, so a slow upload never looks stalled
48
+ - Say what went wrong in the file's own row, in words the user can act on
49
+ - Let the user remove a single file without starting over
50
+ - Collapse long lists with the multiple state rather than growing the surface
51
+
52
+ ## Don't
53
+
54
+ - Rely on drag and drop as the only way to add a file
55
+ - Draw the resting drop zone and its drag-over state the same way
56
+ - Report failures only as a count or a colour
57
+ - Clear the whole list when one file fails
58
+ - Let a long file name run out of its row instead of truncating it
59
+ - Leave the surface without a clear way to cancel or confirm
60
+
61
+ ## Accessibility
62
+
63
+ - The drop zone reads as an interactive target at rest, not only while a file is dragged over it
64
+ - Drag-over is shown by border and fill together, so the change survives without colour
65
+ - Progress, success and error are each distinguishable by icon and text, never by colour alone
66
+ - Error text sits in the row it belongs to and stays legible at the small size
67
+ - Remove and menu controls stay comfortable targets for touch as rows tighten
68
+ - Focus is clearly visible on the picker, on each file row and on its controls