@aleph-alpha/ui-library 6.3.2 → 6.3.4
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.
- package/config.js +2 -0
- package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
- package/dist/system/components/UiStepper/context.d.ts +8 -0
- package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +14776 -14598
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +217 -5
- package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +227 -0
- package/dist/system/story-sidebar-icons.json +7 -0
- package/package.json +1 -1
- package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
- package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
- package/src/components/UiFileUploadBox/types.ts +8 -5
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
- package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +1017 -4
- package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
- package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
- package/src/components/UiStepper/UiStepper.stories.ts +566 -2
- package/src/components/UiStepper/UiStepper.vue +14 -1
- package/src/components/UiStepper/UiStepperItem.vue +22 -4
- package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
- package/src/components/UiStepper/context.ts +10 -0
- package/src/components/core/calendar/Calendar.vue +234 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
- package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
- package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
- package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
- package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
- package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
- package/src/patterns/UiLayout/layout-shell.ts +159 -13
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
- package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
- package/src/patterns/UiTopBar/accessory-dropdown.ts +97 -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 {
|
|
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
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
<
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
|
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,
|
|
712
|
-
// the switch consumes a single Tab stop with Arrow
|
|
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
|
-
|
|
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
|
|
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
|
-
/**
|
|
110
|
-
*
|
|
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,97 @@
|
|
|
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.
|
|
52
|
+
*/
|
|
53
|
+
export const ACCESSORY_DROPDOWN = `
|
|
54
|
+
<UiDropdownMenu v-model:open="accessoryOpen">
|
|
55
|
+
<UiDropdownMenuTrigger as-child>
|
|
56
|
+
<UiToggle v-model="accessoryOpen" aria-label="${ACCESSORY_TRIGGER_NAME}">
|
|
57
|
+
<UiIcon size="s" name="PersonStanding" />
|
|
58
|
+
${ACCESSORY_TRIGGER_NAME}
|
|
59
|
+
<UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />
|
|
60
|
+
</UiToggle>
|
|
61
|
+
</UiDropdownMenuTrigger>
|
|
62
|
+
<UiDropdownMenuContent>
|
|
63
|
+
${ACCESSORY_DROPDOWN_ITEMS.map(
|
|
64
|
+
(item) => `<UiDropdownMenuItem>${item}</UiDropdownMenuItem>`,
|
|
65
|
+
).join('\n ')}
|
|
66
|
+
</UiDropdownMenuContent>
|
|
67
|
+
</UiDropdownMenu>`;
|
|
68
|
+
|
|
69
|
+
/** The menu as a product would write it, unindented. */
|
|
70
|
+
const SOURCE_LINES = [
|
|
71
|
+
`<UiDropdownMenu v-model:open="accessoryOpen">`,
|
|
72
|
+
` <UiDropdownMenuTrigger as-child>`,
|
|
73
|
+
` <UiToggle v-model="accessoryOpen" aria-label="${ACCESSORY_TRIGGER_NAME}">`,
|
|
74
|
+
` <UiIcon size="s" name="PersonStanding" />`,
|
|
75
|
+
` ${ACCESSORY_TRIGGER_NAME}`,
|
|
76
|
+
` <UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />`,
|
|
77
|
+
` </UiToggle>`,
|
|
78
|
+
` </UiDropdownMenuTrigger>`,
|
|
79
|
+
` <UiDropdownMenuContent>`,
|
|
80
|
+
...ACCESSORY_DROPDOWN_ITEMS.map(
|
|
81
|
+
(item) => ` <UiDropdownMenuItem>${item}</UiDropdownMenuItem>`,
|
|
82
|
+
),
|
|
83
|
+
` </UiDropdownMenuContent>`,
|
|
84
|
+
`</UiDropdownMenu>`,
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The menu as a product would write it, for the docs source panels. The first
|
|
89
|
+
* line is left bare so it can be interpolated after an indent already in place.
|
|
90
|
+
* @param indent Indentation to put in front of every line but the first.
|
|
91
|
+
* @returns The markup, ready to drop into a template source string.
|
|
92
|
+
*/
|
|
93
|
+
export function accessoryDropdownSource(indent: string): string {
|
|
94
|
+
return SOURCE_LINES.map((line, index) =>
|
|
95
|
+
index === 0 ? line : `${indent}${line}`,
|
|
96
|
+
).join('\n');
|
|
97
|
+
}
|