@jskit-ai/material-web 0.1.11 → 0.1.13
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 +7 -0
- package/README.md +7 -2
- package/package.json +1 -1
- package/src/client/colorSchemes.js +5 -0
- package/src/client/material.css +63 -7
- package/test/fixtures/layering/index.html +2 -0
- package/test/fixtures/layering/main.js +36 -0
- package/test/fixtures/layering/vite.config.js +7 -0
- package/test/layering.browser.test.js +44 -0
- package/test/materialWeb.test.js +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- An element an app places absolutely in a button's, chip's, list item's, card's or avatar's content is placed in the control again, as Vuetify places it. 0.1.10 positioned those content parts (`position: relative`) so that axe reads their labels above the state layers, which made each part what such an element is placed in: Vibe64 Online's attention dot, at the top right corner of a 144px button, was drawn on the 120px content inside it, over the RAM and CPU readings it marks. Each content part is now a stacking context of its own (`isolation: isolate`) instead, which keeps it above the layers for the browser and for axe-core 4.14. axe-core 4.11 restarts every stacking context at the top of the page, so it ranks an isolated part under its positioned control and judges none of these labels (color-contrast incomplete, bgOverlap): an app checking contrast with axe needs 4.14. `layering.browser.test.js` places a mark at each of the five controls' top right corner.
|
|
6
|
+
- A hovered, focused or pressed button's label keeps WCAG's 4.5:1 over its state layer, which `material.css` draws under the label: control's Releases page measured white on a hovered primary button at 4.43:1, on a focused one at 4.08:1, and a focused tonal error button's label at 4.45:1 (axe `color-contrast`, on a phone in light).
|
|
7
|
+
- Every colour's state layers have Material 3's one opacity (hover 8%, focus and pressed 10%): each Vuetify theme from `materialThemes` sets `--v-theme-<role>-overlay-multiplier` to 1 for every role. Vuetify doubled the layers on a colour whose tone is the theme's opposite (a primary, error or other tone-40 colour in light, a tone-80 one in dark), so a filled or elevated button's hover layer was 16% and its focus layer 20%.
|
|
8
|
+
- The ripple, Material 3's pressed state layer, lies under the label with the other layers (buttons, chips, list items and cards) and is Material 3's 10% (`--v-pressed-opacity`), not Vuetify's 25%; a pressed button shows it alone, without its hover or focus layer (a selected tonal, outlined or text button keeps its selected layer under it). Over the label, it left axe unable to judge any pressed label (bgOverlap); under it at 25% over the 8% hover layer, a pressed primary button's white label would read 3.2:1 (the ripple alone at 10%: 5.08:1, on JSKIT's #415f91 primary).
|
|
9
|
+
- A tonal button in a colour with a container role (primary, secondary, tertiary, error, success, warning or info) draws its label, icons and spinner in that colour's on-container role, as Material 3 does on its tonal containers; its tint and state layers stay the colour's, and a disabled one is drawn as before. Vuetify drew the label in the colour itself over its own tint, so a focus or pressed layer in the colour took it under 4.5:1. A tonal button in an app's own colour keeps Vuetify's drawing.
|
|
10
|
+
shell-web's `colorContrast.browser.test.js` has axe judge a button in each of those seven colours and each variant (flat, elevated, tonal, outlined, text) at rest, hovered, keyboard-focused and pressed, in light and dark.
|
|
11
|
+
|
|
5
12
|
- A chip's label longer than its chip ends in an ellipsis inside it, as a button's does: material.css lets a chip's text-only content shrink and clip (`.v-chip > .v-chip__content:not(:has(> *))`). Vuetify's inline-flex content could not shrink, so a long label was cut mid-word at the chip's edge, or drawn past it on a chip you press. A chip whose label holds elements of its own (an icon or avatar in its default slot) keeps Vuetify's layout; a short label is drawn as before.
|
|
6
13
|
- A tooltip opened by focus closes when its button loses focus to nothing, as `blur()` takes it. Vuetify 4.3.2 ignores such a blur (it keeps it for a click on an empty area inside an open menu), so the tooltip a keyboard user opened stayed over the page, and neither hovering nor leaving its button closed it (mobilynet's screen check met one). The `VTooltip` default's `activatorProps` listens for the `focusout` that follows and hands Vuetify's handler the blur it acts on, unless the pointer is on the tooltip itself, and the focus stays where `blur()` put it; a tooltip given its own `activator-props` replaces it. See the README's Upstream workarounds.
|
|
7
14
|
- axe judges the contrast of every text on a page again. Two things hid every text from it (color-contrast "incomplete", bgOverlap), so even text no one can read passed an accessibility check: a closed menu that stays mounted (`eager`, as shell-web's overflow menu does to keep the app bar's own items mounted on a phone) left Vuetify's overlay root over the whole window at z-index 2000, and Vuetify draws a button's, chip's, list item's, card's and avatar's state layer and underlay over its label. `material.css` now hides any overlay whose content is hidden (the rule it already had for tooltips, generalised), so a closing menu still animates out and its overlay goes once its content has; and draws state layers and tints under the content, as Material 3 orders them: each of those controls is its own stacking context with its layers at z-index -1, and its content parts are positioned (axe-core 4.14 reads the first, 4.11 the second; each alone still found layers over labels). Judged, three texts failed and are fixed or named:
|
package/README.md
CHANGED
|
@@ -107,8 +107,13 @@ export const theme = {
|
|
|
107
107
|
technology, and a closed eager menu lay over the whole page, so axe judged the
|
|
108
108
|
contrast of no text under it), state layers and tints under the label on
|
|
109
109
|
buttons, chips, list items, cards and avatars (axe judges the label's
|
|
110
|
-
contrast),
|
|
111
|
-
|
|
110
|
+
contrast), Material 3's one state-layer opacity on every colour (Vuetify
|
|
111
|
+
doubles it on a colour of the opposite tone, which took a hovered or focused
|
|
112
|
+
primary button's label under 4.5:1), a tonal button's label, icons and spinner
|
|
113
|
+
in its colour's on-container role (primary, secondary, tertiary, error,
|
|
114
|
+
success, warning and info), no activated state layer on a filled or elevated
|
|
115
|
+
button (it took a primary button's label under 4.5:1), `on-surface` text on a
|
|
116
|
+
tonal card of the
|
|
112
117
|
default colour, 40dp outlined segmented buttons and outlined
|
|
113
118
|
filter chips that lead with a check when selected (chips with
|
|
114
119
|
`aria-pressed` too), fixed tabs that share the width or else scroll, dialog
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/material-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Exact Material 3 for JSKIT Vuetify apps: seed-generated light and dark schemes, Material Symbols Rounded icon aliases, Roboto Flex and Material 3 component defaults.",
|
|
6
6
|
"exports": {
|
|
@@ -313,6 +313,11 @@ function vuetifyTheme(schemeColorsByRole, dark) {
|
|
|
313
313
|
colors,
|
|
314
314
|
variables: {
|
|
315
315
|
...STATE_LAYER_VARIABLES,
|
|
316
|
+
// Material 3's state layers have one opacity each, on every colour. Vuetify doubles them on a colour whose
|
|
317
|
+
// luminance is the theme's opposite (a primary button in light): a hovered primary button's white label read
|
|
318
|
+
// 4.43:1 and a focused one 4.08:1, under WCAG's 4.5:1, now that the layer lies under the label.
|
|
319
|
+
...Object.fromEntries(Object.keys(colors).filter((role) => !role.startsWith("on-"))
|
|
320
|
+
.map((role) => [`theme-${role}-overlay-multiplier`, 1])),
|
|
316
321
|
// Channel strings: Vuetify writes them as rgba(var(--v-border-color), var(--v-border-opacity)).
|
|
317
322
|
"border-color": channels(argbFromHex(colors["outline-variant"])),
|
|
318
323
|
"shadow-color": channels(argbFromHex(colors.shadow)),
|
package/src/client/material.css
CHANGED
|
@@ -169,16 +169,19 @@
|
|
|
169
169
|
/* A control's state layer and container tint lie under its content, as Material 3 orders them. Vuetify draws a
|
|
170
170
|
button's, chip's, list item's, card's and avatar's overlay and underlay over the label, so axe found a layer over
|
|
171
171
|
every label and judged the contrast of none (color-contrast incomplete, bgOverlap). Each control is its own
|
|
172
|
-
stacking context with its layers at z-index -1 in it, and its content parts
|
|
173
|
-
|
|
172
|
+
stacking context with its layers at z-index -1 in it, and each of its content parts is one too, which axe-core
|
|
173
|
+
4.14 needs to read the labels above the layers. A content part is isolated, not positioned (as 0.1.10 and 0.1.11
|
|
174
|
+
made it), so a child the app places absolutely in it is placed in the control, as Vuetify places it: a dot at a
|
|
175
|
+
button's top right corner was drawn on its label. axe-core 4.11 ranks an isolated part under its positioned
|
|
176
|
+
control and so judges none of these labels: check contrast with 4.14. */
|
|
174
177
|
:is(.v-btn, .v-chip, .v-list-item, .v-card, .v-avatar) {
|
|
175
178
|
isolation: isolate;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
|
-
.v-btn > :is(.v-btn__overlay, .v-btn__underlay),
|
|
179
|
-
.v-chip > :is(.v-chip__overlay, .v-chip__underlay),
|
|
180
|
-
.v-list-item > :is(.v-list-item__overlay, .v-list-item__underlay),
|
|
181
|
-
.v-card > :is(.v-card__overlay, .v-card__underlay),
|
|
181
|
+
.v-btn > :is(.v-btn__overlay, .v-btn__underlay, .v-ripple__container),
|
|
182
|
+
.v-chip > :is(.v-chip__overlay, .v-chip__underlay, .v-ripple__container),
|
|
183
|
+
.v-list-item > :is(.v-list-item__overlay, .v-list-item__underlay, .v-ripple__container),
|
|
184
|
+
.v-card > :is(.v-card__overlay, .v-card__underlay, .v-ripple__container),
|
|
182
185
|
.v-avatar > .v-avatar__underlay {
|
|
183
186
|
z-index: -1;
|
|
184
187
|
}
|
|
@@ -188,7 +191,7 @@
|
|
|
188
191
|
.v-list-item > :is(.v-list-item__prepend, .v-list-item__content, .v-list-item__append),
|
|
189
192
|
.v-card > :is(.v-card-item, .v-card-title, .v-card-subtitle, .v-card-text, .v-card-actions),
|
|
190
193
|
.v-avatar > :not(.v-avatar__underlay) {
|
|
191
|
-
|
|
194
|
+
isolation: isolate;
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
/* A filled or elevated button has no activated state layer: Material 3 gives these buttons none (a selected
|
|
@@ -207,6 +210,59 @@
|
|
|
207
210
|
opacity: calc(var(--v-focus-opacity) * var(--v-theme-overlay-multiplier));
|
|
208
211
|
}
|
|
209
212
|
|
|
213
|
+
/* The ripple, Material 3's pressed state layer, lies under the label too (above), at its 10%: Vuetify's was 25%,
|
|
214
|
+
over the hover layer and over the label, so axe judged no pressed label at all. A pressed button shows the ripple
|
|
215
|
+
alone, as Material 3 shows one state layer at a time; a selected one keeps its selected layer under it. */
|
|
216
|
+
.v-ripple__animation--in {
|
|
217
|
+
opacity: var(--v-pressed-opacity);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.v-btn:active:not(.v-btn--active) > .v-btn__overlay,
|
|
221
|
+
.v-btn--active:active:is(.v-btn--variant-flat, .v-btn--variant-elevated) > .v-btn__overlay {
|
|
222
|
+
opacity: 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.v-btn--active:active:not(.v-btn--variant-flat, .v-btn--variant-elevated) > .v-btn__overlay {
|
|
226
|
+
opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* A tonal button in a colour with a container role draws its label, icons and spinner in that colour's
|
|
230
|
+
on-container role, as Material 3 does on its tonal containers. Vuetify drew them in the colour itself over the
|
|
231
|
+
colour's tint, which a focus or pressed layer (the colour again) took under WCAG's 4.5:1: 4.45:1 for a focused
|
|
232
|
+
tonal error button. The tint and the state layers stay the colour's. */
|
|
233
|
+
.v-btn--variant-tonal.text-primary {
|
|
234
|
+
--jskit-tonal-label: var(--v-theme-on-primary-container);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.v-btn--variant-tonal.text-secondary {
|
|
238
|
+
--jskit-tonal-label: var(--v-theme-on-secondary-container);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.v-btn--variant-tonal.text-tertiary {
|
|
242
|
+
--jskit-tonal-label: var(--v-theme-on-tertiary-container);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.v-btn--variant-tonal.text-error {
|
|
246
|
+
--jskit-tonal-label: var(--v-theme-on-error-container);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.v-btn--variant-tonal.text-success {
|
|
250
|
+
--jskit-tonal-label: var(--v-theme-on-success-container);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.v-btn--variant-tonal.text-warning {
|
|
254
|
+
--jskit-tonal-label: var(--v-theme-on-warning-container);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.v-btn--variant-tonal.text-info {
|
|
258
|
+
--jskit-tonal-label: var(--v-theme-on-info-container);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.v-btn--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
|
|
262
|
+
.text-info):not(.v-btn--disabled) > :is(.v-btn__prepend, .v-btn__content, .v-btn__append, .v-btn__loader) {
|
|
263
|
+
color: rgb(var(--jskit-tonal-label));
|
|
264
|
+
}
|
|
265
|
+
|
|
210
266
|
/* A label stays on one line, as Material 3 draws it; one longer than its button ends in an ellipsis. */
|
|
211
267
|
.v-btn:not(.v-btn--stacked, .v-btn--icon) > .v-btn__content:not(:has(> *)) {
|
|
212
268
|
display: block;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createApp, h } from "vue";
|
|
2
|
+
import { createVuetify } from "vuetify";
|
|
3
|
+
import { VApp } from "vuetify/components/VApp";
|
|
4
|
+
import { VAvatar } from "vuetify/components/VAvatar";
|
|
5
|
+
import { VBtn } from "vuetify/components/VBtn";
|
|
6
|
+
import { VCard, VCardText, VCardTitle } from "vuetify/components/VCard";
|
|
7
|
+
import { VChip } from "vuetify/components/VChip";
|
|
8
|
+
import { VList, VListItem } from "vuetify/components/VList";
|
|
9
|
+
import { VMain } from "vuetify/components/VMain";
|
|
10
|
+
import "vuetify/styles";
|
|
11
|
+
import "../../../src/client/material.css";
|
|
12
|
+
import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
|
|
13
|
+
|
|
14
|
+
// A button, a chip, a list item, a card and an avatar, with JSKIT's Material 3 options and stylesheet, each holding
|
|
15
|
+
// in its content a mark placed absolutely at its top right corner, as an app places an attention dot or a badge on a
|
|
16
|
+
// control (layering.browser.test.js). The avatar's mark sits in a span of initials, the card's in its text, under its
|
|
17
|
+
// title.
|
|
18
|
+
const mark = (control) => h("span", {
|
|
19
|
+
"data-testid": `${control}-mark`,
|
|
20
|
+
style: "position: absolute; top: 0; right: 0; width: 6px; height: 6px; background: rgb(var(--v-theme-error))"
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const controls = [
|
|
24
|
+
h(VBtn, { width: 144, "data-testid": "button" }, () => ["Usage", mark("button")]),
|
|
25
|
+
h(VChip, { "data-testid": "chip" }, () => ["Shared", mark("chip")]),
|
|
26
|
+
h(VList, null, () => h(VListItem, { title: "Invoices", "data-testid": "list-item" }, () => mark("list-item"))),
|
|
27
|
+
h(VCard, { width: 240, "data-testid": "card" }, () => [
|
|
28
|
+
h(VCardTitle, null, () => "Quarterly report"),
|
|
29
|
+
h(VCardText, null, () => ["Updated yesterday", mark("card")])
|
|
30
|
+
]),
|
|
31
|
+
h(VAvatar, { color: "primary", "data-testid": "avatar" }, () => h("span", null, ["AB", mark("avatar")]))
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => controls.map((control) => h("div", { class: "mb-4" }, control))));
|
|
35
|
+
|
|
36
|
+
createApp(App).use(createVuetify(createMaterialVuetifyOptions())).mount("#app");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { sharedBrowserFixture } from "../../../tooling/testUtils/browserFixture.mjs";
|
|
6
|
+
|
|
7
|
+
const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
|
|
8
|
+
const open = sharedBrowserFixture({
|
|
9
|
+
fixtureRoot: fileURLToPath(new URL("./fixtures/layering", import.meta.url)),
|
|
10
|
+
configFile: "vite.config.js"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const CONTROLS = Object.freeze(["button", "chip", "list-item", "card", "avatar"]);
|
|
14
|
+
|
|
15
|
+
// material.css draws a control's state layers under its content, and the content parts it lifts above them must not
|
|
16
|
+
// become what an absolutely placed child is placed in: an attention dot at a 144px button's top right (Vibe64 Online's
|
|
17
|
+
// resource indicator) moved onto the 120px content inside it, over the readings it marks.
|
|
18
|
+
test("a mark placed absolutely in a button's, chip's, list item's, card's or avatar's content sits at the control's corner", {
|
|
19
|
+
skip: SKIP,
|
|
20
|
+
timeout: 120_000
|
|
21
|
+
}, async (t) => {
|
|
22
|
+
const { vite, browser } = await open(t);
|
|
23
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 }, reducedMotion: "reduce" });
|
|
24
|
+
t.after(() => page.close());
|
|
25
|
+
await page.goto("/");
|
|
26
|
+
await page.getByTestId("avatar-mark").waitFor({ state: "attached" });
|
|
27
|
+
|
|
28
|
+
const placed = {};
|
|
29
|
+
const corners = {};
|
|
30
|
+
for (const control of CONTROLS) {
|
|
31
|
+
// The top right corner of the control's padding box, inside its border, where top: 0 and right: 0 put a child the
|
|
32
|
+
// control contains; and where the mark is drawn, to a tenth of a pixel.
|
|
33
|
+
corners[control] = await page.getByTestId(control).evaluate((element) => {
|
|
34
|
+
const box = element.getBoundingClientRect();
|
|
35
|
+
const round = (value) => Math.round(value * 10) / 10;
|
|
36
|
+
return [round(box.top + element.clientTop), round(box.left + element.clientLeft + element.clientWidth)];
|
|
37
|
+
});
|
|
38
|
+
placed[control] = await page.getByTestId(`${control}-mark`).evaluate((element) => {
|
|
39
|
+
const box = element.getBoundingClientRect();
|
|
40
|
+
return [Math.round(box.top * 10) / 10, Math.round(box.right * 10) / 10];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
assert.deepEqual(placed, corners);
|
|
44
|
+
});
|
package/test/materialWeb.test.js
CHANGED
|
@@ -123,6 +123,17 @@ test("theme variables carry Material 3 state layers and channel strings for bord
|
|
|
123
123
|
assert.equal(light.variables["border-color"], "202, 196, 207");
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
test("every colour's state layers keep Material 3's one opacity: no colour doubles them", () => {
|
|
127
|
+
const { light, dark } = materialThemes("#6750A4", { brand: "#0B57D0" });
|
|
128
|
+
for (const theme of [light, dark]) {
|
|
129
|
+
const roles = Object.keys(theme.colors).filter((role) => !role.startsWith("on-"));
|
|
130
|
+
assert.ok(roles.includes("primary") && roles.includes("error") && roles.includes("brand-container"));
|
|
131
|
+
for (const role of roles) {
|
|
132
|
+
assert.equal(theme.variables[`theme-${role}-overlay-multiplier`], 1, role);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
126
137
|
// A browser's localStorage for one origin; `refuse` makes it throw as blocked or full storage does.
|
|
127
138
|
function browserStorage({ refuse = false } = {}) {
|
|
128
139
|
const items = new Map();
|
|
@@ -234,8 +245,9 @@ test("colours stored under another revision, or that are not a scheme's, are com
|
|
|
234
245
|
assert.equal(JSON.parse(garbage.getItem("jskit:material-themes")).inputs.length, 1);
|
|
235
246
|
});
|
|
236
247
|
|
|
237
|
-
// The colours of each stored revision: one digest of three inputs' light and dark
|
|
238
|
-
|
|
248
|
+
// The colours of each stored revision: one digest of three inputs' light and dark colours, which is what a browser
|
|
249
|
+
// stores (each start builds its themes' variables from them).
|
|
250
|
+
const REVISION_COLOURS = Object.freeze({ 1: "91308426d160318bcfc8363055a003919c691a6dd00da36fe9ff1779827c5caf" });
|
|
239
251
|
|
|
240
252
|
test("the colours a theme input gives change only with the revision browsers store them under", async (t) => {
|
|
241
253
|
const storage = browserStorage();
|
|
@@ -243,7 +255,8 @@ test("the colours a theme input gives change only with the revision browsers sto
|
|
|
243
255
|
const colours = [themes("#6750A4"), themes(...VIBE64_INPUT), themes("#B3261E", { partner: "#0A7D3E", brandAccent: "#FF6D00" })];
|
|
244
256
|
const { revision } = JSON.parse(storage.getItem("jskit:material-themes"));
|
|
245
257
|
// A browser keeps showing the colours it stored until the revision changes.
|
|
246
|
-
|
|
258
|
+
const stored = colours.map(({ light, dark }) => ({ light: light.colors, dark: dark.colors }));
|
|
259
|
+
assert.equal(createHash("sha256").update(JSON.stringify(stored)).digest("hex"), REVISION_COLOURS[revision],
|
|
247
260
|
`The colours differ from revision ${revision}'s: bump THEMES_REVISION in colorSchemes.js and record its digest here.`);
|
|
248
261
|
});
|
|
249
262
|
|