@jskit-ai/material-web 0.1.7 → 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 +7 -0
- package/README.md +17 -5
- package/package.json +1 -1
- package/src/client/defaults.js +13 -6
- package/src/client/material.css +64 -5
- package/test/accessibility.browser.test.js +201 -0
- package/test/fixtures/accessibility/index.html +2 -0
- package/test/fixtures/accessibility/main.js +80 -0
- package/test/fixtures/accessibility/vite.config.js +7 -0
- package/test/fixtures/loading/index.html +2 -0
- package/test/fixtures/loading/main.js +34 -0
- package/test/fixtures/loading/vite.config.js +7 -0
- package/test/loading.browser.test.js +116 -0
- package/test/materialWeb.test.js +28 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.
|
|
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.
|
|
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.
|
|
11
|
+
|
|
5
12
|
- Sliders and range sliders are Material 3's slider: Vuetify's pill variant by default, Material 3's extra-small (default) slider, with a 16dp track, a 4x44dp handle bar set apart from the track by a gap on either side, and a stop indicator at the end of the inactive track; the active track and the handle are `primary`, and the inactive track is `secondary-container` at full strength (the new `trackColor` default). They were Vuetify's default variant, a 4dp track under a round, raised 20dp handle. The md3 blueprint's `color: "primary"` made Vuetify draw the inactive track in `primary` faded to 38% (`v-slider-track__background--opacity`; 24% for the pill variant), and an app's `track-color` was faded the same way, which left a `secondary-container` track nearly invisible; a range slider had no colour at all, so its tracks and handles were a grey `surface-variant`. On a 4dp track, the pale `secondary-container` alone stays hard to see on a light container (1.05:1 on `surface-container-high`), which is why Material 3 draws it 16dp tall and ends it with the stop indicator. A disabled slider is on-surface at 38% for the active track and the handle and 12% for the inactive track, where Vuetify drew `surface-variant` at 38% and the inactive track at 14%. An invalid slider keeps Vuetify's look. The defaults set only `color`, `trackColor` and `variant`, so an app's `color` prop still sets the active track and the handle, and `variant="default"` brings back Vuetify's round handle. material-web's browser test measures each part's colour and opacity, light and dark, and the track, handle and stop indicator.
|
|
6
13
|
|
|
7
14
|
- Fields open fast again: material-web's install script (`postinstall`) stops Vuetify's idle loaders reading layout as they mount ([vuetifyjs/vuetify#23393](https://github.com/vuetifyjs/vuetify/issues/23393)). Every `VField`-based input mounts an idle `VProgressLinear`, whose `useElementIntersection(root)` read `getBoundingClientRect()` at once, a forced layout per field in a form that writes a style as it mounts: 300 fields took 15.9 s to mount, 1.3 s patched (the package's browser test). The script passes `{ immediate: false }` to the three loaders' calls (`VProgressLinear`, `VProgressCircular`, labs' `VLoadingIndicator`) in the installed Vuetify's `lib/` modules and its `dist/vuetify(-labs).esm.js`, `.cjs` and `.js` builds, all or nothing per Vuetify copy, and only where it finds exactly the calls it expects; otherwise it prints one line naming the issue and changes nothing. It never fails an install. Approve it in the app's root `package.json` (`"allowScripts": { "@jskit-ai/material-web": true }`, which `jskit update` adds): a strict install (`strict-allow-scripts`) fails without the approval, and an install with `--ignore-scripts` leaves Vuetify as published until `npm rebuild @jskit-ai/material-web`. Remove it once a fixed Vuetify is pinned; the README's Upstream workarounds says how.
|
package/README.md
CHANGED
|
@@ -43,7 +43,11 @@ export const theme = {
|
|
|
43
43
|
is refused. `defaultTheme` is `"system"`, so the app follows the
|
|
44
44
|
device's light or dark setting. Theme variables carry the Material 3 state
|
|
45
45
|
layers (hover 8%, focus 10%, pressed 10%, dragged 16%) and `border-color` and
|
|
46
|
-
`shadow-color` as channel strings (`outline-variant` and `shadow`).
|
|
46
|
+
`shadow-color` as channel strings (`outline-variant` and `shadow`).
|
|
47
|
+
`border-opacity` is 1, so outlines and dividers draw their role at full
|
|
48
|
+
strength; the Vuetify parts that reuse it for a fill get their own role
|
|
49
|
+
instead (a skeleton loader's bones, a linear progress indicator's track, a
|
|
50
|
+
pagination's current page). There is no
|
|
47
51
|
hand-picked colour and no generator command: change the seed and both schemes
|
|
48
52
|
follow.
|
|
49
53
|
- **Icons.** Every Vuetify alias and JSKIT's own aliases are Material Symbols
|
|
@@ -68,7 +72,9 @@ export const theme = {
|
|
|
68
72
|
`$close`, the inverse-surface snackbar, the Material switch, Material 3's
|
|
69
73
|
slider and range slider (Vuetify's pill variant: a 16dp track, a 4x44dp
|
|
70
74
|
handle bar set apart from it and a stop indicator) in `primary` with a
|
|
71
|
-
`secondary-container` inactive track,
|
|
75
|
+
`secondary-container` inactive track, the linear progress indicator's
|
|
76
|
+
`secondary-container` track (its bar and stop in the app's `color`), and the
|
|
77
|
+
16dp `primary-container` FAB;
|
|
72
78
|
`v-btn-toggle` as a segmented button and `v-chip-group` as filter chips,
|
|
73
79
|
selected in `secondary-container`.
|
|
74
80
|
- **`material.css`.** What props cannot set: 40dp buttons and 40dp icon
|
|
@@ -78,12 +84,18 @@ export const theme = {
|
|
|
78
84
|
buttons in on-surface at 12% and 38%, a slider's inactive track at full
|
|
79
85
|
strength (Vuetify fades it to 24%) and a disabled slider in on-surface at
|
|
80
86
|
38% with its inactive track at 12%, a pagination's current page in the
|
|
81
|
-
activated layer,
|
|
82
|
-
|
|
87
|
+
activated layer, skeleton loader bones in `surface-container-highest` under
|
|
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
|
|
83
93
|
end in an ellipsis, 12dp card corners, 28dp dialogs on
|
|
84
94
|
`surface-container-high` at level 3 and bottom sheets with a square card on
|
|
85
95
|
`surface-container-low`, square full-screen dialogs on `surface`, a 48dp touch target on clickable chips,
|
|
86
|
-
inverse-surface tooltips
|
|
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
|
|
87
99
|
filter chips that lead with a check when selected (chips with
|
|
88
100
|
`aria-pressed` too), fixed tabs that share the width or else scroll, dialog
|
|
89
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.
|
|
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": {
|
package/src/client/defaults.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// JSKIT's Material 3 component defaults, on top of Vuetify's md3 blueprint: full-shape filled buttons, cards that rest
|
|
2
2
|
// flat on surface-container-low, flat expansion panels, outlined fields, 8dp chips that close with $close, segmented buttons and
|
|
3
3
|
// filter chips that select in secondary-container, the inverse-surface snackbar, the Material switch, Material 3's
|
|
4
|
-
// slider (Vuetify's pill variant) with a secondary-container inactive track,
|
|
5
|
-
// number for `rounded` is an exact corner in dp.
|
|
6
|
-
// and
|
|
7
|
-
// defaults: under them, in Vuetify 4.2.1 to 4.3.2, an
|
|
8
|
-
// heights, so a v-select's typeahead never scrolls to
|
|
9
|
-
// README, Upstream workarounds).
|
|
4
|
+
// slider (Vuetify's pill variant) with a secondary-container inactive track, the linear progress indicator's
|
|
5
|
+
// secondary-container track, and the 16dp primary-container FAB. A number for `rounded` is an exact corner in dp.
|
|
6
|
+
// Card, dialog and bottom sheet corners and colours, a menu's own list, skeleton loader bones, and the sizes and states
|
|
7
|
+
// props cannot set, are in material.css. No VMenu sub-component defaults: under them, in Vuetify 4.2.1 to 4.3.2, an
|
|
8
|
+
// ancestor's re-render makes the menu's virtual list lose its item heights, so a v-select's typeahead never scrolls to
|
|
9
|
+
// its match (https://github.com/vuetifyjs/vuetify/issues/23366; README, Upstream workarounds).
|
|
10
10
|
const materialDefaults = Object.freeze({
|
|
11
11
|
VAppBar: {
|
|
12
12
|
color: "surface",
|
|
@@ -85,6 +85,13 @@ const materialDefaults = Object.freeze({
|
|
|
85
85
|
trackColor: "secondary-container",
|
|
86
86
|
variant: "pill"
|
|
87
87
|
},
|
|
88
|
+
// Material 3's linear progress indicator: a secondary-container track beside the primary active indicator and stop.
|
|
89
|
+
// Vuetify draws the track in the bar's own colour at the border opacity, which the outline roles keep at full
|
|
90
|
+
// strength, so the track was as solid as the bar. An app's color prop still sets the bar and the stop, and its
|
|
91
|
+
// bg-color the track.
|
|
92
|
+
VProgressLinear: {
|
|
93
|
+
bgColor: "secondary-container"
|
|
94
|
+
},
|
|
88
95
|
VRangeSlider: {
|
|
89
96
|
color: "primary",
|
|
90
97
|
trackColor: "secondary-container",
|
package/src/client/material.css
CHANGED
|
@@ -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. */
|
|
@@ -435,6 +444,25 @@
|
|
|
435
444
|
opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
|
|
436
445
|
}
|
|
437
446
|
|
|
447
|
+
/* A skeleton loader's bones (text, heading, avatar, image, button, chip, divider, ossein) are
|
|
448
|
+
surface-container-highest, Material 3's most emphasized neutral container, a pale placeholder in light and dark.
|
|
449
|
+
Vuetify draws them in on-surface at the border opacity, which the outline roles keep at full strength, so every
|
|
450
|
+
bone was solid on-surface, near black in light. Each bone's shimmer (its ::after) still sweeps over it. Forced
|
|
451
|
+
colours keep Vuetify's canvastext bones, restated here since this rule outranks Vuetify's. */
|
|
452
|
+
.v-skeleton-loader :is(.v-skeleton-loader__avatar, .v-skeleton-loader__button, .v-skeleton-loader__chip,
|
|
453
|
+
.v-skeleton-loader__divider, .v-skeleton-loader__heading, .v-skeleton-loader__image, .v-skeleton-loader__ossein,
|
|
454
|
+
.v-skeleton-loader__text) {
|
|
455
|
+
background-color: rgb(var(--v-theme-surface-container-highest));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
@media (forced-colors: active) {
|
|
459
|
+
.v-skeleton-loader :is(.v-skeleton-loader__avatar, .v-skeleton-loader__button, .v-skeleton-loader__chip,
|
|
460
|
+
.v-skeleton-loader__divider, .v-skeleton-loader__heading, .v-skeleton-loader__image,
|
|
461
|
+
.v-skeleton-loader__ossein, .v-skeleton-loader__text) {
|
|
462
|
+
background-color: canvastext;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
438
466
|
/* A shown placeholder is on-surface-variant at full strength, as Material 3's text field and search bar draw it,
|
|
439
467
|
instead of Vuetify's faded on-surface (2.2:1). A labelled field still hides it until the field is active. */
|
|
440
468
|
.v-field:is(.v-field--active, .v-field--no-label) :is(input, textarea)::placeholder {
|
|
@@ -442,16 +470,34 @@
|
|
|
442
470
|
opacity: 1;
|
|
443
471
|
}
|
|
444
472
|
|
|
445
|
-
/* A text field's label
|
|
446
|
-
draws them, instead of Vuetify's on-surface at the medium-emphasis opacity: 4.4:1 on a
|
|
447
|
-
WCAG's 4.5:1. A focused field's label keeps the field's
|
|
448
|
-
and a
|
|
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. */
|
|
449
478
|
.v-field:not(.v-field--focused, .v-field--error) .v-label.v-field-label {
|
|
450
479
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
451
480
|
opacity: 1;
|
|
452
481
|
}
|
|
453
482
|
|
|
454
|
-
.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 {
|
|
455
501
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
456
502
|
opacity: 1;
|
|
457
503
|
}
|
|
@@ -469,6 +515,19 @@
|
|
|
469
515
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
470
516
|
}
|
|
471
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
|
+
|
|
472
531
|
/* Dividers and table rules use outline-variant at full strength (the theme's border colour). Vuetify draws a
|
|
473
532
|
divider in the text colour, so one without a color prop takes outline-variant. */
|
|
474
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,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,34 @@
|
|
|
1
|
+
import { createApp, h } from "vue";
|
|
2
|
+
import { createVuetify } from "vuetify";
|
|
3
|
+
import { VApp } from "vuetify/components/VApp";
|
|
4
|
+
import { VCard } from "vuetify/components/VCard";
|
|
5
|
+
import { VMain } from "vuetify/components/VMain";
|
|
6
|
+
import { VProgressLinear } from "vuetify/components/VProgressLinear";
|
|
7
|
+
import { VSkeletonLoader } from "vuetify/components/VSkeletonLoader";
|
|
8
|
+
import "vuetify/styles";
|
|
9
|
+
import "../../../src/client/material.css";
|
|
10
|
+
import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
|
|
11
|
+
|
|
12
|
+
// Skeleton loaders and linear progress indicators with JSKIT's Material 3 options and stylesheet, as an app draws them,
|
|
13
|
+
// in the browser's light or dark scheme (loading.browser.test.js). The first loader is the reported one, a transparent
|
|
14
|
+
// list row on a card; the second has every other bone Vuetify colours (image, heading, button, chip, divider, ossein).
|
|
15
|
+
const parts = [
|
|
16
|
+
{
|
|
17
|
+
testId: "list-row",
|
|
18
|
+
component: VSkeletonLoader,
|
|
19
|
+
props: { type: "list-item-avatar-two-line", color: "transparent" },
|
|
20
|
+
card: true
|
|
21
|
+
},
|
|
22
|
+
{ testId: "bones", component: VSkeletonLoader, props: { type: "card, actions, chip, divider, ossein", height: 360 } },
|
|
23
|
+
{ testId: "progress", component: VProgressLinear, props: { modelValue: 40, color: "primary" } },
|
|
24
|
+
{ testId: "progress-tertiary", component: VProgressLinear, props: { modelValue: 40, color: "tertiary" } },
|
|
25
|
+
{ testId: "progress-indeterminate", component: VProgressLinear, props: { indeterminate: true, color: "primary" } },
|
|
26
|
+
{ testId: "progress-wavy", component: VProgressLinear, props: { modelValue: 40, color: "primary", shape: "wavy" } }
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => parts.map(({ testId, component, props, card }) => {
|
|
30
|
+
const part = h(component, props);
|
|
31
|
+
return h("div", { "data-testid": testId, class: "mb-6" }, card ? h(VCard, () => part) : part);
|
|
32
|
+
})));
|
|
33
|
+
|
|
34
|
+
createApp(App).use(createVuetify(createMaterialVuetifyOptions())).mount("#app");
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import { materialThemes } from "../src/client/index.js";
|
|
7
|
+
|
|
8
|
+
const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
|
|
9
|
+
const open = sharedBrowserFixture({
|
|
10
|
+
fixtureRoot: fileURLToPath(new URL("./fixtures/loading", import.meta.url)),
|
|
11
|
+
configFile: "vite.config.js"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// The bones Vuetify colours; the list-item, card and other bones only lay them out.
|
|
15
|
+
const BONES = ["avatar", "button", "chip", "divider", "heading", "image", "ossein", "text"];
|
|
16
|
+
|
|
17
|
+
// A theme colour as the "r, g, b" a drawn part is measured in.
|
|
18
|
+
const channels = (hex) => [1, 3, 5].map((start) => Number.parseInt(hex.slice(start, start + 2), 16)).join(", ");
|
|
19
|
+
|
|
20
|
+
// What a part draws with one colour property (background-color, or stroke for an SVG path): the colour, painted on a
|
|
21
|
+
// canvas so that rgb(), color(srgb ...) and color-mix() results all read as 8-bit channels, and its opacity on the
|
|
22
|
+
// page, which is the colour's alpha times the part's own opacity and every ancestor's.
|
|
23
|
+
function drawn(locator, property = "backgroundColor") {
|
|
24
|
+
return locator.evaluate((element, colourProperty) => {
|
|
25
|
+
const style = getComputedStyle(element);
|
|
26
|
+
const value = style[colourProperty] === "currentcolor" ? style.color : style[colourProperty];
|
|
27
|
+
const context = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
28
|
+
context.fillStyle = value;
|
|
29
|
+
context.fillRect(0, 0, 1, 1);
|
|
30
|
+
const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data;
|
|
31
|
+
let opacity = alpha / 255;
|
|
32
|
+
for (let node = element; node; node = node.parentElement) opacity *= Number(getComputedStyle(node).opacity);
|
|
33
|
+
return { color: `${red}, ${green}, ${blue}`, opacity: Math.round(opacity * 1000) / 1000 };
|
|
34
|
+
}, property);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// A bone's shimmer is its ::after: a gradient laid over the bone, which the bone's own colour leaves in place.
|
|
38
|
+
const SHIMMER = Object.freeze({ gradient: true, position: "absolute", zIndex: "1" });
|
|
39
|
+
function shimmer(locator) {
|
|
40
|
+
return locator.evaluate((element) => {
|
|
41
|
+
const after = getComputedStyle(element, "::after");
|
|
42
|
+
return { gradient: after.backgroundImage.startsWith("linear-gradient("), position: after.position, zIndex: after.zIndex };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Material 3 has no skeleton component; a bone is surface-container-highest, its most emphasized neutral container,
|
|
47
|
+
// a pale placeholder on every lower surface. Vuetify paints a bone in on-surface at the theme's border opacity, which
|
|
48
|
+
// the Material 3 outline roles need at full strength, so without material.css's rule every bone is solid on-surface.
|
|
49
|
+
test("skeleton bones are surface-container-highest under the shimmer in light and dark, canvastext in forced colours", {
|
|
50
|
+
skip: SKIP,
|
|
51
|
+
timeout: 120_000
|
|
52
|
+
}, async (t) => {
|
|
53
|
+
const { vite, browser } = await open(t);
|
|
54
|
+
for (const scheme of ["light", "dark"]) {
|
|
55
|
+
const { colors } = materialThemes("#6750A4")[scheme];
|
|
56
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
|
|
57
|
+
await page.goto("/");
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
for (const testId of ["list-row", "bones"]) {
|
|
60
|
+
const loader = page.getByTestId(testId).locator(".v-skeleton-loader");
|
|
61
|
+
for (const bone of BONES) {
|
|
62
|
+
const parts = loader.locator(`.v-skeleton-loader__bone.v-skeleton-loader__${bone}`);
|
|
63
|
+
for (let index = 0; index < await parts.count(); index += 1) {
|
|
64
|
+
seen.add(bone);
|
|
65
|
+
const label = `${scheme} ${testId}: ${bone} bone ${index + 1}`;
|
|
66
|
+
const surface = { color: channels(colors["surface-container-highest"]), opacity: 1 };
|
|
67
|
+
assert.deepEqual(await drawn(parts.nth(index)), surface, label);
|
|
68
|
+
assert.deepEqual(await shimmer(parts.nth(index)), SHIMMER, `${label}: shimmer`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
assert.deepEqual([...seen].sort(), BONES, `${scheme}: the fixture draws every coloured bone`);
|
|
73
|
+
await page.close();
|
|
74
|
+
}
|
|
75
|
+
// Forced colours keep Vuetify's canvastext bones, the page's forced text colour, over the forced Canvas around them.
|
|
76
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, forcedColors: "active", reducedMotion: "reduce" });
|
|
77
|
+
await page.goto("/");
|
|
78
|
+
const canvasText = await drawn(page.locator("body"), "color");
|
|
79
|
+
for (const bone of BONES) {
|
|
80
|
+
const part = page.locator(`.v-skeleton-loader__bone.v-skeleton-loader__${bone}`).first();
|
|
81
|
+
assert.deepEqual(await drawn(part), canvasText, `forced colours: ${bone} bone`);
|
|
82
|
+
}
|
|
83
|
+
await page.close();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Material 3's linear progress indicator: the active indicator and the stop in the app's colour, the track in
|
|
87
|
+
// secondary-container, all at full strength. Vuetify paints the track in the bar's colour at the border opacity, so
|
|
88
|
+
// without the VProgressLinear default the track is as solid as the bar and a determinate one reads as full.
|
|
89
|
+
test("linear progress indicators draw a secondary-container track beside the bar, light and dark", {
|
|
90
|
+
skip: SKIP,
|
|
91
|
+
timeout: 120_000
|
|
92
|
+
}, async (t) => {
|
|
93
|
+
const { vite, browser } = await open(t);
|
|
94
|
+
for (const scheme of ["light", "dark"]) {
|
|
95
|
+
const { colors } = materialThemes("#6750A4")[scheme];
|
|
96
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
|
|
97
|
+
await page.goto("/");
|
|
98
|
+
const full = (role) => ({ color: channels(colors[role]), opacity: 1 });
|
|
99
|
+
const part = (testId, selector, property) => drawn(page.getByTestId(testId).locator(selector).first(), property);
|
|
100
|
+
for (const [testId, role] of [["progress", "primary"], ["progress-tertiary", "tertiary"]]) {
|
|
101
|
+
const label = `${scheme} ${testId}`;
|
|
102
|
+
assert.deepEqual(await part(testId, ".v-progress-linear__background"), full("secondary-container"), `${label}: track`);
|
|
103
|
+
assert.deepEqual(await part(testId, ".v-progress-linear__determinate"), full(role), `${label}: active indicator`);
|
|
104
|
+
assert.deepEqual(await part(testId, ".v-progress-linear__stop"), full(role), `${label}: stop indicator`);
|
|
105
|
+
}
|
|
106
|
+
assert.deepEqual(
|
|
107
|
+
await part("progress-indeterminate", ".v-progress-linear__indeterminate > .v-progress-linear__background"),
|
|
108
|
+
full("secondary-container"),
|
|
109
|
+
`${scheme} indeterminate: track`
|
|
110
|
+
);
|
|
111
|
+
const wavyTrack = page.getByTestId("progress-wavy").locator(".v-progress-linear__wavy > .v-progress-linear__track");
|
|
112
|
+
await wavyTrack.first().waitFor({ state: "attached" });
|
|
113
|
+
assert.deepEqual(await drawn(wavyTrack.first(), "stroke"), full("secondary-container"), `${scheme} wavy: track`);
|
|
114
|
+
await page.close();
|
|
115
|
+
}
|
|
116
|
+
});
|
package/test/materialWeb.test.js
CHANGED
|
@@ -252,6 +252,13 @@ test("sliders and range sliders are Material 3's pill sliders, primary with a se
|
|
|
252
252
|
assert.deepEqual(defaults.VRangeSlider, slider);
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
+
test("a linear progress indicator's track is secondary-container", () => {
|
|
256
|
+
const { defaults } = createMaterialVuetifyOptions();
|
|
257
|
+
// Only the track: `color` stays the app's, so its color prop still sets the bar and the stop, and a loader in a
|
|
258
|
+
// coloured bar or card keeps the text colour it inherits. loading.browser.test.js measures what Vuetify then draws.
|
|
259
|
+
assert.deepEqual(defaults.VProgressLinear, { bgColor: "secondary-container" });
|
|
260
|
+
});
|
|
261
|
+
|
|
255
262
|
test("material.css draws cards, a dialog's card and a bottom sheet's card", async () => {
|
|
256
263
|
const css = await readFile(path.join(PACKAGE_ROOT, "src/client/material.css"), "utf8");
|
|
257
264
|
assert.match(css, /\n {2}\.v-card \{\s*border-radius: 12px;\s*\}/u);
|
|
@@ -313,9 +320,20 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
|
|
|
313
320
|
css,
|
|
314
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
|
|
315
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).
|
|
325
|
+
assert.match(
|
|
326
|
+
css,
|
|
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
|
+
);
|
|
316
329
|
assert.match(
|
|
317
330
|
css,
|
|
318
|
-
/\.v-input:not\(\.v-input--
|
|
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
|
|
319
337
|
);
|
|
320
338
|
// So is an inactive, uncoloured list item's subtitle; every enabled item's subtitle, an active one's included, is
|
|
321
339
|
// at full strength in the item's own colour.
|
|
@@ -324,6 +342,15 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
|
|
|
324
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
|
|
325
343
|
);
|
|
326
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);
|
|
327
354
|
// A disabled container button is on-surface 12% and 38%, unlayered over its colour class.
|
|
328
355
|
assert.match(
|
|
329
356
|
css,
|