@jskit-ai/material-web 0.1.8 → 0.1.9

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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A radio group's own label and a checkbox's, radio's or switch's description are `on-surface-variant` at full strength, as a text field's label and supporting text are, instead of `on-surface` at Vuetify's medium-emphasis opacity: a group's label measured 4.19:1 in a dialog's `surface-container-high`, under WCAG's 4.5:1 (axe `color-contrast`). A control's own label was already `on-surface` at full strength, and a disabled group or control keeps its fade. `accessibility.browser.test.js` measures them in light and dark.
6
+ - A hidden tooltip is hidden whole: `material.css` hides a `v-tooltip` overlay while its text is hidden. Vuetify 4.3 mounts a tooltip before it first shows (`eager`), and hidden it was a `role="tooltip"` element whose text alone was hidden, an empty tooltip to assistive technology (axe `aria-tooltip-name`, WCAG 4.1.2), and its activator's `aria-describedby` read nothing, since hidden text counts only when the element named is hidden itself. Now no tooltip without a name is in the accessibility tree, and the activator is described by the tooltip's text whether it shows or not; a showing or fading tooltip is untouched. The shell's menu control, Up button and icon page actions all carry one.
7
+ - A card's subtitle is at full strength, as a list item's already was: `on-surface-variant`, Material 3's supporting text, on a surface card (JSKIT's default `surface-container-low` card included) or one without a colour, and the card's own text colour on a coloured card or one with a text colour class; a text colour class on the subtitle still wins. At Vuetify's medium-emphasis opacity it measured 4.35:1 on the default card, under WCAG 1.4.3's 4.5:1 (axe `color-contrast`).
8
+ - A text field's character counter is `on-surface-variant` at full strength beside its supporting text, and `error` on an invalid field, as its messages are and as Material 3 draws it; a counter past its limit stays `error`, and a disabled field's keeps its fade. It kept Vuetify's medium-emphasis opacity, 4.19:1 in a dialog's field, under WCAG 1.4.3's 4.5:1 (axe `color-contrast`), and Vuetify left an invalid field's counter faded in the field's text colour. material-web's new browser test (`accessibility.browser.test.js`) measures the tooltip's role, name and description, and the contrast of card subtitles and counters in light and dark.
5
9
  - Skeleton loaders are pale placeholders again: every `v-skeleton-loader` bone (text, heading, avatar, image, button, chip, divider and ossein) is `surface-container-highest`, Material 3's most emphasized neutral container, in light and dark. They were solid `on-surface`, near black in light and near white in dark: Vuetify paints a bone in on-surface at the theme's `border-opacity`, which material-web sets to 1 so that Material 3's outline roles draw at full strength. Material 3 has no skeleton component; its one placeholder colour, Wear's `PlaceholderDefaults.color` (on-surface at 10% over surface-container), lands next to surface-container-highest in both schemes. Each bone's shimmer still sweeps over it, forced colours keep Vuetify's `canvastext` bones, and no app needs an override of its own.
6
10
  - Linear progress indicators have Material 3's `secondary-container` track (a `VProgressLinear` default `bgColor`) beside the bar and stop indicator in the app's `color`: Vuetify paints the track in the bar's own colour at the same `border-opacity`, so the track was as solid as the bar, determinate, indeterminate and wavy alike. An app's `bg-color` still sets the track. material-web's browser test measures every coloured bone, its shimmer and each track, light and dark.
7
11
 
package/README.md CHANGED
@@ -85,12 +85,17 @@ export const theme = {
85
85
  strength (Vuetify fades it to 24%) and a disabled slider in on-surface at
86
86
  38% with its inactive track at 12%, a pagination's current page in the
87
87
  activated layer, skeleton loader bones in `surface-container-highest` under
88
- their shimmer, placeholders, text field labels and supporting text and list
89
- item subtitles in on-surface-variant, one-line labels that
88
+ their shimmer, placeholders, text field labels, supporting text and
89
+ character counters, radio group labels, checkbox, radio and switch
90
+ descriptions, and list item and card subtitles in on-surface-variant
91
+ at full strength (an invalid field's counter in error, as its messages),
92
+ one-line labels that
90
93
  end in an ellipsis, 12dp card corners, 28dp dialogs on
91
94
  `surface-container-high` at level 3 and bottom sheets with a square card on
92
95
  `surface-container-low`, square full-screen dialogs on `surface`, a 48dp touch target on clickable chips,
93
- inverse-surface tooltips, 40dp outlined segmented buttons and outlined
96
+ inverse-surface tooltips hidden whole while their text is (Vuetify mounts a
97
+ tooltip before it shows, and its hidden overlay was an empty tooltip to
98
+ assistive technology), 40dp outlined segmented buttons and outlined
94
99
  filter chips that lead with a check when selected (chips with
95
100
  `aria-pressed` too), fixed tabs that share the width or else scroll, dialog
96
101
  actions 24dp from the edges, a menu's own list as its container
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/material-web",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
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": {
@@ -282,6 +282,15 @@
282
282
  padding: 4px 8px;
283
283
  }
284
284
 
285
+ /* A hidden tooltip is hidden whole. Vuetify 4.3 mounts a tooltip before it first shows (eager), and while it is
286
+ hidden only its text is: the role="tooltip" overlay around it stays drawn, an empty tooltip to assistive
287
+ technology (axe aria-tooltip-name), and its activator's aria-describedby reads nothing, since hidden text counts
288
+ only when the element the activator names is hidden itself. The overlay hides only while its text does, so a
289
+ showing or fading tooltip is untouched. */
290
+ .v-tooltip:has(> .v-overlay__content[style*="display: none"]) {
291
+ display: none;
292
+ }
293
+
285
294
  /* Segmented buttons (v-btn-toggle): a 40dp pill in the outline role whose segments share its width, each with a 48dp
286
295
  touch target. An unselected segment has no container; the selected one is secondary-container and leads with a
287
296
  check, which takes the place of its icon. */
@@ -461,16 +470,34 @@
461
470
  opacity: 1;
462
471
  }
463
472
 
464
- /* A text field's label and its supporting text are on-surface-variant at full strength, as Material 3's text field
465
- draws them, instead of Vuetify's on-surface at the medium-emphasis opacity: 4.4:1 on a light surface, under
466
- WCAG's 4.5:1. A focused field's label keeps the field's colour, an invalid field's label and messages keep error,
467
- and a disabled field keeps its own fade. */
473
+ /* A text field's label, its supporting text and its character counter are on-surface-variant at full strength, as
474
+ Material 3's text field draws them, instead of Vuetify's on-surface at the medium-emphasis opacity: 4.4:1 on a
475
+ light surface and 4.19:1 for a counter in a dialog, under WCAG's 4.5:1. A focused field's label keeps the field's
476
+ colour, an invalid field's label, messages and counter are error, a counter past its limit is error too, and a
477
+ disabled field keeps its own fade. */
468
478
  .v-field:not(.v-field--focused, .v-field--error) .v-label.v-field-label {
469
479
  color: rgb(var(--v-theme-on-surface-variant));
470
480
  opacity: 1;
471
481
  }
472
482
 
473
- .v-input:not(.v-input--error, .v-input--disabled) > .v-input__details .v-messages {
483
+ .v-input:not(.v-input--error, .v-input--disabled) > .v-input__details :is(.v-messages, .v-counter) {
484
+ color: rgb(var(--v-theme-on-surface-variant));
485
+ opacity: 1;
486
+ }
487
+
488
+ /* Vuetify draws an invalid field's messages in error at full strength and leaves its counter faded; Material 3's
489
+ counter is error with them. */
490
+ .v-input--error:not(.v-input--disabled) > .v-input__details .v-counter {
491
+ color: rgb(var(--v-theme-error));
492
+ opacity: 1;
493
+ }
494
+
495
+ /* So are a radio group's own label and a checkbox's, radio's or switch's description, its supporting text, instead
496
+ of on-surface at the medium-emphasis opacity: 4.19:1 for a group's label in a dialog, under WCAG's 4.5:1. A
497
+ control's own label is already on-surface at full strength, Material 3's colour for it, and a disabled group or
498
+ control keeps its own fade. */
499
+ .v-radio-group:not(.v-input--disabled) > .v-input__control > .v-label,
500
+ .v-selection-control:not(.v-selection-control--disabled) .v-selection-control__description {
474
501
  color: rgb(var(--v-theme-on-surface-variant));
475
502
  opacity: 1;
476
503
  }
@@ -488,6 +515,19 @@
488
515
  color: rgb(var(--v-theme-on-surface-variant));
489
516
  }
490
517
 
518
+ /* So is a card's subtitle, instead of the card's colour at the medium-emphasis opacity: 4.35:1 on the default
519
+ surface-container-low card, under WCAG's 4.5:1. On a surface card, or one without a colour, it is
520
+ on-surface-variant, Material 3's supporting text; a coloured card keeps its own on-colour, and so does a card with
521
+ its own text colour. A text colour class on the subtitle itself still wins. */
522
+ .v-card-subtitle {
523
+ opacity: 1;
524
+ }
525
+
526
+ .v-card:not([class*="bg-"], [class*=" text-"]) .v-card-subtitle,
527
+ .v-card[class*="bg-surface"]:not([class*=" text-"]) .v-card-subtitle {
528
+ color: rgb(var(--v-theme-on-surface-variant));
529
+ }
530
+
491
531
  /* Dividers and table rules use outline-variant at full strength (the theme's border colour). Vuetify draws a
492
532
  divider in the text colour, so one without a color prop takes outline-variant. */
493
533
  .v-divider {
@@ -0,0 +1,201 @@
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 { expect } from "@playwright/test";
6
+ import { sharedBrowserFixture } from "../../../tooling/testUtils/browserFixture.mjs";
7
+ import { materialThemes } from "../src/client/index.js";
8
+
9
+ const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
10
+ const open = sharedBrowserFixture({
11
+ fixtureRoot: fileURLToPath(new URL("./fixtures/accessibility", import.meta.url)),
12
+ configFile: "vite.config.js"
13
+ });
14
+
15
+ // A theme colour as the "r, g, b" a drawn part is measured in.
16
+ const channels = (hex) => [1, 3, 5].map((start) => Number.parseInt(hex.slice(start, start + 2), 16)).join(", ");
17
+
18
+ // What a piece of text shows on the page: its colour, the background under it and its contrast ratio, as axe's
19
+ // color-contrast measures it. Colours are painted on a canvas so that rgb(), color(srgb ...) and color-mix() all read
20
+ // as 8-bit channels. The text's opacity is its colour's alpha times its own opacity and every ancestor's; the
21
+ // background is the nearest opaque one, under a tonal card's underlay.
22
+ function drawnText(locator) {
23
+ return locator.evaluate((text) => {
24
+ const context = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
25
+ const paint = (value) => {
26
+ context.clearRect(0, 0, 1, 1);
27
+ context.fillStyle = value;
28
+ context.fillRect(0, 0, 1, 1);
29
+ const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data;
30
+ return { red, green, blue, alpha: alpha / 255 };
31
+ };
32
+ const mix = (top, bottom, alpha) => ({
33
+ red: top.red * alpha + bottom.red * (1 - alpha),
34
+ green: top.green * alpha + bottom.green * (1 - alpha),
35
+ blue: top.blue * alpha + bottom.blue * (1 - alpha),
36
+ alpha: 1
37
+ });
38
+ const luminance = ({ red, green, blue }) => {
39
+ const linear = (channel) => {
40
+ const value = channel / 255;
41
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
42
+ };
43
+ return 0.2126 * linear(red) + 0.7152 * linear(green) + 0.0722 * linear(blue);
44
+ };
45
+ let background = null;
46
+ const underlays = [];
47
+ for (let node = text; node && !background; node = node.parentElement) {
48
+ const underlay = node.querySelector(":scope > .v-card__underlay");
49
+ if (underlay) underlays.unshift(underlay);
50
+ const colour = paint(getComputedStyle(node).backgroundColor);
51
+ if (colour.alpha === 1) background = colour;
52
+ }
53
+ for (const underlay of underlays) {
54
+ const layer = paint(getComputedStyle(underlay).backgroundColor);
55
+ background = mix(layer, background, layer.alpha * Number(getComputedStyle(underlay).opacity));
56
+ }
57
+ let opacity = 1;
58
+ for (let node = text; node; node = node.parentElement) opacity *= Number(getComputedStyle(node).opacity);
59
+ const colour = paint(getComputedStyle(text).color);
60
+ const shown = mix(colour, background, colour.alpha * opacity);
61
+ const [lighter, darker] = [luminance(shown), luminance(background)].sort((a, b) => b - a);
62
+ return {
63
+ color: `${colour.red}, ${colour.green}, ${colour.blue}`,
64
+ opacity: Math.round(colour.alpha * opacity * 1000) / 1000,
65
+ background: `${Math.round(background.red)}, ${Math.round(background.green)}, ${Math.round(background.blue)}`,
66
+ ratio: Math.round(((lighter + 0.05) / (darker + 0.05)) * 100) / 100
67
+ };
68
+ });
69
+ }
70
+
71
+ // Vuetify 4.3 mounts a tooltip before it first shows (eager): hidden, it is a role="tooltip" overlay whose text alone
72
+ // is hidden, so assistive technology met an empty tooltip (axe aria-tooltip-name), and the activator's
73
+ // aria-describedby, which names that overlay, read nothing. material.css hides the overlay whole while its text is
74
+ // hidden: no tooltip without a name, and the activator described by the tooltip's text, hidden or shown.
75
+ test("a hidden tooltip leaves no tooltip without a name and still describes its button: WCAG 4.1.2 (axe aria-tooltip-name)", {
76
+ skip: SKIP,
77
+ timeout: 120_000
78
+ }, async (t) => {
79
+ const { vite, browser } = await open(t);
80
+ const page = await browser.newPage({ baseURL: vite.baseURL, reducedMotion: "reduce" });
81
+ await page.goto("/");
82
+ const button = page.getByTestId("tooltip-activator");
83
+ await expect(button).toBeVisible();
84
+ // Vuetify has mounted the tooltip with its text hidden inside it before it ever showed.
85
+ const content = page.locator(".v-tooltip > .v-overlay__content");
86
+ await expect(content).toHaveCount(1);
87
+ await expect(content).toHaveText("Delete this report");
88
+ await expect(content).toBeHidden();
89
+
90
+ await expect(page.getByRole("tooltip"), "no tooltip in the accessibility tree while hidden").toHaveCount(0);
91
+ await expect(button).toHaveAccessibleName("Delete");
92
+ await expect(button).toHaveAccessibleDescription("Delete this report");
93
+
94
+ await button.hover();
95
+ await expect(page.getByRole("tooltip", { name: "Delete this report" })).toBeVisible();
96
+ await expect(button).toHaveAccessibleDescription("Delete this report");
97
+
98
+ await page.mouse.move(0, 0);
99
+ await expect(content).toBeHidden();
100
+ await expect(page.getByRole("tooltip"), "none again once it hides").toHaveCount(0);
101
+ await expect(button).toHaveAccessibleDescription("Delete this report");
102
+ });
103
+
104
+ // A card's subtitle is its supporting text, at full strength: on-surface-variant on a surface card or one without a
105
+ // colour, the card's own text colour on a coloured card, and its own class's colour when it has one. At Vuetify's
106
+ // medium-emphasis opacity it measured 4.35:1 on JSKIT's default surface-container-low card, under WCAG's 4.5:1.
107
+ test("a card's subtitle reads at 4.5:1 or more on every card, in light and dark: WCAG 1.4.3 (axe color-contrast)", {
108
+ skip: SKIP,
109
+ timeout: 120_000
110
+ }, async (t) => {
111
+ const { vite, browser } = await open(t);
112
+ for (const scheme of ["light", "dark"]) {
113
+ const { colors } = materialThemes("#6750A4")[scheme];
114
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
115
+ await page.goto("/");
116
+ const subtitles = {
117
+ "default-card": ["on-surface-variant", "surface-container-low"],
118
+ "surface-card": ["on-surface-variant", "surface-container-high"],
119
+ "uncoloured-card": ["on-surface-variant", "surface"],
120
+ "primary-card": ["on-primary", "primary"],
121
+ "tonal-card": ["primary"],
122
+ "subtitle-class-card": ["error", "surface-container-low"]
123
+ };
124
+ for (const [testId, [role, background]] of Object.entries(subtitles)) {
125
+ const at = `${scheme} ${testId}`;
126
+ const subtitle = await drawnText(page.getByTestId(testId).locator(".v-card-subtitle"));
127
+ assert.ok(subtitle.ratio >= 4.5, `${at}: the subtitle's contrast was ${subtitle.ratio}:1`);
128
+ assert.equal(subtitle.opacity, 1, `${at}: the subtitle is at full strength`);
129
+ assert.equal(subtitle.color, channels(colors[role]), `${at}: the subtitle is ${role}`);
130
+ if (background) assert.equal(subtitle.background, channels(colors[background]), `${at}: on ${background}`);
131
+ }
132
+ await page.close();
133
+ }
134
+ });
135
+
136
+ // A text field's character counter is supporting text beside its messages, at full strength: on-surface-variant on
137
+ // a valid field, error on an invalid one or past its limit, and a disabled field's keeps its fade. At Vuetify's
138
+ // medium-emphasis opacity it measured 4.19:1 on a dialog's surface-container-high, under WCAG's 4.5:1.
139
+ test("a text field's character counter reads at 4.5:1 or more on a dialog's surface, in light and dark: WCAG 1.4.3 (axe color-contrast)", {
140
+ skip: SKIP,
141
+ timeout: 120_000
142
+ }, async (t) => {
143
+ const { vite, browser } = await open(t);
144
+ for (const scheme of ["light", "dark"]) {
145
+ const { colors } = materialThemes("#6750A4")[scheme];
146
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
147
+ await page.goto("/");
148
+ const counters = {
149
+ "counter-field": ["on-surface-variant", "3 / 20"],
150
+ "invalid-counter-field": ["error", "2 / 20"],
151
+ "over-counter-field": ["error", "7 / 4"]
152
+ };
153
+ for (const [testId, [role, text]] of Object.entries(counters)) {
154
+ const at = `${scheme} ${testId}`;
155
+ const counter = page.getByTestId(testId).locator(".v-counter");
156
+ await expect(counter, at).toHaveText(text);
157
+ const drawn = await drawnText(counter);
158
+ assert.ok(drawn.ratio >= 4.5, `${at}: the counter's contrast was ${drawn.ratio}:1`);
159
+ assert.equal(drawn.opacity, 1, `${at}: the counter is at full strength`);
160
+ assert.equal(drawn.color, channels(colors[role]), `${at}: the counter is ${role}`);
161
+ assert.equal(drawn.background, channels(colors["surface-container-high"]), `${at}: on surface-container-high`);
162
+ }
163
+ // WCAG exempts a disabled control's text: it keeps the field's own fade.
164
+ const disabled = await drawnText(page.getByTestId("disabled-counter-field").locator(".v-counter"));
165
+ assert.ok(disabled.opacity < 1, `${scheme}: a disabled field's counter keeps its fade (${disabled.opacity})`);
166
+ await page.close();
167
+ }
168
+ });
169
+
170
+ // A radio group's own label and a selection control's description are supporting text, at full strength in
171
+ // on-surface-variant; a checkbox's own label is on-surface, as Vuetify already draws it. At Vuetify's medium-emphasis
172
+ // opacity a group's label measured 4.19:1 in a dialog's surface-container-high ("Flag to raise"), under WCAG's 4.5:1.
173
+ test("a radio group's label and a checkbox's label and description read at 4.5:1 or more on a dialog's surface, in light and dark: WCAG 1.4.3 (axe color-contrast)", {
174
+ skip: SKIP,
175
+ timeout: 120_000
176
+ }, async (t) => {
177
+ const { vite, browser } = await open(t);
178
+ for (const scheme of ["light", "dark"]) {
179
+ const { colors } = materialThemes("#6750A4")[scheme];
180
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
181
+ await page.goto("/");
182
+ const texts = {
183
+ "radio group's label": [page.getByTestId("radio-group-field").locator(".v-input__control > .v-label"), "on-surface-variant", "Flag to raise"],
184
+ "checkbox's label": [page.getByTestId("checkbox-field").locator(".v-selection-control .v-label"), "on-surface", "Include archived records"],
185
+ "checkbox's description": [page.getByTestId("checkbox-field").locator(".v-selection-control__description"), "on-surface-variant", "Archived records are read-only"]
186
+ };
187
+ for (const [name, [locator, role, text]] of Object.entries(texts)) {
188
+ const at = `${scheme} ${name}`;
189
+ await expect(locator, at).toHaveText(text);
190
+ const drawn = await drawnText(locator);
191
+ assert.ok(drawn.ratio >= 4.5, `${at}: the contrast was ${drawn.ratio}:1`);
192
+ assert.equal(drawn.opacity, 1, `${at}: at full strength`);
193
+ assert.equal(drawn.color, channels(colors[role]), `${at}: ${role}`);
194
+ assert.equal(drawn.background, channels(colors["surface-container-high"]), `${at}: on surface-container-high`);
195
+ }
196
+ // WCAG exempts a disabled control's text: a disabled group's label keeps its fade.
197
+ const disabled = await drawnText(page.getByTestId("disabled-radio-group-field").locator(".v-input__control > .v-label"));
198
+ assert.ok(disabled.opacity < 1, `${scheme}: a disabled radio group's label keeps its fade (${disabled.opacity})`);
199
+ await page.close();
200
+ }
201
+ });
@@ -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 accessibility</title></head><body><div id="app"></div><script type="module" src="/main.js"></script></body></html>
@@ -0,0 +1,80 @@
1
+ import { createApp, h } from "vue";
2
+ import { createVuetify } from "vuetify";
3
+ import { VApp } from "vuetify/components/VApp";
4
+ import { VBtn } from "vuetify/components/VBtn";
5
+ import { VCard, VCardItem, VCardSubtitle, VCardText, VCardTitle } from "vuetify/components/VCard";
6
+ import { VCheckbox } from "vuetify/components/VCheckbox";
7
+ import { VIcon } from "vuetify/components/VIcon";
8
+ import { VMain } from "vuetify/components/VMain";
9
+ import { VRadio } from "vuetify/components/VRadio";
10
+ import { VRadioGroup } from "vuetify/components/VRadioGroup";
11
+ import { VTextField } from "vuetify/components/VTextField";
12
+ import { VTooltip } from "vuetify/components/VTooltip";
13
+ import "vuetify/styles";
14
+ import "../../../src/client/material.css";
15
+ import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
16
+
17
+ // What axe measures on an app's screens, with JSKIT's Material 3 options and stylesheet, as an app draws them, in the
18
+ // browser's light or dark scheme (accessibility.browser.test.js):
19
+ // - an icon button with Vuetify's tooltip as its own child, as the shell's menu control has; the tooltip keeps
20
+ // Vuetify's defaults, so it is mounted before it first shows;
21
+ // - cards with a title and a subtitle: JSKIT's default (flat on surface-container-low), another surface container,
22
+ // one without a colour, a coloured one, a tonal one (its colour is its text colour) and a default one whose subtitle
23
+ // has a colour class of its own;
24
+ // - text fields with a character counter on a dialog's surface-container-high: a valid one, an invalid one, one past
25
+ // its limit and a disabled one;
26
+ // - beside them, a radio group with its own label, a disabled one, and a checkbox with a label and a description.
27
+ const cards = [
28
+ { testId: "default-card", props: {} },
29
+ { testId: "surface-card", props: { color: "surface-container-high" } },
30
+ { testId: "uncoloured-card", props: { color: null } },
31
+ { testId: "primary-card", props: { color: "primary" } },
32
+ { testId: "tonal-card", props: { color: "primary", variant: "tonal" } },
33
+ { testId: "subtitle-class-card", props: {}, subtitleClass: "text-error" }
34
+ ];
35
+
36
+ const fields = [
37
+ { testId: "counter-field", props: { label: "Name", modelValue: "Ana" } },
38
+ { testId: "invalid-counter-field", props: { label: "Code", modelValue: "AB", errorMessages: ["Use four letters"] } },
39
+ { testId: "over-counter-field", props: { label: "Initials", modelValue: "ABCDEFG", counter: 4 } },
40
+ { testId: "disabled-counter-field", props: { label: "Team", modelValue: "Blue", disabled: true } }
41
+ ];
42
+
43
+ const tooltipButton = () => h(VBtn, { icon: true, variant: "text", "aria-label": "Delete", "data-testid": "tooltip-activator" }, () => [
44
+ h(VIcon, { icon: "$delete" }),
45
+ h(VTooltip, { activator: "parent", location: "bottom", text: "Delete this report" })
46
+ ]);
47
+
48
+ const card = ({ testId, props, subtitleClass }) => h(VCard, { ...props, class: "mb-4", "data-testid": testId }, () => (
49
+ h(VCardItem, null, () => [
50
+ h(VCardTitle, null, () => "Quarterly report"),
51
+ h(VCardSubtitle, { class: subtitleClass }, () => "Updated yesterday")
52
+ ])
53
+ ));
54
+
55
+ const radioGroup = (testId, props) => h(VRadioGroup, { label: "Flag to raise", modelValue: "review", ...props, "data-testid": testId }, () => [
56
+ h(VRadio, { label: "Needs review", value: "review" }),
57
+ h(VRadio, { label: "Duplicate", value: "duplicate" })
58
+ ]);
59
+
60
+ const fieldsCard = () => h(VCard, { color: "surface-container-high", "data-testid": "fields-card" }, () => (
61
+ h(VCardText, null, () => [
62
+ ...fields.map(({ testId, props }) => h(VTextField, { counter: 20, persistentCounter: true, ...props, "data-testid": testId })),
63
+ radioGroup("radio-group-field", {}),
64
+ radioGroup("disabled-radio-group-field", { disabled: true }),
65
+ h(VCheckbox, {
66
+ label: "Include archived records",
67
+ description: "Archived records are read-only",
68
+ modelValue: true,
69
+ "data-testid": "checkbox-field"
70
+ })
71
+ ])
72
+ ));
73
+
74
+ const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => [
75
+ h("div", { class: "mb-6" }, tooltipButton()),
76
+ ...cards.map(card),
77
+ fieldsCard()
78
+ ]));
79
+
80
+ 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
+ });
@@ -320,9 +320,20 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
320
320
  css,
321
321
  /\.v-field:not\(\.v-field--focused, \.v-field--error\) \.v-label\.v-field-label \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
322
322
  );
323
+ // Its character counter is with its supporting text; an invalid field's counter is error, as its messages are
324
+ // (accessibility.browser.test.js measures them).
323
325
  assert.match(
324
326
  css,
325
- /\.v-input:not\(\.v-input--error, \.v-input--disabled\) > \.v-input__details \.v-messages \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
327
+ /\.v-input:not\(\.v-input--error, \.v-input--disabled\) > \.v-input__details :is\(\.v-messages, \.v-counter\) \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
328
+ );
329
+ assert.match(
330
+ css,
331
+ /\.v-input--error:not\(\.v-input--disabled\) > \.v-input__details \.v-counter \{\s*color: rgb\(var\(--v-theme-error\)\);\s*opacity: 1;/u
332
+ );
333
+ // So are a radio group's own label and a selection control's description.
334
+ assert.match(
335
+ css,
336
+ /\.v-radio-group:not\(\.v-input--disabled\) > \.v-input__control > \.v-label,\s*\.v-selection-control:not\(\.v-selection-control--disabled\) \.v-selection-control__description \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
326
337
  );
327
338
  // So is an inactive, uncoloured list item's subtitle; every enabled item's subtitle, an active one's included, is
328
339
  // at full strength in the item's own colour.
@@ -331,6 +342,15 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
331
342
  /\.v-list-item:not\(\.v-list-item--active, \.v-list-item--disabled, \[class\*=" text-"\]\) \.v-list-item-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*\}/u
332
343
  );
333
344
  assert.match(css, /\.v-list-item:not\(\.v-list-item--disabled\) \.v-list-item-subtitle \{\s*opacity: 1;\s*\}/u);
345
+ // And a card's subtitle: on-surface-variant on a surface card or one without a colour, unless the card has a text
346
+ // colour of its own.
347
+ assert.match(css, /\n {2}\.v-card-subtitle \{\s*opacity: 1;\s*\}/u);
348
+ assert.match(
349
+ css,
350
+ /\.v-card:not\(\[class\*="bg-"\], \[class\*=" text-"\]\) \.v-card-subtitle,\s*\.v-card\[class\*="bg-surface"\]:not\(\[class\*=" text-"\]\) \.v-card-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*\}/u
351
+ );
352
+ // A tooltip is hidden whole while its text is.
353
+ assert.match(css, /\.v-tooltip:has\(> \.v-overlay__content\[style\*="display: none"\]\) \{\s*display: none;\s*\}/u);
334
354
  // A disabled container button is on-surface 12% and 38%, unlayered over its colour class.
335
355
  assert.match(
336
356
  css,