@jskit-ai/material-web 0.1.12 → 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
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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.
|
|
5
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).
|
|
6
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%.
|
|
7
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).
|
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": {
|
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,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
|
|
@@ -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
|
+
});
|