@jskit-ai/shell-web 0.2.11 → 0.2.12
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 +1 -0
- package/fixtures/adaptive-shell/src/App.vue +5 -0
- package/fixtures/adaptive-shell/src/OwnBarLayout.vue +24 -0
- package/fixtures/adaptive-shell/src/StudioPage.vue +26 -0
- package/fixtures/adaptive-shell/src/main.js +4 -0
- package/package.json +7 -2
- package/src/client/components/ShellLayout.vue +12 -61
- package/src/client/components/ShellPageActions.vue +2 -2
- package/src/client/components/ShellPageActionsTarget.vue +24 -0
- package/src/client/components/ShellPageTitle.vue +49 -0
- package/src/client/components/ShellUpButton.vue +29 -0
- package/src/client/composables/useShellAppBar.js +27 -0
- package/src/client/index.js +4 -0
- package/test/adaptiveShell.browser.test.js +44 -0
- package/test/settingsPlacementContract.test.js +19 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- The application-shell pattern's not-found view renders in the shell, so the top app bar carries its title and the navigation leads back into the app; the shell foundation has it too.
|
|
8
8
|
- `ShellListDetail` lays out list-detail pages such as settings: the list beside the open detail on expanded windows (with the landing child as the empty detail), one pane at a time on narrower ones. The foundation and shell patterns' settings pages use it instead of redirecting their landing page to the first section.
|
|
9
9
|
- The drawer is 360dp wide by default; `drawerWidth="content"` fits it to its labels. A modal drawer (compact and medium windows) opens over the app bar and closes from its scrim or Escape. The drawer's divider shows only between primary and secondary destinations. The `--shell-chrome-*` custom properties, the rail and drawer item tooltips and `@mdi/js` are gone.
|
|
10
|
+
- A layout that draws its own top app bar builds it from the pieces of `ShellLayout`'s bar: `ShellUpButton` (the Up arrow, shown only on inner pages), `ShellPageTitle` (the page's one `h1`) and `ShellPageActionsTarget`, with `useShellAppBar()` once in the layout so its pages enter the trail and their `ShellPageActions` show in its bar. `ShellLayout` is built from the same pieces and looks and behaves as before.
|
|
10
11
|
- Upgrading: see the guide's [Move an app to the Material 3 defaults](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/material-3-migration).
|
|
11
12
|
|
|
12
13
|
## 0.2.0 - 2026-10-29
|
|
@@ -4,10 +4,12 @@ import { RouterView, useRoute } from "vue-router";
|
|
|
4
4
|
import { useTheme } from "vuetify";
|
|
5
5
|
import ShellLayout from "@jskit-ai/shell-web/client/components/ShellLayout";
|
|
6
6
|
import ShellErrorHost from "@jskit-ai/shell-web/client/components/ShellErrorHost";
|
|
7
|
+
import OwnBarLayout from "./OwnBarLayout.vue";
|
|
7
8
|
|
|
8
9
|
const route = useRoute();
|
|
9
10
|
const theme = useTheme();
|
|
10
11
|
const bare = computed(() => route.meta.bare === true);
|
|
12
|
+
const ownBar = computed(() => route.meta.ownBar === true);
|
|
11
13
|
const surface = computed(() => route.path.startsWith("/w/") ? "admin" : "home");
|
|
12
14
|
const surfaceLabel = computed(() => surface.value === "admin" ? "Admin" : "Home");
|
|
13
15
|
const themeMode = computed(() => route.query.theme === "dark" ? "dark" : "light");
|
|
@@ -26,6 +28,9 @@ watchEffect(function applyFixtureTheme() {
|
|
|
26
28
|
<template>
|
|
27
29
|
<v-app>
|
|
28
30
|
<RouterView v-if="bare" />
|
|
31
|
+
<OwnBarLayout v-else-if="ownBar">
|
|
32
|
+
<RouterView />
|
|
33
|
+
</OwnBarLayout>
|
|
29
34
|
<ShellLayout
|
|
30
35
|
v-else
|
|
31
36
|
:surface="surface"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import ShellPageActionsTarget from "@jskit-ai/shell-web/client/components/ShellPageActionsTarget";
|
|
3
|
+
import ShellPageTitle from "@jskit-ai/shell-web/client/components/ShellPageTitle";
|
|
4
|
+
import ShellUpButton from "@jskit-ai/shell-web/client/components/ShellUpButton";
|
|
5
|
+
import { useShellAppBar } from "@jskit-ai/shell-web/client/composables/useShellAppBar";
|
|
6
|
+
|
|
7
|
+
// A layout that draws its own top app bar, as a workspace bar with the app's own controls does, from the shell's
|
|
8
|
+
// pieces: Up, the page title and the page's actions.
|
|
9
|
+
useShellAppBar();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<v-app-bar color="surface" flat :height="64" data-testid="fixture-own-bar">
|
|
14
|
+
<ShellUpButton />
|
|
15
|
+
<div class="flex-grow-1 px-3 text-truncate">
|
|
16
|
+
<ShellPageTitle title="Studio" />
|
|
17
|
+
</div>
|
|
18
|
+
<ShellPageActionsTarget />
|
|
19
|
+
<v-btn variant="text" data-testid="fixture-workspace-control">Workspace</v-btn>
|
|
20
|
+
</v-app-bar>
|
|
21
|
+
<v-main class="bg-background">
|
|
22
|
+
<slot />
|
|
23
|
+
</v-main>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { RouterLink, useRoute } from "vue-router";
|
|
4
|
+
import ShellPageAction from "../../../src/client/components/ShellPageAction.vue";
|
|
5
|
+
import ShellPageActions from "../../../src/client/components/ShellPageActions.vue";
|
|
6
|
+
import { useShellPageTitle } from "../../../src/client/composables/useShellPageTitle.js";
|
|
7
|
+
import { usePaths } from "../../../src/client/navigation/usePaths.js";
|
|
8
|
+
import { records } from "./records.js";
|
|
9
|
+
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const paths = usePaths();
|
|
12
|
+
const record = computed(() => records.contacts.find((item) => item.id === route.params.id) || null);
|
|
13
|
+
|
|
14
|
+
useShellPageTitle(() => (route.params.id ? record.value?.name || "Not found" : ""));
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<section>
|
|
19
|
+
<ShellPageActions v-if="record">
|
|
20
|
+
<ShellPageAction label="Run" primary />
|
|
21
|
+
</ShellPageActions>
|
|
22
|
+
<p v-else>
|
|
23
|
+
<RouterLink :to="paths.page('/studio/ada')">Ada Lovelace</RouterLink>
|
|
24
|
+
</p>
|
|
25
|
+
</section>
|
|
26
|
+
</template>
|
|
@@ -13,6 +13,7 @@ import { adminTheme, theme } from "./theme/index.js";
|
|
|
13
13
|
import RecordListPage from "./RecordListPage.vue";
|
|
14
14
|
import RecordPage from "./RecordPage.vue";
|
|
15
15
|
import ScreenPage from "./ScreenPage.vue";
|
|
16
|
+
import StudioPage from "./StudioPage.vue";
|
|
16
17
|
import SettingsPage from "./SettingsPage.vue";
|
|
17
18
|
import ShellMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellMenuLinkItem";
|
|
18
19
|
import ShellSurfaceAwareMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellSurfaceAwareMenuLinkItem";
|
|
@@ -161,6 +162,9 @@ const routes = [
|
|
|
161
162
|
beforeEnter: refuseBlockedRecord,
|
|
162
163
|
meta: { kind: "suppliers", jskit: { parent: "/suppliers" } }
|
|
163
164
|
},
|
|
165
|
+
// A layout that draws its own top app bar from the shell's pieces.
|
|
166
|
+
{ path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
|
|
167
|
+
{ path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
|
|
164
168
|
{ path: "/home/:section?", component: ScreenPage, meta: { title: "Home surface" } },
|
|
165
169
|
{ path: "/w/:workspaceSlug/admin/:section?", component: ScreenPage, meta: { title: "Admin surface" } },
|
|
166
170
|
{ path: "/help", component: ScreenPage, meta: { title: "Help and support" } },
|
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.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"./client/components/ShellPageActions": "./src/client/components/ShellPageActions.vue",
|
|
29
29
|
"./client/components/ShellPageAction": "./src/client/components/ShellPageAction.vue",
|
|
30
30
|
"./client/components/ShellListDetail": "./src/client/components/ShellListDetail.vue",
|
|
31
|
+
"./client/components/ShellUpButton": "./src/client/components/ShellUpButton.vue",
|
|
32
|
+
"./client/components/ShellPageTitle": "./src/client/components/ShellPageTitle.vue",
|
|
33
|
+
"./client/components/ShellPageActionsTarget": "./src/client/components/ShellPageActionsTarget.vue",
|
|
34
|
+
"./client/composables/useShellAppBar": "./src/client/composables/useShellAppBar.js",
|
|
31
35
|
"./client/composables/useShellLayoutState": "./src/client/composables/useShellLayoutState.js",
|
|
32
36
|
"./client/composables/useShellPageTitle": "./src/client/composables/useShellPageTitle.js",
|
|
33
37
|
"./client/composables/useShellWindowSizeClass": "./src/client/composables/useShellWindowSizeClass.js",
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
"@jskit-ai/architecture-inspector": "0.1.8"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@jskit-ai/material-web": "0.1.
|
|
49
|
+
"@jskit-ai/material-web": "0.1.1",
|
|
46
50
|
"@vue/compiler-sfc": "3.5.44"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
@@ -88,6 +92,7 @@
|
|
|
88
92
|
"@jskit-ai/shell-web/client/navigation/useSurfaceRouteContext",
|
|
89
93
|
"@jskit-ai/shell-web/client/navigation/useShellNavigation",
|
|
90
94
|
"@jskit-ai/shell-web/client/navigation/documentNavigation",
|
|
95
|
+
"@jskit-ai/shell-web/client/composables/useShellAppBar",
|
|
91
96
|
"@jskit-ai/shell-web/client/composables/useShellLayoutState",
|
|
92
97
|
"@jskit-ai/shell-web/client/composables/useShellPageTitle",
|
|
93
98
|
"@jskit-ai/shell-web/client/composables/useShellWindowSizeClass",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, inject, onBeforeUnmount, onMounted,
|
|
3
|
-
import { useRoute } from "vue-router";
|
|
2
|
+
import { computed, inject, onBeforeUnmount, onMounted, ref } from "vue";
|
|
4
3
|
import { useDisplay } from "vuetify";
|
|
4
|
+
import { useShellAppBar } from "../composables/useShellAppBar.js";
|
|
5
5
|
import { useShellDrawer } from "../composables/useShellDrawer.js";
|
|
6
6
|
import { useShellLayoutState } from "../composables/useShellLayoutState.js";
|
|
7
7
|
import { useShellPullToRefresh } from "../composables/useShellPullToRefresh.js";
|
|
@@ -10,15 +10,16 @@ import {
|
|
|
10
10
|
DEFAULT_SHELL_RAIL_WIDTH
|
|
11
11
|
} from "../support/drawerWidth.js";
|
|
12
12
|
import { normalizeDesktopDrawerClosedMode } from "../support/drawerPresentation.js";
|
|
13
|
-
import { SHELL_PAGE_ACTIONS_ID, SHELL_PAGE_ACTIONS_TARGET_KEY } from "../support/navigationPresentation.js";
|
|
14
13
|
import { resolveShellLayoutClass } from "../support/shellLayoutClass.js";
|
|
15
14
|
import { resolveWindowSizeClass } from "../support/windowSizeClass.js";
|
|
16
15
|
import { NO_SHELL_WEB_REFRESH_RUNTIME, SHELL_WEB_REFRESH_RUNTIME_KEY } from "../runtime/refreshRuntime.js";
|
|
17
|
-
import {
|
|
18
|
-
import { useShellNavigation, useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
|
|
16
|
+
import { useShellNavigation } from "../navigation/useShellNavigation.js";
|
|
19
17
|
import ShellNavigationScope from "./ShellNavigationScope.vue";
|
|
20
18
|
import ShellOutlet from "./ShellOutlet.vue";
|
|
19
|
+
import ShellPageActionsTarget from "./ShellPageActionsTarget.vue";
|
|
20
|
+
import ShellPageTitle from "./ShellPageTitle.vue";
|
|
21
21
|
import ShellRouteTransition from "./ShellRouteTransition.vue";
|
|
22
|
+
import ShellUpButton from "./ShellUpButton.vue";
|
|
22
23
|
import { useJskitText } from "../i18n.js";
|
|
23
24
|
|
|
24
25
|
const { t, text } = useJskitText();
|
|
@@ -72,14 +73,11 @@ const {
|
|
|
72
73
|
resolvedSurfaceLabel
|
|
73
74
|
} = layoutState;
|
|
74
75
|
const display = useDisplay();
|
|
75
|
-
const route = useRoute();
|
|
76
76
|
/** @type {import("../types.js").ShellRefreshRuntime} */
|
|
77
77
|
const refreshRuntime = inject(SHELL_WEB_REFRESH_RUNTIME_KEY, NO_SHELL_WEB_REFRESH_RUNTIME);
|
|
78
|
-
const
|
|
79
|
-
const { canGoUp, up } = useShellNavigation();
|
|
78
|
+
const { canGoUp } = useShellNavigation();
|
|
80
79
|
const navigationToggle = ref(null);
|
|
81
80
|
const scrolled = ref(false);
|
|
82
|
-
let releaseShell = null;
|
|
83
81
|
|
|
84
82
|
const viewportWidth = computed(() => display.width.value);
|
|
85
83
|
const sizeClass = computed(() => resolveWindowSizeClass(display.width.value));
|
|
@@ -111,39 +109,24 @@ const standardDrawerVisible = computed(() => !modalLayout.value && drawerPresent
|
|
|
111
109
|
// The menu control sits in the rail or drawer header when one shows, otherwise first in the app bar of a top-level
|
|
112
110
|
// page; an inner page's leading slot is its Up arrow.
|
|
113
111
|
const toggleInAppBar = computed(() => !showsMediumRail.value && !standardDrawerVisible.value);
|
|
114
|
-
const
|
|
115
|
-
const source = navigationRuntime.pageTitleSource.value;
|
|
116
|
-
const runtimeTitle = typeof source === "function" ? source() : "";
|
|
117
|
-
return (
|
|
118
|
-
text(runtimeTitle) ||
|
|
119
|
-
text(resolvePageTitle(route.matched)) ||
|
|
120
|
-
text(props.title) ||
|
|
121
|
-
resolvedSurfaceLabel.value
|
|
122
|
-
);
|
|
123
|
-
});
|
|
112
|
+
const fallbackTitle = computed(() => text(props.title) || resolvedSurfaceLabel.value);
|
|
124
113
|
const navigationStyle = computed(() => ({
|
|
125
114
|
"--shell-navigation-item-spacing": `${resolvedNavigationItemSpacing.value}px`,
|
|
126
115
|
"--shell-navigation-rail-width": `${resolvedRailWidth.value}px`
|
|
127
116
|
}));
|
|
128
117
|
|
|
129
|
-
|
|
118
|
+
useShellAppBar();
|
|
130
119
|
|
|
131
120
|
function updateScrolled() {
|
|
132
121
|
scrolled.value = window.scrollY > 0;
|
|
133
122
|
}
|
|
134
123
|
|
|
135
|
-
function goUp() {
|
|
136
|
-
void up();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
124
|
onMounted(() => {
|
|
140
|
-
releaseShell = navigationRuntime.attachShell();
|
|
141
125
|
window.addEventListener("scroll", updateScrolled, { passive: true });
|
|
142
126
|
updateScrolled();
|
|
143
127
|
});
|
|
144
128
|
|
|
145
129
|
onBeforeUnmount(() => {
|
|
146
|
-
releaseShell?.();
|
|
147
130
|
window.removeEventListener("scroll", updateScrolled);
|
|
148
131
|
});
|
|
149
132
|
</script>
|
|
@@ -159,19 +142,7 @@ onBeforeUnmount(() => {
|
|
|
159
142
|
:data-size-class="sizeClass"
|
|
160
143
|
>
|
|
161
144
|
<div class="shell-layout__app-bar-row">
|
|
162
|
-
<v-
|
|
163
|
-
v-if="canGoUp"
|
|
164
|
-
class="shell-layout__leading"
|
|
165
|
-
icon
|
|
166
|
-
variant="text"
|
|
167
|
-
color="on-surface"
|
|
168
|
-
data-testid="jskit-shell-back"
|
|
169
|
-
:aria-label="t('jskit.shell.actions.back')"
|
|
170
|
-
@click="goUp"
|
|
171
|
-
>
|
|
172
|
-
<v-icon icon="$arrowBack" />
|
|
173
|
-
<v-tooltip activator="parent" location="bottom" :text="t('jskit.shell.actions.back')" />
|
|
174
|
-
</v-btn>
|
|
145
|
+
<ShellUpButton v-if="canGoUp" class="shell-layout__leading" />
|
|
175
146
|
<v-btn
|
|
176
147
|
v-else-if="toggleInAppBar"
|
|
177
148
|
ref="navigationToggle"
|
|
@@ -187,13 +158,11 @@ onBeforeUnmount(() => {
|
|
|
187
158
|
/>
|
|
188
159
|
|
|
189
160
|
<div class="shell-layout__headline" :class="{ 'shell-layout__headline--leading': canGoUp || toggleInAppBar }">
|
|
190
|
-
<
|
|
191
|
-
{{ pageTitle }}
|
|
192
|
-
</h1>
|
|
161
|
+
<ShellPageTitle :title="fallbackTitle" />
|
|
193
162
|
<p v-if="props.subtitle" class="shell-layout__page-subtitle">{{ text(props.subtitle) }}</p>
|
|
194
163
|
</div>
|
|
195
164
|
|
|
196
|
-
<
|
|
165
|
+
<ShellPageActionsTarget />
|
|
197
166
|
|
|
198
167
|
<slot name="top-right" :surface="resolvedSurface">
|
|
199
168
|
<div class="shell-layout__top-right">
|
|
@@ -403,19 +372,6 @@ onBeforeUnmount(() => {
|
|
|
403
372
|
padding-inline-start: 4px;
|
|
404
373
|
}
|
|
405
374
|
|
|
406
|
-
.shell-layout__page-title {
|
|
407
|
-
color: rgb(var(--v-theme-on-surface));
|
|
408
|
-
font-size: 1.375rem;
|
|
409
|
-
font-weight: 400;
|
|
410
|
-
letter-spacing: 0;
|
|
411
|
-
line-height: 1.75rem;
|
|
412
|
-
margin: 0;
|
|
413
|
-
outline: none;
|
|
414
|
-
overflow: hidden;
|
|
415
|
-
text-overflow: ellipsis;
|
|
416
|
-
white-space: nowrap;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
375
|
.shell-layout__page-subtitle {
|
|
420
376
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
421
377
|
font-size: 0.75rem;
|
|
@@ -428,7 +384,6 @@ onBeforeUnmount(() => {
|
|
|
428
384
|
white-space: nowrap;
|
|
429
385
|
}
|
|
430
386
|
|
|
431
|
-
.shell-layout__page-actions,
|
|
432
387
|
.shell-layout__top-right {
|
|
433
388
|
align-items: center;
|
|
434
389
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
@@ -437,10 +392,6 @@ onBeforeUnmount(() => {
|
|
|
437
392
|
min-width: 0;
|
|
438
393
|
}
|
|
439
394
|
|
|
440
|
-
.shell-layout__page-actions:empty {
|
|
441
|
-
display: none;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
395
|
/* Navigation rail (medium windows, and expanded ones with the drawer collapsed): 80dp, menu control on top. */
|
|
445
396
|
.shell-layout__rail,
|
|
446
397
|
.shell-layout__drawer {
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The app bar's actions target. The current page's actions show in the shell's top app bar after the page title
|
|
10
|
-
* (Material 3 puts a page's actions there); put ShellPageAction buttons inside. Outside a
|
|
11
|
-
* where they are written.
|
|
10
|
+
* (Material 3 puts a page's actions there); put ShellPageAction buttons inside. Outside a layout that owns the top
|
|
11
|
+
* app bar (ShellLayout, or one that calls useShellAppBar()) they render where they are written.
|
|
12
12
|
* @type {string}
|
|
13
13
|
*/
|
|
14
14
|
const target = inject(SHELL_PAGE_ACTIONS_TARGET_KEY, NO_SHELL_PAGE_ACTIONS_TARGET);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { SHELL_PAGE_ACTIONS_ID } from "../support/navigationPresentation.js";
|
|
3
|
+
|
|
4
|
+
// Where the current page's ShellPageActions show: after the page title in the top app bar. ShellLayout's bar has it;
|
|
5
|
+
// a layout that draws its own top app bar renders it once there and calls useShellAppBar().
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div :id="SHELL_PAGE_ACTIONS_ID" class="shell-page-actions-target" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<style scoped>
|
|
13
|
+
.shell-page-actions-target {
|
|
14
|
+
align-items: center;
|
|
15
|
+
color: rgb(var(--v-theme-on-surface-variant));
|
|
16
|
+
display: flex;
|
|
17
|
+
flex: 0 0 auto;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.shell-page-actions-target:empty {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useRoute } from "vue-router";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
5
|
+
import { PAGE_TITLE_ID, resolvePageTitle } from "../navigation/shellNavigationRuntime.js";
|
|
6
|
+
import { useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
|
|
7
|
+
|
|
8
|
+
// The page's one h1, in the top app bar: the title the page sets (useShellPageTitle), else its route's
|
|
9
|
+
// meta.jskit.title, else `title`. The shell moves focus here after navigation. ShellLayout's bar shows it; a layout
|
|
10
|
+
// that draws its own top app bar renders it once in that bar.
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
// The title of pages that declare none and set none. A message key or plain text.
|
|
13
|
+
title: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: ""
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const { text } = useJskitText();
|
|
20
|
+
const route = useRoute();
|
|
21
|
+
const navigationRuntime = useShellNavigationRuntime();
|
|
22
|
+
const pageTitle = computed(() => {
|
|
23
|
+
const source = navigationRuntime.pageTitleSource.value;
|
|
24
|
+
const runtimeTitle = typeof source === "function" ? source() : "";
|
|
25
|
+
return text(runtimeTitle) || text(resolvePageTitle(route.matched)) || text(props.title);
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<h1 :id="PAGE_TITLE_ID" class="shell-page-title" tabindex="-1" data-testid="jskit-shell-page-title">
|
|
31
|
+
{{ pageTitle }}
|
|
32
|
+
</h1>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style scoped>
|
|
36
|
+
/* Material 3 small top app bar headline: title-large. */
|
|
37
|
+
.shell-page-title {
|
|
38
|
+
color: rgb(var(--v-theme-on-surface));
|
|
39
|
+
font-size: 1.375rem;
|
|
40
|
+
font-weight: 400;
|
|
41
|
+
letter-spacing: 0;
|
|
42
|
+
line-height: 1.75rem;
|
|
43
|
+
margin: 0;
|
|
44
|
+
outline: none;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
text-overflow: ellipsis;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useJskitText } from "../i18n.js";
|
|
3
|
+
import { useShellNavigation } from "../navigation/useShellNavigation.js";
|
|
4
|
+
|
|
5
|
+
// The top app bar's Up arrow. On an inner page (one that declares meta.jskit.parent) it returns to where the person
|
|
6
|
+
// came from or else to that parent, through JSKIT navigation; on a top-level page it renders nothing. ShellLayout's
|
|
7
|
+
// bar shows it; a layout that draws its own top app bar puts it first in that bar and calls useShellAppBar().
|
|
8
|
+
const { t } = useJskitText();
|
|
9
|
+
const { canGoUp, up } = useShellNavigation();
|
|
10
|
+
|
|
11
|
+
function goUp() {
|
|
12
|
+
void up();
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<v-btn
|
|
18
|
+
v-if="canGoUp"
|
|
19
|
+
icon
|
|
20
|
+
variant="text"
|
|
21
|
+
color="on-surface"
|
|
22
|
+
data-testid="jskit-shell-back"
|
|
23
|
+
:aria-label="t('jskit.shell.actions.back')"
|
|
24
|
+
@click="goUp"
|
|
25
|
+
>
|
|
26
|
+
<v-icon icon="$arrowBack" />
|
|
27
|
+
<v-tooltip activator="parent" location="bottom" :text="t('jskit.shell.actions.back')" />
|
|
28
|
+
</v-btn>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, provide } from "vue";
|
|
2
|
+
import { useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
|
|
3
|
+
import { SHELL_PAGE_ACTIONS_ID, SHELL_PAGE_ACTIONS_TARGET_KEY } from "../support/navigationPresentation.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes the calling layout the owner of the shell's top app bar: the pages it renders enter the navigation trail, so
|
|
7
|
+
* Up returns to where a page was opened from, and their ShellPageActions show in its ShellPageActionsTarget.
|
|
8
|
+
* ShellLayout calls it. A layout that draws its own top app bar calls it once and renders ShellUpButton,
|
|
9
|
+
* ShellPageTitle and ShellPageActionsTarget in that bar.
|
|
10
|
+
*/
|
|
11
|
+
function useShellAppBar() {
|
|
12
|
+
const navigationRuntime = useShellNavigationRuntime();
|
|
13
|
+
let release = null;
|
|
14
|
+
|
|
15
|
+
provide(SHELL_PAGE_ACTIONS_TARGET_KEY, `#${SHELL_PAGE_ACTIONS_ID}`);
|
|
16
|
+
|
|
17
|
+
onMounted(() => {
|
|
18
|
+
release = navigationRuntime.attachShell();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
onBeforeUnmount(() => {
|
|
22
|
+
release?.();
|
|
23
|
+
release = null;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useShellAppBar };
|
package/src/client/index.js
CHANGED
|
@@ -13,6 +13,10 @@ export { default as ShellTabLinkItem } from "./components/ShellTabLinkItem.vue";
|
|
|
13
13
|
export { default as ShellPageActions } from "./components/ShellPageActions.vue";
|
|
14
14
|
export { default as ShellPageAction } from "./components/ShellPageAction.vue";
|
|
15
15
|
export { default as ShellListDetail } from "./components/ShellListDetail.vue";
|
|
16
|
+
export { default as ShellUpButton } from "./components/ShellUpButton.vue";
|
|
17
|
+
export { default as ShellPageTitle } from "./components/ShellPageTitle.vue";
|
|
18
|
+
export { default as ShellPageActionsTarget } from "./components/ShellPageActionsTarget.vue";
|
|
19
|
+
export { useShellAppBar } from "./composables/useShellAppBar.js";
|
|
16
20
|
export { useShellLayoutState } from "./composables/useShellLayoutState.js";
|
|
17
21
|
export { useShellPageTitle } from "./composables/useShellPageTitle.js";
|
|
18
22
|
export { useShellWindowSizeClass } from "./composables/useShellWindowSizeClass.js";
|
|
@@ -452,6 +452,50 @@ test("shell-web's app bar fills with surface-container once the page scrolls und
|
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
454
|
|
|
455
|
+
test("shell-web's bar pieces give a layout that draws its own top app bar the shell's Up, title and actions", {
|
|
456
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
457
|
+
timeout: 120_000
|
|
458
|
+
}, async () => {
|
|
459
|
+
const vite = await startViteFixture({ fixtureRoot: FIXTURE_ROOT });
|
|
460
|
+
let browser;
|
|
461
|
+
try {
|
|
462
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
463
|
+
for (const viewport of DEFAULT_VIEWPORTS) {
|
|
464
|
+
const page = await browser.newPage({
|
|
465
|
+
baseURL: vite.baseURL,
|
|
466
|
+
viewport: { width: viewport.width, height: viewport.height }
|
|
467
|
+
});
|
|
468
|
+
const at = `${viewport.width}px`;
|
|
469
|
+
const ownBar = page.getByTestId("fixture-own-bar");
|
|
470
|
+
|
|
471
|
+
// A top-level page: the title is the page's one h1, in the app's own bar, with no arrow.
|
|
472
|
+
await page.goto("/home/studio");
|
|
473
|
+
await expect(ownBar.getByRole("heading", { level: 1, name: "Studio" }), at).toBeVisible();
|
|
474
|
+
await expect(page.getByRole("heading", { level: 1 }), at).toHaveCount(1);
|
|
475
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
476
|
+
|
|
477
|
+
// An inner page: Up, its title and its actions, in the app's own bar; Up returns along the trail.
|
|
478
|
+
await page.getByRole("link", { name: "Ada Lovelace", exact: true }).click();
|
|
479
|
+
await expect(page).toHaveURL(/\/home\/studio\/ada$/u);
|
|
480
|
+
await expect(ownBar.getByTestId("jskit-shell-page-title"), at).toHaveText("Ada Lovelace");
|
|
481
|
+
await expect(ownBar.getByTestId("jskit-shell-back"), at).toHaveAccessibleName("Back");
|
|
482
|
+
await expect(ownBar.getByRole("button", { name: "Run" }), at).toBeVisible();
|
|
483
|
+
await pressShellBack(page);
|
|
484
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
485
|
+
await expect(shellBackButton(page), at).toHaveCount(0);
|
|
486
|
+
|
|
487
|
+
// A pasted link goes Up to the declared parent.
|
|
488
|
+
await page.goto("/home/studio/ada");
|
|
489
|
+
await pressShellBack(page);
|
|
490
|
+
await expect(page).toHaveURL(/\/home\/studio$/u);
|
|
491
|
+
await page.close();
|
|
492
|
+
}
|
|
493
|
+
} finally {
|
|
494
|
+
await browser?.close();
|
|
495
|
+
await stopProcess(vite);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
|
|
455
499
|
async function openMainDestination(page, label) {
|
|
456
500
|
await page.getByRole("link", { name: label, exact: true }).filter({ visible: true }).first().click();
|
|
457
501
|
}
|
|
@@ -70,7 +70,21 @@ test("shell-web application pattern exposes surface-derived settings outlets", a
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
test("shell-web shell layout registers navigation at the app layout level", async () => {
|
|
73
|
+
const layoutSource = await readClientSources("components/ShellLayout.vue");
|
|
73
74
|
const source = await readClientSources("composables/useShellDrawer.js", "components/ShellLayout.vue");
|
|
75
|
+
const barPieces = await readClientSources(
|
|
76
|
+
"components/ShellUpButton.vue",
|
|
77
|
+
"components/ShellPageTitle.vue",
|
|
78
|
+
"components/ShellPageActionsTarget.vue",
|
|
79
|
+
"composables/useShellAppBar.js"
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// ShellLayout's bar is made of the pieces a layout with its own top app bar uses: one owner, no copy.
|
|
83
|
+
assert.match(layoutSource, /useShellAppBar\(\);/u);
|
|
84
|
+
assert.match(layoutSource, /<ShellUpButton v-if="canGoUp" class="shell-layout__leading" \/>/u);
|
|
85
|
+
assert.match(layoutSource, /<ShellPageTitle :title="fallbackTitle" \/>/u);
|
|
86
|
+
assert.match(layoutSource, /<ShellPageActionsTarget \/>/u);
|
|
87
|
+
assert.doesNotMatch(layoutSource, /\$arrowBack|PAGE_TITLE_ID|SHELL_PAGE_ACTIONS_ID|attachShell/u);
|
|
74
88
|
|
|
75
89
|
assert.doesNotMatch(source, /<v-layout\b/);
|
|
76
90
|
assert.doesNotMatch(source, /overflow-hidden/);
|
|
@@ -80,9 +94,11 @@ test("shell-web shell layout registers navigation at the app layout level", asyn
|
|
|
80
94
|
assert.match(source, /data-testid="jskit-shell-app-bar"/);
|
|
81
95
|
assert.match(source, /:height="64"/u);
|
|
82
96
|
assert.match(source, /:color="scrolled \? 'surface-container' : 'surface'"/u);
|
|
83
|
-
assert.match(
|
|
84
|
-
assert.match(
|
|
85
|
-
assert.match(
|
|
97
|
+
assert.match(barPieces, /data-testid="jskit-shell-back"[\s\S]*:aria-label="t\('jskit\.shell\.actions\.back'\)"/u);
|
|
98
|
+
assert.match(barPieces, /:id="PAGE_TITLE_ID"/u);
|
|
99
|
+
assert.match(barPieces, /:id="SHELL_PAGE_ACTIONS_ID"/u);
|
|
100
|
+
assert.match(barPieces, /provide\(SHELL_PAGE_ACTIONS_TARGET_KEY, `#\$\{SHELL_PAGE_ACTIONS_ID\}`\)/u);
|
|
101
|
+
assert.match(barPieces, /release = navigationRuntime\.attachShell\(\);/u);
|
|
86
102
|
assert.match(source, /shell-layout__surface-label/);
|
|
87
103
|
assert.doesNotMatch(source, /shell-layout__surface-chip/);
|
|
88
104
|
assert.doesNotMatch(source, /<v-chip[^>]*resolvedSurfaceLabel/);
|