@jskit-ai/material-web 0.1.15 → 0.1.17

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,9 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A tonal alert in a colour with a container role (primary, secondary, tertiary, error, success, warning or info) is that colour's container, with its title, text, icon and close button in the colour's on-container role, as Material 3 draws a tonal surface; a border stays the colour's. Vuetify drew the text in the colour over a tint of it at the activated opacity, over whatever surface the alert lay on: a tonal error alert's text read 4.49:1 in a light dialog's `surface-container-high` in the default theme, under WCAG's 4.5:1, and control's refused dialogs measured 4.48:1 in its own (axe `color-contrast`, which judges a dialog's and a tonal alert's texts since the overlay container and the alert's tint were restacked). `tonalAlerts.browser.test.js` has axe judge each of the seven colours' title and text on the page, in a card and in a dialog, in light and dark.
6
+
7
+ - `createMaterialVuetifyOptions()` starts loading the theme's typefaces in a browser, Roboto Flex unless the app names its own, at the regular and medium weights Material 3's type roles use (`document.fonts.load`, without waiting), so they are usually in before the app mounts. A face was fetched only when laid-out text first used it, after the app mounted, since the foundations' boot loader draws in system-ui: the page first showed in the fallback font and whatever was measured from text, such as shell-web's content-fitted drawer, changed when it arrived (in shell-web's adaptive shell fixture, Roboto Flex was first asked for 137-161 ms after the shell mounted, and the page then moved 2px). A face that is slow or fails leaves the fallback in place, as `font-display: swap` does.
5
8
  - axe judges the text of a tonal alert, an alert with a border, an editable stepper step, a tonal snackbar and an expansion panel's title, the title's in each state that shows its state layer. Vuetify draws each one's own layer (the alert's tint and its border box, the step's state layer and underlay, the snackbar's tint, the title's state layer on hover, on keyboard focus and on an open `focusable` panel) as a positioned box after the text it covers, so axe found it over the text and judged none of it (color-contrast incomplete, bgOverlap). material.css draws the alert's, step's and snackbar's layers under the text, as it already did a button's, chip's, list item's, card's and avatar's: each component is a stacking context with its layers at z-index -1 in it, and each part holding its text is one too. A title's text is the title's own, with no part to lift above a layer, so material.css draws its state as the title's own background, the text's colour at the state's opacity, and hides Vuetify's layer; a title with a background of its own (its `color`, a bg- class or an inline background) keeps Vuetify's layer, since no rule can mix a tint into a background another rule sets. The tints are the text's own colour, so the window's pixels are the same but for rounding, two levels of 255 at most. An icon button's text is judged as Vuetify draws it. A circular progress's reading keeps Vuetify's order: its ring is an svg, which axe takes for an image whether it lies over the reading or under it (bgOverlap, imgNode), so it judges the reading neither way. `underlayStacking.browser.test.js` has axe judge each of these texts, the titles' at rest, hovered and focused, finds a title of its own colour judged on its background at rest and under Vuetify's layer when hovered, and finds the same pixels, but for rounding, as with Vuetify's drawing.
6
9
  - A keyboard press's ripple ends with the press on a control whose own key handler moves focus away, as mobilynet's map card does: Enter opens a panel and focuses its title. Vuetify's ripple directive hears a key after the control's own listeners, so the card's blur came before its ripple existed, the ripple then showed on a card that no longer held focus, Enter came up on the panel's title, and nothing ended it. It stayed drawn, axe read its whole box, which reaches past the card, as covering mobilynet's label above it (color-contrast incomplete, bgOverlap), and Vuetify's flag that a keyboard ripple is showing stayed set, so the next control pressed with Enter showed none. `createMaterialVuetifyOptions()`, in a browser, now listens on the window once: when a key comes up, each control around where it went down that shows a ripple but no longer holds focus is sent the blur it missed, and Vuetify's own blur listener ends the ripple and clears the flag. A blur listener of the control's own hears that blur too, a second time. `keyboardRipple.browser.test.js` presses Enter on such a card, then on a button.
7
10
  - axe judges the texts of a dialog, menu, tooltip or snackbar open over page content that has a z-index of its own. Vuetify places every overlay in a container (`.v-overlay-container`) with `contain: layout` and `display: contents`, which draws no box, so the browser makes no stacking context of it; axe-core 4.14 counts `contain: layout` as one whatever the element draws, ranked the container at the page's base level, and so ranked every overlay under any content with a z-index of 1 or more. Over such content it found the page over a dialog's text and judged none of it (color-contrast incomplete, bgOverlap): mobilynet's dialogs, over its pages' content at z-index 1. axe-core 4.11 read `contain` too, but ranked the container by its position, an entry the overlay's own stacking context took out of the order; 4.14 keeps a stacking context in the order. material.css sets the container's `contain` to none, which the browser draws the same: `overlayStacking.browser.test.js` opens a dialog over a div at z-index 1, has axe judge each of its texts, and finds the same elements under every text (elementsFromPoint) and the same pixels as with Vuetify's `contain: layout`.
package/README.md CHANGED
@@ -111,7 +111,8 @@ export const theme = {
111
111
  doubles it on a colour of the opposite tone, which took a hovered or focused
112
112
  primary button's label under 4.5:1), a tonal button's label, icons and spinner
113
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
114
+ success, warning and info), a tonal alert in such a colour as its container
115
+ with on-container text, no activated state layer on a filled or elevated
115
116
  button (it took a primary button's label under 4.5:1), `on-surface` text on a
116
117
  tonal card of the
117
118
  default colour, 40dp outlined segmented buttons and outlined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/material-web",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
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": {
@@ -8,6 +8,9 @@ import { materialSymbols } from "./symbols.js";
8
8
  const DEFAULT_SEED = "#6750A4";
9
9
  // Roboto Flex, Material 3's default for both typefaces (material.css loads it).
10
10
  const ROBOTO_FLEX = '"Roboto Flex Variable", "Roboto Flex", Roboto, system-ui, sans-serif';
11
+ // The weights Material 3's type roles use: regular for display, headline, title-large and body; medium for the other
12
+ // titles and the labels.
13
+ const TYPE_ROLE_WEIGHTS = Object.freeze([400, 500]);
11
14
 
12
15
  /**
13
16
  * Material 3's two typefaces as Vuetify theme variables: brand for display, headline and title-large (Vuetify's
@@ -25,6 +28,25 @@ function typefaceVariables({ brand = ROBOTO_FLEX, plain = ROBOTO_FLEX } = {}) {
25
28
  return { "font-heading": family(brand, "brand"), "font-body": family(plain, "plain") };
26
29
  }
27
30
 
31
+ /**
32
+ * Starts loading the theme's typefaces in a browser as the app boots, without waiting for them. A face is otherwise
33
+ * fetched only when laid-out text first uses it, after the app mounts (a boot loader draws in system-ui), so the page
34
+ * first showed in the fallback font and whatever was measured from text, such as the shell's content-fitted drawer,
35
+ * changed when the face arrived. Started here it is usually in before the app mounts; a face that is slow or fails
36
+ * leaves the fallback in place, as font-display: swap does.
37
+ * @param {Window | undefined} view
38
+ * @param {Record<string, string>} typefaces The theme's font variables, each a CSS font-family value.
39
+ */
40
+ function startLoadingTypefaces(view, typefaces) {
41
+ const fonts = view?.document?.fonts;
42
+ if (!fonts) return;
43
+ for (const family of new Set(Object.values(typefaces))) {
44
+ for (const weight of TYPE_ROLE_WEIGHTS) {
45
+ fonts.load(`${weight} 1em ${family}`).catch(() => undefined);
46
+ }
47
+ }
48
+ }
49
+
28
50
  /**
29
51
  * An app's own icons as Vuetify aliases: `{ name: "<24x24 path data>" }` becomes `$name`.
30
52
  * @param {Record<string, string>} icons
@@ -47,7 +69,8 @@ function appIconAliases(icons) {
47
69
  * plain typefaces (Roboto Flex unless the app names its own), Material Symbols Rounded behind every icon alias (plus
48
70
  * the app's own), and JSKIT's Material 3 component defaults. Pass the result to createVuetify(); import
49
71
  * "@jskit-ai/material-web/client/material.css" after "vuetify/styles". In a browser it also makes a keyboard press's
50
- * ripple end with the press on a control whose own key handler moves focus away (keyboardRipple.js), once per window.
72
+ * ripple end with the press on a control whose own key handler moves focus away (keyboardRipple.js), once per window,
73
+ * and starts loading the typefaces (startLoadingTypefaces), so they are usually in before the app mounts.
51
74
  * @param {{ seed?: string, colors?: Record<string, string | { value: string, blend?: boolean }>, icons?: Record<string, string>, typography?: { brand?: string, plain?: string } }} [theme]
52
75
  */
53
76
  function createMaterialVuetifyOptions({ seed = DEFAULT_SEED, colors = {}, icons = {}, typography = {} } = {}) {
@@ -58,6 +81,7 @@ function createMaterialVuetifyOptions({ seed = DEFAULT_SEED, colors = {}, icons
58
81
  }
59
82
  const aliases = { ...materialSymbols, ...appIconAliases(icons) };
60
83
  endKeyboardRipplesWithThePress(globalThis.window);
84
+ startLoadingTypefaces(globalThis.window, typefaces);
61
85
  return {
62
86
  blueprint: md3,
63
87
  defaults: materialDefaults,
@@ -301,36 +301,43 @@
301
301
  opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
302
302
  }
303
303
 
304
- /* A tonal button in a colour with a container role draws its label, icons and spinner in that colour's
305
- on-container role, as Material 3 does on its tonal containers. Vuetify drew them in the colour itself over the
306
- 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
307
- tonal error button. The tint and the state layers stay the colour's. */
308
- .v-btn--variant-tonal.text-primary {
304
+ /* A tonal button or alert in a colour with a container role draws its text in that colour's on-container role,
305
+ as Material 3 does on its tonal containers. Vuetify drew it in the colour itself over the colour's tint, which a
306
+ focus or pressed layer (the colour again) took under WCAG's 4.5:1: 4.45:1 for a focused tonal error button. A
307
+ tonal button's label, icons and spinner take the on-container role; its tint and state layers stay the colour's. */
308
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-primary {
309
309
  --jskit-tonal-label: var(--v-theme-on-primary-container);
310
+ --jskit-tonal-container: var(--v-theme-primary-container);
310
311
  }
311
312
 
312
- .v-btn--variant-tonal.text-secondary {
313
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-secondary {
313
314
  --jskit-tonal-label: var(--v-theme-on-secondary-container);
315
+ --jskit-tonal-container: var(--v-theme-secondary-container);
314
316
  }
315
317
 
316
- .v-btn--variant-tonal.text-tertiary {
318
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-tertiary {
317
319
  --jskit-tonal-label: var(--v-theme-on-tertiary-container);
320
+ --jskit-tonal-container: var(--v-theme-tertiary-container);
318
321
  }
319
322
 
320
- .v-btn--variant-tonal.text-error {
323
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-error {
321
324
  --jskit-tonal-label: var(--v-theme-on-error-container);
325
+ --jskit-tonal-container: var(--v-theme-error-container);
322
326
  }
323
327
 
324
- .v-btn--variant-tonal.text-success {
328
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-success {
325
329
  --jskit-tonal-label: var(--v-theme-on-success-container);
330
+ --jskit-tonal-container: var(--v-theme-success-container);
326
331
  }
327
332
 
328
- .v-btn--variant-tonal.text-warning {
333
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-warning {
329
334
  --jskit-tonal-label: var(--v-theme-on-warning-container);
335
+ --jskit-tonal-container: var(--v-theme-warning-container);
330
336
  }
331
337
 
332
- .v-btn--variant-tonal.text-info {
338
+ :is(.v-btn--variant-tonal, .v-alert--variant-tonal).text-info {
333
339
  --jskit-tonal-label: var(--v-theme-on-info-container);
340
+ --jskit-tonal-container: var(--v-theme-info-container);
334
341
  }
335
342
 
336
343
  .v-btn--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
@@ -338,6 +345,25 @@
338
345
  color: rgb(var(--jskit-tonal-label));
339
346
  }
340
347
 
348
+ /* A tonal alert in such a colour is that colour's container, with its title, text, icon and close button in the
349
+ colour's on-container role: Vuetify's tint of the colour, at the activated opacity over whatever surface the
350
+ alert lay on, left the colour's own text at 4.49:1 on a light dialog's surface-container-high (a tonal error
351
+ alert, under WCAG's 4.5:1), and a container keeps its contrast on every surface. A border stays the colour's. */
352
+ .v-alert--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
353
+ .text-info) {
354
+ background-color: rgb(var(--jskit-tonal-container));
355
+ }
356
+
357
+ .v-alert--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
358
+ .text-info) > .v-alert__underlay {
359
+ opacity: 0;
360
+ }
361
+
362
+ .v-alert--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
363
+ .text-info) > :is(.v-alert__prepend, .v-alert__content, .v-alert__append, .v-alert__close) {
364
+ color: rgb(var(--jskit-tonal-label));
365
+ }
366
+
341
367
  /* A label stays on one line, as Material 3 draws it; one longer than its button ends in an ellipsis. */
342
368
  .v-btn:not(.v-btn--stacked, .v-btn--icon) > .v-btn__content:not(:has(> *)) {
343
369
  display: block;
@@ -0,0 +1,2 @@
1
+ <!doctype html>
2
+ <html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Material 3 tonal alerts</title></head><body><div id="app"></div><script type="module" src="/main.js"></script></body></html>
@@ -0,0 +1,36 @@
1
+ import { createApp, h } from "vue";
2
+ import { createVuetify } from "vuetify";
3
+ import { VAlert } from "vuetify/components/VAlert";
4
+ import { VApp } from "vuetify/components/VApp";
5
+ import { VCard, VCardText } from "vuetify/components/VCard";
6
+ import { VDialog } from "vuetify/components/VDialog";
7
+ import { VMain } from "vuetify/components/VMain";
8
+ import "vuetify/styles";
9
+ import "../../../src/client/material.css";
10
+ import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
11
+
12
+ // A tonal alert in each colour with a container role, with JSKIT's Material 3 options and stylesheet, in the
13
+ // browser's light or dark scheme (tonalAlerts.browser.test.js), on the surface the page's ?surface= names: on the
14
+ // page, in a card (JSKIT's default, surface-container-low) or in a dialog's card (surface-container-high), one
15
+ // surface a page so that no alert lies under another surface's dialog or its scrim.
16
+ const COLORS = Object.freeze(["primary", "secondary", "tertiary", "error", "warning", "info", "success"]);
17
+ const surface = new URLSearchParams(globalThis.location.search).get("surface") || "page";
18
+
19
+ const alerts = () => COLORS.map((color) => h(VAlert, {
20
+ variant: "tonal",
21
+ color,
22
+ title: `The ${color} alert`,
23
+ text: `What the ${color} alert says.`,
24
+ class: "mb-3",
25
+ "data-testid": color
26
+ }));
27
+
28
+ const card = () => h(VCard, null, () => h(VCardText, null, alerts));
29
+
30
+ const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => {
31
+ if (surface === "card") return card();
32
+ if (surface === "dialog") return h(VDialog, { modelValue: true, persistent: true, width: 560 }, card);
33
+ return alerts();
34
+ }));
35
+
36
+ createApp(App).use(createVuetify(createMaterialVuetifyOptions())).mount("#app");
@@ -0,0 +1,7 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { defineConfig } from "vite";
3
+
4
+ export default defineConfig({
5
+ root: fileURLToPath(new URL(".", import.meta.url)),
6
+ server: { host: "127.0.0.1" }
7
+ });
@@ -13,14 +13,14 @@ import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
13
13
 
14
14
  // Each Vuetify component that draws a layer of its own over its text, beyond the button, chip, list item, card and
15
15
  // avatar material.css already restacks, with JSKIT's Material 3 options and stylesheet
16
- // (underlayStacking.browser.test.js): a tonal alert (its tint), an alert with a border (its border box), icon buttons
16
+ // (underlayStacking.browser.test.js): a tonal alert without a colour (its tint: one in a colour with a container role
17
+ // is that container, with no tint, tonalAlerts.browser.test.js), an alert with a border (its border box), icon buttons
17
18
  // with a text at rest, tonal and active (their state layer and underlay), an editable stepper's step (its state layer
18
- // and underlay), a tonal snackbar (its tint) and focusable expansion panels, the first open (each title's state
19
- // layer, shown on the open one, on hover and on focus, and on a disabled one), one with a title of its own colour.
19
+ // and underlay), a tonal snackbar (its tint) and focusable expansion panels, the first open (each title's state layer,
20
+ // shown on the open one, on hover and on focus, and on a disabled one), one with a title of its own colour.
20
21
  const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => [
21
22
  h(VAlert, {
22
23
  variant: "tonal",
23
- color: "primary",
24
24
  title: "Backups",
25
25
  text: "The last backup finished an hour ago.",
26
26
  class: "mb-4",
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { createRequire } from "node:module";
5
5
  import path from "node:path";
6
+ import process from "node:process";
6
7
  import test from "node:test";
7
8
  import { Hct, argbFromHex } from "@material/material-color-utilities";
8
9
  import { materialThemes, createMaterialVuetifyOptions } from "../src/client/index.js";
@@ -271,6 +272,57 @@ test("a browser that refuses storage still gets its theme", async (t) => {
271
272
  assert.deepEqual(sandboxed.materialThemes(...VIBE64_INPUT), materialThemes(...VIBE64_INPUT));
272
273
  });
273
274
 
275
+ // A window whose document's fonts list each face asked for, answering with `answer`.
276
+ function fontsWindow(t, answer = () => Promise.resolve([])) {
277
+ const loads = [];
278
+ globalThis.window = {
279
+ addEventListener() {},
280
+ removeEventListener() {},
281
+ document: {
282
+ fonts: {
283
+ load(font) {
284
+ loads.push(font);
285
+ return answer(font);
286
+ }
287
+ }
288
+ }
289
+ };
290
+ t.after(() => delete globalThis.window);
291
+ return loads;
292
+ }
293
+
294
+ test("in a browser the Vuetify options start loading the theme's typefaces, regular and medium, without waiting", (t) => {
295
+ const loads = fontsWindow(t, () => new Promise(() => {}));
296
+ const robotoFlex = '"Roboto Flex Variable", "Roboto Flex", Roboto, system-ui, sans-serif';
297
+
298
+ createMaterialVuetifyOptions();
299
+ assert.deepEqual(loads, [`400 1em ${robotoFlex}`, `500 1em ${robotoFlex}`]);
300
+
301
+ loads.length = 0;
302
+ createMaterialVuetifyOptions({ typography: { brand: '"Fraunces", serif', plain: '"Inter", sans-serif' } });
303
+ assert.deepEqual(loads, [
304
+ '400 1em "Fraunces", serif',
305
+ '500 1em "Fraunces", serif',
306
+ '400 1em "Inter", sans-serif',
307
+ '500 1em "Inter", sans-serif'
308
+ ]);
309
+ });
310
+
311
+ test("a typeface that fails to load leaves the fallback in place, with no unhandled failure", async (t) => {
312
+ const unhandled = [];
313
+ const onUnhandled = (reason) => unhandled.push(reason);
314
+ process.on("unhandledRejection", onUnhandled);
315
+ t.after(() => process.off("unhandledRejection", onUnhandled));
316
+ const loads = fontsWindow(t, () => Promise.reject(new Error("NetworkError: the font did not load")));
317
+
318
+ const options = createMaterialVuetifyOptions();
319
+ await new Promise((resolve) => setImmediate(resolve));
320
+
321
+ assert.equal(loads.length, 2);
322
+ assert.equal(options.theme.themes.light.variables["font-body"], '"Roboto Flex Variable", "Roboto Flex", Roboto, system-ui, sans-serif');
323
+ assert.deepEqual(unhandled, []);
324
+ });
325
+
274
326
  test("a seed that is not a six-digit hex colour is refused", () => {
275
327
  assert.throws(() => materialThemes("purple"), /six-digit hex/u);
276
328
  assert.throws(() => createMaterialVuetifyOptions({ seed: "#123" }), /six-digit hex/u);
@@ -0,0 +1,84 @@
1
+ import assert from "node:assert/strict";
2
+ import { createRequire } from "node:module";
3
+ import process from "node:process";
4
+ import test from "node:test";
5
+ import { fileURLToPath } from "node:url";
6
+ import { expect } from "@playwright/test";
7
+ import { sharedBrowserFixture } from "../../../tooling/testUtils/browserFixture.mjs";
8
+ import { materialThemes } from "../src/client/index.js";
9
+
10
+ const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
11
+ const AXE_PATH = createRequire(import.meta.url).resolve("axe-core/axe.min.js");
12
+ const open = sharedBrowserFixture({
13
+ fixtureRoot: fileURLToPath(new URL("./fixtures/tonal-alerts", import.meta.url)),
14
+ configFile: "vite.config.js"
15
+ });
16
+
17
+ // The fixture's colours, each with a container role, and the surfaces it draws them on (fixtures/tonal-alerts).
18
+ const COLORS = Object.freeze(["primary", "secondary", "tertiary", "error", "warning", "info", "success"]);
19
+ const SURFACES = Object.freeze(["page", "card", "dialog"]);
20
+
21
+ // axe's color-contrast verdict on the texts of each alert on the page, by the alert's data-testid and the text: what
22
+ // it made of the text (passed, failed or unjudged), the text's colour and the background it measured under it, and
23
+ // the ratio of the two.
24
+ async function judgedAlertTexts(page) {
25
+ await page.addScriptTag({ path: AXE_PATH });
26
+ return page.evaluate(async () => {
27
+ const results = await globalThis.axe.run(document, { runOnly: { type: "rule", values: ["color-contrast"] } });
28
+ const ownText = (element) => [...element.childNodes].filter((node) => node.nodeType === 3).map((node) => node.textContent).join("").trim();
29
+ const verdicts = {};
30
+ for (const [outcome, found] of [["passed", results.passes], ["failed", results.violations], ["unjudged", results.incomplete]]) {
31
+ for (const node of found.flatMap((rule) => rule.nodes)) {
32
+ const element = document.querySelector(node.target[0]);
33
+ const alert = element?.closest(".v-alert[data-testid]");
34
+ if (!alert) continue;
35
+ const data = node.any[0]?.data || {};
36
+ verdicts[`${alert.dataset.testid}: ${ownText(element)}`] = {
37
+ outcome,
38
+ fg: String(data.fgColor || "").toLowerCase(),
39
+ bg: String(data.bgColor || "").toLowerCase(),
40
+ ratio: data.contrastRatio
41
+ };
42
+ }
43
+ }
44
+ return verdicts;
45
+ });
46
+ }
47
+
48
+ // Vuetify draws a tonal alert's texts in its colour over a tint of that colour, at the activated opacity, over
49
+ // whatever surface the alert lies on: a tonal error alert's text read 4.48:1 in a light dialog (surface-container-high),
50
+ // under WCAG's 4.5:1, on control's refused dialogs. Material 3's tonal surface is a colour's container, with its text
51
+ // in the colour's on-container role, whatever lies under it: every tonal alert in a colour with a container role is
52
+ // drawn so, on the page, in a card and in a dialog, in light and dark, and axe judges each text so.
53
+ test("a tonal alert in each colour with a container role is its container with on-container text, at 4.5:1 or more on the page, in a card and in a dialog, in light and dark: WCAG 1.4.3 (axe color-contrast)", {
54
+ skip: SKIP,
55
+ timeout: 120_000
56
+ }, async (t) => {
57
+ const { vite, browser } = await open(t);
58
+ const seen = {};
59
+ const expected = {};
60
+ for (const scheme of ["light", "dark"]) {
61
+ const { colors } = materialThemes("#6750A4")[scheme];
62
+ for (const surface of SURFACES) {
63
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce", viewport: { width: 1280, height: 1400 } });
64
+ try {
65
+ await page.goto(`/?surface=${surface}`);
66
+ await expect(page.locator(".v-alert")).toHaveCount(COLORS.length);
67
+ await page.waitForFunction(() => document.getAnimations().every((animation) => animation.playState !== "running"));
68
+ const verdicts = await judgedAlertTexts(page);
69
+ for (const color of COLORS) {
70
+ for (const text of [`The ${color} alert`, `What the ${color} alert says.`]) {
71
+ const at = `${scheme} ${surface} ${color}: ${text}`;
72
+ const verdict = verdicts[`${color}: ${text}`];
73
+ seen[at] = !verdict ? "not judged" : verdict.outcome === "passed" ? `passed: ${verdict.fg} on ${verdict.bg}`
74
+ : `${verdict.outcome} at ${verdict.ratio}:1: ${verdict.fg} on ${verdict.bg}`;
75
+ expected[at] = `passed: ${colors[`on-${color}-container`].toLowerCase()} on ${colors[`${color}-container`].toLowerCase()}`;
76
+ }
77
+ }
78
+ } finally {
79
+ await page.close();
80
+ }
81
+ }
82
+ }
83
+ assert.deepEqual(seen, expected);
84
+ });