@aleph-alpha/ui-library 6.3.3 → 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/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
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
3
|
+
import {
|
|
4
|
+
UiCard,
|
|
5
|
+
UiCardContent,
|
|
6
|
+
UiCardDescription,
|
|
7
|
+
UiCardHeader,
|
|
8
|
+
UiCardTitle,
|
|
9
|
+
} from '../../components/UiCard';
|
|
10
|
+
import { UiRadioGroup, UiRadioGroupItem } from '../../components/UiRadioGroup';
|
|
3
11
|
import { renderShellWith } from './layout-shell';
|
|
4
12
|
import UiLayoutContent from './UiLayoutContent.vue';
|
|
5
13
|
|
|
@@ -683,6 +691,357 @@ export const SidebarMax: Story = {
|
|
|
683
691
|
play: sidebarViewPlay(6, 6),
|
|
684
692
|
};
|
|
685
693
|
|
|
694
|
+
/**
|
|
695
|
+
* The switch that owns the arrangement. It sits on the content's own grid, so
|
|
696
|
+
* it rides the column split it is setting, and it writes to the same `layout`
|
|
697
|
+
* ref the bar's toolbar is bound to — picking a mode here moves the bar's
|
|
698
|
+
* pressed state, and pressing the bar moves the selection here.
|
|
699
|
+
*
|
|
700
|
+
* `sidebarMode` only applies while the `sidebar` slot is filled, so its options
|
|
701
|
+
* appear with that mode rather than sitting inert the rest of the time.
|
|
702
|
+
*/
|
|
703
|
+
const MODE_SWITCH_CARD = `
|
|
704
|
+
<UiCard class="col-span-full mx-auto w-full max-w-sm bg-background-surface-secondary fixed bottom-10 right-10 z-50">
|
|
705
|
+
<UiCardHeader>
|
|
706
|
+
<UiCardTitle>Content mode</UiCardTitle>
|
|
707
|
+
<UiCardDescription>
|
|
708
|
+
The bar's layout switch and this card share one ref, so the two can
|
|
709
|
+
never disagree about what is rendered.
|
|
710
|
+
</UiCardDescription>
|
|
711
|
+
</UiCardHeader>
|
|
712
|
+
<UiCardContent class="flex flex-col gap-4">
|
|
713
|
+
<UiRadioGroup v-model="layout" name="content-mode" aria-label="Content mode">
|
|
714
|
+
<div class="flex items-center gap-x-2">
|
|
715
|
+
<UiRadioGroupItem id="mode-focus" value="focus" />
|
|
716
|
+
<label for="mode-focus" class="label-14-medium">Focus — twelve columns</label>
|
|
717
|
+
</div>
|
|
718
|
+
<div class="flex items-center gap-x-2">
|
|
719
|
+
<UiRadioGroupItem id="mode-split" value="split" />
|
|
720
|
+
<label for="mode-split" class="label-14-medium">Split — two six-column parts</label>
|
|
721
|
+
</div>
|
|
722
|
+
<div class="flex items-center gap-x-2">
|
|
723
|
+
<UiRadioGroupItem id="mode-sidebar" value="sidebar" />
|
|
724
|
+
<label for="mode-sidebar" class="label-14-medium">Sidebar — secondary content</label>
|
|
725
|
+
</div>
|
|
726
|
+
</UiRadioGroup>
|
|
727
|
+
|
|
728
|
+
<!-- The column split is a property of the sidebar view, so it is offered
|
|
729
|
+
with it instead of standing as a fourth mode. -->
|
|
730
|
+
<UiRadioGroup
|
|
731
|
+
v-if="layout === 'sidebar'"
|
|
732
|
+
v-model="sidebarMode"
|
|
733
|
+
name="sidebar-mode"
|
|
734
|
+
aria-label="Sidebar mode"
|
|
735
|
+
class="border-l border-border-surface-default pl-4"
|
|
736
|
+
>
|
|
737
|
+
<div class="flex items-center gap-x-2">
|
|
738
|
+
<UiRadioGroupItem id="sidebar-default" value="default" />
|
|
739
|
+
<label for="sidebar-default" class="label-14-medium">Default — 8 to 4</label>
|
|
740
|
+
</div>
|
|
741
|
+
<div class="flex items-center gap-x-2">
|
|
742
|
+
<UiRadioGroupItem id="sidebar-wide" value="wide" />
|
|
743
|
+
<label for="sidebar-wide" class="label-14-medium">Wide — 7 to 5</label>
|
|
744
|
+
</div>
|
|
745
|
+
<div class="flex items-center gap-x-2">
|
|
746
|
+
<UiRadioGroupItem id="sidebar-max" value="max" />
|
|
747
|
+
<label for="sidebar-max" class="label-14-medium">Max — 6 to 6</label>
|
|
748
|
+
</div>
|
|
749
|
+
</UiRadioGroup>
|
|
750
|
+
|
|
751
|
+
<!-- The region is replaced without focus moving, so the new arrangement
|
|
752
|
+
is announced rather than changing silently (WCAG 4.1.3). -->
|
|
753
|
+
<p role="status" class="body-12-regular text-content-on-surface-muted">
|
|
754
|
+
{{ layoutStatus }}
|
|
755
|
+
</p>
|
|
756
|
+
</UiCardContent>
|
|
757
|
+
</UiCard>
|
|
758
|
+
`;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* The content column driven by that switch. `UiLayoutContent` reads the mode
|
|
762
|
+
* from which slots are filled, not from a prop, so the conditions sit on the
|
|
763
|
+
* `<template>` elements themselves: a `v-if` *inside* a slot would leave the
|
|
764
|
+
* slot present and the component stuck in that view, rendering an empty area.
|
|
765
|
+
*
|
|
766
|
+
* The overlay keeps drawing the columns of whichever area it is in, so the
|
|
767
|
+
* grid under the card changes with the mode.
|
|
768
|
+
*/
|
|
769
|
+
const contentModesTemplate = `
|
|
770
|
+
<!-- the inline --spacing pins the theme's spacing base for the Vitest
|
|
771
|
+
browser project, which serves utilities without the theme preflight.
|
|
772
|
+
The sheet styling drops in the sidebar view, where the primary area
|
|
773
|
+
becomes the sheet and the sidebar stays on the base layer. -->
|
|
774
|
+
<UiLayoutContent
|
|
775
|
+
:id="contentRegionId"
|
|
776
|
+
:sidebar-mode="sidebarMode"
|
|
777
|
+
:class="[
|
|
778
|
+
'relative min-h-0 min-w-0 flex-1',
|
|
779
|
+
layout === 'sidebar' ? '' : 'overflow-hidden rounded-md shadow-lg',
|
|
780
|
+
]"
|
|
781
|
+
style="--spacing: 0.25rem"
|
|
782
|
+
>
|
|
783
|
+
<div class="relative h-full min-h-0">
|
|
784
|
+
<div
|
|
785
|
+
class="grid h-full min-h-0 content-center gap-6"
|
|
786
|
+
:class="primaryGridClass"
|
|
787
|
+
>
|
|
788
|
+
${MODE_SWITCH_CARD}
|
|
789
|
+
</div>
|
|
790
|
+
|
|
791
|
+
<div
|
|
792
|
+
class="pointer-events-none absolute inset-0 grid gap-6"
|
|
793
|
+
:class="primaryGridClass"
|
|
794
|
+
data-layout-grid-columns
|
|
795
|
+
aria-hidden="true"
|
|
796
|
+
>
|
|
797
|
+
<div v-for="n in primaryColumnCount" :key="n" class="bg-red-500/10" />
|
|
798
|
+
</div>
|
|
799
|
+
</div>
|
|
800
|
+
|
|
801
|
+
<template v-if="layout === 'split'" #split>
|
|
802
|
+
${splitPaneTemplate}
|
|
803
|
+
</template>
|
|
804
|
+
|
|
805
|
+
<template v-if="layout === 'sidebar'" #sidebar>
|
|
806
|
+
<div class="relative h-full min-h-0">
|
|
807
|
+
<div
|
|
808
|
+
class="grid h-full min-h-0 content-center gap-6"
|
|
809
|
+
:class="sidebarGridClass"
|
|
810
|
+
aria-hidden="true"
|
|
811
|
+
>
|
|
812
|
+
<div class="col-span-2 h-4 rounded-md bg-background-surface-muted" />
|
|
813
|
+
<div class="col-span-2 h-24 rounded-md bg-background-surface-muted" />
|
|
814
|
+
<div class="col-span-2 h-24 rounded-md bg-background-surface-muted" />
|
|
815
|
+
<div class="col-span-full h-40 rounded-md bg-background-surface-muted" />
|
|
816
|
+
</div>
|
|
817
|
+
|
|
818
|
+
<div
|
|
819
|
+
class="pointer-events-none absolute inset-0 grid gap-6"
|
|
820
|
+
:class="sidebarGridClass"
|
|
821
|
+
data-layout-grid-columns
|
|
822
|
+
aria-hidden="true"
|
|
823
|
+
>
|
|
824
|
+
<div v-for="n in sidebarColumnCount" :key="n" class="bg-[#00E1FF1A]" />
|
|
825
|
+
</div>
|
|
826
|
+
</div>
|
|
827
|
+
</template>
|
|
828
|
+
</UiLayoutContent>
|
|
829
|
+
`;
|
|
830
|
+
|
|
831
|
+
const contentModesTemplateSource = `<script setup lang="ts">
|
|
832
|
+
import { ref } from 'vue'
|
|
833
|
+
import { UiLayoutContent, UiTopBar } from '@aleph-alpha/ui-library'
|
|
834
|
+
|
|
835
|
+
// one ref for the arrangement; the bar and the content switch both write it
|
|
836
|
+
const layout = ref<'focus' | 'split' | 'sidebar'>('focus')
|
|
837
|
+
const sidebarMode = ref<'default' | 'wide' | 'max'>('default')
|
|
838
|
+
</script>
|
|
839
|
+
|
|
840
|
+
<template>
|
|
841
|
+
<UiTopBar>
|
|
842
|
+
<template #layout-actions>
|
|
843
|
+
<!-- aria-pressed comes from the toolbar once an item declares a value
|
|
844
|
+
inside a v-model group; aria-controls names the region it swaps -->
|
|
845
|
+
<UiFloatActionItems v-model="layout" aria-label="Layout actions">
|
|
846
|
+
<UiFloatActionItems
|
|
847
|
+
type="button"
|
|
848
|
+
value="focus"
|
|
849
|
+
aria-label="Focus layout"
|
|
850
|
+
aria-controls="layout-content"
|
|
851
|
+
>
|
|
852
|
+
<UiIcon name="scan" size="s" />
|
|
853
|
+
</UiFloatActionItems>
|
|
854
|
+
<UiFloatActionItems
|
|
855
|
+
type="button"
|
|
856
|
+
value="split"
|
|
857
|
+
aria-label="Split layout"
|
|
858
|
+
aria-controls="layout-content"
|
|
859
|
+
>
|
|
860
|
+
<UiIcon name="panel-right" size="s" />
|
|
861
|
+
</UiFloatActionItems>
|
|
862
|
+
</UiFloatActionItems>
|
|
863
|
+
</template>
|
|
864
|
+
</UiTopBar>
|
|
865
|
+
|
|
866
|
+
<!-- the mode decides which slots exist: the component reads slot presence,
|
|
867
|
+
so the v-if belongs on the <template>, never inside it -->
|
|
868
|
+
<UiLayoutContent
|
|
869
|
+
id="layout-content"
|
|
870
|
+
:sidebar-mode="sidebarMode"
|
|
871
|
+
class="relative min-h-0 min-w-0 flex-1"
|
|
872
|
+
>
|
|
873
|
+
<ModeSwitchCard v-model:layout="layout" v-model:sidebar-mode="sidebarMode" />
|
|
874
|
+
|
|
875
|
+
<template v-if="layout === 'split'" #split>
|
|
876
|
+
<SecondaryPane />
|
|
877
|
+
</template>
|
|
878
|
+
|
|
879
|
+
<template v-if="layout === 'sidebar'" #sidebar>
|
|
880
|
+
<SecondaryPane />
|
|
881
|
+
</template>
|
|
882
|
+
</UiLayoutContent>
|
|
883
|
+
</template>`;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Every content mode behind one switch, with the bar's layout actions wired to
|
|
887
|
+
* the same state: the card in the content area is the full list, the bar is a
|
|
888
|
+
* shortcut to the two modes the design puts there, and both read back whatever
|
|
889
|
+
* the other set.
|
|
890
|
+
*/
|
|
891
|
+
export const AllContentModes: Story = {
|
|
892
|
+
globals: { mediaBreakpoint: 'default' },
|
|
893
|
+
render: renderShellWith(
|
|
894
|
+
contentModesTemplate,
|
|
895
|
+
{
|
|
896
|
+
UiCard,
|
|
897
|
+
UiCardContent,
|
|
898
|
+
UiCardDescription,
|
|
899
|
+
UiCardHeader,
|
|
900
|
+
UiCardTitle,
|
|
901
|
+
UiLayoutContent,
|
|
902
|
+
UiRadioGroup,
|
|
903
|
+
UiRadioGroupItem,
|
|
904
|
+
},
|
|
905
|
+
true,
|
|
906
|
+
),
|
|
907
|
+
parameters: {
|
|
908
|
+
// The play switches modes, so the end state is whatever it last picked —
|
|
909
|
+
// the per-mode stories above carry the visual baseline instead.
|
|
910
|
+
chromatic: { disableSnapshot: true },
|
|
911
|
+
docs: {
|
|
912
|
+
description: {
|
|
913
|
+
story:
|
|
914
|
+
'All content modes behind a single switch. The card in the content area owns the full list — focus, split, and the three sidebar splits — while the bar carries the two modes the design puts in it. Both write the same `layout` ref, so pressing one moves the other.\n\n`UiLayoutContent` decides its mode from which slots are filled rather than from a prop, so the mode conditions sit on the `<template #split>` and `<template #sidebar>` elements themselves. A `v-if` inside a slot would leave the slot present and the component stuck in that view.',
|
|
915
|
+
},
|
|
916
|
+
source: {
|
|
917
|
+
code: contentModesTemplateSource,
|
|
918
|
+
},
|
|
919
|
+
},
|
|
920
|
+
},
|
|
921
|
+
play: async ({ canvasElement, step }) => {
|
|
922
|
+
// Scenario (content modes): a user switches the arrangement from the card
|
|
923
|
+
// in the content area and from the bar, and the two stay in agreement.
|
|
924
|
+
const canvas = within(canvasElement);
|
|
925
|
+
const modeRadio = (name: string | RegExp) =>
|
|
926
|
+
canvas.getByRole('radio', { name });
|
|
927
|
+
|
|
928
|
+
/** The grid overlays on the canvas — one per area the mode renders. */
|
|
929
|
+
const grids = () =>
|
|
930
|
+
Array.from(
|
|
931
|
+
canvasElement.querySelectorAll<HTMLElement>(
|
|
932
|
+
'[data-layout-grid-columns]',
|
|
933
|
+
),
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Columns drawn by the nth overlay. Throws rather than returning
|
|
938
|
+
* `undefined`, so a missing area fails the step instead of passing it.
|
|
939
|
+
* @param index Which overlay to measure, in document order.
|
|
940
|
+
* @returns How many columns that overlay draws.
|
|
941
|
+
*/
|
|
942
|
+
const columnsIn = (index: number) => {
|
|
943
|
+
const grid = grids().at(index);
|
|
944
|
+
if (!grid) throw new Error(`no grid overlay at index ${index}`);
|
|
945
|
+
return grid.children.length;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
await step(
|
|
949
|
+
'interaction: the card switches the content area between the three modes',
|
|
950
|
+
async () => {
|
|
951
|
+
// Focus: the twelve columns, and no second area.
|
|
952
|
+
await expect(modeRadio(/^Focus/)).toBeChecked();
|
|
953
|
+
await expect(grids()).toHaveLength(1);
|
|
954
|
+
await expect(columnsIn(0)).toBe(12);
|
|
955
|
+
|
|
956
|
+
// Split and sidebar each add a second area with its own grid.
|
|
957
|
+
await userEvent.click(modeRadio(/^Split/));
|
|
958
|
+
await waitFor(() => expect(grids()).toHaveLength(2));
|
|
959
|
+
|
|
960
|
+
await userEvent.click(modeRadio(/^Sidebar/));
|
|
961
|
+
await waitFor(() => expect(grids()).toHaveLength(2));
|
|
962
|
+
},
|
|
963
|
+
);
|
|
964
|
+
|
|
965
|
+
await step(
|
|
966
|
+
'interaction: the sidebar split is offered with the sidebar view, and changes its columns',
|
|
967
|
+
async () => {
|
|
968
|
+
await expect(modeRadio(/^Default — 8 to 4/)).toBeChecked();
|
|
969
|
+
await waitFor(() => expect(columnsIn(0)).toBe(8));
|
|
970
|
+
await expect(columnsIn(1)).toBe(4);
|
|
971
|
+
|
|
972
|
+
await userEvent.click(modeRadio(/^Max — 6 to 6/));
|
|
973
|
+
await waitFor(() => {
|
|
974
|
+
expect(columnsIn(0)).toBe(6);
|
|
975
|
+
expect(columnsIn(1)).toBe(6);
|
|
976
|
+
});
|
|
977
|
+
},
|
|
978
|
+
);
|
|
979
|
+
|
|
980
|
+
await step(
|
|
981
|
+
'interaction: the bar writes the same state, so the card reads back what it set',
|
|
982
|
+
async () => {
|
|
983
|
+
const barSplit = canvas.getByRole('button', { name: 'Split layout' });
|
|
984
|
+
|
|
985
|
+
await userEvent.click(barSplit);
|
|
986
|
+
await waitFor(() => expect(modeRadio(/^Split/)).toBeChecked());
|
|
987
|
+
await expect(barSplit).toHaveAttribute('aria-pressed', 'true');
|
|
988
|
+
|
|
989
|
+
// The sidebar split leaves the switch, since the mode no longer applies.
|
|
990
|
+
await expect(
|
|
991
|
+
canvas.queryByRole('radio', { name: /^Default — 8 to 4/ }),
|
|
992
|
+
).toBeNull();
|
|
993
|
+
},
|
|
994
|
+
);
|
|
995
|
+
|
|
996
|
+
await step(
|
|
997
|
+
'keyboard: arrow keys move through the modes and select on arrival',
|
|
998
|
+
async () => {
|
|
999
|
+
await userEvent.click(modeRadio(/^Focus/));
|
|
1000
|
+
await expect(modeRadio(/^Focus/)).toHaveFocus();
|
|
1001
|
+
|
|
1002
|
+
// A radio group is one tab stop with arrow keys inside it, so the whole
|
|
1003
|
+
// switch is operable without a pointer (WCAG 2.1.1). Selection follows
|
|
1004
|
+
// focus, so each arrow swaps the content while this group holds focus;
|
|
1005
|
+
// it keeps focus because the default slot stays in one place in the
|
|
1006
|
+
// DOM across the three modes, leaving the group patched, not remounted.
|
|
1007
|
+
await userEvent.keyboard('{ArrowDown>}');
|
|
1008
|
+
await expect(modeRadio(/^Split/)).toHaveFocus();
|
|
1009
|
+
await waitFor(async () => {
|
|
1010
|
+
await expect(modeRadio(/^Split/)).toBeChecked();
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
await userEvent.keyboard('{ArrowDown>}');
|
|
1014
|
+
await expect(modeRadio(/^Sidebar/)).toHaveFocus();
|
|
1015
|
+
await waitFor(async () => {
|
|
1016
|
+
await expect(modeRadio(/^Sidebar/)).toBeChecked();
|
|
1017
|
+
});
|
|
1018
|
+
},
|
|
1019
|
+
);
|
|
1020
|
+
|
|
1021
|
+
await step(
|
|
1022
|
+
'screen-reader: the bar names the region it swaps, and the new mode is announced',
|
|
1023
|
+
async () => {
|
|
1024
|
+
const main = canvas.getByRole('main');
|
|
1025
|
+
|
|
1026
|
+
for (const name of ['Focus layout', 'Split layout']) {
|
|
1027
|
+
await expect(canvas.getByRole('button', { name })).toHaveAttribute(
|
|
1028
|
+
'aria-controls',
|
|
1029
|
+
main.id,
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// The status region carries the arrangement, so the swap is not silent.
|
|
1034
|
+
await expect(canvas.getByRole('status')).toHaveTextContent(
|
|
1035
|
+
'Sidebar view, 6 to 6',
|
|
1036
|
+
);
|
|
1037
|
+
await expect(
|
|
1038
|
+
canvas.getByRole('radiogroup', { name: 'Content mode' }),
|
|
1039
|
+
).toBeVisible();
|
|
1040
|
+
},
|
|
1041
|
+
);
|
|
1042
|
+
},
|
|
1043
|
+
};
|
|
1044
|
+
|
|
686
1045
|
/**
|
|
687
1046
|
* The page of default content a modal demo opens over: the same skeleton the
|
|
688
1047
|
* grid demo uses, sitting inside the content area behind the backdrop.
|
|
@@ -38,6 +38,28 @@ const SIDEBAR_MODE_SPANS: Record<
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const sidebarSpans = computed(() => SIDEBAR_MODE_SPANS[props.sidebarMode]);
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* The two classes below are read from the render function rather than cached in
|
|
44
|
+
* a `computed`: they depend on slot presence, and `useSlots()` returns a plain
|
|
45
|
+
* object, so a computed would not invalidate when a slot appears or disappears.
|
|
46
|
+
*/
|
|
47
|
+
function layoutClass(): string {
|
|
48
|
+
if (slots.sidebar) return 'grid h-full min-h-0 grid-cols-12';
|
|
49
|
+
if (slots.split) return 'grid h-full min-h-0 grid-cols-2';
|
|
50
|
+
return 'contents';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function primaryClass(): string {
|
|
54
|
+
if (slots.sidebar) {
|
|
55
|
+
return cn(
|
|
56
|
+
'min-w-0 rounded-xl bg-background-surface-secondary px-8 lg-min:px-12',
|
|
57
|
+
sidebarSpans.value.content,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (slots.split) return 'min-w-0 pr-7';
|
|
61
|
+
return 'contents';
|
|
62
|
+
}
|
|
41
63
|
</script>
|
|
42
64
|
|
|
43
65
|
<template>
|
|
@@ -63,36 +85,36 @@ const sidebarSpans = computed(() => SIDEBAR_MODE_SPANS[props.sidebarMode]);
|
|
|
63
85
|
)
|
|
64
86
|
"
|
|
65
87
|
>
|
|
66
|
-
<!-- The
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
76
|
-
"
|
|
77
|
-
>
|
|
88
|
+
<!-- The default slot keeps one position in the DOM across all three views,
|
|
89
|
+
so switching view mode patches the layout instead of remounting the
|
|
90
|
+
content, and scroll position, form state and focus survive the switch.
|
|
91
|
+
In the plain view both wrappers are `display: contents`, so they add
|
|
92
|
+
no layout box of their own. -->
|
|
93
|
+
<div :class="layoutClass()">
|
|
94
|
+
<!-- In the sidebar view the primary area is the rounded sheet; in the
|
|
95
|
+
split view it keeps a 28px margin from the divider. -->
|
|
96
|
+
<div :class="primaryClass()">
|
|
78
97
|
<slot />
|
|
79
98
|
</div>
|
|
80
|
-
|
|
99
|
+
|
|
100
|
+
<!-- The sidebar view: secondary content locked to the right edge, its
|
|
101
|
+
share of the 12 columns set by `sidebarMode`, with no surface or
|
|
102
|
+
radius of its own. -->
|
|
103
|
+
<div
|
|
104
|
+
v-if="slots.sidebar"
|
|
105
|
+
:class="cn('min-w-0 px-8 lg-min:px-12', sidebarSpans.sidebar)"
|
|
106
|
+
>
|
|
81
107
|
<slot name="sidebar" />
|
|
82
108
|
</div>
|
|
83
|
-
</div>
|
|
84
109
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<div class="min-w-0 border-l border-background-surface-primary pl-7">
|
|
110
|
+
<!-- The split view: a border divides the content box into two equal
|
|
111
|
+
parts, and each part keeps a 28px margin from it. -->
|
|
112
|
+
<div
|
|
113
|
+
v-else-if="slots.split"
|
|
114
|
+
class="min-w-0 border-l border-background-surface-primary pl-7"
|
|
115
|
+
>
|
|
92
116
|
<slot name="split" />
|
|
93
117
|
</div>
|
|
94
118
|
</div>
|
|
95
|
-
|
|
96
|
-
<slot v-else />
|
|
97
119
|
</component>
|
|
98
120
|
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
3
3
|
import { mobileTemplateSource, renderMobileShell } from './layout-shell';
|
|
4
|
+
import { ACCESSORY_TRIGGER_NAME } from '../UiTopBar/accessory-dropdown';
|
|
4
5
|
|
|
5
6
|
const meta = {
|
|
6
7
|
title: 'Patterns/UiLayout/Mobile',
|
|
@@ -60,6 +61,18 @@ export const Default: Story = {
|
|
|
60
61
|
},
|
|
61
62
|
);
|
|
62
63
|
|
|
64
|
+
await step(
|
|
65
|
+
'mobile: the accessibility menu the wide bar carries is deliberately absent at 320px (WCAG 1.4.10)',
|
|
66
|
+
async () => {
|
|
67
|
+
// The bar prefers its `mobile-` slots, so the desktop layout-actions
|
|
68
|
+
// region does not reflow onto the phone: it is the pill and the menu
|
|
69
|
+
// button here, and nothing else.
|
|
70
|
+
await expect(
|
|
71
|
+
canvas.queryByRole('button', { name: ACCESSORY_TRIGGER_NAME }),
|
|
72
|
+
).toBeNull();
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
63
76
|
await step(
|
|
64
77
|
'mobile: the menu button meets the minimum touch-target size (WCAG 2.5.8)',
|
|
65
78
|
async () => {
|