@aleph-alpha/ui-library 6.3.3 → 6.4.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 (105) hide show
  1. package/config.js +2 -1
  2. package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
  3. package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
  4. package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
  5. package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
  6. package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
  7. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
  8. package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
  9. package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
  10. package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
  11. package/dist/system/components/UiStepper/context.d.ts +8 -0
  12. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
  13. package/dist/system/components/UiToggle/types.d.ts +10 -2
  14. package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
  15. package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
  16. package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
  17. package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
  18. package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
  19. package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
  20. package/dist/system/components/core/toggle/index.d.ts +47 -2
  21. package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
  22. package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
  23. package/dist/system/components/core/toggle-group/context.d.ts +1 -0
  24. package/dist/system/components/core/toggle-group/index.d.ts +10 -2
  25. package/dist/system/icons/story-sidebar-icons.json +7 -0
  26. package/dist/system/lib.js +14114 -13755
  27. package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
  28. package/dist/system/patterns/UiLayout/layout-shell.d.ts +379 -8
  29. package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
  30. package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +232 -0
  31. package/dist/system/story-sidebar-icons.json +7 -0
  32. package/package.json +2 -2
  33. package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
  34. package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
  35. package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
  36. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
  37. package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
  38. package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
  39. package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
  40. package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
  41. package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
  42. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
  43. package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
  44. package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
  45. package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
  46. package/src/components/UiDropdownMenu/types.ts +3 -0
  47. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
  49. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
  50. package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
  51. package/src/components/UiFileUploadBox/types.ts +8 -5
  52. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
  53. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
  54. package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
  55. package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
  56. package/src/components/UiSnackbar/UiSnackbar.stories.ts +1089 -4
  57. package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
  58. package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
  59. package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
  60. package/src/components/UiStepper/UiStepper.stories.ts +566 -2
  61. package/src/components/UiStepper/UiStepper.vue +14 -1
  62. package/src/components/UiStepper/UiStepperItem.vue +22 -4
  63. package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
  64. package/src/components/UiStepper/context.ts +10 -0
  65. package/src/components/UiToggle/UiToggle.stories.ts +386 -261
  66. package/src/components/UiToggle/UiToggle.vue +2 -0
  67. package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
  68. package/src/components/UiToggle/types.ts +10 -2
  69. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
  70. package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
  71. package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
  72. package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
  73. package/src/components/UiToggleGroup/types.ts +12 -2
  74. package/src/components/core/calendar/Calendar.vue +234 -2
  75. package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
  76. package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
  77. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  78. package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
  79. package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
  80. package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
  81. package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
  82. package/src/components/core/toggle/Toggle.vue +12 -5
  83. package/src/components/core/toggle/index.ts +47 -19
  84. package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
  85. package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
  86. package/src/components/core/toggle-group/context.ts +1 -0
  87. package/src/components/core/toggle-group/index.ts +10 -24
  88. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
  89. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
  90. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
  91. package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
  92. package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
  93. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
  94. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
  95. package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
  96. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
  97. package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
  98. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
  99. package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
  100. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
  101. package/src/patterns/UiLayout/layout-shell.ts +159 -13
  102. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
  103. package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
  104. package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
  105. package/src/patterns/UiTopBar/accessory-dropdown.ts +99 -0
@@ -15,6 +15,14 @@ import {
15
15
  profileCardState,
16
16
  } from '../UiProfileCard/profile-card';
17
17
  import { UiSidebarTrigger } from '../UiSidebar';
18
+ import {
19
+ ACCESSORY_DROPDOWN,
20
+ ACCESSORY_DROPDOWN_COMPONENTS,
21
+ ACCESSORY_DROPDOWN_ITEMS,
22
+ ACCESSORY_TRIGGER_NAME,
23
+ accessoryDropdownSource,
24
+ accessoryDropdownState,
25
+ } from './accessory-dropdown';
18
26
 
19
27
  /*
20
28
  * The bar itself ships no controls — these are the pieces of the reference
@@ -89,6 +97,8 @@ const SIDEBAR_TOGGLE = `
89
97
 
90
98
  /** The desktop layout switch: a single-select pill toolbar. */
91
99
  const LAYOUT_ACTIONS = `
100
+ <div class="flex items-center gap-4">
101
+ ${ACCESSORY_DROPDOWN}
92
102
  <UiFloatActionItems v-model="layout" aria-label="Layout actions">
93
103
  <UiTooltip content="Focus layout" side="bottom">
94
104
  <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
@@ -101,6 +111,7 @@ const LAYOUT_ACTIONS = `
101
111
  </UiFloatActionItems>
102
112
  </UiTooltip>
103
113
  </UiFloatActionItems>
114
+ </div>
104
115
  `;
105
116
 
106
117
  /*
@@ -152,12 +163,18 @@ function desktopSetup() {
152
163
  // Stands in for the sidebar's `open` state, which a product binds to the
153
164
  // sidebar the bar sits above.
154
165
  const sidebarOpen = ref(true);
155
- return { layout, sidebarOpen, ...profileCardState() };
166
+ return {
167
+ layout,
168
+ sidebarOpen,
169
+ ...profileCardState(),
170
+ ...accessoryDropdownState(),
171
+ };
156
172
  }
157
173
 
158
174
  /** The parts of the reference design, the profile card's own included. */
159
175
  const DESKTOP_COMPONENTS = {
160
176
  ...PROFILE_CARD_COMPONENTS,
177
+ ...ACCESSORY_DROPDOWN_COMPONENTS,
161
178
  UiTopBar,
162
179
  UiFloatActionItems,
163
180
  UiAvatar,
@@ -232,7 +249,7 @@ function renderSlotVisibility(args: UiTopBarProps = {}) {
232
249
  <div class="flex flex-wrap items-center gap-x-6 gap-y-1">
233
250
  ${switchRow('top-bar-show-logo', 'showLogo', 'Show logo')}
234
251
  ${switchRow('top-bar-show-sidebar-action', 'showSidebarToggle', 'Show sidebar action')}
235
- ${switchRow('top-bar-show-layout-switch', 'showLayoutActions', 'Show layout switch')}
252
+ ${switchRow('top-bar-show-layout-switch', 'showLayoutActions', 'Show layout actions')}
236
253
  ${switchRow('top-bar-show-profile', 'showProfile', 'Show profile')}
237
254
  </div>
238
255
  </div>
@@ -276,37 +293,34 @@ const desktopTemplateSource = `<template>
276
293
  <AppWordmark />
277
294
  </template>
278
295
 
279
- <!-- Bind this to the same ref the sidebar's v-model:open is bound to. -->
280
- <template #sidebar-toggle>
281
- <UiSidebarTrigger
282
- v-model:open="sidebarOpen"
283
- tooltip="Toggle sidebar"
284
- tooltip-side="bottom"
285
- />
286
- </template>
287
-
288
- <template #layout-actions>
289
- <UiFloatActionItems v-model="layout" aria-label="Layout actions">
290
- <UiTooltip content="Focus layout" side="bottom">
291
- <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
292
- <UiIcon name="scan" size="s" />
293
- </UiFloatActionItems>
294
- </UiTooltip>
296
+ <!-- Bind this to the same ref the sidebar's v-model:open is bound to. -->
297
+ <template #sidebar-toggle>
298
+ <UiSidebarTrigger
299
+ v-model:open="sidebarOpen"
300
+ tooltip="Toggle sidebar"
301
+ tooltip-side="bottom"
302
+ />
295
303
  </template>
296
304
 
305
+ <!-- The region takes however many controls the design calls for; the
306
+ accessibility menu leads the layout switch here. -->
297
307
  <template #layout-actions>
298
- <UiFloatActionItems v-model="layout" aria-label="Layout actions">
299
- <UiTooltip content="Focus layout" side="bottom">
300
- <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
301
- <UiIcon name="scan" size="s" />
302
- </UiFloatActionItems>
303
- </UiTooltip>
304
- <UiTooltip content="Split layout" side="bottom">
305
- <UiFloatActionItems type="button" value="split" aria-label="Split layout">
306
- <UiIcon name="panel-right" size="s" />
307
- </UiFloatActionItems>
308
- </UiTooltip>
309
- </UiFloatActionItems>
308
+ <div class="flex items-center gap-4">
309
+ ${accessoryDropdownSource(' ')}
310
+
311
+ <UiFloatActionItems v-model="layout" aria-label="Layout actions">
312
+ <UiTooltip content="Focus layout" side="bottom">
313
+ <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
314
+ <UiIcon name="scan" size="s" />
315
+ </UiFloatActionItems>
316
+ </UiTooltip>
317
+ <UiTooltip content="Split layout" side="bottom">
318
+ <UiFloatActionItems type="button" value="split" aria-label="Split layout">
319
+ <UiIcon name="panel-right" size="s" />
320
+ </UiFloatActionItems>
321
+ </UiTooltip>
322
+ </UiFloatActionItems>
323
+ </div>
310
324
  </template>
311
325
 
312
326
  <!-- The avatar and the card it opens are Patterns/UiProfileCard. -->
@@ -387,6 +401,9 @@ export const Desktop: Story = {
387
401
  await expect(
388
402
  canvas.getByRole('button', { name: 'Focus layout' }),
389
403
  ).toHaveAttribute('aria-pressed', 'true');
404
+ await expect(
405
+ canvas.getByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
406
+ ).toHaveAttribute('aria-expanded', 'false');
390
407
  },
391
408
  );
392
409
  },
@@ -557,7 +574,7 @@ export const SlotVisibility: Story = {
557
574
  for (const name of [
558
575
  'Show logo',
559
576
  'Show sidebar action',
560
- 'Show layout switch',
577
+ 'Show layout actions',
561
578
  'Show profile',
562
579
  ]) {
563
580
  await expect(canvas.getByRole('switch', { name })).toBeChecked();
@@ -573,6 +590,10 @@ export const SlotVisibility: Story = {
573
590
  await expect(
574
591
  canvas.getByRole('toolbar', { name: 'Layout actions' }),
575
592
  ).toBeVisible();
593
+ // The region holds both controls the design puts there.
594
+ await expect(
595
+ canvas.getByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
596
+ ).toBeVisible();
576
597
  await expect(
577
598
  canvas.getByRole('button', { name: 'Open profile menu' }),
578
599
  ).toBeVisible();
@@ -607,6 +628,8 @@ export const Accessibility: Story = {
607
628
  <li>The bar ships no controls, so naming them is on you: every icon-only control you pass in needs an <code class="label-14-regular">aria-label</code>.</li>
608
629
  <li>A control that toggles something (a menu button, the sidebar trigger) must carry <code class="label-14-regular">aria-expanded</code>, so a swapped icon is never the only signal.</li>
609
630
  <li>Use <code class="label-14-regular">aria-pressed</code> on a layout switch so the selection is not conveyed by colour alone.</li>
631
+ <li>A labelled control that opens a menu — the accessibility toggle below — needs both <code class="label-14-regular">aria-haspopup</code> and <code class="label-14-regular">aria-expanded</code>, so a chevron that flips direction is never the only sign the menu is open (WCAG 1.4.1).</li>
632
+ <li>The <code class="label-14-regular">layout-actions</code> region takes as many controls as the design calls for, and each is its own Tab stop in the order you write them. Mind that order: it is what a keyboard user walks through.</li>
610
633
  <li>Focus order follows DOM order: leading gutter, then trailing actions, then profile. Keep that order in the default slot too.</li>
611
634
  <li>Mobile controls need a 24px minimum target; the reference pills are 40px.</li>
612
635
  <li>Wrap each icon-only action in <code class="label-14-regular">UiTooltip</code> on a focusable trigger, so the tip is reachable by keyboard and not only by hover. A tooltip supplements the accessible name, it never replaces it.</li>
@@ -708,11 +731,14 @@ export const KeyboardFocusOrder: Story = {
708
731
  },
709
732
  play: async ({ canvasElement, step }) => {
710
733
  // Scenario (UiTopBar): a keyboard user Tabs across the bar. Focus follows the
711
- // visual left-to-right order — gutter toggle, layout switch, profile — and
712
- // the switch consumes a single Tab stop with Arrow keys moving between its
713
- // modes.
734
+ // visual left-to-right order — gutter toggle, accessibility menu, layout
735
+ // switch, profile — and the switch consumes a single Tab stop with Arrow
736
+ // keys moving between its modes.
714
737
  const canvas = within(canvasElement);
715
738
  const toggle = canvas.getByRole('button', { name: 'Toggle sidebar' });
739
+ const accessory = canvas.getByRole('button', {
740
+ name: ACCESSORY_TRIGGER_NAME,
741
+ });
716
742
  const focusAction = canvas.getByRole('button', { name: 'Focus layout' });
717
743
  const splitAction = canvas.getByRole('button', { name: 'Split layout' });
718
744
  const profile = canvas.getByRole('button', { name: 'Open profile menu' });
@@ -725,6 +751,14 @@ export const KeyboardFocusOrder: Story = {
725
751
  },
726
752
  );
727
753
 
754
+ await step(
755
+ 'keyboard: the next Tab stop is the accessibility menu, ahead of the switch it precedes (WCAG 2.4.3)',
756
+ async () => {
757
+ await userEvent.tab();
758
+ await expect(accessory).toHaveFocus();
759
+ },
760
+ );
761
+
728
762
  await step(
729
763
  'keyboard: the layout switch is one Tab stop with Arrow-key movement (WCAG 2.1.1)',
730
764
  async () => {
@@ -763,6 +797,136 @@ export const KeyboardFocusOrder: Story = {
763
797
  },
764
798
  };
765
799
 
800
+ /**
801
+ * The accessibility menu in the layout-actions region: the toggle that opens it,
802
+ * the state it reports, and the items it lists. Hidden test-only story.
803
+ */
804
+ export const AccessibilityMenu: Story = {
805
+ name: 'test - Accessibility menu',
806
+ tags: ['!dev', '!autodocs'],
807
+ render: () => ({
808
+ components: DESKTOP_COMPONENTS,
809
+ setup: desktopSetup,
810
+ template: `
811
+ <UiTopBar>
812
+ <template #logo>${LOGO}</template>
813
+ <template #sidebar-toggle>${SIDEBAR_TOGGLE}</template>
814
+ <template #layout-actions>${LAYOUT_ACTIONS}</template>
815
+ <template #profile>${PROFILE}</template>
816
+ </UiTopBar>
817
+ `,
818
+ }),
819
+ parameters: {
820
+ // The play opens the menu, which is portalled over the bar.
821
+ chromatic: { disableSnapshot: true },
822
+ },
823
+ play: async ({ canvasElement, step }) => {
824
+ // Scenario (UiTopBar): the accessibility toggle in the layout-actions region
825
+ // opens a menu of two links. The toggle carries the menu's state, so the
826
+ // chevron is never the only signal that it is open, and Escape closes the
827
+ // menu and hands the bar back.
828
+ const canvas = within(canvasElement);
829
+ const body = within(document.body);
830
+ const accessory = canvas.getByRole('button', {
831
+ name: ACCESSORY_TRIGGER_NAME,
832
+ });
833
+
834
+ await step(
835
+ 'screen-reader: the toggle announces the menu it owns, closed and unpressed (WCAG 4.1.2)',
836
+ async () => {
837
+ await expect(accessory).toHaveAccessibleName(ACCESSORY_TRIGGER_NAME);
838
+ await expect(accessory).toHaveAttribute('aria-haspopup', 'menu');
839
+ await expect(accessory).toHaveAttribute('aria-expanded', 'false');
840
+ await expect(accessory).toHaveAttribute('aria-pressed', 'false');
841
+ },
842
+ );
843
+
844
+ await step(
845
+ 'interaction: the toggle opens the menu and its items',
846
+ async () => {
847
+ await userEvent.click(accessory);
848
+
849
+ const menu = await body.findByRole('menu');
850
+ await waitFor(async () => {
851
+ await expect(menu).toBeVisible();
852
+ });
853
+ for (const item of ACCESSORY_DROPDOWN_ITEMS) {
854
+ await expect(
855
+ body.getByRole('menuitem', { name: item }),
856
+ ).toBeVisible();
857
+ }
858
+ },
859
+ );
860
+
861
+ await step(
862
+ 'screen-reader: the open menu is reported on the toggle, not left to the chevron (WCAG 1.4.1 / 4.1.2)',
863
+ async () => {
864
+ await expect(accessory).toHaveAttribute('aria-expanded', 'true');
865
+ await expect(accessory).toHaveAttribute('aria-pressed', 'true');
866
+ },
867
+ );
868
+
869
+ await step(
870
+ 'keyboard: Arrow keys move through the items (WCAG 2.1.1)',
871
+ async () => {
872
+ const [first, second] = ACCESSORY_DROPDOWN_ITEMS;
873
+
874
+ // A pointer leaves focus on the menu itself rather than on a row, so
875
+ // the first Arrow is what steps into the list.
876
+ await userEvent.keyboard('{ArrowDown}');
877
+ await waitFor(async () => {
878
+ await expect(
879
+ body.getByRole('menuitem', { name: first }),
880
+ ).toHaveFocus();
881
+ });
882
+
883
+ await userEvent.keyboard('{ArrowDown}');
884
+ await expect(
885
+ body.getByRole('menuitem', { name: second }),
886
+ ).toHaveFocus();
887
+ },
888
+ );
889
+
890
+ await step(
891
+ 'keyboard: Escape closes the menu and hands focus back to the toggle (WCAG 2.1.2)',
892
+ async () => {
893
+ await userEvent.keyboard('{Escape}');
894
+
895
+ await waitFor(async () => {
896
+ await expect(body.queryByRole('menu')).toBeNull();
897
+ });
898
+ // Reka hands focus back on the next tick, once the closing animation
899
+ // has been kicked off.
900
+ await waitFor(async () => {
901
+ await expect(accessory).toHaveFocus();
902
+ });
903
+ await expect(accessory).toHaveAttribute('aria-expanded', 'false');
904
+ await expect(accessory).toHaveAttribute('aria-pressed', 'false');
905
+ },
906
+ );
907
+
908
+ await step(
909
+ 'keyboard: Enter reopens it, so the pointer is not the only way in (WCAG 2.1.1)',
910
+ async () => {
911
+ accessory.focus();
912
+ await userEvent.keyboard('{Enter}');
913
+
914
+ await waitFor(async () => {
915
+ await expect(await body.findByRole('menu')).toBeVisible();
916
+ });
917
+ await expect(accessory).toHaveAttribute('aria-expanded', 'true');
918
+
919
+ // The open menu hides the rest of the page from assistive tech, so it
920
+ // is closed again before the axe audit runs on the story.
921
+ await userEvent.keyboard('{Escape}');
922
+ await waitFor(async () => {
923
+ await expect(body.queryByRole('menu')).toBeNull();
924
+ });
925
+ },
926
+ );
927
+ },
928
+ };
929
+
766
930
  /**
767
931
  * The profile slot opening the card it is composed from. Hidden test-only
768
932
  * story.
@@ -922,12 +1086,16 @@ export const SlotVisibilityToggles: Story = {
922
1086
  ).toBeNull(),
923
1087
  );
924
1088
 
925
- await toggle('Show layout switch');
1089
+ // One switch, one slot: the region's two controls go together.
1090
+ await toggle('Show layout actions');
926
1091
  await waitFor(() =>
927
1092
  expect(
928
1093
  canvas.queryByRole('toolbar', { name: 'Layout actions' }),
929
1094
  ).toBeNull(),
930
1095
  );
1096
+ await expect(
1097
+ canvas.queryByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
1098
+ ).toBeNull();
931
1099
 
932
1100
  await toggle('Show profile');
933
1101
  await waitFor(() =>
@@ -1012,9 +1180,14 @@ export const ZoomMagnification: Story = {
1012
1180
  },
1013
1181
  play: async ({ canvasElement, step }) => {
1014
1182
  // Scenario (UiTopBar): at 200% page zoom the bar keeps its landmark, the logo
1015
- // and composed actions stay visible, and the layout switch stays operable.
1183
+ // and composed actions stay visible, and both the layout switch and the
1184
+ // accessibility menu stay operable.
1016
1185
  const canvas = within(canvasElement);
1186
+ const body = within(document.body);
1017
1187
  const splitAction = canvas.getByRole('button', { name: 'Split layout' });
1188
+ const accessory = canvas.getByRole('button', {
1189
+ name: ACCESSORY_TRIGGER_NAME,
1190
+ });
1018
1191
 
1019
1192
  await step(
1020
1193
  'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
@@ -1031,6 +1204,7 @@ export const ZoomMagnification: Story = {
1031
1204
  await expect(
1032
1205
  canvas.getByRole('toolbar', { name: 'Layout actions' }),
1033
1206
  ).toBeVisible();
1207
+ await expect(accessory).toBeVisible();
1034
1208
  },
1035
1209
  );
1036
1210
 
@@ -1038,6 +1212,28 @@ export const ZoomMagnification: Story = {
1038
1212
  await userEvent.click(splitAction);
1039
1213
  await expect(splitAction).toHaveAttribute('aria-pressed', 'true');
1040
1214
  });
1215
+
1216
+ await step(
1217
+ 'zoom: the accessibility menu still opens, and over the bar rather than off-screen',
1218
+ async () => {
1219
+ await userEvent.click(accessory);
1220
+
1221
+ const menu = await body.findByRole('menu');
1222
+ await waitFor(async () => {
1223
+ await expect(menu).toBeVisible();
1224
+ });
1225
+ await expect(menu.getBoundingClientRect().left).toBeGreaterThanOrEqual(
1226
+ 0,
1227
+ );
1228
+
1229
+ // The open menu hides the rest of the page from assistive tech, so it
1230
+ // is closed again before the axe audit runs on the story.
1231
+ await userEvent.keyboard('{Escape}');
1232
+ await waitFor(async () => {
1233
+ await expect(body.queryByRole('menu')).toBeNull();
1234
+ });
1235
+ },
1236
+ );
1041
1237
  },
1042
1238
  };
1043
1239
 
@@ -1115,6 +1311,19 @@ export const MobileBreakpoint: Story = {
1115
1311
  }
1116
1312
  },
1117
1313
  );
1314
+
1315
+ await step(
1316
+ 'mobile: the accessibility menu is deliberately not in the bar at 320px (WCAG 1.4.10)',
1317
+ async () => {
1318
+ // The desktop layout-actions region does not survive the mode switch,
1319
+ // so the two controls above are the whole bar. On a phone the menu
1320
+ // belongs to the navigation the menu button opens, not to the 320px bar,
1321
+ // which has no room for a labelled control beside the brand pill.
1322
+ await expect(
1323
+ canvas.queryByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
1324
+ ).toBeNull();
1325
+ },
1326
+ );
1118
1327
  },
1119
1328
  };
1120
1329
 
@@ -106,8 +106,10 @@ const sidebarToggleSlot = computed(() => slotName('sidebar-toggle'));
106
106
  const layoutActionsSlot = computed(() => slotName('layout-actions'));
107
107
  const profileSlot = computed(() => slotName('profile'));
108
108
 
109
- /** `py-2.5` is the scale step for the specified 10px padding; the 14px
110
- * horizontal padding has no scale step, so it is written out. */
109
+ /**
110
+ * `py-2.5` is the scale step for the specified 10px padding; the 14px
111
+ * horizontal padding has no scale step, so it is written out.
112
+ */
111
113
  const rootClass = computed(() =>
112
114
  cn(
113
115
  'flex w-full items-center gap-4 px-[0.875rem] py-2.5',
@@ -0,0 +1,99 @@
1
+ import { ref } from 'vue';
2
+ import {
3
+ UiDropdownMenu,
4
+ UiDropdownMenuContent,
5
+ UiDropdownMenuItem,
6
+ UiDropdownMenuTrigger,
7
+ } from '../../components/UiDropdownMenu';
8
+ import { UiIcon } from '../../components/UiIcon';
9
+ import { UiToggle } from '../../components/UiToggle';
10
+
11
+ /*
12
+ * The accessibility menu of the reference design. It lives here rather than in
13
+ * the stories, so the shells that put it in their bar open the very menu the
14
+ * top bar documents instead of a copy of it.
15
+ */
16
+
17
+ /** Every part the menu is built from. */
18
+ export const ACCESSORY_DROPDOWN_COMPONENTS = {
19
+ UiDropdownMenu,
20
+ UiDropdownMenuContent,
21
+ UiDropdownMenuItem,
22
+ UiDropdownMenuTrigger,
23
+ UiIcon,
24
+ UiToggle,
25
+ };
26
+
27
+ /**
28
+ * The trigger's accessible name. Exported so the plays query the control by the
29
+ * same name the template gives it.
30
+ */
31
+ export const ACCESSORY_TRIGGER_NAME = 'Accessibility';
32
+
33
+ /** What the menu offers, in the order it lists them. */
34
+ export const ACCESSORY_DROPDOWN_ITEMS = [
35
+ 'Report Accessibility Issue',
36
+ 'Accessibility Statement',
37
+ ];
38
+
39
+ /**
40
+ * The menu's own open state. It is named apart from `open`, which the shells
41
+ * already bind to the sidebar.
42
+ * @returns Setup bindings for {@link ACCESSORY_DROPDOWN}.
43
+ */
44
+ export function accessoryDropdownState() {
45
+ return { accessoryOpen: ref(false) };
46
+ }
47
+
48
+ /**
49
+ * The accessibility toggle and the menu it opens. The trigger is a `UiToggle`
50
+ * bound to the same state as the menu, so the pressed look and the menu never
51
+ * disagree, and the chevron is a second signal rather than the only one. It is
52
+ * `soft`, the fill meant for menu triggers: while the menu is open the trigger
53
+ * reads as lit up rather than as a second filled button beside it.
54
+ */
55
+ export const ACCESSORY_DROPDOWN = `
56
+ <UiDropdownMenu v-model:open="accessoryOpen">
57
+ <UiDropdownMenuTrigger as-child>
58
+ <UiToggle v-model="accessoryOpen" soft aria-label="${ACCESSORY_TRIGGER_NAME}">
59
+ <UiIcon size="s" name="PersonStanding" />
60
+ ${ACCESSORY_TRIGGER_NAME}
61
+ <UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />
62
+ </UiToggle>
63
+ </UiDropdownMenuTrigger>
64
+ <UiDropdownMenuContent>
65
+ ${ACCESSORY_DROPDOWN_ITEMS.map(
66
+ (item) => `<UiDropdownMenuItem>${item}</UiDropdownMenuItem>`,
67
+ ).join('\n ')}
68
+ </UiDropdownMenuContent>
69
+ </UiDropdownMenu>`;
70
+
71
+ /** The menu as a product would write it, unindented. */
72
+ const SOURCE_LINES = [
73
+ `<UiDropdownMenu v-model:open="accessoryOpen">`,
74
+ ` <UiDropdownMenuTrigger as-child>`,
75
+ ` <UiToggle v-model="accessoryOpen" soft aria-label="${ACCESSORY_TRIGGER_NAME}">`,
76
+ ` <UiIcon size="s" name="PersonStanding" />`,
77
+ ` ${ACCESSORY_TRIGGER_NAME}`,
78
+ ` <UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />`,
79
+ ` </UiToggle>`,
80
+ ` </UiDropdownMenuTrigger>`,
81
+ ` <UiDropdownMenuContent>`,
82
+ ...ACCESSORY_DROPDOWN_ITEMS.map(
83
+ (item) => ` <UiDropdownMenuItem>${item}</UiDropdownMenuItem>`,
84
+ ),
85
+ ` </UiDropdownMenuContent>`,
86
+ `</UiDropdownMenu>`,
87
+ ];
88
+
89
+ /**
90
+ * The menu as a product would write it, for the docs source panels. The first
91
+ * line is left bare so it can be interpolated after an indent already in place.
92
+ * @param indent Indentation to put in front of every line but the first.
93
+ * @returns The markup, ready to drop into a template source string.
94
+ */
95
+ export function accessoryDropdownSource(indent: string): string {
96
+ return SOURCE_LINES.map((line, index) =>
97
+ index === 0 ? line : `${indent}${line}`,
98
+ ).join('\n');
99
+ }