@jskit-ai/material-web 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - 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
+ - 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
+
8
+ - 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.
9
+
5
10
  - 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.
6
11
  - `material.css` draws every `v-bottom-navigation` as Material 3's navigation bar: a destination (each of its stacked buttons) has its icon, its `prepend-icon` or the first icon in its content (bare or in a badge), 24dp in a 64x32 pill that is its active indicator (`secondary-container`, the icon `on-secondary-container`) and holds its hover, focus and pressed state layer, where Vuetify drew its overlay and ripple across the whole button; the label is label-medium, 4dp below, `on-surface-variant` at rest and `on-surface` when active. A comfortable bar (48dp) drops the 4dp and a compact one (40dp) has a 24dp pill, so neither clips a label. The colours apply only where the app set none: a bar's `bg-color` (other than a surface tone) or colour class, and a destination's `color`, `base-color` or colour class, keep the app's colour on label and icon, the active pill drawn in that colour. An append icon, a badge's own icon and `mode="horizontal"` keep Vuetify's look. It was drawn only by the shell's `ShellTabLinkItem`, so an app's own bar of `v-btn`s kept Vuetify's look.
7
12
  - **Breaking (visual).** Fields (`v-text-field`, `v-textarea`, `v-select`, `v-autocomplete`, `v-combobox`, `v-file-input`) keep Vuetify's line for their supporting text, as a Material 3 text field does: the defaults no longer set `hideDetails: "auto"`. With it, a field had no line until it had a message, so an error shown on blur or submit pushed the rest of the form down under the person's finger, and forms made up the space with a margin under each field. Upgrading: in a form, remove the `mb-*` margin under each field (the line is the gap now); a field outside a form (a search box, a filter, a toolbar select, a composer) sets `hide-details`, or `hide-details="auto"` to show a message only when it has one.
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`). There is no
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
@@ -65,15 +69,23 @@ export const theme = {
65
69
  - **Components.** The md3 blueprint plus JSKIT's defaults: full-shape filled
66
70
  buttons (with `to`, active only on exactly their route), cards that rest
67
71
  flat on `surface-container-low` (`variant="elevated"` for level 1), flat expansion panels, outlined fields, 8dp chips that close with
68
- `$close`, the inverse-surface snackbar, the Material switch and the 16dp
69
- `primary-container` FAB; `v-btn-toggle` as a segmented button and
70
- `v-chip-group` as filter chips, selected in `secondary-container`.
72
+ `$close`, the inverse-surface snackbar, the Material switch, Material 3's
73
+ slider and range slider (Vuetify's pill variant: a 16dp track, a 4x44dp
74
+ handle bar set apart from it and a stop indicator) in `primary` with a
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;
78
+ `v-btn-toggle` as a segmented button and `v-chip-group` as filter chips,
79
+ selected in `secondary-container`.
71
80
  - **`material.css`.** What props cannot set: 40dp buttons and 40dp icon
72
81
  buttons (none under 32dp, whatever its density), a 48dp touch target on
73
82
  every button size (small and x-small keep their look, and their state
74
83
  layers keep their corners) that stops at a neighbouring button, disabled container
75
- buttons in on-surface at 12% and 38%, a pagination's current page in the
76
- activated layer, placeholders, text field labels and supporting text and list
84
+ buttons in on-surface at 12% and 38%, a slider's inactive track at full
85
+ strength (Vuetify fades it to 24%) and a disabled slider in on-surface at
86
+ 38% with its inactive track at 12%, a pagination's current page in the
87
+ activated layer, skeleton loader bones in `surface-container-highest` under
88
+ their shimmer, placeholders, text field labels and supporting text and list
77
89
  item subtitles in on-surface-variant, one-line labels that
78
90
  end in an ellipsis, 12dp card corners, 28dp dialogs on
79
91
  `surface-container-high` at level 3 and bottom sheets with a square card on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/material-web",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
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": {
@@ -1,11 +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
- // filter chips that select in secondary-container, the inverse-surface snackbar, the Material switch,
4
- // and the 16dp primary-container FAB. A number for `rounded` is an exact corner in dp. Card, dialog and bottom sheet
5
- // corners and colours, a menu's own list, and the sizes and states props cannot set, are in material.css. No VMenu sub-component
6
- // defaults: under them, in Vuetify 4.2.1 to 4.3.2, an ancestor's re-render makes the menu's virtual list lose its item
7
- // heights, so a v-select's typeahead never scrolls to its match (https://github.com/vuetifyjs/vuetify/issues/23366;
8
- // README, Upstream workarounds).
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, 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).
9
10
  const materialDefaults = Object.freeze({
10
11
  VAppBar: {
11
12
  color: "surface",
@@ -74,6 +75,28 @@ const materialDefaults = Object.freeze({
74
75
  variant: "text"
75
76
  }
76
77
  },
78
+ // Material 3 sliders: Vuetify's pill variant, Material 3's slider at its default (extra-small) size, with a 16dp track,
79
+ // a 4x44dp handle bar set apart from the track by a gap, and a stop indicator at the end of the track. The active
80
+ // track and the handle follow `color`, so an app's color prop still sets them, and the inactive track is
81
+ // secondary-container, which material.css draws at full strength: on Vuetify's 4dp track that pale role all but
82
+ // vanished on a light container. The md3 blueprint gives a range slider no colour at all.
83
+ VSlider: {
84
+ color: "primary",
85
+ trackColor: "secondary-container",
86
+ variant: "pill"
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
+ },
95
+ VRangeSlider: {
96
+ color: "primary",
97
+ trackColor: "secondary-container",
98
+ variant: "pill"
99
+ },
77
100
  VSwitch: {
78
101
  color: "primary",
79
102
  inset: "material"
@@ -77,6 +77,30 @@
77
77
  padding-inline: 0 16px;
78
78
  }
79
79
 
80
+ /* Sliders and range sliders: the inactive track (secondary-container, the track-color default) at full strength, as
81
+ Material 3 draws it. Vuetify fades it to 38% (24% for the pill variant) whenever the slider has a colour, which the
82
+ md3 blueprint always gives it, so an app's own track-color was faded too: a secondary-container track all but
83
+ vanished on a light surface. An invalid slider keeps Vuetify's faded track in the error colour, which tells its
84
+ two parts apart. */
85
+ .v-slider:not(.v-input--disabled, .v-input--error) .v-slider-track__background--opacity {
86
+ opacity: 1;
87
+ }
88
+
89
+ /* A disabled slider is Material 3's on-surface: 38% for the active track and the handle (Vuetify's fade of the whole
90
+ slider, --v-disabled-opacity, which keeps the handle opaque over the track) and 12% for the inactive track, where
91
+ Vuetify faded surface-variant parts to 38% and the inactive track again, to 14%. */
92
+ .v-slider.v-input--disabled :is(.v-slider-track__background, .v-slider-track__fill) {
93
+ background-color: rgb(var(--v-theme-on-surface));
94
+ }
95
+
96
+ .v-slider.v-input--disabled .v-slider-track__background {
97
+ opacity: calc(0.12 / var(--v-disabled-opacity));
98
+ }
99
+
100
+ .v-slider.v-input--disabled .v-slider-thumb {
101
+ color: rgb(var(--v-theme-on-surface));
102
+ }
103
+
80
104
  /* FABs are not common buttons: 56dp (small 40dp, large 96dp with a 36dp icon), and the extended FAB is 56dp tall. */
81
105
  .v-fab .v-btn {
82
106
  --jskit-fab-size: 56px;
@@ -411,6 +435,25 @@
411
435
  opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
412
436
  }
413
437
 
438
+ /* A skeleton loader's bones (text, heading, avatar, image, button, chip, divider, ossein) are
439
+ surface-container-highest, Material 3's most emphasized neutral container, a pale placeholder in light and dark.
440
+ Vuetify draws them in on-surface at the border opacity, which the outline roles keep at full strength, so every
441
+ bone was solid on-surface, near black in light. Each bone's shimmer (its ::after) still sweeps over it. Forced
442
+ colours keep Vuetify's canvastext bones, restated here since this rule outranks Vuetify's. */
443
+ .v-skeleton-loader :is(.v-skeleton-loader__avatar, .v-skeleton-loader__button, .v-skeleton-loader__chip,
444
+ .v-skeleton-loader__divider, .v-skeleton-loader__heading, .v-skeleton-loader__image, .v-skeleton-loader__ossein,
445
+ .v-skeleton-loader__text) {
446
+ background-color: rgb(var(--v-theme-surface-container-highest));
447
+ }
448
+
449
+ @media (forced-colors: active) {
450
+ .v-skeleton-loader :is(.v-skeleton-loader__avatar, .v-skeleton-loader__button, .v-skeleton-loader__chip,
451
+ .v-skeleton-loader__divider, .v-skeleton-loader__heading, .v-skeleton-loader__image,
452
+ .v-skeleton-loader__ossein, .v-skeleton-loader__text) {
453
+ background-color: canvastext;
454
+ }
455
+ }
456
+
414
457
  /* A shown placeholder is on-surface-variant at full strength, as Material 3's text field and search bar draw it,
415
458
  instead of Vuetify's faded on-surface (2.2:1). A labelled field still hides it until the field is active. */
416
459
  .v-field:is(.v-field--active, .v-field--no-label) :is(input, textarea)::placeholder {
@@ -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 loading</title></head><body><div id="app"></div><script type="module" src="/main.js"></script></body></html>
@@ -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,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
+ });
@@ -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 sliders</title></head><body><div id="app"></div><script type="module" src="/main.js"></script></body></html>
@@ -0,0 +1,23 @@
1
+ import { createApp, h } from "vue";
2
+ import { createVuetify } from "vuetify";
3
+ import { VApp } from "vuetify/components/VApp";
4
+ import { VMain } from "vuetify/components/VMain";
5
+ import { VRangeSlider } from "vuetify/components/VRangeSlider";
6
+ import { VSlider } from "vuetify/components/VSlider";
7
+ import "vuetify/styles";
8
+ import "../../../src/client/material.css";
9
+ import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
10
+
11
+ // A slider, a range slider and a disabled slider with JSKIT's Material 3 options and stylesheet, as an app draws them,
12
+ // in the browser's light or dark scheme (sliders.browser.test.js).
13
+ const sliders = [
14
+ { testId: "slider", component: VSlider, props: { label: "Slider", modelValue: 40 } },
15
+ { testId: "range-slider", component: VRangeSlider, props: { label: "Range", modelValue: [20, 70] } },
16
+ { testId: "disabled-slider", component: VSlider, props: { label: "Disabled", modelValue: 40, disabled: true } }
17
+ ];
18
+
19
+ const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => sliders.map(({ testId, component, props }) => (
20
+ h("div", { "data-testid": testId }, h(component, props))
21
+ ))));
22
+
23
+ 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
+ });
@@ -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
+ });
@@ -243,6 +243,22 @@ test("segmented buttons and filter chips select in secondary-container; a menu's
243
243
  assert.equal(defaults.VDialog, undefined, "no VDialog defaults");
244
244
  });
245
245
 
246
+ test("sliders and range sliders are Material 3's pill sliders, primary with a secondary-container inactive track", () => {
247
+ const { defaults } = createMaterialVuetifyOptions();
248
+ // Nothing sets thumbColor or trackFillColor, which Vuetify prefers to `color`: an app's color prop still sets the
249
+ // active track and the handle. sliders.browser.test.js measures what material.css then draws.
250
+ const slider = { color: "primary", trackColor: "secondary-container", variant: "pill" };
251
+ assert.deepEqual(defaults.VSlider, slider);
252
+ assert.deepEqual(defaults.VRangeSlider, slider);
253
+ });
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
+
246
262
  test("material.css draws cards, a dialog's card and a bottom sheet's card", async () => {
247
263
  const css = await readFile(path.join(PACKAGE_ROOT, "src/client/material.css"), "utf8");
248
264
  assert.match(css, /\n {2}\.v-card \{\s*border-radius: 12px;\s*\}/u);
@@ -0,0 +1,77 @@
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/sliders", import.meta.url)),
11
+ configFile: "vite.config.js"
12
+ });
13
+
14
+ // A theme colour as the "r, g, b" a computed style holds.
15
+ const channels = (hex) => [1, 3, 5].map((start) => Number.parseInt(hex.slice(start, start + 2), 16)).join(", ");
16
+
17
+ // What a slider part draws: its colour and its opacity on the page, which is its colour's alpha times its own opacity
18
+ // and every ancestor's.
19
+ function drawn(locator) {
20
+ return locator.evaluate((element) => {
21
+ const [red, green, blue, alpha = 1] = getComputedStyle(element).backgroundColor.match(/[\d.]+/gu).map(Number);
22
+ let opacity = alpha;
23
+ for (let node = element; node; node = node.parentElement) opacity *= Number(getComputedStyle(node).opacity);
24
+ return { color: `${red}, ${green}, ${blue}`, opacity: Math.round(opacity * 1000) / 1000 };
25
+ });
26
+ }
27
+
28
+ // Material 3's slider: the active track and the handle in primary and the inactive track in secondary-container, all
29
+ // at full strength; disabled, on-surface at 38% for the active track and the handle and 12% for the inactive track.
30
+ test("sliders draw Material 3's tracks and handle, at full strength when enabled and at 38% and 12% when disabled", {
31
+ skip: SKIP,
32
+ timeout: 120_000
33
+ }, async (t) => {
34
+ const { vite, browser } = await open(t);
35
+ for (const scheme of ["light", "dark"]) {
36
+ const { colors } = materialThemes("#6750A4")[scheme];
37
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: scheme, reducedMotion: "reduce" });
38
+ await page.goto("/");
39
+ const part = (testId, selector) => drawn(page.getByTestId(testId).locator(selector).first());
40
+ for (const testId of ["slider", "range-slider"]) {
41
+ const enabled = (role) => ({ color: channels(colors[role]), opacity: 1 });
42
+ assert.deepEqual(await part(testId, ".v-slider-track__background"), enabled("secondary-container"), `${scheme} ${testId}: inactive track`);
43
+ assert.deepEqual(await part(testId, ".v-slider-track__fill"), enabled("primary"), `${scheme} ${testId}: active track`);
44
+ assert.deepEqual(await part(testId, ".v-slider-thumb__surface"), enabled("primary"), `${scheme} ${testId}: handle`);
45
+ }
46
+ const disabled = (opacity) => ({ color: channels(colors["on-surface"]), opacity });
47
+ assert.deepEqual(await part("disabled-slider", ".v-slider-track__background"), disabled(0.12), `${scheme} disabled: inactive track`);
48
+ assert.deepEqual(await part("disabled-slider", ".v-slider-track__fill"), disabled(0.38), `${scheme} disabled: active track`);
49
+ assert.deepEqual(await part("disabled-slider", ".v-slider-thumb__surface"), disabled(0.38), `${scheme} disabled: handle`);
50
+ }
51
+ });
52
+
53
+ // Material 3's slider at its default size, Vuetify's pill variant: a 16dp track, a 4x44dp handle bar with a gap between
54
+ // it and the inactive track, and a stop indicator in the active colour at the end of the inactive track.
55
+ test("sliders have Material 3's 16dp track, a 4x44dp handle bar set apart from the track, and a stop indicator", {
56
+ skip: SKIP,
57
+ timeout: 120_000
58
+ }, async (t) => {
59
+ const { vite, browser } = await open(t);
60
+ const { colors } = materialThemes("#6750A4").light;
61
+ const page = await browser.newPage({ baseURL: vite.baseURL, colorScheme: "light", reducedMotion: "reduce" });
62
+ await page.goto("/");
63
+ for (const testId of ["slider", "range-slider", "disabled-slider"]) {
64
+ const slider = page.getByTestId(testId);
65
+ const box = (selector) => slider.locator(selector).last().boundingBox();
66
+ const [track, handle, inactive] = await Promise.all(
67
+ [".v-slider-track", ".v-slider-thumb__surface", ".v-slider-track__background--after"].map(box)
68
+ );
69
+ assert.equal(track.height, 16, `${testId}: track height`);
70
+ assert.deepEqual([handle.width, handle.height], [4, 44], `${testId}: handle`);
71
+ assert.ok(inactive.x - (handle.x + handle.width) >= 4, `${testId}: a gap between the handle and the inactive track`);
72
+ }
73
+ for (const testId of ["slider", "range-slider"]) {
74
+ const stop = drawn(page.getByTestId(testId).locator(".v-slider-track__stop--end"));
75
+ assert.deepEqual(await stop, { color: channels(colors.primary), opacity: 1 }, `${testId}: stop indicator`);
76
+ }
77
+ });