@aleph-alpha/ui-library 6.3.1 → 6.3.3
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/lib.js +5 -2
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +19 -7
- package/dist/system/patterns/UiSidebar/UiSidebar.vue.d.ts +22 -2
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +12 -4
- package/package.json +2 -2
- package/src/components/UiButton/UiButton.stories.ts +88 -0
- package/src/patterns/UiLayout/UiLayout.stories.ts +47 -12
- package/src/patterns/UiLayout/layout-shell.ts +33 -9
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +143 -1
- package/src/patterns/UiSidebar/UiSidebar.vue +17 -0
- package/src/patterns/UiSidebar/UiSidebarTrigger.vue +3 -1
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +30 -0
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +1 -1
- package/src/patterns/UiTopBar/UiTopBar.vue +3 -2
- package/src/patterns/UiTopBar/__tests__/UiTopBar.test.ts +4 -4
package/config.js
CHANGED
|
@@ -1373,8 +1373,10 @@ const scrollbarCSS = `
|
|
|
1373
1373
|
transition: background-color ${SCROLLBAR_FADE_OUT_DURATION} ease;
|
|
1374
1374
|
}
|
|
1375
1375
|
html.ui-scrollbar-autohide[data-ui-scrollbar='visible']::-webkit-scrollbar-thumb,
|
|
1376
|
+
html.ui-scrollbar-autohide[data-ui-scrollbar='visible'] body::-webkit-scrollbar-thumb,
|
|
1376
1377
|
html.ui-scrollbar-autohide [data-ui-scrollbar='visible']::-webkit-scrollbar-thumb,
|
|
1377
1378
|
html.ui-scrollbar-autohide.ui-scrollbar-always::-webkit-scrollbar-thumb,
|
|
1379
|
+
html.ui-scrollbar-autohide.ui-scrollbar-always body::-webkit-scrollbar-thumb,
|
|
1378
1380
|
html.ui-scrollbar-autohide .ui-scrollbar-always::-webkit-scrollbar-thumb {
|
|
1379
1381
|
background-color: ${SCROLLBAR_THUMB_COLOR};
|
|
1380
1382
|
transition-duration: ${SCROLLBAR_FADE_IN_DURATION};
|
package/dist/system/lib.js
CHANGED
|
@@ -62559,6 +62559,7 @@ const nfe = VV, f2e = { class: "inline-flex" }, y2e = ["id", "popover", "data-si
|
|
|
62559
62559
|
"onUpdate:open": d[0] || (d[0] = (c) => o("update:open", c))
|
|
62560
62560
|
}), {
|
|
62561
62561
|
default: m(() => [
|
|
62562
|
+
a.open === !1 ? g(s.$slots, "start-action", { key: 0 }) : te("", !0),
|
|
62562
62563
|
g(s.$slots, "default")
|
|
62563
62564
|
]),
|
|
62564
62565
|
_: 3
|
|
@@ -62835,7 +62836,9 @@ const nfe = VV, f2e = { class: "inline-flex" }, y2e = ["id", "popover", "data-si
|
|
|
62835
62836
|
() => O(
|
|
62836
62837
|
"inline-flex rounded-sm p-2",
|
|
62837
62838
|
"group-data-[collapsible=icon]:h-8 group-data-[collapsible=icon]:w-8 group-data-[collapsible=icon]:p-0",
|
|
62838
|
-
|
|
62839
|
+
// Muted at rest so the icon does not compete with the navigation it sits
|
|
62840
|
+
// beside; hover and focus lift it back to primary.
|
|
62841
|
+
"text-content-on-surface-muted hover:text-content-on-surface-primary focus:text-content-on-surface-primary",
|
|
62839
62842
|
n.class
|
|
62840
62843
|
)
|
|
62841
62844
|
);
|
|
@@ -63496,7 +63499,7 @@ const nfe = VV, f2e = { class: "inline-flex" }, y2e = ["id", "popover", "data-si
|
|
|
63496
63499
|
}
|
|
63497
63500
|
const s = M(() => r("logo")), d = M(() => r("sidebar-toggle")), c = M(() => r("layout-actions")), u = M(() => r("profile")), p = M(
|
|
63498
63501
|
() => O(
|
|
63499
|
-
"flex w-full items-center gap-4 px-
|
|
63502
|
+
"flex w-full items-center gap-4 px-[0.875rem] py-2.5",
|
|
63500
63503
|
"bg-background-surface-primary text-content-on-surface-primary",
|
|
63501
63504
|
a.class ?? ""
|
|
63502
63505
|
)
|
|
@@ -430,8 +430,12 @@ export declare function renderShell(defaultOpen?: boolean, rows?: number, histor
|
|
|
430
430
|
mobileTransitionDuration: string;
|
|
431
431
|
resizable: boolean;
|
|
432
432
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
433
|
-
$slots: {
|
|
434
|
-
default
|
|
433
|
+
$slots: Readonly<{
|
|
434
|
+
default(): unknown;
|
|
435
|
+
'start-action'(): unknown;
|
|
436
|
+
}> & {
|
|
437
|
+
default(): unknown;
|
|
438
|
+
'start-action'(): unknown;
|
|
435
439
|
};
|
|
436
440
|
});
|
|
437
441
|
UiSidebarContent: {
|
|
@@ -1374,8 +1378,12 @@ export declare function renderShellWith(contentTemplate: string, extraComponents
|
|
|
1374
1378
|
mobileTransitionDuration: string;
|
|
1375
1379
|
resizable: boolean;
|
|
1376
1380
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
1377
|
-
$slots: {
|
|
1378
|
-
default
|
|
1381
|
+
$slots: Readonly<{
|
|
1382
|
+
default(): unknown;
|
|
1383
|
+
'start-action'(): unknown;
|
|
1384
|
+
}> & {
|
|
1385
|
+
default(): unknown;
|
|
1386
|
+
'start-action'(): unknown;
|
|
1379
1387
|
};
|
|
1380
1388
|
});
|
|
1381
1389
|
UiSidebarContent: {
|
|
@@ -2316,8 +2324,12 @@ export declare function renderMobileShell(defaultOpen?: boolean, rows?: number,
|
|
|
2316
2324
|
mobileTransitionDuration: string;
|
|
2317
2325
|
resizable: boolean;
|
|
2318
2326
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
2319
|
-
$slots: {
|
|
2320
|
-
default
|
|
2327
|
+
$slots: Readonly<{
|
|
2328
|
+
default(): unknown;
|
|
2329
|
+
'start-action'(): unknown;
|
|
2330
|
+
}> & {
|
|
2331
|
+
default(): unknown;
|
|
2332
|
+
'start-action'(): unknown;
|
|
2321
2333
|
};
|
|
2322
2334
|
});
|
|
2323
2335
|
UiSidebarContent: {
|
|
@@ -2833,7 +2845,7 @@ export declare function renderMobileShell(defaultOpen?: boolean, rows?: number,
|
|
|
2833
2845
|
template: string;
|
|
2834
2846
|
};
|
|
2835
2847
|
/** What the arrangement looks like in a product, with the scaffolding removed. */
|
|
2836
|
-
export declare const templateSource = "<!-- one fade for the shell: the band spans both columns on the bottom edge -->\n<UiFadeMask\n position=\"bottom\"\n background=\"primary\"\n class=\"flex h-svh w-full flex-col overflow-hidden\"\n :style=\"shellStyle\"\n>\n <!-- full-width bar; its toggle drives the same ref the sidebar is bound to,\n which is what `v-model:open` on the trigger is for: the bar is the\n sidebar's sibling, so there is no context for it to reach -->\n <UiTopBar ref=\"topBarRef\" class=\"shrink-0\" leading-width=\"calc(var(--sidebar-width, 16rem) - 1rem)\">\n <template #logo><AppWordmark /></template>\n <template #sidebar-toggle>\n <UiSidebarTrigger v-model:open=\"open\" tooltip=\"Toggle sidebar\"
|
|
2848
|
+
export declare const templateSource = "<!-- one fade for the shell: the band spans both columns on the bottom edge -->\n<UiFadeMask\n position=\"bottom\"\n background=\"primary\"\n class=\"flex h-svh w-full flex-col overflow-hidden\"\n :style=\"shellStyle\"\n>\n <!-- full-width bar; its toggle drives the same ref the sidebar is bound to,\n which is what `v-model:open` on the trigger is for: the bar is the\n sidebar's sibling, so there is no context for it to reach. The bar only\n carries it while the sidebar is expanded \u2014 collapsed, the rail shows its\n own (see `start-action` below) -->\n <UiTopBar ref=\"topBarRef\" class=\"shrink-0\" leading-width=\"calc(var(--sidebar-width, 16rem) - 1rem)\">\n <template #logo><AppWordmark /></template>\n <template v-if=\"open\" #sidebar-toggle>\n <UiSidebarTrigger v-model:open=\"open\" tooltip=\"Toggle sidebar\" />\n </template>\n <!-- the avatar and the card it opens are Patterns/UiProfileCard -->\n <template #profile><ProfileCard /></template>\n </UiTopBar>\n\n <!-- the row beneath: sidebar column + content column -->\n <div class=\"flex min-h-0 w-full flex-1\">\n <!-- isolate: rows raise their own icons, which would otherwise escape the\n column and land over the shell's fade -->\n <UiSidebar v-model:open=\"open\" collapsible=\"icon\" class=\"isolate\" role=\"navigation\" aria-label=\"Main\">\n <!-- rendered only while the bound `open` is false: the collapsed rail\n carries the toggle the bar gave up, and inside the sidebar the\n trigger reads the context, so it takes no binding of its own -->\n <template #start-action>\n <UiSidebarMenu>\n <UiSidebarMenuItem>\n <UiSidebarTrigger tooltip=\"Toggle sidebar\" />\n </UiSidebarMenuItem>\n </UiSidebarMenu>\n </template>\n <UiSidebarContent>\u2026</UiSidebarContent>\n </UiSidebar>\n\n <main class=\"bg-background flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden\">\n <PageHeading />\n <!-- bottom padding matches the fade band so the last row clears it -->\n <div class=\"min-h-0 flex-1 overflow-y-auto pb-16 md:pb-24\"><PageContent /></div>\n </main>\n </div>\n</UiFadeMask>";
|
|
2837
2849
|
/** The same shell on a phone: mobile bar slots, and a page that slides aside. */
|
|
2838
2850
|
export declare const mobileTemplateSource = "<div class=\"relative h-svh w-full overflow-hidden\" :style=\"shellStyle\">\n <!-- the bar floats over both layers: mobile slots, no surface of its own -->\n <UiTopBar ref=\"topBarRef\" class=\"absolute inset-x-0 top-0 z-20 bg-transparent\">\n <template #logo><AppWordmark /></template>\n <template #mobile-logo><WorkspacePill /></template>\n <template #mobile-layout-actions>\n <MenuButton :aria-expanded=\"open\" @click=\"open = !open\" />\n </template>\n </UiTopBar>\n\n <!-- the base layer never moves, so it is a plain column, not the drawer; it\n starts below the bar, which is showing its controls -->\n <div class=\"absolute inset-0 isolate flex\" :style=\"{ paddingTop: 'var(--sidebar-offset-top, 3.75rem)' }\">\n <UiSidebar\n v-model:open=\"open\"\n collapsible=\"none\"\n class=\"h-full w-full\"\n role=\"navigation\"\n aria-label=\"Main\"\n :aria-hidden=\"open ? undefined : 'true'\"\n :inert=\"open ? undefined : true\"\n >\n <!-- the fade stays inside the scroll area here, so it dissolves the\n history above the profile row instead of over it -->\n <UiFadeMask position=\"bottom\" background=\"primary\" class=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n <UiSidebarContent>\u2026</UiSidebarContent>\n </UiFadeMask>\n <!-- the same card as on a wide screen, opening upwards from the row that\n replaces the avatar the bar gave up -->\n <UiSidebarFooter><ProfileCard /></UiSidebarFooter>\n </UiSidebar>\n </div>\n\n <!-- the sheet is what slides, revealing the layer it was covering; it runs\n the full height and fades at both ends, so the bar floats on the top one -->\n <main\n class=\"bg-background absolute inset-0 flex flex-col overflow-hidden transition-transform duration-200 ease-out\"\n :class=\"open ? 'translate-x-full' : 'translate-x-0'\"\n :inert=\"open || undefined\"\n >\n <!-- one mask, a band on each edge: the page fades under the bar and again\n at the bottom -->\n <UiFadeMask position=\"both\" background=\"secondary\" class=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n <!-- bottom padding matches the fade band so the last row clears it -->\n <div class=\"min-h-0 flex-1 overflow-y-auto pb-16 md:pb-24\" :style=\"{ paddingTop: 'var(--sidebar-offset-top, 3.75rem)' }\">\n <PageHeading />\n <PageContent />\n </div>\n </UiFadeMask>\n </main>\n</div>";
|
|
2839
2851
|
export {};
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
declare function __VLS_template(): {
|
|
2
2
|
attrs: Partial<{}>;
|
|
3
|
-
slots: {
|
|
4
|
-
|
|
3
|
+
slots: Readonly<{
|
|
4
|
+
/** Sidebar body — content, groups, and footer. */
|
|
5
|
+
default(): unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Rendered at the top of the sidebar only while a bound `open` is `false`,
|
|
8
|
+
* so the collapsed icon rail can carry its own control — typically a
|
|
9
|
+
* `UiSidebarTrigger` that expands it again. Requires the controlled API
|
|
10
|
+
* (`v-model:open`); an uncontrolled sidebar never renders this slot, since
|
|
11
|
+
* the wrapper cannot see the state the core manages internally.
|
|
12
|
+
*/
|
|
13
|
+
'start-action'(): unknown;
|
|
14
|
+
}> & {
|
|
15
|
+
/** Sidebar body — content, groups, and footer. */
|
|
16
|
+
default(): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Rendered at the top of the sidebar only while a bound `open` is `false`,
|
|
19
|
+
* so the collapsed icon rail can carry its own control — typically a
|
|
20
|
+
* `UiSidebarTrigger` that expands it again. Requires the controlled API
|
|
21
|
+
* (`v-model:open`); an uncontrolled sidebar never renders this slot, since
|
|
22
|
+
* the wrapper cannot see the state the core manages internally.
|
|
23
|
+
*/
|
|
24
|
+
'start-action'(): unknown;
|
|
5
25
|
};
|
|
6
26
|
refs: {};
|
|
7
27
|
rootEl: any;
|
|
@@ -59,8 +59,12 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
|
|
|
59
59
|
mobileTransitionDuration: string;
|
|
60
60
|
resizable: boolean;
|
|
61
61
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
62
|
-
$slots: {
|
|
63
|
-
default
|
|
62
|
+
$slots: Readonly<{
|
|
63
|
+
default(): unknown;
|
|
64
|
+
'start-action'(): unknown;
|
|
65
|
+
}> & {
|
|
66
|
+
default(): unknown;
|
|
67
|
+
'start-action'(): unknown;
|
|
64
68
|
};
|
|
65
69
|
});
|
|
66
70
|
UiSidebarContent: {
|
|
@@ -134,8 +138,12 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
|
|
|
134
138
|
mobileTransitionDuration: string;
|
|
135
139
|
resizable: boolean;
|
|
136
140
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
137
|
-
$slots: {
|
|
138
|
-
default
|
|
141
|
+
$slots: Readonly<{
|
|
142
|
+
default(): unknown;
|
|
143
|
+
'start-action'(): unknown;
|
|
144
|
+
}> & {
|
|
145
|
+
default(): unknown;
|
|
146
|
+
'start-action'(): unknown;
|
|
139
147
|
};
|
|
140
148
|
});
|
|
141
149
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/system/lib.js",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"@aleph-alpha/eslint-config-frontend": "0.7.1",
|
|
91
91
|
"@aleph-alpha/prettier-config-frontend": "2.1.1",
|
|
92
92
|
"@aleph-alpha/storybook-addon-filters": "0.0.1",
|
|
93
|
-
"@aleph-alpha/storybook-addon-theming": "0.0.1",
|
|
94
93
|
"@aleph-alpha/storybook-addon-sidebar": "0.0.1",
|
|
94
|
+
"@aleph-alpha/storybook-addon-theming": "0.0.1",
|
|
95
95
|
"@aleph-alpha/tsconfig-frontend": "0.7.3"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
@@ -870,6 +870,94 @@ export const Sizes: Story = {
|
|
|
870
870
|
},
|
|
871
871
|
};
|
|
872
872
|
|
|
873
|
+
const IconsizesTemplateSource = `<script setup lang="ts">
|
|
874
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
875
|
+
</script>
|
|
876
|
+
|
|
877
|
+
<template>
|
|
878
|
+
<div class="grid gap-4 md:grid-cols-4">
|
|
879
|
+
<!-- icon-xs is only available on the ghost variant -->
|
|
880
|
+
<UiButton variant="ghost" size="icon-xs" aria-label="Close">
|
|
881
|
+
<UiIcon name="Image" />
|
|
882
|
+
</UiButton>
|
|
883
|
+
<UiButton size="icon-sm" aria-label="Close">
|
|
884
|
+
<UiIcon name="Image" />
|
|
885
|
+
</UiButton>
|
|
886
|
+
<UiButton size="icon" aria-label="Close">
|
|
887
|
+
<UiIcon name="Image" />
|
|
888
|
+
</UiButton>
|
|
889
|
+
<UiButton size="icon-lg" aria-label="Close">
|
|
890
|
+
<UiIcon name="Image" />
|
|
891
|
+
</UiButton>
|
|
892
|
+
</div>
|
|
893
|
+
</template>`;
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Icon-only button size guidance.
|
|
897
|
+
*/
|
|
898
|
+
export const IconSizes: Story = {
|
|
899
|
+
render: (args) => ({
|
|
900
|
+
components: { UiButton, UiIcon },
|
|
901
|
+
setup() {
|
|
902
|
+
return { UiButton, UiIcon, args };
|
|
903
|
+
},
|
|
904
|
+
template: `
|
|
905
|
+
<section class="flex flex-col gap-6 rounded-lg bg-background-surface-primary p-4">
|
|
906
|
+
<div>
|
|
907
|
+
<h2 class="heading-s text-content-on-surface-primary">Sizes</h2>
|
|
908
|
+
<p class="body-14-regular mt-2 text-content-on-surface-primary">
|
|
909
|
+
Buttons come in three sizes: small, default and large. Buttons should match in size.
|
|
910
|
+
</p>
|
|
911
|
+
</div>
|
|
912
|
+
|
|
913
|
+
<div class="grid gap-3 md:grid-cols-4">
|
|
914
|
+
<div v-if="args.variant === 'ghost'" class="flex flex-col gap-3">
|
|
915
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Extra Small Icon</h3>
|
|
916
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
917
|
+
<UiButton :variant="args.variant" size="icon-xs" aria-label="Close">
|
|
918
|
+
<UiIcon name="Image" />
|
|
919
|
+
</UiButton>
|
|
920
|
+
</div>
|
|
921
|
+
</div>
|
|
922
|
+
<div class="flex flex-col gap-3">
|
|
923
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Small Icon</h3>
|
|
924
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
925
|
+
<UiButton :variant="args.variant" size="icon-sm" aria-label="Close">
|
|
926
|
+
<UiIcon name="Image" />
|
|
927
|
+
</UiButton>
|
|
928
|
+
</div>
|
|
929
|
+
</div>
|
|
930
|
+
|
|
931
|
+
<div class="flex flex-col gap-3">
|
|
932
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Default Icon</h3>
|
|
933
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
934
|
+
<UiButton :variant="args.variant" size="icon" aria-label="Close">
|
|
935
|
+
<UiIcon name="Image" />
|
|
936
|
+
</UiButton>
|
|
937
|
+
</div>
|
|
938
|
+
</div>
|
|
939
|
+
|
|
940
|
+
<div class="flex flex-col gap-3">
|
|
941
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Large Icon</h3>
|
|
942
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
943
|
+
<UiButton :variant="args.variant" size="icon-lg" aria-label="Close">
|
|
944
|
+
<UiIcon name="Image" />
|
|
945
|
+
</UiButton>
|
|
946
|
+
</div>
|
|
947
|
+
</div>
|
|
948
|
+
</div>
|
|
949
|
+
</section>
|
|
950
|
+
`,
|
|
951
|
+
}),
|
|
952
|
+
parameters: {
|
|
953
|
+
docs: {
|
|
954
|
+
source: {
|
|
955
|
+
code: IconsizesTemplateSource,
|
|
956
|
+
},
|
|
957
|
+
},
|
|
958
|
+
},
|
|
959
|
+
};
|
|
960
|
+
|
|
873
961
|
const iconUsageTemplateSource = `<script setup lang="ts">
|
|
874
962
|
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
875
963
|
|
|
@@ -86,8 +86,9 @@ export const Default: Story = {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Collapsing
|
|
90
|
-
* the
|
|
89
|
+
* Collapsing hands the toggle over: while the sidebar is expanded the control
|
|
90
|
+
* sits in the bar, and once the column narrows to the icon rail the bar gives
|
|
91
|
+
* it up and the rail carries its own trigger at the top instead.
|
|
91
92
|
*/
|
|
92
93
|
export const TogglingTheSidebar: Story = {
|
|
93
94
|
globals: { mediaBreakpoint: 'default' },
|
|
@@ -98,16 +99,19 @@ export const TogglingTheSidebar: Story = {
|
|
|
98
99
|
},
|
|
99
100
|
play: async ({ canvasElement, step }) => {
|
|
100
101
|
// Scenario (sidebar layout): the toggle in the bar collapses the navigation
|
|
101
|
-
// beneath it,
|
|
102
|
+
// beneath it, reappears at the top of the icon rail, and works from the
|
|
103
|
+
// keyboard in both homes.
|
|
102
104
|
const canvas = within(canvasElement);
|
|
103
105
|
const nav = canvas.getByRole('navigation', { name: 'Main' });
|
|
104
106
|
const bar = canvas.getByRole('banner', { name: 'Top bar' });
|
|
105
|
-
const toggle = canvas.getByRole('button', { name: 'Toggle sidebar' });
|
|
106
107
|
|
|
107
108
|
await step(
|
|
108
|
-
'interaction: the toggle collapses the sidebar to the icon rail',
|
|
109
|
+
'interaction: the toggle in the bar collapses the sidebar to the icon rail',
|
|
109
110
|
async () => {
|
|
111
|
+
const toggle = canvas.getByRole('button', { name: 'Toggle sidebar' });
|
|
112
|
+
|
|
110
113
|
await expect(nav).toHaveAttribute('data-state', 'expanded');
|
|
114
|
+
await expect(bar.contains(toggle)).toBe(true);
|
|
111
115
|
|
|
112
116
|
await userEvent.click(toggle);
|
|
113
117
|
|
|
@@ -115,29 +119,60 @@ export const TogglingTheSidebar: Story = {
|
|
|
115
119
|
expect(nav).toHaveAttribute('data-state', 'collapsed'),
|
|
116
120
|
);
|
|
117
121
|
await expect(nav).toHaveAttribute('data-collapsible', 'icon');
|
|
122
|
+
},
|
|
123
|
+
);
|
|
118
124
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
await step(
|
|
126
|
+
'interaction: the collapsed rail carries the toggle, and the bar gives it up',
|
|
127
|
+
async () => {
|
|
128
|
+
// The control moved, so it is re-queried: the one in the bar unmounted
|
|
129
|
+
// with its `v-if`, and the rail rendered its own through `start-action`.
|
|
130
|
+
const railToggle = await canvas.findByRole('button', {
|
|
131
|
+
name: 'Toggle sidebar',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await expect(nav.contains(railToggle)).toBe(true);
|
|
135
|
+
await expect(bar.contains(railToggle)).toBe(false);
|
|
123
136
|
},
|
|
124
137
|
);
|
|
125
138
|
|
|
126
139
|
await step(
|
|
127
|
-
'
|
|
140
|
+
'screen-reader: the rail toggle announces the collapsed state (WCAG 4.1.2)',
|
|
128
141
|
async () => {
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
await expect(
|
|
143
|
+
canvas.getByRole('button', { name: 'Toggle sidebar' }),
|
|
144
|
+
).toHaveAttribute('aria-expanded', 'false');
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
await step(
|
|
149
|
+
'keyboard: the rail toggle is focusable and Enter expands again (WCAG 2.1.1)',
|
|
150
|
+
async () => {
|
|
151
|
+
const railToggle = canvas.getByRole('button', {
|
|
152
|
+
name: 'Toggle sidebar',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
railToggle.focus();
|
|
156
|
+
await expect(railToggle).toHaveFocus();
|
|
131
157
|
|
|
132
158
|
await userEvent.keyboard('{Enter}');
|
|
133
159
|
|
|
134
160
|
await waitFor(() =>
|
|
135
161
|
expect(nav).toHaveAttribute('data-state', 'expanded'),
|
|
136
162
|
);
|
|
163
|
+
|
|
164
|
+
// And the control is back in the bar.
|
|
165
|
+
const barToggle = await canvas.findByRole('button', {
|
|
166
|
+
name: 'Toggle sidebar',
|
|
167
|
+
});
|
|
168
|
+
await expect(bar.contains(barToggle)).toBe(true);
|
|
137
169
|
},
|
|
138
170
|
);
|
|
139
171
|
|
|
140
172
|
await step('keyboard: and Space collapses it again', async () => {
|
|
173
|
+
const barToggle = canvas.getByRole('button', { name: 'Toggle sidebar' });
|
|
174
|
+
|
|
175
|
+
barToggle.focus();
|
|
141
176
|
await userEvent.keyboard(' ');
|
|
142
177
|
|
|
143
178
|
await waitFor(() =>
|
|
@@ -90,7 +90,9 @@ const LAYOUT_ACTIONS = `
|
|
|
90
90
|
* The bar: wordmark and sidebar toggle leading, layout switch and profile
|
|
91
91
|
* trailing. The bar is a sibling of the sidebar rather than an ancestor, so the
|
|
92
92
|
* toggle takes the same `open` ref the sidebar is bound to instead of reaching
|
|
93
|
-
* for the sidebar context.
|
|
93
|
+
* for the sidebar context. It carries the toggle only while the sidebar is
|
|
94
|
+
* expanded — collapsed, the icon rail shows its own through `start-action`,
|
|
95
|
+
* so the control sits on the column it reopens.
|
|
94
96
|
* @param layoutActions Whether the bar carries the layout switch.
|
|
95
97
|
* @returns Template string for the bar.
|
|
96
98
|
*/
|
|
@@ -103,11 +105,10 @@ function topBar(layoutActions = true) {
|
|
|
103
105
|
>
|
|
104
106
|
<template #logo>${WORDMARK}</template>
|
|
105
107
|
|
|
106
|
-
<template #sidebar-toggle>
|
|
108
|
+
<template v-if="open" #sidebar-toggle>
|
|
107
109
|
<UiSidebarTrigger
|
|
108
110
|
v-model:open="open"
|
|
109
111
|
tooltip="Toggle sidebar"
|
|
110
|
-
tooltip-side="bottom"
|
|
111
112
|
/>
|
|
112
113
|
</template>
|
|
113
114
|
|
|
@@ -205,9 +206,11 @@ function menuGroup(label: string, items: string): string {
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
/**
|
|
208
|
-
* The navigation column. No logo and
|
|
209
|
-
*
|
|
210
|
-
*
|
|
209
|
+
* The navigation column. No logo, and the bar above carries the toggle while
|
|
210
|
+
* the column is expanded; collapsed, the rail takes it over through
|
|
211
|
+
* `start-action`, where the trigger reads the sidebar context it sits in. The
|
|
212
|
+
* sidebar renders an unlabelled element, so the landmark is named here rather
|
|
213
|
+
* than baked into the pattern.
|
|
211
214
|
*/
|
|
212
215
|
const SIDEBAR = `
|
|
213
216
|
<UiSidebar
|
|
@@ -217,6 +220,15 @@ const SIDEBAR = `
|
|
|
217
220
|
role="navigation"
|
|
218
221
|
aria-label="Main"
|
|
219
222
|
>
|
|
223
|
+
<template #start-action>
|
|
224
|
+
<!-- The menu is a list, so the trigger needs a row of its own: a bare
|
|
225
|
+
button directly inside the <ul> is an axe violation (list). -->
|
|
226
|
+
<UiSidebarMenu>
|
|
227
|
+
<UiSidebarMenuItem>
|
|
228
|
+
<UiSidebarTrigger tooltip="Toggle sidebar" />
|
|
229
|
+
</UiSidebarMenuItem>
|
|
230
|
+
</UiSidebarMenu>
|
|
231
|
+
</template>
|
|
220
232
|
<UiSidebarContent>
|
|
221
233
|
<UiSidebarMenu class="px-2">
|
|
222
234
|
<template v-for="item in primaryItems" :key="item.title">
|
|
@@ -743,11 +755,13 @@ export const templateSource = `<!-- one fade for the shell: the band spans both
|
|
|
743
755
|
>
|
|
744
756
|
<!-- full-width bar; its toggle drives the same ref the sidebar is bound to,
|
|
745
757
|
which is what \`v-model:open\` on the trigger is for: the bar is the
|
|
746
|
-
sidebar's sibling, so there is no context for it to reach
|
|
758
|
+
sidebar's sibling, so there is no context for it to reach. The bar only
|
|
759
|
+
carries it while the sidebar is expanded — collapsed, the rail shows its
|
|
760
|
+
own (see \`start-action\` below) -->
|
|
747
761
|
<UiTopBar ref="topBarRef" class="shrink-0" leading-width="calc(var(--sidebar-width, 16rem) - 1rem)">
|
|
748
762
|
<template #logo><AppWordmark /></template>
|
|
749
|
-
<template #sidebar-toggle>
|
|
750
|
-
<UiSidebarTrigger v-model:open="open" tooltip="Toggle sidebar"
|
|
763
|
+
<template v-if="open" #sidebar-toggle>
|
|
764
|
+
<UiSidebarTrigger v-model:open="open" tooltip="Toggle sidebar" />
|
|
751
765
|
</template>
|
|
752
766
|
<!-- the avatar and the card it opens are Patterns/UiProfileCard -->
|
|
753
767
|
<template #profile><ProfileCard /></template>
|
|
@@ -758,6 +772,16 @@ export const templateSource = `<!-- one fade for the shell: the band spans both
|
|
|
758
772
|
<!-- isolate: rows raise their own icons, which would otherwise escape the
|
|
759
773
|
column and land over the shell's fade -->
|
|
760
774
|
<UiSidebar v-model:open="open" collapsible="icon" class="isolate" role="navigation" aria-label="Main">
|
|
775
|
+
<!-- rendered only while the bound \`open\` is false: the collapsed rail
|
|
776
|
+
carries the toggle the bar gave up, and inside the sidebar the
|
|
777
|
+
trigger reads the context, so it takes no binding of its own -->
|
|
778
|
+
<template #start-action>
|
|
779
|
+
<UiSidebarMenu>
|
|
780
|
+
<UiSidebarMenuItem>
|
|
781
|
+
<UiSidebarTrigger tooltip="Toggle sidebar" />
|
|
782
|
+
</UiSidebarMenuItem>
|
|
783
|
+
</UiSidebarMenu>
|
|
784
|
+
</template>
|
|
761
785
|
<UiSidebarContent>…</UiSidebarContent>
|
|
762
786
|
</UiSidebar>
|
|
763
787
|
|
|
@@ -18,6 +18,7 @@ import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
|
|
|
18
18
|
import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
|
|
19
19
|
import UiSidebarPopoverMenu from './UiSidebarPopoverMenu.vue';
|
|
20
20
|
import UiSidebarPopoverMenuItem from './UiSidebarPopoverMenuItem.vue';
|
|
21
|
+
import UiSidebarTrigger from './UiSidebarTrigger.vue';
|
|
21
22
|
const meta: Meta<typeof UiSidebar> = {
|
|
22
23
|
title: 'Patterns/UiSidebar/UiSidebar',
|
|
23
24
|
component: UiSidebar,
|
|
@@ -42,7 +43,7 @@ const meta: Meta<typeof UiSidebar> = {
|
|
|
42
43
|
docs: {
|
|
43
44
|
description: {
|
|
44
45
|
component:
|
|
45
|
-
'Application sidebar shell wrapping the core `Sidebar` primitive. It owns its own open state — nothing needs to wrap it — and accepts `v-model:open` when a control outside it should drive the collapse. On desktop it is an ordinary flex child, so the main content column beside it is a plain `<main class="flex-1">`. Controls adjust `side` and `collapsible` for the demo layout.',
|
|
46
|
+
'Application sidebar shell wrapping the core `Sidebar` primitive. It owns its own open state — nothing needs to wrap it — and accepts `v-model:open` when a control outside it should drive the collapse. On desktop it is an ordinary flex child, so the main content column beside it is a plain `<main class="flex-1">`. While a bound `open` is `false`, the `start-action` slot renders at the top of the collapsed rail — the shell in **Patterns/UiLayout** uses it to hand the toggle from the top bar to the rail. Controls adjust `side` and `collapsible` for the demo layout.',
|
|
46
47
|
},
|
|
47
48
|
},
|
|
48
49
|
},
|
|
@@ -504,6 +505,147 @@ export const ControlledOpenState: Story = {
|
|
|
504
505
|
},
|
|
505
506
|
};
|
|
506
507
|
|
|
508
|
+
/**
|
|
509
|
+
* The collapsed rail carrying its own toggle: content passed to `start-action`
|
|
510
|
+
* renders at the top of the sidebar only while the bound `open` is `false`,
|
|
511
|
+
* and leaves again the moment it expands. Here the control outside the sidebar
|
|
512
|
+
* mirrors a top bar — shown only while the sidebar is open, so exactly one
|
|
513
|
+
* toggle exists at a time, the way the shell in **Patterns/UiLayout** wires it.
|
|
514
|
+
*/
|
|
515
|
+
export const CollapsedStartAction: Story = {
|
|
516
|
+
render: () => ({
|
|
517
|
+
components: {
|
|
518
|
+
UiIcon,
|
|
519
|
+
UiSidebar,
|
|
520
|
+
UiSidebarContent,
|
|
521
|
+
UiSidebarMenu,
|
|
522
|
+
UiSidebarMenuButton,
|
|
523
|
+
UiSidebarMenuItem,
|
|
524
|
+
UiSidebarTrigger,
|
|
525
|
+
},
|
|
526
|
+
setup() {
|
|
527
|
+
const open = ref(false);
|
|
528
|
+
const items = [
|
|
529
|
+
{ title: 'Home', icon: 'home' },
|
|
530
|
+
{ title: 'Collections', icon: 'folder' },
|
|
531
|
+
];
|
|
532
|
+
|
|
533
|
+
return { items, open };
|
|
534
|
+
},
|
|
535
|
+
template: `
|
|
536
|
+
<div class="flex h-svh w-full overflow-hidden px-2 py-3">
|
|
537
|
+
<UiSidebar v-model:open="open" collapsible="icon">
|
|
538
|
+
<template #start-action>
|
|
539
|
+
<!-- The menu is a list, so the trigger needs a row of its own: a
|
|
540
|
+
bare button directly inside the <ul> is an axe violation. -->
|
|
541
|
+
<UiSidebarMenu>
|
|
542
|
+
<UiSidebarMenuItem>
|
|
543
|
+
<UiSidebarTrigger tooltip="Toggle sidebar" />
|
|
544
|
+
</UiSidebarMenuItem>
|
|
545
|
+
</UiSidebarMenu>
|
|
546
|
+
</template>
|
|
547
|
+
<UiSidebarContent>
|
|
548
|
+
<UiSidebarMenu class="px-2">
|
|
549
|
+
<UiSidebarMenuItem v-for="item in items" :key="item.title">
|
|
550
|
+
<UiSidebarMenuButton :tooltip="item.title" :aria-label="item.title">
|
|
551
|
+
<template #start-icon>
|
|
552
|
+
<UiIcon :name="item.icon" size="s" />
|
|
553
|
+
</template>
|
|
554
|
+
{{ item.title }}
|
|
555
|
+
</UiSidebarMenuButton>
|
|
556
|
+
</UiSidebarMenuItem>
|
|
557
|
+
</UiSidebarMenu>
|
|
558
|
+
</UiSidebarContent>
|
|
559
|
+
</UiSidebar>
|
|
560
|
+
|
|
561
|
+
<main class="bg-background flex min-h-0 min-w-0 flex-1 flex-col p-4">
|
|
562
|
+
<!-- Stands in for the top bar: the control lives out here only while
|
|
563
|
+
the sidebar is expanded, so the rail and the bar never show a
|
|
564
|
+
toggle at the same time. -->
|
|
565
|
+
<UiSidebarTrigger
|
|
566
|
+
v-if="open"
|
|
567
|
+
v-model:open="open"
|
|
568
|
+
tooltip="Toggle sidebar"
|
|
569
|
+
/>
|
|
570
|
+
</main>
|
|
571
|
+
</div>
|
|
572
|
+
`,
|
|
573
|
+
}),
|
|
574
|
+
play: async ({ canvasElement, step }) => {
|
|
575
|
+
// Scenario (UiSidebar): the collapsed rail offers the way back out through
|
|
576
|
+
// its `start-action` slot, and the control trades places with the one
|
|
577
|
+
// outside as the state flips. Ends collapsed, where it started.
|
|
578
|
+
const canvas = within(canvasElement);
|
|
579
|
+
const sidebar = canvasElement.querySelector<HTMLElement>(
|
|
580
|
+
'[data-slot="sidebar"]',
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
await step(
|
|
584
|
+
'interaction: the collapsed rail renders the start-action content',
|
|
585
|
+
async () => {
|
|
586
|
+
await expect(sidebar).toHaveAttribute('data-state', 'collapsed');
|
|
587
|
+
|
|
588
|
+
const railToggle = canvas.getByRole('button', {
|
|
589
|
+
name: 'Toggle sidebar',
|
|
590
|
+
});
|
|
591
|
+
await expect(sidebar?.contains(railToggle)).toBe(true);
|
|
592
|
+
},
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
await step(
|
|
596
|
+
'screen-reader: the rail toggle announces the collapsed state (WCAG 4.1.2)',
|
|
597
|
+
async () => {
|
|
598
|
+
await expect(
|
|
599
|
+
canvas.getByRole('button', { name: 'Toggle sidebar' }),
|
|
600
|
+
).toHaveAttribute('aria-expanded', 'false');
|
|
601
|
+
},
|
|
602
|
+
);
|
|
603
|
+
|
|
604
|
+
await step(
|
|
605
|
+
'keyboard: Enter on the rail toggle expands the sidebar, and the slot leaves with it (WCAG 2.1.1)',
|
|
606
|
+
async () => {
|
|
607
|
+
const railToggle = canvas.getByRole('button', {
|
|
608
|
+
name: 'Toggle sidebar',
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
railToggle.focus();
|
|
612
|
+
await expect(railToggle).toHaveFocus();
|
|
613
|
+
|
|
614
|
+
await userEvent.keyboard('{Enter}');
|
|
615
|
+
|
|
616
|
+
await waitFor(() =>
|
|
617
|
+
expect(sidebar).toHaveAttribute('data-state', 'expanded'),
|
|
618
|
+
);
|
|
619
|
+
|
|
620
|
+
// The slot is gone, so the only toggle left is the one outside.
|
|
621
|
+
const outerToggle = await canvas.findByRole('button', {
|
|
622
|
+
name: 'Toggle sidebar',
|
|
623
|
+
});
|
|
624
|
+
await expect(sidebar?.contains(outerToggle)).toBe(false);
|
|
625
|
+
await expect(outerToggle).toHaveAttribute('aria-expanded', 'true');
|
|
626
|
+
},
|
|
627
|
+
);
|
|
628
|
+
|
|
629
|
+
await step(
|
|
630
|
+
'interaction: collapsing from outside brings the slot back',
|
|
631
|
+
async () => {
|
|
632
|
+
await userEvent.click(
|
|
633
|
+
canvas.getByRole('button', { name: 'Toggle sidebar' }),
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
await waitFor(() =>
|
|
637
|
+
expect(sidebar).toHaveAttribute('data-state', 'collapsed'),
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
const railToggle = await canvas.findByRole('button', {
|
|
641
|
+
name: 'Toggle sidebar',
|
|
642
|
+
});
|
|
643
|
+
await expect(sidebar?.contains(railToggle)).toBe(true);
|
|
644
|
+
},
|
|
645
|
+
);
|
|
646
|
+
},
|
|
647
|
+
};
|
|
648
|
+
|
|
507
649
|
/**
|
|
508
650
|
* A draggable outer border. The handle is a real control rather than a hit
|
|
509
651
|
* area, so the width is reachable without a pointer: arrows nudge it by
|
|
@@ -19,6 +19,19 @@ const props = withDefaults(defineProps<UiSidebarProps>(), {
|
|
|
19
19
|
|
|
20
20
|
const emit = defineEmits<UiSidebarEmits>();
|
|
21
21
|
|
|
22
|
+
defineSlots<{
|
|
23
|
+
/** Sidebar body — content, groups, and footer. */
|
|
24
|
+
default(): unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Rendered at the top of the sidebar only while a bound `open` is `false`,
|
|
27
|
+
* so the collapsed icon rail can carry its own control — typically a
|
|
28
|
+
* `UiSidebarTrigger` that expands it again. Requires the controlled API
|
|
29
|
+
* (`v-model:open`); an uncontrolled sidebar never renders this slot, since
|
|
30
|
+
* the wrapper cannot see the state the core manages internally.
|
|
31
|
+
*/
|
|
32
|
+
'start-action'(): unknown;
|
|
33
|
+
}>();
|
|
34
|
+
|
|
22
35
|
// `open` is only forwarded when the consumer controls it; passing `undefined`
|
|
23
36
|
// through would otherwise pin the sidebar into controlled mode with no value.
|
|
24
37
|
const openProps = computed(() => ({
|
|
@@ -57,6 +70,10 @@ const resizeOptions = computed(() => {
|
|
|
57
70
|
v-bind="{ ...openProps, ...$attrs }"
|
|
58
71
|
@update:open="emit('update:open', $event)"
|
|
59
72
|
>
|
|
73
|
+
<!-- `open === false` rather than `!open`: `open` is `undefined` when the
|
|
74
|
+
sidebar is uncontrolled, and the slot must not sit in an expanded
|
|
75
|
+
sidebar just because nothing is bound. -->
|
|
76
|
+
<slot v-if="props.open === false" name="start-action" />
|
|
60
77
|
<slot />
|
|
61
78
|
</Sidebar>
|
|
62
79
|
</template>
|
|
@@ -44,7 +44,9 @@ const triggerClass = computed(() =>
|
|
|
44
44
|
cn(
|
|
45
45
|
'inline-flex rounded-sm p-2',
|
|
46
46
|
'group-data-[collapsible=icon]:h-8 group-data-[collapsible=icon]:w-8 group-data-[collapsible=icon]:p-0',
|
|
47
|
-
|
|
47
|
+
// Muted at rest so the icon does not compete with the navigation it sits
|
|
48
|
+
// beside; hover and focus lift it back to primary.
|
|
49
|
+
'text-content-on-surface-muted hover:text-content-on-surface-primary focus:text-content-on-surface-primary',
|
|
48
50
|
attrs.class as string | undefined,
|
|
49
51
|
),
|
|
50
52
|
);
|
|
@@ -241,6 +241,36 @@ describe('UiSidebar', () => {
|
|
|
241
241
|
// viewport by the `test - Mobile Breakpoint` story, where the breakpoint is
|
|
242
242
|
// the browser's rather than a mocked `matchMedia`.
|
|
243
243
|
|
|
244
|
+
test('renders the start-action slot only while a bound open is false', async () => {
|
|
245
|
+
const { queryByTestId, rerender } = render(UiSidebar, {
|
|
246
|
+
props: { open: false, collapsible: 'icon' },
|
|
247
|
+
slots: {
|
|
248
|
+
'start-action': '<span data-testid="rail-action">Toggle</span>',
|
|
249
|
+
default: 'Content',
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(queryByTestId('rail-action')).toBeInTheDocument();
|
|
254
|
+
|
|
255
|
+
await rerender({ open: true });
|
|
256
|
+
|
|
257
|
+
expect(queryByTestId('rail-action')).not.toBeInTheDocument();
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test('never renders the start-action slot when open is not bound', () => {
|
|
261
|
+
// `open` stays undefined in uncontrolled mode, so the wrapper cannot tell
|
|
262
|
+
// collapsed from expanded — the slot must not show up in either state.
|
|
263
|
+
const { queryByTestId } = render(UiSidebar, {
|
|
264
|
+
props: { defaultOpen: false, collapsible: 'icon' },
|
|
265
|
+
slots: {
|
|
266
|
+
'start-action': '<span data-testid="rail-action">Toggle</span>',
|
|
267
|
+
default: 'Content',
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
expect(queryByTestId('rail-action')).not.toBeInTheDocument();
|
|
272
|
+
});
|
|
273
|
+
|
|
244
274
|
test('supports configurable mobile transition duration', () => {
|
|
245
275
|
const { container } = render({
|
|
246
276
|
components: { UiSidebar },
|
|
@@ -861,7 +861,7 @@ export const DefaultSlotWrapper: Story = {
|
|
|
861
861
|
async () => {
|
|
862
862
|
const banner = canvas.getByRole('banner', { name: 'Top bar' });
|
|
863
863
|
await expect(banner).toBeVisible();
|
|
864
|
-
await expect(banner).toHaveClass('px-
|
|
864
|
+
await expect(banner).toHaveClass('px-[0.875rem]', 'py-2.5');
|
|
865
865
|
},
|
|
866
866
|
);
|
|
867
867
|
|
|
@@ -106,10 +106,11 @@ 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`
|
|
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. */
|
|
110
111
|
const rootClass = computed(() =>
|
|
111
112
|
cn(
|
|
112
|
-
'flex w-full items-center gap-4 px-
|
|
113
|
+
'flex w-full items-center gap-4 px-[0.875rem] py-2.5',
|
|
113
114
|
'bg-background-surface-primary text-content-on-surface-primary',
|
|
114
115
|
attrs.class ?? '',
|
|
115
116
|
),
|
|
@@ -39,12 +39,12 @@ describe('UiTopBar', () => {
|
|
|
39
39
|
vi.restoreAllMocks();
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
test('renders a named banner landmark with the
|
|
42
|
+
test('renders a named banner landmark with the specified 10px/14px padding', () => {
|
|
43
43
|
const { getByRole } = render(UiTopBar);
|
|
44
44
|
|
|
45
45
|
const banner = getByRole('banner', { name: 'Top bar' });
|
|
46
46
|
expect(banner.tagName).toBe('HEADER');
|
|
47
|
-
expect(banner).toHaveClass('px-
|
|
47
|
+
expect(banner).toHaveClass('px-[0.875rem]', 'py-2.5');
|
|
48
48
|
expect(banner).toHaveAttribute('data-mode', 'desktop');
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -97,7 +97,7 @@ describe('UiTopBar', () => {
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
const banner = getByRole('banner');
|
|
100
|
-
expect(banner).toHaveClass('border-b', 'px-
|
|
100
|
+
expect(banner).toHaveClass('border-b', 'px-[0.875rem]');
|
|
101
101
|
expect(banner).toHaveAttribute('data-testid', 'bar');
|
|
102
102
|
expect(banner).toHaveAttribute('id', 'app-top-bar');
|
|
103
103
|
});
|
|
@@ -119,7 +119,7 @@ describe('UiTopBar', () => {
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
expect(getByRole('banner', { name: 'Top bar' })).toHaveClass(
|
|
122
|
-
'px-
|
|
122
|
+
'px-[0.875rem]',
|
|
123
123
|
'py-2.5',
|
|
124
124
|
);
|
|
125
125
|
});
|