@aleph-alpha/ui-library 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/system/icons/story-sidebar-icons.json +74 -17
  2. package/dist/system/lib.js +8 -5
  3. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  4. package/dist/system/story-sidebar-icons.json +74 -17
  5. package/package.json +8 -3
  6. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  7. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  8. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  9. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  10. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  11. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  12. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  13. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  14. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  15. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  16. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  17. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  18. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  19. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  20. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  21. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  22. package/src/components/UiButton/UiButton.stories.ts +5 -2
  23. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  24. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  25. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  26. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  27. package/src/components/UiCard/UiCard.guidance.md +65 -0
  28. package/src/components/UiCard/UiCard.stories.ts +393 -0
  29. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  30. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  31. package/src/components/UiChip/UiChip.guidance.md +64 -0
  32. package/src/components/UiChip/UiChip.stories.ts +162 -138
  33. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  34. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  35. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  36. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  37. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  38. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  39. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  40. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  41. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
  42. package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
  43. package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
  44. package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
  45. package/src/components/UiField/UiField.guidance.md +63 -0
  46. package/src/components/UiField/UiField.stories.ts +90 -113
  47. package/src/components/UiFileType/UiFileType.stories.ts +254 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
  49. package/src/components/UiIcon/UiIcon.stories.ts +256 -1
  50. package/src/components/UiInput/UiInput.guidance.md +64 -0
  51. package/src/components/UiInput/UiInput.stories.ts +132 -80
  52. package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
  53. package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
  54. package/src/components/UiItem/UiItem.guidance.md +66 -0
  55. package/src/components/UiItem/UiItem.stories.ts +81 -28
  56. package/src/components/UiKbd/UiKbd.guidance.md +65 -0
  57. package/src/components/UiKbd/UiKbd.stories.ts +373 -3
  58. package/src/components/UiLabel/UiLabel.guidance.md +65 -0
  59. package/src/components/UiLabel/UiLabel.stories.ts +163 -139
  60. package/src/components/UiListbox/UiListbox.stories.ts +197 -195
  61. package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
  62. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
  63. package/src/components/UiPopover/UiPopover.guidance.md +65 -0
  64. package/src/components/UiPopover/UiPopover.stories.ts +115 -91
  65. package/src/components/UiProgress/UiProgress.guidance.md +65 -0
  66. package/src/components/UiProgress/UiProgress.stories.ts +300 -0
  67. package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
  68. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
  69. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
  70. package/src/components/UiResizable/UiResizable.guidance.md +65 -0
  71. package/src/components/UiResizable/UiResizable.stories.ts +176 -152
  72. package/src/components/UiSelect/UiSelect.guidance.md +66 -0
  73. package/src/components/UiSelect/UiSelect.stories.ts +150 -126
  74. package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
  75. package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
  76. package/src/components/UiSheet/UiSheet.guidance.md +66 -0
  77. package/src/components/UiSheet/UiSheet.stories.ts +194 -170
  78. package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
  79. package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
  80. package/src/components/UiSlider/UiSlider.guidance.md +66 -0
  81. package/src/components/UiSlider/UiSlider.stories.ts +150 -126
  82. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  83. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  84. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  85. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  86. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  87. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  88. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  89. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  90. package/src/components/UiTable/UiTable.guidance.md +66 -0
  91. package/src/components/UiTable/UiTable.stories.ts +530 -12
  92. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  93. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  94. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  95. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  96. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  97. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  98. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  99. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  100. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  101. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  102. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  103. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  104. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  105. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  106. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  107. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  108. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  109. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  110. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  111. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  112. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  113. package/src/patterns/UiPlaceholder/types.ts +1 -0
  114. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
  115. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -21,6 +21,7 @@ import {
21
21
  UiListboxItem,
22
22
  UiListboxItemIndicator,
23
23
  } from '../UiListbox';
24
+ import { guidanceSectionClass } from '../../../.storybook/guidance';
24
25
 
25
26
  /**
26
27
  * UiTagsInput is an input that collects multiple short string values as tags, with keyboard add/remove support.
@@ -153,6 +154,159 @@ export const Default: Story = {
153
154
  },
154
155
  };
155
156
 
157
+ /**
158
+ * Accessibility guidance for labelling the field, naming remove controls,
159
+ * announcing changes, keyboard operation, and contrast.
160
+ */
161
+ export const Accessibility: Story = {
162
+ render: () => ({
163
+ components: {
164
+ UiTagsInput,
165
+ UiTagsInputInput,
166
+ UiTagsInputItem,
167
+ UiTagsInputItemText,
168
+ UiTagsInputItemDelete,
169
+ },
170
+ setup() {
171
+ const tags = ref(['Apple', 'Banana']);
172
+ const accessibleTags = ref(['Apple', 'Banana']);
173
+ return { tags, accessibleTags };
174
+ },
175
+ template: `
176
+ <section class="${guidanceSectionClass}">
177
+ <div>
178
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
179
+ Accessibility
180
+ </h2>
181
+ </div>
182
+
183
+ <div class="flex flex-col gap-6">
184
+ <div class="flex flex-col gap-2">
185
+ <h3 class="body-m-medium text-content-on-surface-primary">
186
+ Give the field a real label
187
+ </h3>
188
+ <p class="body-m-regular text-content-on-surface-primary">
189
+ The placeholder is not a label. Associate a
190
+ <code>UiLabel</code> with the inner input (or pass an
191
+ <code>aria-label</code>) so the field keeps its name once the
192
+ user starts typing and the placeholder disappears (WCAG 3.3.2).
193
+ </p>
194
+ </div>
195
+
196
+ <div class="flex flex-col gap-2">
197
+ <h3 class="body-m-medium text-content-on-surface-primary">
198
+ Remove controls name their tag
199
+ </h3>
200
+ <p class="body-m-regular text-content-on-surface-primary">
201
+ Each delete button is announced as
202
+ <code>Remove &lt;tag&gt;</code>, so it is distinguishable from
203
+ the tag beside it and from every other remove control. Pass
204
+ <code>label</code> to translate or reword it.
205
+ </p>
206
+ </div>
207
+
208
+ <div class="flex flex-col gap-2">
209
+ <h3 class="body-m-medium text-content-on-surface-primary">
210
+ Additions and removals are announced
211
+ </h3>
212
+ <p class="body-m-regular text-content-on-surface-primary">
213
+ Adding or removing a tag changes the DOM without moving focus,
214
+ which a screen reader would otherwise pass over in silence. The
215
+ component announces the change through a polite live region
216
+ (WCAG 4.1.3). Use <code>added-label</code> and
217
+ <code>removed-label</code> to translate the wording.
218
+ </p>
219
+ </div>
220
+
221
+ <div class="flex flex-col gap-2">
222
+ <h3 class="body-m-medium text-content-on-surface-primary">
223
+ Tags are exposed as text, not as list items
224
+ </h3>
225
+ <p class="body-m-regular text-content-on-surface-primary">
226
+ Each tag is a generic element, so its value reaches assistive
227
+ technology as plain text. A <code>list</code> role is not an
228
+ option here because the text input shares the container and
229
+ would be an invalid child. axe reports one needs-review result
230
+ on the tag (<code>aria-prohibited-attr</code>) for an
231
+ <code>aria-labelledby</code> that browsers ignore; it is
232
+ reviewed and expected, not an outstanding failure.
233
+ </p>
234
+ </div>
235
+
236
+ <div class="flex flex-col gap-2">
237
+ <h3 class="body-m-medium text-content-on-surface-primary">
238
+ Keyboard model
239
+ </h3>
240
+ <p class="body-m-regular text-content-on-surface-primary">
241
+ Only the text field is a tab stop; tags are reached with the
242
+ arrow keys and removed with <kbd>Delete</kbd> or
243
+ <kbd>Backspace</kbd>. Because tag selection moves reka's internal
244
+ index rather than DOM focus, never rely on a visible focus ring
245
+ alone to tell the user which tag is selected.
246
+ </p>
247
+ </div>
248
+
249
+ <div class="flex flex-col gap-2">
250
+ <h3 class="body-m-medium text-content-on-surface-primary">
251
+ Enable accessibility theme
252
+ </h3>
253
+ <p class="body-m-regular text-content-on-surface-primary">
254
+ When accessibility is required, enable our accessibility theme.
255
+ This increases contrast and makes sure there are no color
256
+ contrast issues.
257
+ </p>
258
+ </div>
259
+ </div>
260
+
261
+ <div class="grid gap-4 md:grid-cols-2">
262
+ <div class="flex flex-col gap-3">
263
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
264
+ Default
265
+ </h3>
266
+ <div class="flex flex-col gap-4 border border-border-surface-default p-6">
267
+ <UiTagsInput v-model="tags">
268
+ <UiTagsInputItem v-for="item in tags" :key="item" :value="item">
269
+ <UiTagsInputItemText />
270
+ <UiTagsInputItemDelete />
271
+ </UiTagsInputItem>
272
+ <UiTagsInputInput aria-label="Fruits" placeholder="Fruits..." />
273
+ </UiTagsInput>
274
+ </div>
275
+ </div>
276
+
277
+ <div class="accessible-theme flex flex-col gap-3">
278
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
279
+ Accessible
280
+ </h3>
281
+ <div class="flex flex-col gap-4 border border-border-surface-default p-6">
282
+ <UiTagsInput v-model="accessibleTags">
283
+ <UiTagsInputItem v-for="item in accessibleTags" :key="item" :value="item">
284
+ <UiTagsInputItemText />
285
+ <UiTagsInputItemDelete />
286
+ </UiTagsInputItem>
287
+ <UiTagsInputInput aria-label="Fruits" placeholder="Fruits..." />
288
+ </UiTagsInput>
289
+ </div>
290
+ </div>
291
+ </div>
292
+ </section>
293
+ `,
294
+ }),
295
+ tags: ['!autodocs'],
296
+ parameters: {
297
+ surface: 'primary',
298
+ a11y: { test: 'off' },
299
+ chromatic: {
300
+ disableSnapshot: true,
301
+ },
302
+ docs: {
303
+ canvas: {
304
+ sourceState: 'none',
305
+ },
306
+ },
307
+ },
308
+ };
309
+
156
310
  const emptyTemplateSource = `<script setup lang="ts">
157
311
  import { ref } from 'vue'
158
312
  import {
@@ -755,158 +909,6 @@ export const WithListbox: Story = {
755
909
  },
756
910
  };
757
911
 
758
- /**
759
- * Accessibility guidance for labelling the field, naming remove controls,
760
- * announcing changes, keyboard operation, and contrast.
761
- */
762
- export const Accessibility: Story = {
763
- render: () => ({
764
- components: {
765
- UiTagsInput,
766
- UiTagsInputInput,
767
- UiTagsInputItem,
768
- UiTagsInputItemText,
769
- UiTagsInputItemDelete,
770
- },
771
- setup() {
772
- const tags = ref(['Apple', 'Banana']);
773
- const accessibleTags = ref(['Apple', 'Banana']);
774
- return { tags, accessibleTags };
775
- },
776
- template: `
777
- <section class="flex flex-col gap-6 p-4">
778
- <div>
779
- <h2 class="heading-m font-bold text-content-on-surface-primary">
780
- Accessibility
781
- </h2>
782
- </div>
783
-
784
- <div class="flex flex-col gap-6">
785
- <div class="flex flex-col gap-2">
786
- <h3 class="body-m-medium text-content-on-surface-primary">
787
- Give the field a real label
788
- </h3>
789
- <p class="body-m-regular text-content-on-surface-primary">
790
- The placeholder is not a label. Associate a
791
- <code>UiLabel</code> with the inner input (or pass an
792
- <code>aria-label</code>) so the field keeps its name once the
793
- user starts typing and the placeholder disappears (WCAG 3.3.2).
794
- </p>
795
- </div>
796
-
797
- <div class="flex flex-col gap-2">
798
- <h3 class="body-m-medium text-content-on-surface-primary">
799
- Remove controls name their tag
800
- </h3>
801
- <p class="body-m-regular text-content-on-surface-primary">
802
- Each delete button is announced as
803
- <code>Remove &lt;tag&gt;</code>, so it is distinguishable from
804
- the tag beside it and from every other remove control. Pass
805
- <code>label</code> to translate or reword it.
806
- </p>
807
- </div>
808
-
809
- <div class="flex flex-col gap-2">
810
- <h3 class="body-m-medium text-content-on-surface-primary">
811
- Additions and removals are announced
812
- </h3>
813
- <p class="body-m-regular text-content-on-surface-primary">
814
- Adding or removing a tag changes the DOM without moving focus,
815
- which a screen reader would otherwise pass over in silence. The
816
- component announces the change through a polite live region
817
- (WCAG 4.1.3). Use <code>added-label</code> and
818
- <code>removed-label</code> to translate the wording.
819
- </p>
820
- </div>
821
-
822
- <div class="flex flex-col gap-2">
823
- <h3 class="body-m-medium text-content-on-surface-primary">
824
- Tags are exposed as text, not as list items
825
- </h3>
826
- <p class="body-m-regular text-content-on-surface-primary">
827
- Each tag is a generic element, so its value reaches assistive
828
- technology as plain text. A <code>list</code> role is not an
829
- option here because the text input shares the container and
830
- would be an invalid child. axe reports one needs-review result
831
- on the tag (<code>aria-prohibited-attr</code>) for an
832
- <code>aria-labelledby</code> that browsers ignore; it is
833
- reviewed and expected, not an outstanding failure.
834
- </p>
835
- </div>
836
-
837
- <div class="flex flex-col gap-2">
838
- <h3 class="body-m-medium text-content-on-surface-primary">
839
- Keyboard model
840
- </h3>
841
- <p class="body-m-regular text-content-on-surface-primary">
842
- Only the text field is a tab stop; tags are reached with the
843
- arrow keys and removed with <kbd>Delete</kbd> or
844
- <kbd>Backspace</kbd>. Because tag selection moves reka's internal
845
- index rather than DOM focus, never rely on a visible focus ring
846
- alone to tell the user which tag is selected.
847
- </p>
848
- </div>
849
-
850
- <div class="flex flex-col gap-2">
851
- <h3 class="body-m-medium text-content-on-surface-primary">
852
- Enable accessibility theme
853
- </h3>
854
- <p class="body-m-regular text-content-on-surface-primary">
855
- When accessibility is required, enable our accessibility theme.
856
- This increases contrast and makes sure there are no color
857
- contrast issues.
858
- </p>
859
- </div>
860
- </div>
861
-
862
- <div class="grid gap-4 md:grid-cols-2">
863
- <div class="flex flex-col gap-3">
864
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
865
- Default
866
- </h3>
867
- <div class="flex flex-col gap-4 border border-border-surface-default p-6">
868
- <UiTagsInput v-model="tags">
869
- <UiTagsInputItem v-for="item in tags" :key="item" :value="item">
870
- <UiTagsInputItemText />
871
- <UiTagsInputItemDelete />
872
- </UiTagsInputItem>
873
- <UiTagsInputInput aria-label="Fruits" placeholder="Fruits..." />
874
- </UiTagsInput>
875
- </div>
876
- </div>
877
-
878
- <div class="accessible-theme flex flex-col gap-3">
879
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
880
- Accessible
881
- </h3>
882
- <div class="flex flex-col gap-4 border border-border-surface-default p-6">
883
- <UiTagsInput v-model="accessibleTags">
884
- <UiTagsInputItem v-for="item in accessibleTags" :key="item" :value="item">
885
- <UiTagsInputItemText />
886
- <UiTagsInputItemDelete />
887
- </UiTagsInputItem>
888
- <UiTagsInputInput aria-label="Fruits" placeholder="Fruits..." />
889
- </UiTagsInput>
890
- </div>
891
- </div>
892
- </div>
893
- </section>
894
- `,
895
- }),
896
- tags: ['!autodocs'],
897
- parameters: {
898
- a11y: { test: 'off' },
899
- chromatic: {
900
- disableSnapshot: true,
901
- },
902
- docs: {
903
- canvas: {
904
- sourceState: 'none',
905
- },
906
- },
907
- },
908
- };
909
-
910
912
  /*
911
913
  * ─────────────────────────────────────────────────────────────────────────────
912
914
  * Interaction & accessibility tests (play functions)
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29209:71794'
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 Textarea component takes text that runs longer than a line. Its height is a promise: it tells the user roughly how much is expected before they start writing.
10
+
11
+ Use it when the answer is sentences — a note, a description, a message. When the value is a single short thing, Input is the right control, and its shorter field says so.
12
+
13
+ ### Height sets the expectation
14
+
15
+ The size of the field is the clearest instruction it gives:
16
+
17
+ - The default height matches the length of answer you expect
18
+ - It grows with the content, or scrolls, but never hides what is typed
19
+ - The description states any limit before the user reaches it
20
+ - A character count appears only where a limit really applies
21
+
22
+ ### Show state as it changes
23
+
24
+ The field reports back at every step:
25
+
26
+ 1. Default, empty and waiting
27
+ 2. Focus, showing where typing will land
28
+ 3. Filled, holding text the user can still read and edit
29
+ 4. Error, with the reason beneath the field
30
+
31
+ ### Consistency
32
+
33
+ Every textarea is composed the same way:
34
+
35
+ - Textarea, as the typing surface
36
+ - Field, giving it label, description and error
37
+ - States: default, filled, focus, disabled, error and error focus
38
+ - One default height per kind of answer
39
+ - A character count only where a limit applies
40
+
41
+ ## Do
42
+
43
+ - Set the default height to the length of answer you expect
44
+ - Pair every textarea with a visible label through Field
45
+ - State any length limit in the description, before it is reached
46
+ - Let the field grow or scroll rather than hiding typed text
47
+ - Show the error beneath the field, once the user has left it
48
+ - Keep resize behaviour consistent across a product
49
+
50
+ ## Don't
51
+
52
+ - Use a textarea for a single short value — use Input
53
+ - Use a one-line-high textarea
54
+ - Reveal a length limit only when the user hits it
55
+ - Show a character count where there is no limit
56
+ - Hide typed text as the content grows
57
+ - Rely on the border colour alone to show an error
58
+
59
+ ## Accessibility
60
+
61
+ - Every textarea has a visible label above it; a placeholder never stands in for one
62
+ - The focus state is distinguishable from hover, filled and error
63
+ - The error state is carried by text beneath the field as well as by the border
64
+ - The field is tall enough that several lines are visible while typing
65
+ - Any length limit is stated in text, not only signalled when it is reached
66
+ - Disabled fields are distinguishable by more than reduced opacity
@@ -2,6 +2,16 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
2
  import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
3
3
  import UiTextarea from './UiTextarea.vue';
4
4
  import { ref } from 'vue';
5
+ import {
6
+ accessibilityRequirementsTemplate,
7
+ designNotesStory,
8
+ guidanceLinks,
9
+ guidanceSectionClass,
10
+ parseGuidance,
11
+ } from '../../../.storybook/guidance';
12
+ import guidanceMarkdown from './UiTextarea.guidance.md?raw';
13
+
14
+ const guidance = parseGuidance(guidanceMarkdown);
5
15
 
6
16
  /**
7
17
  * UiTextarea is a multi-line text-entry primitive for longer-form content like comments, descriptions, and prompts.
@@ -31,6 +41,9 @@ const meta: Meta<typeof UiTextarea> = {
31
41
  required: false,
32
42
  placeholder: 'Type your message here.',
33
43
  },
44
+ parameters: {
45
+ docs: { links: guidanceLinks(guidance) },
46
+ },
34
47
  };
35
48
 
36
49
  export default meta;
@@ -86,6 +99,79 @@ export const Default: Story = {
86
99
  },
87
100
  };
88
101
 
102
+ /**
103
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
104
+ */
105
+ export const DesignNotes: Story = {
106
+ ...designNotesStory(guidance),
107
+ tags: ['!autodocs'],
108
+ };
109
+
110
+ /**
111
+ * Accessibility guidance for textarea labelling, keyboard operability, and contrast.
112
+ */
113
+ export const Accessibility: Story = {
114
+ render: () => ({
115
+ components: { UiTextarea },
116
+ template: `
117
+ <section class="${guidanceSectionClass}">
118
+ <div>
119
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
120
+ Accessibility
121
+ </h2>
122
+ </div>
123
+
124
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
125
+
126
+ <div class="flex flex-col gap-6">
127
+ <div class="flex flex-col gap-2">
128
+ <h3 class="body-m-medium text-content-on-surface-primary">
129
+ Enable accessibility theme
130
+ </h3>
131
+ <p class="body-m-regular text-content-on-surface-primary">
132
+ When accessibility is required, enable our accessibility theme. This
133
+ increases contrast and ensures there are no color contrast issues.
134
+ </p>
135
+ </div>
136
+ </div>
137
+
138
+ <div class="grid gap-4 md:grid-cols-2">
139
+ <div class="flex flex-col gap-3">
140
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
141
+ Default
142
+ </h3>
143
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
144
+ <UiTextarea name="a11y-default" placeholder="Placeholder" class="max-w-xs" />
145
+ </div>
146
+ </div>
147
+
148
+ <div class="accessible-theme flex flex-col gap-3">
149
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
150
+ Accessible
151
+ </h3>
152
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
153
+ <UiTextarea name="a11y-accessible" placeholder="Placeholder" class="max-w-xs" />
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </section>
158
+ `,
159
+ }),
160
+ tags: ['!autodocs'],
161
+ parameters: {
162
+ surface: 'primary',
163
+ a11y: { test: 'off' },
164
+ chromatic: {
165
+ disableSnapshot: true,
166
+ },
167
+ docs: {
168
+ canvas: {
169
+ sourceState: 'none',
170
+ },
171
+ },
172
+ },
173
+ };
174
+
89
175
  const withLabelTemplateSource = `<script setup lang="ts">
90
176
  import { UiTextarea } from '@aleph-alpha/ui-library'
91
177
  </script>
@@ -283,68 +369,6 @@ export const Disabled: Story = {
283
369
  },
284
370
  };
285
371
 
286
- /**
287
- * Accessibility guidance for textarea labelling, keyboard operability, and contrast.
288
- */
289
- export const Accessibility: Story = {
290
- render: () => ({
291
- components: { UiTextarea },
292
- template: `
293
- <section class="flex flex-col gap-6 p-4">
294
- <div>
295
- <h2 class="heading-m font-bold text-content-on-surface-primary">
296
- Accessibility
297
- </h2>
298
- </div>
299
-
300
- <div class="flex flex-col gap-6">
301
- <div class="flex flex-col gap-2">
302
- <h3 class="body-m-medium text-content-on-surface-primary">
303
- Enable accessibility theme
304
- </h3>
305
- <p class="body-m-regular text-content-on-surface-primary">
306
- When accessibility is required, enable our accessibility theme. This
307
- increases contrast and ensures there are no color contrast issues.
308
- </p>
309
- </div>
310
- </div>
311
-
312
- <div class="grid gap-4 md:grid-cols-2">
313
- <div class="flex flex-col gap-3">
314
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
315
- Default
316
- </h3>
317
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
318
- <UiTextarea name="a11y-default" placeholder="Placeholder" class="max-w-xs" />
319
- </div>
320
- </div>
321
-
322
- <div class="accessible-theme flex flex-col gap-3">
323
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
324
- Accessible
325
- </h3>
326
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
327
- <UiTextarea name="a11y-accessible" placeholder="Placeholder" class="max-w-xs" />
328
- </div>
329
- </div>
330
- </div>
331
- </section>
332
- `,
333
- }),
334
- tags: ['!autodocs'],
335
- parameters: {
336
- a11y: { test: 'off' },
337
- chromatic: {
338
- disableSnapshot: true,
339
- },
340
- docs: {
341
- canvas: {
342
- sourceState: 'none',
343
- },
344
- },
345
- },
346
- };
347
-
348
372
  /**
349
373
  * `UiTextarea` is fully keyboard operable: it focuses with `Tab`, shows the
350
374
  * library focus ring, and uses `border/input/error` when invalid. Hidden
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29211:259'
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 Toggle component is a button that stays pressed. It holds a state rather than firing an action, so the user can see at a glance whether the option is on.
10
+
11
+ Use it for options applied immediately in place — bold in an editor, a view mode, a filter that is on or off. Switch is for settings, and Checkbox for a choice submitted with a form.
12
+
13
+ ### Pressed has to look pressed
14
+
15
+ A toggle is useless if its state is ambiguous:
16
+
17
+ - Active differs from hover by more than a shade
18
+ - Active soft is a quieter on-state, not a second meaning
19
+ - The label or icon stays the same whichever way the toggle is set
20
+ - Outline recedes and default carries weight — one variant per group
21
+
22
+ ### One option per toggle
23
+
24
+ A toggle answers a single yes-or-no:
25
+
26
+ 1. The label or icon names the option, not the state
27
+ 2. A number shows a count where the option has one
28
+ 3. Size follows the density of the row it sits in
29
+ 4. Related toggles belong in a Toggle Group
30
+
31
+ ### Consistency
32
+
33
+ Every toggle is built from the same parts:
34
+
35
+ - Toggle, default or outline
36
+ - Sizes: sm, default and lg
37
+ - States: default, hover, focus, active, active soft and disabled
38
+ - Optional leading and trailing icon, and an optional number
39
+ - One variant and one size per group of toggles
40
+
41
+ ## Do
42
+
43
+ - Make the active state clearly different from hover, not just a shade darker
44
+ - Keep the label and icon the same whichever way the toggle is set
45
+ - Use one variant and one size within a group
46
+ - Give icon-only toggles a tooltip
47
+ - Show a count with the number where the option has one
48
+ - Use a Toggle Group when the toggles are related
49
+
50
+ ## Don't
51
+
52
+ - Use a toggle for an action that fires and finishes — use a button
53
+ - Change the label depending on the state
54
+ - Rely on fill colour alone to show the active state
55
+ - Mix default and outline variants in one group
56
+ - Use active soft to mean something different from active
57
+ - Use icon-only toggles with no tooltip
58
+
59
+ ## Accessibility
60
+
61
+ - Active and inactive differ in fill and border together, so the state survives without colour
62
+ - Focus is visible on the toggle and distinguishable from both hover and active
63
+ - Active soft stays distinguishable from inactive, not just a faint tint
64
+ - Icon-only toggles carry a tooltip, so the option can be read
65
+ - The toggle is a comfortable target at the sm size as well as the default
66
+ - Disabled toggles are distinguishable by more than reduced opacity