@jskit-ai/material-web 0.1.6 → 0.1.7

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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - 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
+
5
7
  - 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
8
  - `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
9
  - **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
@@ -65,14 +65,19 @@ export const theme = {
65
65
  - **Components.** The md3 blueprint plus JSKIT's defaults: full-shape filled
66
66
  buttons (with `to`, active only on exactly their route), cards that rest
67
67
  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`.
68
+ `$close`, the inverse-surface snackbar, the Material switch, Material 3's
69
+ slider and range slider (Vuetify's pill variant: a 16dp track, a 4x44dp
70
+ 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;
72
+ `v-btn-toggle` as a segmented button and `v-chip-group` as filter chips,
73
+ selected in `secondary-container`.
71
74
  - **`material.css`.** What props cannot set: 40dp buttons and 40dp icon
72
75
  buttons (none under 32dp, whatever its density), a 48dp touch target on
73
76
  every button size (small and x-small keep their look, and their state
74
77
  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
78
+ buttons in on-surface at 12% and 38%, a slider's inactive track at full
79
+ strength (Vuetify fades it to 24%) and a disabled slider in on-surface at
80
+ 38% with its inactive track at 12%, a pagination's current page in the
76
81
  activated layer, placeholders, text field labels and supporting text and list
77
82
  item subtitles in on-surface-variant, one-line labels that
78
83
  end in an ellipsis, 12dp card corners, 28dp dialogs 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.7",
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,8 +1,9 @@
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
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
6
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
7
8
  // heights, so a v-select's typeahead never scrolls to its match (https://github.com/vuetifyjs/vuetify/issues/23366;
8
9
  // README, Upstream workarounds).
@@ -74,6 +75,21 @@ 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
+ VRangeSlider: {
89
+ color: "primary",
90
+ trackColor: "secondary-container",
91
+ variant: "pill"
92
+ },
77
93
  VSwitch: {
78
94
  color: "primary",
79
95
  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;
@@ -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
+ });
@@ -243,6 +243,15 @@ 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
+
246
255
  test("material.css draws cards, a dialog's card and a bottom sheet's card", async () => {
247
256
  const css = await readFile(path.join(PACKAGE_ROOT, "src/client/material.css"), "utf8");
248
257
  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
+ });