@jskit-ai/material-web 0.1.12 → 0.1.14
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
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- axe judges every text beside an open menu or a snackbar. Vuetify places a menu's content and a snackbar's message in an overlay the size of the window (or of the container it is attached to), transparent and taking no clicks, and axe found that box over every other text on the page and judged none of them (color-contrast incomplete, bgOverlap): 36 texts on mobilynet's page with a menu open, so text no one could read there passed. material.css hides a menu's and a snackbar's overlay and shows what it holds (`.v-overlay:is(.v-menu, .v-snackbar)`, visibility), so nothing changes on screen, clicks and assistive technology reach the same elements (a snackbar's `role="status"` is on its content), and the content is the only box it lays over the page. Select, autocomplete and combobox lists are menus too. A tooltip keeps its overlay, which carries its `role="tooltip"`. A test that asked whether a snackbar's root (`.v-snackbar`) is visible now asks its message (`.v-snackbar__wrapper`): the root is hidden.
|
|
6
|
+
- An active button whose label is drawn in its colour (filled, elevated, text, outlined) shows one state layer at a time, as Material 3 does: hovered, focused or pressed, that state's layer alone. Vuetify added the hover or focus layer to its activated one, 18% or 20% of a text button's colour under its label, which took a primary text button's label to 4.13:1 under the mouse that had just opened its menu; Vuetify draws a button as active while its menu is open, and a filled or elevated one now has no activated layer then either, as when its route is current. A selected tonal button keeps its selected layer under the others: its on-container label keeps 4.5:1 over both.
|
|
7
|
+
shell-web's `colorContrast.browser.test.js` opens a text button's menu and a filled button's, and shows a snackbar, at 1280 and has axe judge every text on the page, and judges every colour and variant active, at rest, hovered, focused and pressed, in light and dark.
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
5
10
|
- 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).
|
|
6
11
|
- 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%.
|
|
7
12
|
- 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).
|
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.14",
|
|
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": {
|
package/src/client/material.css
CHANGED
|
@@ -169,8 +169,11 @@
|
|
|
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
|
}
|
|
@@ -188,38 +191,49 @@
|
|
|
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
|
|
195
198
|
segment is secondary-container), and Vuetify's, the label's colour at 10% over the container, took a primary
|
|
196
199
|
button's white label under WCAG's 4.5:1 (4.11:1 in JSKIT's fixture theme) for as long as the button stayed
|
|
197
|
-
active, as one whose route is current does
|
|
198
|
-
|
|
200
|
+
active, as one whose route is current does, or whose menu is open (Vuetify draws a menu's button as active
|
|
201
|
+
then). */
|
|
202
|
+
.v-btn:where(.v-btn--active, [aria-haspopup="menu"][aria-expanded="true"]):is(.v-btn--variant-flat,
|
|
203
|
+
.v-btn--variant-elevated) > .v-btn__overlay {
|
|
199
204
|
opacity: 0;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
|
-
|
|
207
|
+
/* An active button that draws its label in its colour (filled, elevated, text, outlined) shows one state layer at a
|
|
208
|
+
time, as Material 3 does: hovered, focused or pressed, that state's layer alone. Vuetify added it to the activated
|
|
209
|
+
layer, 18% or 20% of a text button's colour under its label, which took a primary label to 4.13:1 under the mouse
|
|
210
|
+
that had just opened its menu. A tonal button's label is its on-container colour, which keeps 4.5:1 over both
|
|
211
|
+
layers, so a selected tonal button keeps its selected layer under the others. */
|
|
212
|
+
.v-btn:where(.v-btn--active, [aria-haspopup="menu"][aria-expanded="true"]):is(.v-btn--variant-flat,
|
|
213
|
+
.v-btn--variant-elevated, .v-btn--variant-text, .v-btn--variant-outlined):hover > .v-btn__overlay {
|
|
203
214
|
opacity: calc(var(--v-hover-opacity) * var(--v-theme-overlay-multiplier));
|
|
204
215
|
}
|
|
205
216
|
|
|
206
|
-
.v-btn
|
|
217
|
+
.v-btn:where(.v-btn--active, [aria-haspopup="menu"][aria-expanded="true"]):is(.v-btn--variant-flat,
|
|
218
|
+
.v-btn--variant-elevated, .v-btn--variant-text, .v-btn--variant-outlined):focus-visible > .v-btn__overlay {
|
|
207
219
|
opacity: calc(var(--v-focus-opacity) * var(--v-theme-overlay-multiplier));
|
|
208
220
|
}
|
|
209
221
|
|
|
210
222
|
/* The ripple, Material 3's pressed state layer, lies under the label too (above), at its 10%: Vuetify's was 25%,
|
|
211
223
|
over the hover layer and over the label, so axe judged no pressed label at all. A pressed button shows the ripple
|
|
212
|
-
alone, as Material 3 shows one state layer at a time; a selected one keeps its selected layer under it. */
|
|
224
|
+
alone, as Material 3 shows one state layer at a time; a selected tonal one keeps its selected layer under it. */
|
|
213
225
|
.v-ripple__animation--in {
|
|
214
226
|
opacity: var(--v-pressed-opacity);
|
|
215
227
|
}
|
|
216
228
|
|
|
217
229
|
.v-btn:active:not(.v-btn--active) > .v-btn__overlay,
|
|
218
|
-
.v-btn--active:active:is(.v-btn--variant-flat, .v-btn--variant-elevated
|
|
230
|
+
.v-btn--active:active:is(.v-btn--variant-flat, .v-btn--variant-elevated, .v-btn--variant-text,
|
|
231
|
+
.v-btn--variant-outlined) > .v-btn__overlay {
|
|
219
232
|
opacity: 0;
|
|
220
233
|
}
|
|
221
234
|
|
|
222
|
-
.v-btn--active:active:not(.v-btn--variant-flat, .v-btn--variant-elevated
|
|
235
|
+
.v-btn--active:active:not(.v-btn--variant-flat, .v-btn--variant-elevated, .v-btn--variant-text,
|
|
236
|
+
.v-btn--variant-outlined) > .v-btn__overlay {
|
|
223
237
|
opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
|
|
224
238
|
}
|
|
225
239
|
|
|
@@ -400,6 +414,22 @@
|
|
|
400
414
|
display: none;
|
|
401
415
|
}
|
|
402
416
|
|
|
417
|
+
/* An open menu or a snackbar lies over the page only where it draws. Vuetify places a menu's content and a
|
|
418
|
+
snackbar's message in an overlay that spans the whole window (or the container it is attached to), transparent
|
|
419
|
+
and taking no clicks, and axe found that box over every text beside it and judged the contrast of none of them
|
|
420
|
+
(color-contrast incomplete, bgOverlap): 36 texts on mobilynet's page with a menu open. The overlay is hidden and
|
|
421
|
+
what it holds (the content, and the scrim when a menu has one) is shown, so nothing changes on screen and the
|
|
422
|
+
content is the only box it lays over the page; a snackbar's role="status" is on its content. Select,
|
|
423
|
+
autocomplete and combobox lists are menus too. A tooltip keeps its overlay: Vuetify puts its role="tooltip"
|
|
424
|
+
there, which a hidden overlay would take from assistive technology. */
|
|
425
|
+
.v-overlay:is(.v-menu, .v-snackbar) {
|
|
426
|
+
visibility: hidden;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.v-overlay:is(.v-menu, .v-snackbar) > * {
|
|
430
|
+
visibility: visible;
|
|
431
|
+
}
|
|
432
|
+
|
|
403
433
|
/* Segmented buttons (v-btn-toggle): a 40dp pill in the outline role whose segments share its width, each with a 48dp
|
|
404
434
|
touch target. An unselected segment has no container; the selected one is secondary-container and leads with a
|
|
405
435
|
check, which takes the place of its icon. */
|
|
@@ -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
|
+
});
|