@jskit-ai/shell-web 0.2.19 → 0.2.21
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/CHANGELOG.md +3 -0
- package/README.md +15 -0
- package/fixtures/adaptive-shell/src/ActionsPage.vue +8 -3
- package/fixtures/adaptive-shell/src/App.vue +2 -1
- package/fixtures/adaptive-shell/src/ComponentsPage.vue +53 -3
- package/fixtures/adaptive-shell/src/StatusButton.vue +34 -1
- package/fixtures/adaptive-shell/src/main.js +5 -4
- package/package.json +4 -4
- package/src/client/components/ShellLayout.vue +60 -17
- package/src/client/components/ShellPageActionsTarget.vue +32 -5
- package/src/client/components/ShellTabLinkItem.vue +7 -62
- package/src/client/composables/useShellDrawer.js +8 -6
- package/src/client/composables/useShellTopRightOverflow.js +108 -0
- package/src/client/support/topRightOverflow.js +28 -0
- package/src/test/adaptiveShellSmoke.js +39 -9
- package/test/adaptiveShell.browser.test.js +257 -71
- package/test/materialBaselines.browser.test.js +1 -1
- package/test/settingsPlacementContract.test.js +6 -2
- package/test/topRightOverflow.test.js +31 -0
- package/test/useShellDrawer.test.js +19 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The navigation bar's destinations (`ShellTabLinkItem`) are plain `v-btn`s with an icon and a label, drawn by `@jskit-ai/material-web`'s `material.css` as every `v-bottom-navigation` is: their icon is 24dp in the 64x32 indicator (it was 19dp), and `.tab-link-item__indicator` is gone (the indicator is the icon's own box, `.tab-link-item .v-icon`).
|
|
6
|
+
- On compact windows the top app bar moves only the top-right items it has no room for into its overflow menu: the items stay while they fit beside the whole page title, and those that don't follow the page actions into the menu, farthest from the corner first. The item nearest the corner (the account avatar) still stays unless the page's primary action takes its place, and medium and wider windows are unchanged. The bar used to decide by the window's size class alone, so a short title and three small icons went into the menu. It measures the title and its items as drawn, and again when the bar's content changes (a new title, an item's count, a page action), when the window is resized and when fonts load. Each top-right item now renders once and moves between the bar and the menu as the same component, and the menu keeps it mounted while it is closed: an item that does more than draw a button (a live count, a panel, a floating button it teleports above the navigation bar) existed only while the menu was open on a phone, and was created anew each time it moved. `ShellPageActionsTarget` keeps its `#menu` slot mounted while the menu is closed and takes `menu-items` (default true), false while the slot holds nothing to show. `ShellLayout` sizes the title's `h1` to its text, up to the room it has.
|
|
7
|
+
- `ShellLayout`'s drawer fits its labels and identity by default (what `drawerWidth="content"` did), instead of Material 3's fixed 360dp, so an app no longer wraps `ShellLayout` to get a narrow drawer. It stays within 120-360dp and, as a modal drawer, leaves 56dp of the page beside it. `drawerWidth="material"` gives Material 3's full 360dp (narrowed on a small window, as before), a number still fixes the width and `"content"` still fits it. `runAdaptiveShellSmokeCase` reads the drawer's width again while it settles, and accepts a fitted drawer at its 120dp minimum or one its identity widens past the labels.
|
|
5
8
|
- A content-sized drawer (`drawer-width="content"`) fits the identity at its top (`ShellLayout`'s `top-left` slot or the `shell-layout:top-left` outlet, such as a workspace switcher) as well as its labels. It measured only the labels, so a name longer than they were was cut to the drawer's width; the identity is now read at the width its content wants, its 12dp padding included, and the drawer takes the wider of that and the labels, up to 360dp as before.
|
|
6
9
|
- The shell's client provider starts loading the app's `src/placementTopology.js`, `src/placement.js` and `src/error.js` together instead of each after the one before; it still reads, checks and applies them in the same order, and each is still optional. Measured on the accounts starter with 60 ms of latency per request: the three arrived by 851 ms instead of 935 ms (721-790, 799-865 and 869-935 ms before, 718-851 ms together after), and the bootstrap request that follows them started 82 ms sooner.
|
|
7
10
|
- After Up or the browser's Back, the shell's attempts to focus the element that opened the page left (every 100 ms for up to 1.5 s, until the page draws it) stop at the next navigation and when focus has moved since they started. Before, they outlived both: a Back then a Forward within 1.5 s could focus a matching link or tab on the next page and take the caret from a field someone was typing in. Focus that only fell back to the page body, as when the left page's element goes away, still gets the opener.
|
package/README.md
CHANGED
|
@@ -9,3 +9,18 @@ The static Vue architecture inspector lives in
|
|
|
9
9
|
`@jskit-ai/architecture-inspector`; see its README for the command contract.
|
|
10
10
|
`@jskit-ai/shell-web/architecture` and `src/architecture/cli.js` re-export it
|
|
11
11
|
unchanged for existing consumers.
|
|
12
|
+
|
|
13
|
+
## Top app bar and snackbar placement
|
|
14
|
+
|
|
15
|
+
On compact windows the top app bar shows the page's single `primary` action and
|
|
16
|
+
puts its other actions in the "More actions" menu. The bar's own top-right items
|
|
17
|
+
(tools, a notification bell, the account avatar) stay while they fit beside the
|
|
18
|
+
whole page title; those that don't follow the actions into the menu, farthest
|
|
19
|
+
from the corner first, and the item nearest the corner stays unless the
|
|
20
|
+
`primary` action takes its place. An item keeps running while it is in the
|
|
21
|
+
menu, closed or open, so its live count, its panel or a floating button it shows
|
|
22
|
+
elsewhere on the page stay. Medium and wider bars show them all.
|
|
23
|
+
|
|
24
|
+
`ShellErrorHost` centres its snackbar above the navigation bar on compact
|
|
25
|
+
windows and starts it at the content's start edge, at most half the content's
|
|
26
|
+
width, on wider ones, so it never covers the FAB or the actions it reports on.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
-
import { RouterLink } from "vue-router";
|
|
3
|
+
import { RouterLink, useRoute } from "vue-router";
|
|
4
4
|
import ShellPageAction from "../../../src/client/components/ShellPageAction.vue";
|
|
5
5
|
import ShellPageActions from "../../../src/client/components/ShellPageActions.vue";
|
|
6
6
|
import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
|
|
@@ -10,13 +10,16 @@ import TitleClaim from "./TitleClaim.vue";
|
|
|
10
10
|
|
|
11
11
|
// Page actions in every form: icon-only and labelled, links that leave the app or download a file, a destructive one,
|
|
12
12
|
// an overflow one and, on compact windows, more than the bar holds; the adaptive primary action opening a dialog; and
|
|
13
|
-
// a nested component that claims the title for a while.
|
|
13
|
+
// a nested component that claims the title for a while, or a title too long for a phone's bar. `?title=` sets the
|
|
14
|
+
// page's own title.
|
|
14
15
|
const paths = usePaths();
|
|
16
|
+
const route = useRoute();
|
|
15
17
|
const log = ref([]);
|
|
16
18
|
const dialog = ref(false);
|
|
17
19
|
const panel = ref(false);
|
|
20
|
+
const longTitle = ref(false);
|
|
18
21
|
|
|
19
|
-
useShellPageTitle("Page actions");
|
|
22
|
+
useShellPageTitle(() => String(route.query.title || "Page actions"));
|
|
20
23
|
</script>
|
|
21
24
|
|
|
22
25
|
<template>
|
|
@@ -60,6 +63,8 @@ useShellPageTitle("Page actions");
|
|
|
60
63
|
</p>
|
|
61
64
|
<v-btn variant="text" data-testid="fixture-toggle-panel" @click="panel = !panel">Toggle panel</v-btn>
|
|
62
65
|
<TitleClaim v-if="panel" title="Panel title" />
|
|
66
|
+
<v-btn variant="text" data-testid="fixture-toggle-long-title" @click="longTitle = !longTitle">Toggle long title</v-btn>
|
|
67
|
+
<TitleClaim v-if="longTitle" title="Quarterly statements for every supplier" />
|
|
63
68
|
|
|
64
69
|
<v-dialog v-model="dialog" max-width="400">
|
|
65
70
|
<v-card title="New record" data-testid="fixture-new-dialog">
|
|
@@ -19,7 +19,8 @@ const surfaceLabel = computed(() => ({ admin: "Admin", account: "Account" })[sur
|
|
|
19
19
|
const themeMode = computed(() => route.query.theme === "dark" ? "dark" : "light");
|
|
20
20
|
const railWidth = computed(() => Number(route.query.railWidth) || undefined);
|
|
21
21
|
const navigationItemSpacing = computed(() => Number(route.query.navigationItemSpacing) || undefined);
|
|
22
|
-
|
|
22
|
+
// ?drawerWidth=material asks for Material 3's full drawer width; unset, the drawer fits its labels.
|
|
23
|
+
const drawerWidth = computed(() => (route.query.drawerWidth === "material" ? "material" : undefined));
|
|
23
24
|
// ?identity=<name> puts an identity at the top of the drawer, as a workspace switcher does.
|
|
24
25
|
const identity = computed(() => String(route.query.identity || ""));
|
|
25
26
|
|
|
@@ -5,9 +5,13 @@ import { usePaths } from "../../../src/client/navigation/usePaths.js";
|
|
|
5
5
|
// Material 3 components as JSKIT's defaults draw them: a segmented button, filter chips (in a chip group and toggled
|
|
6
6
|
// with aria-pressed), fixed tabs that share a phone's width or scroll, a menu's own list beside a list in a rich menu
|
|
7
7
|
// panel, dialog actions, a disabled filled button, a card and expansion panels at rest, a pagination's current page,
|
|
8
|
-
// placeholders, a
|
|
9
|
-
//
|
|
10
|
-
// that jumps to its last item as the
|
|
8
|
+
// placeholders, a card's list with an active item and one at rest, each with a subtitle, a button to the page above
|
|
9
|
+
// this one, which isn't active here, and a segmented button and a button group in the narrow `auto` column of a
|
|
10
|
+
// filter row, beside wide fields, a dialog holding a virtual-scroll list that jumps to its last item as the
|
|
11
|
+
// expansion panel around it re-renders, and an app's own navigation bars, each a v-bottom-navigation in a layout of
|
|
12
|
+
// its own: a plain one, with one destination's icon in its content and the other's a prepend-icon; one the app
|
|
13
|
+
// colours (bg-color) and one whose color tints its active destination; and comfortable, compact and horizontal ones;
|
|
14
|
+
// each with a badge on the active destination's icon and a destination with an append icon below its label.
|
|
11
15
|
const paths = usePaths();
|
|
12
16
|
const page = ref(2);
|
|
13
17
|
const view = ref("day");
|
|
@@ -21,6 +25,13 @@ const bookingsDialog = ref(false);
|
|
|
21
25
|
const bookings = Array.from({ length: 40 }, (_, index) => `Booking ${index + 1}`);
|
|
22
26
|
const bookingsScroll = ref(null);
|
|
23
27
|
const pageRenders = ref(0);
|
|
28
|
+
const navigationBars = [
|
|
29
|
+
{ id: "coloured", props: { bgColor: "primary" } },
|
|
30
|
+
{ id: "tinted", props: { color: "primary" } },
|
|
31
|
+
{ id: "comfortable", props: { density: "comfortable" } },
|
|
32
|
+
{ id: "compact", props: { density: "compact" } },
|
|
33
|
+
{ id: "horizontal", props: { mode: "horizontal" } }
|
|
34
|
+
];
|
|
24
35
|
// The panel around the dialog re-renders first (as a form does when a field changes), then the list scrolls to its
|
|
25
36
|
// last item.
|
|
26
37
|
function jumpToLastBooking() {
|
|
@@ -115,6 +126,40 @@ function jumpToLastBooking() {
|
|
|
115
126
|
<v-card class="align-self-stretch" data-testid="fixture-card">
|
|
116
127
|
<v-card-text>A card at rest.</v-card-text>
|
|
117
128
|
</v-card>
|
|
129
|
+
<v-card class="align-self-stretch" data-testid="fixture-subtitled-list">
|
|
130
|
+
<v-list>
|
|
131
|
+
<v-list-item active title="Notifications" subtitle="Email and push" data-testid="fixture-active-item" />
|
|
132
|
+
<v-list-item title="Privacy" subtitle="Who sees your profile" data-testid="fixture-rest-item" />
|
|
133
|
+
</v-list>
|
|
134
|
+
</v-card>
|
|
135
|
+
<v-layout class="align-self-stretch fixture-navigation-bar" data-testid="fixture-navigation-bar">
|
|
136
|
+
<v-bottom-navigation model-value="home" grow>
|
|
137
|
+
<v-btn value="home" data-testid="fixture-navigation-active">
|
|
138
|
+
<v-icon icon="$home" />
|
|
139
|
+
<span>Home</span>
|
|
140
|
+
</v-btn>
|
|
141
|
+
<v-btn value="search" prepend-icon="$search" data-testid="fixture-navigation-rest">Search</v-btn>
|
|
142
|
+
</v-bottom-navigation>
|
|
143
|
+
</v-layout>
|
|
144
|
+
<v-layout
|
|
145
|
+
v-for="bar in navigationBars"
|
|
146
|
+
:key="bar.id"
|
|
147
|
+
class="align-self-stretch fixture-navigation-bar"
|
|
148
|
+
:data-testid="`fixture-navigation-${bar.id}`"
|
|
149
|
+
>
|
|
150
|
+
<v-bottom-navigation model-value="home" grow v-bind="bar.props">
|
|
151
|
+
<v-btn value="home" :data-testid="`fixture-navigation-${bar.id}-active`">
|
|
152
|
+
<v-badge icon="$check" color="error">
|
|
153
|
+
<v-icon icon="$home" />
|
|
154
|
+
</v-badge>
|
|
155
|
+
<span>Home</span>
|
|
156
|
+
</v-btn>
|
|
157
|
+
<v-btn value="search" prepend-icon="$search" :data-testid="`fixture-navigation-${bar.id}-rest`">Search</v-btn>
|
|
158
|
+
<v-btn value="more" prepend-icon="$menu" append-icon="$expand" :data-testid="`fixture-navigation-${bar.id}-append`">
|
|
159
|
+
More
|
|
160
|
+
</v-btn>
|
|
161
|
+
</v-bottom-navigation>
|
|
162
|
+
</v-layout>
|
|
118
163
|
<v-expansion-panels data-testid="fixture-expansion-panels">
|
|
119
164
|
<v-expansion-panel title="Delivery" text="Delivered on Tuesdays." />
|
|
120
165
|
<v-expansion-panel title="Returns" text="Returned within 30 days." />
|
|
@@ -157,6 +202,11 @@ function jumpToLastBooking() {
|
|
|
157
202
|
</template>
|
|
158
203
|
|
|
159
204
|
<style scoped>
|
|
205
|
+
.fixture-navigation-bar {
|
|
206
|
+
height: 80px;
|
|
207
|
+
position: relative;
|
|
208
|
+
}
|
|
209
|
+
|
|
160
210
|
/* A filter row as an app lays one out: the segmented button and the button group in `auto` columns beside wide
|
|
161
211
|
fields, so their segments get only the room their own padding and labels need. At 1440 the row is 1032px and the
|
|
162
212
|
fields' minimums (34rem) leave the two auto columns 416px: whole labels need 381px with 12dp segments and 501px
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
|
|
2
|
+
import { onBeforeUnmount, onMounted } from "vue";
|
|
3
|
+
|
|
4
|
+
// One of the top app bar's own items (an app's tools, status or avatar), from a top-right placement. It counts its
|
|
5
|
+
// mounts and unmounts by label in window.__fixtureStatusLifecycle, so a test can tell it stays mounted wherever the
|
|
6
|
+
// bar puts it, and with `surface` it also draws a surface of its own elsewhere on the page, as an item that opens a
|
|
7
|
+
// panel or a floating button does.
|
|
3
8
|
const props = defineProps({
|
|
4
9
|
icon: {
|
|
5
10
|
type: String,
|
|
@@ -8,10 +13,38 @@ const props = defineProps({
|
|
|
8
13
|
label: {
|
|
9
14
|
type: String,
|
|
10
15
|
required: true
|
|
16
|
+
},
|
|
17
|
+
surface: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
11
20
|
}
|
|
12
21
|
});
|
|
22
|
+
|
|
23
|
+
function count(event) {
|
|
24
|
+
const lifecycle = window.__fixtureStatusLifecycle || (window.__fixtureStatusLifecycle = {});
|
|
25
|
+
const key = `${props.label} ${event}`;
|
|
26
|
+
lifecycle[key] = (lifecycle[key] || 0) + 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onMounted(() => count("mounted"));
|
|
30
|
+
onBeforeUnmount(() => count("unmounted"));
|
|
13
31
|
</script>
|
|
14
32
|
|
|
15
33
|
<template>
|
|
16
34
|
<v-btn :icon="props.icon" variant="text" color="on-surface-variant" :aria-label="props.label" data-testid="fixture-status" />
|
|
35
|
+
<Teleport v-if="props.surface" to="body">
|
|
36
|
+
<div class="fixture-status-surface" data-testid="fixture-status-surface">{{ props.label }}</div>
|
|
37
|
+
</Teleport>
|
|
17
38
|
</template>
|
|
39
|
+
|
|
40
|
+
<style scoped>
|
|
41
|
+
.fixture-status-surface {
|
|
42
|
+
background: rgb(var(--v-theme-surface-container-high));
|
|
43
|
+
border-radius: 8px;
|
|
44
|
+
inset-block-end: 96px;
|
|
45
|
+
inset-inline-start: 16px;
|
|
46
|
+
padding: 4px 8px;
|
|
47
|
+
position: fixed;
|
|
48
|
+
z-index: 1;
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -208,19 +208,20 @@ const placements = [
|
|
|
208
208
|
}
|
|
209
209
|
];
|
|
210
210
|
|
|
211
|
-
// `?topRight=3` gives the top app bar three items of its own, as an app's tools, status and avatar
|
|
211
|
+
// `?topRight=3` gives the top app bar three items of its own, as an app's tools, status and avatar; the status draws a
|
|
212
|
+
// surface of its own on the page too.
|
|
212
213
|
const statusPlacements = [
|
|
213
214
|
["$settings", "Tools"],
|
|
214
|
-
["$notifications", "Status"],
|
|
215
|
+
["$notifications", "Status", true],
|
|
215
216
|
["$accountCircle", "Account"]
|
|
216
|
-
].slice(0, Number(new URLSearchParams(window.location.search).get("topRight")) || 0).map(([icon, label], index) => ({
|
|
217
|
+
].slice(0, Number(new URLSearchParams(window.location.search).get("topRight")) || 0).map(([icon, label, surface], index) => ({
|
|
217
218
|
id: `fixture.status.${index}`,
|
|
218
219
|
target: "shell.status",
|
|
219
220
|
kind: "component",
|
|
220
221
|
componentToken: "fixture.status-button",
|
|
221
222
|
surfaces: ["home", "admin"],
|
|
222
223
|
order: 10 + index,
|
|
223
|
-
props: { icon, label }
|
|
224
|
+
props: { icon, label, surface: Boolean(surface) }
|
|
224
225
|
}));
|
|
225
226
|
|
|
226
227
|
const menuRenderers = Object.freeze({ link: "fixture.surface-menu-link" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/shell-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"./locales/en.json": "./locales/en.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@jskit-ai/architecture-inspector": "0.1.
|
|
49
|
+
"@jskit-ai/architecture-inspector": "0.1.15"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@jskit-ai/material-web": "0.1.
|
|
52
|
+
"@jskit-ai/material-web": "0.1.5",
|
|
53
53
|
"@vue/compiler-sfc": "3.5.44"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@jskit-ai/kernel": "0.2.
|
|
56
|
+
"@jskit-ai/kernel": "0.2.17",
|
|
57
57
|
"pinia": "^4.0.3",
|
|
58
58
|
"vue": "^3.5.44",
|
|
59
59
|
"vue-router": "^5.3.1",
|
|
@@ -6,6 +6,7 @@ import { useShellDrawer } from "../composables/useShellDrawer.js";
|
|
|
6
6
|
import { useShellOutletPlacements } from "../composables/useShellOutletPlacements.js";
|
|
7
7
|
import { useShellLayoutState } from "../composables/useShellLayoutState.js";
|
|
8
8
|
import { useShellPullToRefresh } from "../composables/useShellPullToRefresh.js";
|
|
9
|
+
import { useShellTopRightOverflow } from "../composables/useShellTopRightOverflow.js";
|
|
9
10
|
import {
|
|
10
11
|
DEFAULT_SHELL_NAVIGATION_ITEM_SPACING,
|
|
11
12
|
DEFAULT_SHELL_RAIL_WIDTH
|
|
@@ -51,10 +52,11 @@ const props = defineProps({
|
|
|
51
52
|
type: String,
|
|
52
53
|
default: "rail"
|
|
53
54
|
},
|
|
54
|
-
//
|
|
55
|
+
// "content" fits the drawer to its labels and identity, up to Material 3's 360dp; "material" is that full width and a
|
|
56
|
+
// number fixes it.
|
|
55
57
|
drawerWidth: {
|
|
56
58
|
type: [Number, String],
|
|
57
|
-
default:
|
|
59
|
+
default: "content"
|
|
58
60
|
},
|
|
59
61
|
railWidth: {
|
|
60
62
|
type: Number,
|
|
@@ -145,16 +147,25 @@ const navigationStyle = computed(() => ({
|
|
|
145
147
|
"--shell-navigation-rail-width": `${resolvedRailWidth.value}px`
|
|
146
148
|
}));
|
|
147
149
|
|
|
148
|
-
// A compact bar
|
|
149
|
-
//
|
|
150
|
-
//
|
|
150
|
+
// A compact bar moves the top-right items it has no room for beside the whole title into its overflow menu, after the
|
|
151
|
+
// page actions, farthest from the corner first; the one nearest the corner (the account menu) stays unless the page's
|
|
152
|
+
// primary action takes its place. Each item renders once and moves there and back mounted, so an item that does more
|
|
153
|
+
// than draw a button (a live count, a panel or a button it teleports elsewhere) keeps working while it is in the menu.
|
|
154
|
+
// A layout's own top-right slot stays as it is.
|
|
155
|
+
const TOP_RIGHT_MENU_ID = "jskit-shell-top-right-menu";
|
|
151
156
|
const { pageActions } = useShellAppBar();
|
|
152
157
|
const topRight = useShellOutletPlacements("shell-layout:top-right");
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
const appBarRow = ref(null);
|
|
159
|
+
const appBarHeadline = ref(null);
|
|
160
|
+
const topRightItems = ref(null);
|
|
161
|
+
const { inMenu: topRightInMenu } = useShellTopRightOverflow({
|
|
162
|
+
enabled: computed(() => isCompactLayout.value && !slots["top-right"]),
|
|
163
|
+
placements: topRight,
|
|
164
|
+
pageActions,
|
|
165
|
+
row: appBarRow,
|
|
166
|
+
headline: appBarHeadline,
|
|
167
|
+
items: topRightItems,
|
|
168
|
+
menuId: TOP_RIGHT_MENU_ID
|
|
158
169
|
});
|
|
159
170
|
|
|
160
171
|
function updateScrolled() {
|
|
@@ -181,7 +192,7 @@ onBeforeUnmount(() => {
|
|
|
181
192
|
data-testid="jskit-shell-app-bar"
|
|
182
193
|
:data-size-class="sizeClass"
|
|
183
194
|
>
|
|
184
|
-
<div class="shell-layout__app-bar-row">
|
|
195
|
+
<div ref="appBarRow" class="shell-layout__app-bar-row">
|
|
185
196
|
<ShellUpButton v-if="canGoUp" class="shell-layout__leading" />
|
|
186
197
|
<v-btn
|
|
187
198
|
v-else-if="toggleInAppBar"
|
|
@@ -197,20 +208,35 @@ onBeforeUnmount(() => {
|
|
|
197
208
|
@click="toggleDrawer"
|
|
198
209
|
/>
|
|
199
210
|
|
|
200
|
-
<div
|
|
211
|
+
<div
|
|
212
|
+
ref="appBarHeadline"
|
|
213
|
+
class="shell-layout__headline"
|
|
214
|
+
:class="{ 'shell-layout__headline--leading': canGoUp || toggleInAppBar }"
|
|
215
|
+
>
|
|
201
216
|
<ShellPageTitle :title="fallbackTitle" />
|
|
202
217
|
<p v-if="props.subtitle" class="shell-layout__page-subtitle">{{ text(props.subtitle) }}</p>
|
|
203
218
|
</div>
|
|
204
219
|
|
|
205
|
-
<ShellPageActionsTarget>
|
|
206
|
-
<template v-if="
|
|
207
|
-
<
|
|
220
|
+
<ShellPageActionsTarget :menu-items="topRightInMenu > 0">
|
|
221
|
+
<template v-if="topRight.length > 0 && !slots['top-right']" #menu>
|
|
222
|
+
<div :id="TOP_RIGHT_MENU_ID" class="shell-layout__top-right-menu" />
|
|
208
223
|
</template>
|
|
209
224
|
</ShellPageActionsTarget>
|
|
210
225
|
|
|
211
226
|
<slot name="top-right" :surface="resolvedSurface">
|
|
212
|
-
<div class="shell-layout__top-right">
|
|
213
|
-
|
|
227
|
+
<div ref="topRightItems" class="shell-layout__top-right">
|
|
228
|
+
<!-- One instance per item, in the bar or moved into the menu; `order` keeps the bar's order in both. -->
|
|
229
|
+
<Teleport
|
|
230
|
+
v-for="(entry, index) in topRight"
|
|
231
|
+
:key="entry.id"
|
|
232
|
+
defer
|
|
233
|
+
:to="`#${TOP_RIGHT_MENU_ID}`"
|
|
234
|
+
:disabled="index >= topRightInMenu"
|
|
235
|
+
>
|
|
236
|
+
<div class="shell-layout__top-right-item" :data-placement-id="entry.id" :style="{ order: index }">
|
|
237
|
+
<ShellOutlet target="shell-layout:top-right" :start="index" :end="index + 1" />
|
|
238
|
+
</div>
|
|
239
|
+
</Teleport>
|
|
214
240
|
</div>
|
|
215
241
|
</slot>
|
|
216
242
|
</div>
|
|
@@ -421,6 +447,12 @@ onBeforeUnmount(() => {
|
|
|
421
447
|
padding-inline-start: 4px;
|
|
422
448
|
}
|
|
423
449
|
|
|
450
|
+
/* The title's box is its text, up to the room it has, so the bar can tell how wide the whole title is. */
|
|
451
|
+
.shell-layout__headline :deep(.shell-page-title) {
|
|
452
|
+
inline-size: fit-content;
|
|
453
|
+
max-inline-size: 100%;
|
|
454
|
+
}
|
|
455
|
+
|
|
424
456
|
.shell-layout__page-subtitle {
|
|
425
457
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
426
458
|
font-size: 0.75rem;
|
|
@@ -441,6 +473,17 @@ onBeforeUnmount(() => {
|
|
|
441
473
|
min-width: 0;
|
|
442
474
|
}
|
|
443
475
|
|
|
476
|
+
.shell-layout__top-right-item {
|
|
477
|
+
align-items: center;
|
|
478
|
+
display: flex;
|
|
479
|
+
flex: 0 0 auto;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* The items in the menu are the menu panel's own, laid out by it. */
|
|
483
|
+
.shell-layout__top-right-menu {
|
|
484
|
+
display: contents;
|
|
485
|
+
}
|
|
486
|
+
|
|
444
487
|
/* Navigation rail (medium windows, and expanded ones with the drawer collapsed): 80dp, menu control on top. */
|
|
445
488
|
.shell-layout__rail,
|
|
446
489
|
.shell-layout__drawer {
|
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, inject, mergeProps, useSlots } from "vue";
|
|
2
|
+
import { computed, inject, mergeProps, ref, useSlots, watch } from "vue";
|
|
3
3
|
import { useJskitText } from "../i18n.js";
|
|
4
4
|
import { SHELL_PAGE_ACTIONS_ID } from "../support/navigationPresentation.js";
|
|
5
5
|
import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
|
|
6
6
|
|
|
7
7
|
// Where the current page's ShellPageActions show: after the page title in the top app bar, followed by the bar's
|
|
8
8
|
// overflow menu (Material 3's trailing "More actions" menu) when an action goes there. Its `menu` slot adds the
|
|
9
|
-
// bar's own items that don't fit (on a phone, ShellLayout's top-right items) below the actions.
|
|
9
|
+
// bar's own items that don't fit (on a phone, ShellLayout's top-right items) below the actions. The menu keeps the slot
|
|
10
|
+
// mounted while it is closed, so an item there that does more than draw a button keeps working. ShellLayout's bar has
|
|
10
11
|
// it; a layout that draws its own top app bar renders it once there and calls useShellAppBar().
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
// Whether the `menu` slot holds items now. A layout that moves its items in and out of the slot keeps it and says
|
|
14
|
+
// when it holds any: with none, the menu shows only the page's actions, or no menu button without them.
|
|
15
|
+
menuItems: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: true
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
11
21
|
const { t } = useJskitText();
|
|
12
22
|
/** @type {import("../support/pageActions.js").ShellPageActionsRegistry} */
|
|
13
23
|
const registry = inject(SHELL_PAGE_ACTIONS_REGISTRY_KEY, NO_SHELL_PAGE_ACTIONS_REGISTRY);
|
|
14
24
|
const menuEntries = registry.menuEntries;
|
|
15
25
|
const moreLabel = computed(() => t("jskit.shell.actions.more"));
|
|
16
26
|
const slots = useSlots();
|
|
27
|
+
const menuOpen = ref(false);
|
|
28
|
+
|
|
29
|
+
// Read as the menu renders, since slots are not reactive.
|
|
30
|
+
function showsItems() {
|
|
31
|
+
return props.menuItems && Boolean(slots.menu);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function showsMenu() {
|
|
35
|
+
return menuEntries.value.length > 0 || showsItems();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Nothing left to show, such as the last item moving back to a bar that has grown: the menu closes.
|
|
39
|
+
watch(showsMenu, (shows) => {
|
|
40
|
+
if (!shows) {
|
|
41
|
+
menuOpen.value = false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
17
44
|
|
|
18
45
|
// A menu item's props: the action's own attributes, then its label, icon, colour, link or download, and state.
|
|
19
46
|
function itemProps(entry) {
|
|
@@ -35,9 +62,9 @@ function itemProps(entry) {
|
|
|
35
62
|
|
|
36
63
|
<template>
|
|
37
64
|
<div :id="SHELL_PAGE_ACTIONS_ID" class="shell-page-actions-target" />
|
|
38
|
-
<v-menu v-if="menuEntries.length > 0 || slots.menu" location="bottom end">
|
|
65
|
+
<v-menu v-if="menuEntries.length > 0 || slots.menu" v-model="menuOpen" location="bottom end" :eager="Boolean(slots.menu)">
|
|
39
66
|
<template #activator="{ props: menuProps }">
|
|
40
|
-
<v-tooltip :text="moreLabel" location="bottom">
|
|
67
|
+
<v-tooltip v-if="showsMenu()" :text="moreLabel" location="bottom">
|
|
41
68
|
<template #activator="{ props: tooltipProps }">
|
|
42
69
|
<v-btn
|
|
43
70
|
v-bind="mergeProps(menuProps, tooltipProps)"
|
|
@@ -71,7 +98,7 @@ function itemProps(entry) {
|
|
|
71
98
|
@click="entry.activate"
|
|
72
99
|
/>
|
|
73
100
|
</v-list>
|
|
74
|
-
<div class="shell-page-actions-target__items" data-testid="jskit-shell-page-actions-overflow-items">
|
|
101
|
+
<div v-show="showsItems()" class="shell-page-actions-target__items" data-testid="jskit-shell-page-actions-overflow-items">
|
|
75
102
|
<slot name="menu" />
|
|
76
103
|
</div>
|
|
77
104
|
</v-sheet>
|
|
@@ -15,10 +15,11 @@ import {
|
|
|
15
15
|
import { useJskitText } from "../i18n.js";
|
|
16
16
|
import ShellSectionTabLinkItem from "./ShellSectionTabLinkItem.vue";
|
|
17
17
|
|
|
18
|
-
// A Material 3 navigation bar destination:
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
18
|
+
// A Material 3 navigation bar destination: its icon and its label below, which @jskit-ai/material-web's material.css
|
|
19
|
+
// draws as it draws every v-bottom-navigation's buttons (the icon in its 64x32 indicator); the active one's icon is
|
|
20
|
+
// the filled one. It is one only in ShellLayout's navigation bar; placed anywhere else (a page's section tabs), it is
|
|
21
|
+
// a section tab, ShellSectionTabLinkItem, which a page.section-nav names itself. In the bar it is a text button, so
|
|
22
|
+
// no app's filled-button defaults fill it.
|
|
22
23
|
const props = defineProps(shellNavigationLinkProps);
|
|
23
24
|
/** @type {{ value: string }} */
|
|
24
25
|
const presentation = inject(SHELL_NAVIGATION_PRESENTATION_KEY, NO_SHELL_NAVIGATION_PRESENTATION);
|
|
@@ -40,7 +41,7 @@ const displayIcon = computed(() =>
|
|
|
40
41
|
<ShellSectionTabLinkItem v-if="!inNavigationBar" v-bind="props" />
|
|
41
42
|
<v-btn
|
|
42
43
|
v-else-if="resolvedTarget.href"
|
|
43
|
-
class="tab-link-item
|
|
44
|
+
class="tab-link-item"
|
|
44
45
|
:class="{ 'tab-link-item--active': active }"
|
|
45
46
|
:to="resolvedTarget.sameOrigin ? resolvedTarget.href : undefined"
|
|
46
47
|
:href="resolvedTarget.sameOrigin ? undefined : resolvedTarget.href"
|
|
@@ -49,82 +50,26 @@ const displayIcon = computed(() =>
|
|
|
49
50
|
:exact="props.exact"
|
|
50
51
|
:ripple="false"
|
|
51
52
|
variant="text"
|
|
52
|
-
color="on-surface-variant"
|
|
53
53
|
min-width="0"
|
|
54
54
|
stacked
|
|
55
55
|
>
|
|
56
|
-
<
|
|
57
|
-
<v-icon v-if="displayIcon" :icon="displayIcon" />
|
|
58
|
-
</span>
|
|
56
|
+
<v-icon v-if="displayIcon" :icon="displayIcon" />
|
|
59
57
|
<span class="tab-link-item__label">{{ resolvedLabel || t("jskit.shell.layout.tab") }}</span>
|
|
60
58
|
</v-btn>
|
|
61
59
|
</template>
|
|
62
60
|
|
|
63
61
|
<style scoped>
|
|
64
62
|
.tab-link-item {
|
|
65
|
-
color: rgb(var(--v-theme-on-surface-variant));
|
|
66
63
|
flex: 1 1 0;
|
|
67
64
|
height: 100%;
|
|
68
65
|
min-height: 48px;
|
|
69
66
|
padding-inline: 0;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
.tab-link-item > :deep(.v-btn__overlay),
|
|
73
|
-
.tab-link-item > :deep(.v-btn__underlay) {
|
|
74
|
-
display: none;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.tab-link-item :deep(.v-btn__content) {
|
|
78
|
-
flex-direction: column;
|
|
79
|
-
gap: 4px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.tab-link-item__indicator {
|
|
83
|
-
align-items: center;
|
|
84
|
-
border-radius: 16px;
|
|
85
|
-
display: flex;
|
|
86
|
-
height: 32px;
|
|
87
|
-
justify-content: center;
|
|
88
|
-
overflow: hidden;
|
|
89
|
-
position: relative;
|
|
90
|
-
width: 64px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.tab-link-item__indicator::before {
|
|
94
|
-
background: currentColor;
|
|
95
|
-
content: "";
|
|
96
|
-
inset: 0;
|
|
97
|
-
opacity: 0;
|
|
98
|
-
position: absolute;
|
|
99
|
-
transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.tab-link-item:hover .tab-link-item__indicator::before {
|
|
103
|
-
opacity: var(--v-hover-opacity);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.tab-link-item:focus-visible .tab-link-item__indicator::before,
|
|
107
|
-
.tab-link-item:active .tab-link-item__indicator::before {
|
|
108
|
-
opacity: var(--v-focus-opacity);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.tab-link-item--active .tab-link-item__indicator {
|
|
112
|
-
background: rgb(var(--v-theme-secondary-container));
|
|
113
|
-
color: rgb(var(--v-theme-on-secondary-container));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
69
|
.tab-link-item__label {
|
|
117
|
-
font-size: 0.75rem;
|
|
118
|
-
font-weight: 500;
|
|
119
|
-
letter-spacing: 0.03125rem;
|
|
120
|
-
line-height: 1rem;
|
|
121
70
|
max-width: 5.5rem;
|
|
122
71
|
overflow: hidden;
|
|
123
72
|
text-overflow: ellipsis;
|
|
124
73
|
white-space: nowrap;
|
|
125
74
|
}
|
|
126
|
-
|
|
127
|
-
.tab-link-item--active .tab-link-item__label {
|
|
128
|
-
color: rgb(var(--v-theme-on-surface));
|
|
129
|
-
}
|
|
130
75
|
</style>
|
|
@@ -26,8 +26,9 @@ function navigationDrawerElement() {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* The shell's navigation drawer: what opens it on each layout, how it presents, and how wide it is. The drawer is
|
|
29
|
-
* modal on compact and medium windows and a standard drawer, collapsing to a rail, on expanded ones. It
|
|
30
|
-
*
|
|
29
|
+
* modal on compact and medium windows and a standard drawer, collapsing to a rail, on expanded ones. It fits its labels
|
|
30
|
+
* and identity, within Material 3's 360dp and leaving a modal drawer's 56dp of the page, unless `drawerWidth` is
|
|
31
|
+
* "material" (Material 3's full width) or a number, which fixes it.
|
|
31
32
|
* @param {object} options
|
|
32
33
|
* @param {{ desktopDrawerClosedMode: string, drawerWidth: number | string | null, railWidth: number, navigationItemSpacing: number }} options.props
|
|
33
34
|
* @param {import("vue").Ref<boolean>} options.modalLayout
|
|
@@ -57,13 +58,14 @@ function useShellDrawer({ props, modalLayout, viewportWidth, navigationToggle, l
|
|
|
57
58
|
modal: modalLayout.value,
|
|
58
59
|
open: drawerOpen.value
|
|
59
60
|
}));
|
|
60
|
-
const fixedDrawerWidth = computed(() => props.drawerWidth
|
|
61
|
+
const fixedDrawerWidth = computed(() => !["content", null, undefined].includes(props.drawerWidth));
|
|
61
62
|
const resolvedDrawerWidth = computed(() => {
|
|
63
|
+
const materialWidth = resolveMaterialDrawerWidth({ modal: modalLayout.value, viewportWidth: viewportWidth.value });
|
|
62
64
|
if (!fixedDrawerWidth.value) {
|
|
63
|
-
return normalizeShellDrawerWidth(measuredDrawerWidth.value);
|
|
65
|
+
return Math.min(normalizeShellDrawerWidth(measuredDrawerWidth.value), materialWidth);
|
|
64
66
|
}
|
|
65
|
-
if (props.drawerWidth ===
|
|
66
|
-
return
|
|
67
|
+
if (props.drawerWidth === "material") {
|
|
68
|
+
return materialWidth;
|
|
67
69
|
}
|
|
68
70
|
return normalizeShellDrawerWidth(props.drawerWidth);
|
|
69
71
|
});
|