@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
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, fn, userEvent, within } from 'storybook/test';
2
3
  import * as lucideIcons from '@/icons/lucide';
3
4
  import { computed, ref, watch, type Component, type Ref } from 'vue';
4
5
  import { UiIcon } from '.';
@@ -131,7 +132,8 @@ export const Default: Story = {
131
132
  render: (args) => ({
132
133
  components: { UiIcon },
133
134
  setup() {
134
- return { args };
135
+ const { ChevronDownIcon, CheckIcon } = lucideIcons;
136
+ return { args, ChevronDownIcon, CheckIcon };
135
137
  },
136
138
  template: `
137
139
  <div class="flex items-center gap-4">
@@ -144,6 +146,22 @@ export const Default: Story = {
144
146
  parameters: {
145
147
  docs: { source: { code: defaultTemplateSource } },
146
148
  },
149
+ play: async ({ canvasElement, step }) => {
150
+ // Scenario (UiIcon): each icon renders as an SVG, and a labelled icon is
151
+ // exposed as a named image.
152
+ const canvas = within(canvasElement);
153
+
154
+ await step('interaction: every icon renders an SVG', async () => {
155
+ const icons = canvasElement.querySelectorAll('svg[data-slot="icon"]');
156
+ await expect(icons).toHaveLength(3);
157
+ });
158
+
159
+ await step('interaction: a labelled icon is a named image', async () => {
160
+ for (const name of ['Help', 'Down', 'Check']) {
161
+ await expect(canvas.getByRole('img', { name })).toBeVisible();
162
+ }
163
+ });
164
+ },
147
165
  };
148
166
 
149
167
  const sizesTemplateSource = `<script setup lang="ts">
@@ -166,6 +184,9 @@ import { StarIcon } from '@aleph-alpha/ui-library/icons'
166
184
  export const Sizes: Story = {
167
185
  render: () => ({
168
186
  components: { UiIcon },
187
+ setup() {
188
+ return { StarIcon: lucideIcons.StarIcon };
189
+ },
169
190
  template: `
170
191
  <div class="flex items-center gap-4">
171
192
  <UiIcon :name="StarIcon" :size="16" />
@@ -502,3 +523,237 @@ import { CryptoBtc, CryptoEth } from '@aleph-alpha/ui-library/icons'
502
523
  </div>
503
524
  </template>`,
504
525
  );
526
+
527
+ const onOpenSettings = fn();
528
+
529
+ // The three ways an icon shows up: meaningful on its own (labelled), next to
530
+ // text (decorative), and as the only content of a button (button is named).
531
+ const renderTestIcons = () => ({
532
+ components: { UiIcon, UiButton },
533
+ setup() {
534
+ const { CheckIcon, CircleAlertIcon, SettingsIcon } = lucideIcons;
535
+ return { CheckIcon, CircleAlertIcon, SettingsIcon, onOpenSettings };
536
+ },
537
+ template: `
538
+ <div class="flex flex-wrap items-center gap-4">
539
+ <UiIcon :name="CircleAlertIcon" aria-label="Warning" />
540
+ <span class="body-s-medium inline-flex items-center gap-2">
541
+ <UiIcon :name="CheckIcon" size="s" />
542
+ Saved
543
+ </span>
544
+ <UiButton size="icon" variant="outline" aria-label="Open settings" @click="onOpenSettings">
545
+ <UiIcon :name="SettingsIcon" size="m" />
546
+ </UiButton>
547
+ </div>
548
+ `,
549
+ });
550
+
551
+ /**
552
+ * Icons never take focus themselves; an icon-only button is reached and
553
+ * activated with the keyboard (WCAG 2.1.1). Hidden test-only story.
554
+ */
555
+ export const KeyboardNavigation: Story = {
556
+ name: 'test - Keyboard Navigation',
557
+ tags: ['!dev', '!autodocs'],
558
+ parameters: {
559
+ controls: { disable: true },
560
+ // Focus moves during the play function.
561
+ chromatic: { disableSnapshot: true },
562
+ docs: {
563
+ description: {
564
+ story:
565
+ 'Press `Tab`: focus skips the icons and lands on the settings button; `Enter` activates it.',
566
+ },
567
+ },
568
+ },
569
+ render: renderTestIcons,
570
+ play: async ({ canvasElement, step }) => {
571
+ // Scenario (UiIcon): a keyboard user tabs past the icons straight to the
572
+ // icon-only button and activates it.
573
+ onOpenSettings.mockClear();
574
+ const canvas = within(canvasElement);
575
+ const button = canvas.getByRole('button', { name: 'Open settings' });
576
+
577
+ await step('keyboard: icons are not focusable', async () => {
578
+ for (const icon of canvasElement.querySelectorAll('svg')) {
579
+ await expect(icon).not.toHaveAttribute('tabindex');
580
+ }
581
+ });
582
+
583
+ await step(
584
+ 'keyboard: Tab skips the icons and reaches the icon-only button',
585
+ async () => {
586
+ await userEvent.tab();
587
+ await expect(button).toHaveFocus();
588
+ },
589
+ );
590
+
591
+ await step('keyboard: Enter activates the icon-only button', async () => {
592
+ await userEvent.keyboard('{Enter}');
593
+ await expect(onOpenSettings).toHaveBeenCalledTimes(1);
594
+ });
595
+ },
596
+ };
597
+
598
+ /**
599
+ * What assistive technology reads: a labelled icon is a named image, a
600
+ * decorative icon is hidden, and an icon-only button is named by its own
601
+ * `aria-label` (WCAG 1.1.1, 4.1.2). Hidden test-only story.
602
+ */
603
+ export const ScreenReader: Story = {
604
+ name: 'test - Screen Reader',
605
+ tags: ['!dev', '!autodocs'],
606
+ parameters: {
607
+ controls: { disable: true },
608
+ chromatic: { disableSnapshot: true },
609
+ docs: {
610
+ description: {
611
+ story:
612
+ 'Verifies which icons assistive technology announces and which it skips.',
613
+ },
614
+ },
615
+ },
616
+ render: renderTestIcons,
617
+ play: async ({ canvasElement, step }) => {
618
+ // Scenario (UiIcon): a screen-reader user hears "Warning, image", then
619
+ // "Saved" without an extra icon, then "Open settings, button".
620
+ const canvas = within(canvasElement);
621
+ const [labelled, decorative, buttonIcon] =
622
+ canvasElement.querySelectorAll('svg');
623
+
624
+ await step(
625
+ 'screen-reader: a labelled icon is announced as a named image (WCAG 1.1.1)',
626
+ async () => {
627
+ await expect(labelled).toHaveAttribute('role', 'img');
628
+ await expect(canvas.getByRole('img', { name: 'Warning' })).toBe(
629
+ labelled,
630
+ );
631
+ },
632
+ );
633
+
634
+ await step(
635
+ 'screen-reader: an icon next to text is hidden as decoration',
636
+ async () => {
637
+ await expect(decorative).toHaveAttribute('aria-hidden', 'true');
638
+ await expect(decorative).not.toHaveAttribute('role');
639
+ await expect(canvas.getAllByRole('img')).toHaveLength(1);
640
+ },
641
+ );
642
+
643
+ await step(
644
+ 'screen-reader: an icon-only button takes its name from the button (WCAG 4.1.2)',
645
+ async () => {
646
+ await expect(buttonIcon).toHaveAttribute('aria-hidden', 'true');
647
+ await expect(
648
+ canvas.getByRole('button', { name: 'Open settings' }),
649
+ ).toBeInTheDocument();
650
+ },
651
+ );
652
+ },
653
+ };
654
+
655
+ /**
656
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
657
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
658
+ */
659
+ export const ZoomMagnification: Story = {
660
+ name: 'test - Zoom Magnification',
661
+ tags: ['!dev', '!autodocs'],
662
+ globals: { zoom: '200' },
663
+ parameters: {
664
+ controls: { disable: true },
665
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
666
+ // already covers magnified snapshots, so skip this one.
667
+ chromatic: { disableSnapshot: true },
668
+ docs: {
669
+ description: {
670
+ story:
671
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
672
+ },
673
+ },
674
+ },
675
+ render: renderTestIcons,
676
+ play: async ({ canvasElement, step }) => {
677
+ // Scenario (UiIcon): at 200% page zoom the icons scale with the text and
678
+ // the icon-only button still works.
679
+ onOpenSettings.mockClear();
680
+ const canvas = within(canvasElement);
681
+
682
+ await step(
683
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
684
+ async () => {
685
+ await expect(document.documentElement.style.zoom).toBe('200%');
686
+ },
687
+ );
688
+
689
+ await step(
690
+ 'zoom: icons keep their size tokens and stay visible',
691
+ async () => {
692
+ const [labelled, decorative] = canvasElement.querySelectorAll('svg');
693
+ await expect(labelled).toHaveAttribute('width', '24');
694
+ await expect(decorative).toHaveAttribute('width', '16');
695
+ await expect(labelled).toBeVisible();
696
+ await expect(canvas.getByText('Saved')).toBeVisible();
697
+ },
698
+ );
699
+
700
+ await step('zoom: the icon-only button still works', async () => {
701
+ await userEvent.click(
702
+ canvas.getByRole('button', { name: 'Open settings' }),
703
+ );
704
+ await expect(onOpenSettings).toHaveBeenCalledTimes(1);
705
+ });
706
+ },
707
+ };
708
+
709
+ /**
710
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
711
+ * toolbar. Icons wrap with their row, and the icon-only button stays large
712
+ * enough to tap (WCAG 2.5.8). Hidden test-only story.
713
+ */
714
+ export const MobileBreakpoint: Story = {
715
+ name: 'test - Mobile Breakpoint',
716
+ tags: ['!dev', '!autodocs'],
717
+ globals: { mediaBreakpoint: 'reflow' },
718
+ parameters: {
719
+ controls: { disable: true },
720
+ // Reflow snapshots are already covered by the accessible-reflow mode.
721
+ chromatic: { disableSnapshot: true },
722
+ docs: {
723
+ description: {
724
+ story:
725
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
726
+ },
727
+ },
728
+ },
729
+ render: renderTestIcons,
730
+ play: async ({ canvasElement, step }) => {
731
+ // Scenario (UiIcon): at the 320px breakpoint the row fits the viewport and
732
+ // the icon-only button can be tapped.
733
+ onOpenSettings.mockClear();
734
+ const canvas = within(canvasElement);
735
+ const button = canvas.getByRole('button', { name: 'Open settings' });
736
+
737
+ await step(
738
+ 'mobile: the row fits the 320px viewport (WCAG 1.4.10 Reflow)',
739
+ async () => {
740
+ const { scrollWidth, clientWidth } = document.documentElement;
741
+ await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
742
+ },
743
+ );
744
+
745
+ await step(
746
+ 'mobile: the icon-only button meets the minimum target size (WCAG 2.5.8)',
747
+ async () => {
748
+ const { width, height } = button.getBoundingClientRect();
749
+ await expect(width).toBeGreaterThanOrEqual(24);
750
+ await expect(height).toBeGreaterThanOrEqual(24);
751
+ },
752
+ );
753
+
754
+ await step('mobile: the icon-only button works by tap', async () => {
755
+ await userEvent.click(button);
756
+ await expect(onOpenSettings).toHaveBeenCalledTimes(1);
757
+ });
758
+ },
759
+ };
@@ -0,0 +1,64 @@
1
+ ---
2
+ figma: '26977:2355'
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 input field is a base component for form fields. It should not be used on its own unless there is a specific need for text input without labels. Please use the field component and the documentation there.
10
+
11
+ ### A field is only half the control
12
+
13
+ An input on its own tells the user nothing:
14
+
15
+ - The label names what the value is
16
+ - The description carries format or constraint
17
+ - The placeholder shows an example, never the label
18
+ - The error explains what to change, beside the field
19
+
20
+ ### Show state as it changes
21
+
22
+ The field reports back at every step:
23
+
24
+ 1. Default, empty and waiting
25
+ 2. Focus, showing where typing will land
26
+ 3. Filled, holding a value the user can still read
27
+ 4. Error, with the reason beneath the field
28
+
29
+ ### Consistency
30
+
31
+ Every input is composed the same way:
32
+
33
+ - Input, as the typing surface
34
+ - Field, giving it label, description and error
35
+ - Input group, when a unit, action or status belongs inside the boundary
36
+ - States: default, focus, filled, disabled and error
37
+ - One width rule per form, so fields align
38
+
39
+ ## Do
40
+
41
+ - Pair every input with a visible label through Field
42
+ - Size the field to the length of the value it expects
43
+ - Use the placeholder for an example, not for the label
44
+ - Show the error beneath the field, once the user has left it
45
+ - Keep the disabled state distinguishable from the filled state
46
+ - Use Input Group when a unit or action belongs inside the boundary
47
+
48
+ ## Don't
49
+
50
+ - Use an input on its own, without a label
51
+ - Put the label inside the field as a placeholder
52
+ - Make every field the same width regardless of content
53
+ - Show an error before the user has finished typing
54
+ - Rely on the border colour alone to show an error
55
+ - Disable a field with no explanation of why
56
+
57
+ ## Accessibility
58
+
59
+ - Every input has a visible label above it; a placeholder never stands in for one
60
+ - The focus state is distinguishable from hover, filled and error
61
+ - The error state is carried by text beneath the field as well as by the border
62
+ - Placeholder text is not the only place the expected format appears
63
+ - The field is tall and wide enough to be a comfortable target on touch
64
+ - 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, within } from 'storybook/test';
3
3
  import UiInput from './UiInput.vue';
4
4
  import { UiButton } from '../UiButton';
5
+ import {
6
+ accessibilityRequirementsTemplate,
7
+ designNotesStory,
8
+ guidanceLinks,
9
+ guidanceSectionClass,
10
+ parseGuidance,
11
+ } from '../../../.storybook/guidance';
12
+ import guidanceMarkdown from './UiInput.guidance.md?raw';
13
+
14
+ const guidance = parseGuidance(guidanceMarkdown);
5
15
 
6
16
  /**
7
17
  * Text input is an interactive field that allows users to enter text and data. It’s commonly used in form patterns.
@@ -29,6 +39,9 @@ const meta: Meta<typeof UiInput> = {
29
39
  disabled: false,
30
40
  required: false,
31
41
  },
42
+ parameters: {
43
+ docs: { links: guidanceLinks(guidance) },
44
+ },
32
45
  };
33
46
 
34
47
  export default meta;
@@ -83,6 +96,79 @@ export const Default: Story = {
83
96
  },
84
97
  };
85
98
 
99
+ /**
100
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
101
+ */
102
+ export const DesignNotes: Story = {
103
+ ...designNotesStory(guidance),
104
+ tags: ['!autodocs'],
105
+ };
106
+
107
+ /**
108
+ * Accessibility guidance for input labelling, keyboard operability, and contrast.
109
+ */
110
+ export const Accessibility: Story = {
111
+ render: () => ({
112
+ components: { UiInput },
113
+ template: `
114
+ <section class="${guidanceSectionClass}">
115
+ <div>
116
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
117
+ Accessibility
118
+ </h2>
119
+ </div>
120
+
121
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
122
+
123
+ <div class="flex flex-col gap-6">
124
+ <div class="flex flex-col gap-2">
125
+ <h3 class="body-m-medium text-content-on-surface-primary">
126
+ Enable accessibility theme
127
+ </h3>
128
+ <p class="body-m-regular text-content-on-surface-primary">
129
+ When accessibility is required, enable our accessibility theme. This
130
+ increases contrast and ensures there are no color contrast issues.
131
+ </p>
132
+ </div>
133
+ </div>
134
+
135
+ <div class="grid gap-4 md:grid-cols-2">
136
+ <div class="flex flex-col gap-3">
137
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
138
+ Default
139
+ </h3>
140
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
141
+ <UiInput name="a11y-default" placeholder="Placeholder" class="max-w-xs" />
142
+ </div>
143
+ </div>
144
+
145
+ <div class="accessible-theme flex flex-col gap-3">
146
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
147
+ Accessible
148
+ </h3>
149
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
150
+ <UiInput name="a11y-accessible" placeholder="Placeholder" class="max-w-xs" />
151
+ </div>
152
+ </div>
153
+ </div>
154
+ </section>
155
+ `,
156
+ }),
157
+ tags: ['!autodocs'],
158
+ parameters: {
159
+ surface: 'primary',
160
+ a11y: { test: 'off' },
161
+ chromatic: {
162
+ disableSnapshot: true,
163
+ },
164
+ docs: {
165
+ canvas: {
166
+ sourceState: 'none',
167
+ },
168
+ },
169
+ },
170
+ };
171
+
86
172
  const withLabelTemplateSource = `<script setup lang="ts">
87
173
  import { UiInput } from '@aleph-alpha/ui-library'
88
174
  </script>
@@ -359,97 +445,63 @@ export const FileUpload: Story = {
359
445
  };
360
446
 
361
447
  /**
362
- * Design guidance for when to use the raw input vs. the field component.
448
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
449
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
363
450
  */
364
- export const DesignNotes: Story = {
451
+ export const ZoomMagnification: Story = {
452
+ name: 'test - Zoom Magnification',
453
+ tags: ['!dev', '!autodocs'],
454
+ globals: { zoom: '200' },
365
455
  render: () => ({
366
- template: `
367
- <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
368
- <div>
369
- <h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
370
- <p class="body-m-regular mt-2 text-content-on-surface-primary">
371
- The input field is a base component for form fields. It should not be
372
- used on its own unless there is a specific need for text input without
373
- labels. Please use the <strong class="font-semibold">field component</strong> and the
374
- documentation there.
375
- </p>
376
- </div>
377
- </section>
378
- `,
456
+ components: { UiInput },
457
+ setup() {
458
+ return { onUpdate };
459
+ },
460
+ template: `<div class="grid w-full max-w-sm items-center gap-1.5">
461
+ <label for="zoom-email" class="body-s-medium">Email</label>
462
+ <UiInput id="zoom-email" name="email" type="email" placeholder="Email" @update:model-value="onUpdate" />
463
+ </div>`,
379
464
  }),
380
- tags: ['!autodocs'],
381
465
  parameters: {
382
- a11y: { test: 'off' },
383
- chromatic: {
384
- disableSnapshot: true,
385
- },
466
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
467
+ // already covers magnified snapshots, so skip this one.
468
+ chromatic: { disableSnapshot: true },
386
469
  docs: {
387
- canvas: {
388
- sourceState: 'none',
470
+ description: {
471
+ story:
472
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
389
473
  },
390
474
  },
391
475
  },
392
- };
393
-
394
- /**
395
- * Accessibility guidance for input labelling, keyboard operability, and contrast.
396
- */
397
- export const Accessibility: Story = {
398
- render: () => ({
399
- components: { UiInput },
400
- template: `
401
- <section class="flex flex-col gap-6 p-4">
402
- <div>
403
- <h2 class="heading-m font-bold text-content-on-surface-primary">
404
- Accessibility
405
- </h2>
406
- </div>
407
-
408
- <div class="flex flex-col gap-6">
409
- <div class="flex flex-col gap-2">
410
- <h3 class="body-m-medium text-content-on-surface-primary">
411
- Enable accessibility theme
412
- </h3>
413
- <p class="body-m-regular text-content-on-surface-primary">
414
- When accessibility is required, enable our accessibility theme. This
415
- increases contrast and ensures there are no color contrast issues.
416
- </p>
417
- </div>
418
- </div>
476
+ play: async ({ canvasElement, step }) => {
477
+ // Scenario (UiInput): at 200% page zoom the label and input stay readable
478
+ // and associated, and the input still accepts text.
479
+ onUpdate.mockClear();
480
+ const canvas = within(canvasElement);
481
+ const input = canvas.getByRole('textbox', { name: 'Email' });
419
482
 
420
- <div class="grid gap-4 md:grid-cols-2">
421
- <div class="flex flex-col gap-3">
422
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
423
- Default
424
- </h3>
425
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
426
- <UiInput name="a11y-default" placeholder="Placeholder" class="max-w-xs" />
427
- </div>
428
- </div>
483
+ await step(
484
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
485
+ async () => {
486
+ await expect(document.documentElement.style.zoom).toBe('200%');
487
+ },
488
+ );
429
489
 
430
- <div class="accessible-theme flex flex-col gap-3">
431
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
432
- Accessible
433
- </h3>
434
- <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
435
- <UiInput name="a11y-accessible" placeholder="Placeholder" class="max-w-xs" />
436
- </div>
437
- </div>
438
- </div>
439
- </section>
440
- `,
441
- }),
442
- tags: ['!autodocs'],
443
- parameters: {
444
- a11y: { test: 'off' },
445
- chromatic: {
446
- disableSnapshot: true,
447
- },
448
- docs: {
449
- canvas: {
450
- sourceState: 'none',
490
+ await step(
491
+ 'zoom: the label and input stay visible and associated',
492
+ async () => {
493
+ await expect(canvas.getByText('Email')).toBeVisible();
494
+ await expect(input).toBeVisible();
495
+ await expect(input).toHaveAccessibleName('Email');
451
496
  },
452
- },
497
+ );
498
+
499
+ await step('zoom: typing still updates the value', async () => {
500
+ await userEvent.click(input);
501
+ await userEvent.keyboard('ada@company.com');
502
+ await expect(input).toHaveValue('ada@company.com');
503
+ await expect(onUpdate).toHaveBeenLastCalledWith('ada@company.com');
504
+ });
453
505
  },
454
506
  };
455
507
 
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29197:70718'
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 Input Group component attaches addons to an input or a textarea — a unit, an icon, a shortcut, a button, a status. Everything sits inside one boundary, so the field and its context read as a single control.
10
+
11
+ Use it when the extra element belongs to the value being typed: a currency symbol, a domain prefix, a clear action, a validation tick. When the element acts on something else, keep it outside the field.
12
+
13
+ ### The addon belongs to the value
14
+
15
+ An addon inside the boundary is a claim about the value:
16
+
17
+ - Prefixes and suffixes that are part of the value, such as a currency or a domain
18
+ - Actions on the value, such as clear, reveal or submit
19
+ - Status about the value, such as a tick or a spinner
20
+ - Never navigation, or actions belonging to the wider page
21
+
22
+ ### Place by relationship
23
+
24
+ Where an addon sits says what it does:
25
+
26
+ 1. Inline start for what precedes the value, such as a symbol or a search icon
27
+ 2. Inline end for actions on the value, and for status
28
+ 3. Block start and end for content needing its own row, such as a toolbar or a counter
29
+ 4. At most two addons per side, so the field stays readable
30
+
31
+ ### Consistency
32
+
33
+ Every input group is built from the same parts:
34
+
35
+ - Input group, wrapping an input or a textarea
36
+ - Inline addons: icon, text, keyboard shortcut, spinner, check circle, button, tooltip, dropdown
37
+ - Block addons, aligned to the start or the end
38
+ - Input group button, at xs or sm, with icon-only sizes
39
+ - States: default, focus, filled, disabled, error and error focus
40
+
41
+ ## Do
42
+
43
+ - Keep addons inside the boundary only when they belong to the value
44
+ - Put symbols and prefixes at the inline start, actions and status at the inline end
45
+ - Limit each side to two addons
46
+ - Use a block addon when the content needs a row of its own
47
+ - Let the whole group show the focus and error state together
48
+ - Match the addon button size to the field, not to the buttons around it
49
+
50
+ ## Don't
51
+
52
+ - Put page-level actions inside the field boundary
53
+ - Fill both sides with addons until the value has no room
54
+ - Show the error state on the addon but not on the field
55
+ - Use an addon where a label or help text would say it better
56
+ - Let an addon be the only explanation of the expected format
57
+ - Mix icon-only addons whose meanings are not distinguishable
58
+
59
+ ## Accessibility
60
+
61
+ - The whole group shows focus as one boundary, so it is clear the field is active
62
+ - The error state is carried by text beneath the field as well as by the boundary
63
+ - Addon buttons and icons are comfortable targets and do not shrink with the field
64
+ - Icon-only addons carry a tooltip or visible text, so their purpose is readable
65
+ - Text addons hold contrast against the addon's own fill, not just the field's
66
+ - The typing area keeps enough room that the value stays legible with addons on both sides