@jskit-ai/shell-web 0.2.20 → 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 +1 -0
- package/README.md +15 -0
- package/fixtures/adaptive-shell/src/ComponentsPage.vue +53 -3
- package/package.json +4 -4
- package/src/client/components/ShellTabLinkItem.vue +7 -62
- package/test/adaptiveShell.browser.test.js +161 -1
- package/test/materialBaselines.browser.test.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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`).
|
|
5
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.
|
|
6
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.
|
|
7
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.
|
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.
|
|
@@ -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
|
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",
|
|
@@ -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>
|
|
@@ -768,7 +768,7 @@ test("a page's section tabs are Material 3 primary tabs at every width, and the
|
|
|
768
768
|
await expect(page.getByTestId("fixture-section-tabs").getByRole("link", { name: "Activity" })).toHaveAttribute("aria-current", "page");
|
|
769
769
|
if (viewport.name === "compact") {
|
|
770
770
|
// The navigation bar's destinations keep their 64x32 indicators.
|
|
771
|
-
const indicator = page.getByTestId("jskit-shell-bottom-nav").locator(".tab-link-
|
|
771
|
+
const indicator = page.getByTestId("jskit-shell-bottom-nav").locator(".tab-link-item .v-icon").first();
|
|
772
772
|
const box = await indicator.boundingBox();
|
|
773
773
|
assert.deepEqual([Math.round(box.width), Math.round(box.height)], [64, 32], `${at}: a navigation bar destination`);
|
|
774
774
|
}
|
|
@@ -1343,6 +1343,166 @@ test("a virtual-scroll list in a dialog reaches its last item after the page aro
|
|
|
1343
1343
|
}
|
|
1344
1344
|
});
|
|
1345
1345
|
|
|
1346
|
+
// A list item's subtitle is at full strength, as Material 3's list draws its supporting text: on-surface-variant on an
|
|
1347
|
+
// item at rest, the item's own colour on an active one, over the card and the active item's selected state layer.
|
|
1348
|
+
// Vuetify's medium-emphasis opacity measured 4.35:1 at rest and 4.45:1 active on the card, under WCAG's 4.5:1.
|
|
1349
|
+
test("a list item's subtitle is readable at rest and active, in light and dark", {
|
|
1350
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
1351
|
+
timeout: 60_000
|
|
1352
|
+
}, async (t) => {
|
|
1353
|
+
const { vite, browser } = await startFixture(t);
|
|
1354
|
+
for (const theme of ["light", "dark"]) {
|
|
1355
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: theme, viewport: { width: 390, height: 844 } });
|
|
1356
|
+
await page.goto(`/home/components?theme=${theme}`);
|
|
1357
|
+
const onSurfaceVariant = await readRoleColor(page, "on-surface-variant");
|
|
1358
|
+
for (const testId of ["fixture-active-item", "fixture-rest-item"]) {
|
|
1359
|
+
const item = await page.getByTestId(testId).evaluate((element) => {
|
|
1360
|
+
const style = (node) => window.getComputedStyle(node);
|
|
1361
|
+
const overlay = element.querySelector(".v-list-item__overlay");
|
|
1362
|
+
const subtitle = element.querySelector(".v-list-item-subtitle");
|
|
1363
|
+
return {
|
|
1364
|
+
card: style(element.closest(".v-card")).backgroundColor,
|
|
1365
|
+
color: style(element).color,
|
|
1366
|
+
// Vuetify draws a state layer only on an item that is active or can be clicked.
|
|
1367
|
+
overlay: overlay ? [style(overlay).backgroundColor, Number(style(overlay).opacity)] : ["rgb(0, 0, 0)", 0],
|
|
1368
|
+
subtitle: [style(subtitle).color, Number(style(subtitle).opacity)]
|
|
1369
|
+
};
|
|
1370
|
+
});
|
|
1371
|
+
const at = `${testId} in ${theme}`;
|
|
1372
|
+
// What shows under the subtitle: the card, then the item's state layer at its opacity.
|
|
1373
|
+
const card = parseRgb(item.card);
|
|
1374
|
+
const layer = parseRgb(item.overlay[0]);
|
|
1375
|
+
const mix = (top, bottom, alpha) => ({
|
|
1376
|
+
red: top.red * alpha + bottom.red * (1 - alpha),
|
|
1377
|
+
green: top.green * alpha + bottom.green * (1 - alpha),
|
|
1378
|
+
blue: top.blue * alpha + bottom.blue * (1 - alpha)
|
|
1379
|
+
});
|
|
1380
|
+
const background = mix(layer, card, layer.alpha * item.overlay[1]);
|
|
1381
|
+
const text = parseRgb(item.subtitle[0]);
|
|
1382
|
+
const ratio = contrastRatio(mix(text, background, text.alpha * item.subtitle[1]), background);
|
|
1383
|
+
assert.equal(item.subtitle[1], 1, `${at}: the subtitle is at full strength`);
|
|
1384
|
+
assert.equal(item.subtitle[0], testId === "fixture-rest-item" ? onSurfaceVariant : item.color, `${at}: its colour`);
|
|
1385
|
+
assert.ok(ratio >= 4.5, `${at}: the subtitle's contrast was ${ratio.toFixed(2)}:1`);
|
|
1386
|
+
}
|
|
1387
|
+
await page.close();
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
test("an app's own v-bottom-navigation is Material 3's navigation bar: a 64x32 indicator around a 24dp icon, in light and dark", {
|
|
1392
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
1393
|
+
timeout: 60_000
|
|
1394
|
+
}, async (t) => {
|
|
1395
|
+
const { vite, browser } = await startFixture(t);
|
|
1396
|
+
for (const theme of ["light", "dark"]) {
|
|
1397
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: theme, viewport: { width: 390, height: 844 } });
|
|
1398
|
+
await page.goto(`/home/components?theme=${theme}`);
|
|
1399
|
+
const roles = {};
|
|
1400
|
+
for (const role of ["secondary-container", "on-secondary-container", "on-surface", "on-surface-variant"]) {
|
|
1401
|
+
roles[role] = await readRoleColor(page, role);
|
|
1402
|
+
}
|
|
1403
|
+
const read = (testId) => page.getByTestId(testId).evaluate((button) => {
|
|
1404
|
+
const style = (node) => window.getComputedStyle(node);
|
|
1405
|
+
const icon = button.querySelector(".v-icon");
|
|
1406
|
+
// A label in a span of its own beside an icon in the content, or the content itself beside a prepend-icon.
|
|
1407
|
+
const label = button.querySelector(".v-btn__content > span") || button.querySelector(".v-btn__content");
|
|
1408
|
+
const box = (node) => node.getBoundingClientRect();
|
|
1409
|
+
const visible = (node) => node && style(node).display !== "none";
|
|
1410
|
+
return {
|
|
1411
|
+
indicator: [Math.round(box(icon).width), Math.round(box(icon).height), style(icon).borderTopLeftRadius],
|
|
1412
|
+
glyph: Math.round(box(icon.querySelector("svg")).width),
|
|
1413
|
+
colors: [style(icon).backgroundColor, style(icon).color, style(label).color],
|
|
1414
|
+
stateLayer: style(icon).backgroundImage,
|
|
1415
|
+
label: [style(label).fontSize, style(label).lineHeight, style(label).fontWeight],
|
|
1416
|
+
gap: Math.round(box(label).top - box(icon).bottom),
|
|
1417
|
+
// The state layer is the indicator's, not Vuetify's across the whole button.
|
|
1418
|
+
buttonLayers: [".v-btn__overlay", ".v-btn__underlay"].some((selector) => visible(button.querySelector(`:scope > ${selector}`)))
|
|
1419
|
+
};
|
|
1420
|
+
});
|
|
1421
|
+
const at = (name) => `${name} in ${theme}`;
|
|
1422
|
+
const active = await read("fixture-navigation-active");
|
|
1423
|
+
const rest = await read("fixture-navigation-rest");
|
|
1424
|
+
for (const [name, destination] of [["active", active], ["rest", rest]]) {
|
|
1425
|
+
assert.deepEqual(destination.indicator, [64, 32, "16px"], at(`${name}: the indicator`));
|
|
1426
|
+
assert.equal(destination.glyph, 24, at(`${name}: the icon`));
|
|
1427
|
+
assert.deepEqual(destination.label, ["12px", "16px", "500"], at(`${name}: label-medium`));
|
|
1428
|
+
assert.equal(destination.gap, 4, at(`${name}: the label 4dp below the indicator`));
|
|
1429
|
+
assert.equal(destination.buttonLayers, false, at(`${name}: no whole-button state layer`));
|
|
1430
|
+
}
|
|
1431
|
+
assert.deepEqual(active.colors, [roles["secondary-container"], roles["on-secondary-container"], roles["on-surface"]], at("active"));
|
|
1432
|
+
assert.deepEqual(rest.colors, ["rgba(0, 0, 0, 0)", roles["on-surface-variant"], roles["on-surface-variant"]], at("rest"));
|
|
1433
|
+
// Hovered, the destination's indicator takes its state layer.
|
|
1434
|
+
await page.getByTestId("fixture-navigation-rest").hover();
|
|
1435
|
+
await expect.poll(() => page.getByTestId("fixture-navigation-rest").locator(".v-icon")
|
|
1436
|
+
.evaluate((icon) => window.getComputedStyle(icon).backgroundImage)).not.toBe(rest.stateLayer);
|
|
1437
|
+
await page.close();
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
test("an app's colours win over the navigation bar's, and a denser bar, a badge and an append icon keep its shape", {
|
|
1442
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
1443
|
+
timeout: 60_000
|
|
1444
|
+
}, async (t) => {
|
|
1445
|
+
const { vite, browser } = await startFixture(t);
|
|
1446
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 } });
|
|
1447
|
+
await page.goto("/home/components");
|
|
1448
|
+
const roles = {};
|
|
1449
|
+
for (const role of ["primary", "on-primary", "secondary-container", "on-surface-variant"]) {
|
|
1450
|
+
roles[role] = await readRoleColor(page, role);
|
|
1451
|
+
}
|
|
1452
|
+
const transparent = "rgba(0, 0, 0, 0)";
|
|
1453
|
+
const read = (testId) => page.getByTestId(testId).evaluate((button) => {
|
|
1454
|
+
const style = (node) => window.getComputedStyle(node);
|
|
1455
|
+
const box = (node) => node.getBoundingClientRect();
|
|
1456
|
+
const bar = box(button.closest(".v-bottom-navigation"));
|
|
1457
|
+
// The destination's icon, a prepend-icon or one in a badge; its label, in a span or the content itself.
|
|
1458
|
+
const icon = button.querySelector(".v-btn__prepend > .v-icon, .v-badge__wrapper > .v-icon");
|
|
1459
|
+
const label = button.querySelector(".v-btn__content > span") || button.querySelector(".v-btn__content");
|
|
1460
|
+
return {
|
|
1461
|
+
indicator: [Math.round(box(icon).width), Math.round(box(icon).height)],
|
|
1462
|
+
colors: [style(icon).backgroundColor, style(icon).color, style(label).color],
|
|
1463
|
+
fits: box(icon).top >= bar.top - 0.5 && box(label).bottom <= bar.bottom + 0.5,
|
|
1464
|
+
// An append icon and a badge's own icon are not the destination's.
|
|
1465
|
+
otherIcons: Array.from(button.querySelectorAll(".v-btn__append .v-icon, .v-badge__badge .v-icon"))
|
|
1466
|
+
.map((other) => Math.round(box(other).width))
|
|
1467
|
+
};
|
|
1468
|
+
});
|
|
1469
|
+
|
|
1470
|
+
// A bar the app colours: every destination takes the bar's on-primary, and the active indicator is drawn in it.
|
|
1471
|
+
const coloured = { active: await read("fixture-navigation-coloured-active"), rest: await read("fixture-navigation-coloured-rest") };
|
|
1472
|
+
assert.deepEqual(coloured.active.colors.slice(1), [roles["on-primary"], roles["on-primary"]], "coloured bar: active");
|
|
1473
|
+
assert.ok(![transparent, roles["secondary-container"]].includes(coloured.active.colors[0]), `coloured bar: ${coloured.active.colors[0]}`);
|
|
1474
|
+
assert.deepEqual(coloured.rest.colors, [transparent, roles["on-primary"], roles["on-primary"]], "coloured bar: rest");
|
|
1475
|
+
|
|
1476
|
+
// A bar whose color tints its active destination: that one is primary, the rest keep Material 3's colours.
|
|
1477
|
+
const tinted = { active: await read("fixture-navigation-tinted-active"), rest: await read("fixture-navigation-tinted-rest") };
|
|
1478
|
+
assert.deepEqual(tinted.active.colors.slice(1), [roles.primary, roles.primary], "tinted bar: active");
|
|
1479
|
+
assert.ok(![transparent, roles["secondary-container"]].includes(tinted.active.colors[0]), `tinted bar: ${tinted.active.colors[0]}`);
|
|
1480
|
+
assert.deepEqual(tinted.rest.colors, [transparent, roles["on-surface-variant"], roles["on-surface-variant"]], "tinted bar: rest");
|
|
1481
|
+
|
|
1482
|
+
// Denser bars fit their destinations: a comfortable one (48dp) drops the label's 4dp, a compact one (40dp) has a
|
|
1483
|
+
// 24dp indicator. The badge's icon and an append icon (below the label of a stacked button) keep their own size.
|
|
1484
|
+
for (const [density, indicator] of [["comfortable", [64, 32]], ["compact", [64, 24]]]) {
|
|
1485
|
+
for (const name of ["active", "rest"]) {
|
|
1486
|
+
const destination = await read(`fixture-navigation-${density}-${name}`);
|
|
1487
|
+
assert.deepEqual(destination.indicator, indicator, `${density} ${name}: the indicator`);
|
|
1488
|
+
assert.equal(destination.fits, true, `${density} ${name}: the indicator and label inside the bar`);
|
|
1489
|
+
}
|
|
1490
|
+
for (const name of ["active", "append"]) {
|
|
1491
|
+
const destination = await read(`fixture-navigation-${density}-${name}`);
|
|
1492
|
+
assert.deepEqual(destination.indicator, indicator, `${density} ${name}: the indicator`);
|
|
1493
|
+
assert.equal(destination.otherIcons.length, 1, `${density} ${name}: its badge or append icon`);
|
|
1494
|
+
assert.ok(destination.otherIcons[0] < 64, `${density} ${name}: ${destination.otherIcons}`);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
// A horizontal bar lays its destinations flat, as Vuetify draws them: no indicator around the icon.
|
|
1499
|
+
for (const name of ["active", "rest"]) {
|
|
1500
|
+
const destination = await read(`fixture-navigation-horizontal-${name}`);
|
|
1501
|
+
assert.ok(destination.indicator[0] < 64, `horizontal ${name}: ${destination.indicator}`);
|
|
1502
|
+
}
|
|
1503
|
+
await page.close();
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1346
1506
|
test("segmented buttons, filter chips, fixed tabs, menus and dialog actions take Material 3's shapes and colours", {
|
|
1347
1507
|
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
1348
1508
|
timeout: 90_000
|
|
@@ -26,7 +26,7 @@ const SHELL_PROBES = Object.freeze([
|
|
|
26
26
|
{ name: "upButton", selector: "[data-testid=jskit-shell-back]", width: true },
|
|
27
27
|
{ name: "menuButton", selector: "[data-testid=jskit-shell-nav-toggle]", width: true },
|
|
28
28
|
{ name: "navigationBar", selector: "[data-testid=jskit-shell-bottom-nav]", width: true },
|
|
29
|
-
{ name: "navigationBarIndicator", selector: ".tab-link-item--active .
|
|
29
|
+
{ name: "navigationBarIndicator", selector: ".tab-link-item--active .v-icon", width: true },
|
|
30
30
|
{ name: "navigationBarLabel", selector: ".tab-link-item__label" },
|
|
31
31
|
{ name: "rail", selector: "[data-testid=jskit-shell-rail]", width: true },
|
|
32
32
|
{ name: "railIndicator", selector: "[data-testid=jskit-shell-rail] .v-list-item--active .shell-menu-link-item__indicator", width: true },
|