@jskit-ai/material-web 0.1.7 → 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,9 @@
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
+
5
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.
6
9
 
7
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.
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
@@ -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, and the 16dp `primary-container` FAB;
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,7 +84,8 @@ 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, placeholders, text field labels and supporting text and list
87
+ activated layer, skeleton loader bones in `surface-container-highest` under
88
+ their shimmer, placeholders, text field labels and supporting text and list
82
89
  item subtitles in on-surface-variant, one-line labels that
83
90
  end in an ellipsis, 12dp card corners, 28dp dialogs on
84
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.7",
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,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, and the 16dp primary-container FAB. A
5
- // number for `rounded` is an exact corner in dp. Card, dialog and bottom sheet corners and colours, a menu's own list,
6
- // and the sizes and states props cannot set, are in material.css. No VMenu sub-component
7
- // 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
8
- // heights, so a v-select's typeahead never scrolls to its match (https://github.com/vuetifyjs/vuetify/issues/23366;
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",
@@ -435,6 +435,25 @@
435
435
  opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
436
436
  }
437
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
+
438
457
  /* A shown placeholder is on-surface-variant at full strength, as Material 3's text field and search bar draw it,
439
458
  instead of Vuetify's faded on-surface (2.2:1). A labelled field still hides it until the field is active. */
440
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,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
+ });
@@ -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);