@jskit-ai/material-web 0.1.11 → 0.1.12
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 +6 -0
- package/README.md +7 -2
- package/package.json +1 -1
- package/src/client/colorSchemes.js +5 -0
- package/src/client/material.css +57 -4
- package/test/materialWeb.test.js +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- A hovered, focused or pressed button's label keeps WCAG's 4.5:1 over its state layer, which `material.css` draws under the label: control's Releases page measured white on a hovered primary button at 4.43:1, on a focused one at 4.08:1, and a focused tonal error button's label at 4.45:1 (axe `color-contrast`, on a phone in light).
|
|
6
|
+
- Every colour's state layers have Material 3's one opacity (hover 8%, focus and pressed 10%): each Vuetify theme from `materialThemes` sets `--v-theme-<role>-overlay-multiplier` to 1 for every role. Vuetify doubled the layers on a colour whose tone is the theme's opposite (a primary, error or other tone-40 colour in light, a tone-80 one in dark), so a filled or elevated button's hover layer was 16% and its focus layer 20%.
|
|
7
|
+
- The ripple, Material 3's pressed state layer, lies under the label with the other layers (buttons, chips, list items and cards) and is Material 3's 10% (`--v-pressed-opacity`), not Vuetify's 25%; a pressed button shows it alone, without its hover or focus layer (a selected tonal, outlined or text button keeps its selected layer under it). Over the label, it left axe unable to judge any pressed label (bgOverlap); under it at 25% over the 8% hover layer, a pressed primary button's white label would read 3.2:1 (the ripple alone at 10%: 5.08:1, on JSKIT's #415f91 primary).
|
|
8
|
+
- A tonal button in a colour with a container role (primary, secondary, tertiary, error, success, warning or info) draws its label, icons and spinner in that colour's on-container role, as Material 3 does on its tonal containers; its tint and state layers stay the colour's, and a disabled one is drawn as before. Vuetify drew the label in the colour itself over its own tint, so a focus or pressed layer in the colour took it under 4.5:1. A tonal button in an app's own colour keeps Vuetify's drawing.
|
|
9
|
+
shell-web's `colorContrast.browser.test.js` has axe judge a button in each of those seven colours and each variant (flat, elevated, tonal, outlined, text) at rest, hovered, keyboard-focused and pressed, in light and dark.
|
|
10
|
+
|
|
5
11
|
- A chip's label longer than its chip ends in an ellipsis inside it, as a button's does: material.css lets a chip's text-only content shrink and clip (`.v-chip > .v-chip__content:not(:has(> *))`). Vuetify's inline-flex content could not shrink, so a long label was cut mid-word at the chip's edge, or drawn past it on a chip you press. A chip whose label holds elements of its own (an icon or avatar in its default slot) keeps Vuetify's layout; a short label is drawn as before.
|
|
6
12
|
- A tooltip opened by focus closes when its button loses focus to nothing, as `blur()` takes it. Vuetify 4.3.2 ignores such a blur (it keeps it for a click on an empty area inside an open menu), so the tooltip a keyboard user opened stayed over the page, and neither hovering nor leaving its button closed it (mobilynet's screen check met one). The `VTooltip` default's `activatorProps` listens for the `focusout` that follows and hands Vuetify's handler the blur it acts on, unless the pointer is on the tooltip itself, and the focus stays where `blur()` put it; a tooltip given its own `activator-props` replaces it. See the README's Upstream workarounds.
|
|
7
13
|
- axe judges the contrast of every text on a page again. Two things hid every text from it (color-contrast "incomplete", bgOverlap), so even text no one can read passed an accessibility check: a closed menu that stays mounted (`eager`, as shell-web's overflow menu does to keep the app bar's own items mounted on a phone) left Vuetify's overlay root over the whole window at z-index 2000, and Vuetify draws a button's, chip's, list item's, card's and avatar's state layer and underlay over its label. `material.css` now hides any overlay whose content is hidden (the rule it already had for tooltips, generalised), so a closing menu still animates out and its overlay goes once its content has; and draws state layers and tints under the content, as Material 3 orders them: each of those controls is its own stacking context with its layers at z-index -1, and its content parts are positioned (axe-core 4.14 reads the first, 4.11 the second; each alone still found layers over labels). Judged, three texts failed and are fixed or named:
|
package/README.md
CHANGED
|
@@ -107,8 +107,13 @@ export const theme = {
|
|
|
107
107
|
technology, and a closed eager menu lay over the whole page, so axe judged the
|
|
108
108
|
contrast of no text under it), state layers and tints under the label on
|
|
109
109
|
buttons, chips, list items, cards and avatars (axe judges the label's
|
|
110
|
-
contrast),
|
|
111
|
-
|
|
110
|
+
contrast), Material 3's one state-layer opacity on every colour (Vuetify
|
|
111
|
+
doubles it on a colour of the opposite tone, which took a hovered or focused
|
|
112
|
+
primary button's label under 4.5:1), a tonal button's label, icons and spinner
|
|
113
|
+
in its colour's on-container role (primary, secondary, tertiary, error,
|
|
114
|
+
success, warning and info), no activated state layer on a filled or elevated
|
|
115
|
+
button (it took a primary button's label under 4.5:1), `on-surface` text on a
|
|
116
|
+
tonal card of the
|
|
112
117
|
default colour, 40dp outlined segmented buttons and outlined
|
|
113
118
|
filter chips that lead with a check when selected (chips with
|
|
114
119
|
`aria-pressed` too), fixed tabs that share the width or else scroll, dialog
|
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.12",
|
|
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": {
|
|
@@ -313,6 +313,11 @@ function vuetifyTheme(schemeColorsByRole, dark) {
|
|
|
313
313
|
colors,
|
|
314
314
|
variables: {
|
|
315
315
|
...STATE_LAYER_VARIABLES,
|
|
316
|
+
// Material 3's state layers have one opacity each, on every colour. Vuetify doubles them on a colour whose
|
|
317
|
+
// luminance is the theme's opposite (a primary button in light): a hovered primary button's white label read
|
|
318
|
+
// 4.43:1 and a focused one 4.08:1, under WCAG's 4.5:1, now that the layer lies under the label.
|
|
319
|
+
...Object.fromEntries(Object.keys(colors).filter((role) => !role.startsWith("on-"))
|
|
320
|
+
.map((role) => [`theme-${role}-overlay-multiplier`, 1])),
|
|
316
321
|
// Channel strings: Vuetify writes them as rgba(var(--v-border-color), var(--v-border-opacity)).
|
|
317
322
|
"border-color": channels(argbFromHex(colors["outline-variant"])),
|
|
318
323
|
"shadow-color": channels(argbFromHex(colors.shadow)),
|
package/src/client/material.css
CHANGED
|
@@ -175,10 +175,10 @@
|
|
|
175
175
|
isolation: isolate;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
.v-btn > :is(.v-btn__overlay, .v-btn__underlay),
|
|
179
|
-
.v-chip > :is(.v-chip__overlay, .v-chip__underlay),
|
|
180
|
-
.v-list-item > :is(.v-list-item__overlay, .v-list-item__underlay),
|
|
181
|
-
.v-card > :is(.v-card__overlay, .v-card__underlay),
|
|
178
|
+
.v-btn > :is(.v-btn__overlay, .v-btn__underlay, .v-ripple__container),
|
|
179
|
+
.v-chip > :is(.v-chip__overlay, .v-chip__underlay, .v-ripple__container),
|
|
180
|
+
.v-list-item > :is(.v-list-item__overlay, .v-list-item__underlay, .v-ripple__container),
|
|
181
|
+
.v-card > :is(.v-card__overlay, .v-card__underlay, .v-ripple__container),
|
|
182
182
|
.v-avatar > .v-avatar__underlay {
|
|
183
183
|
z-index: -1;
|
|
184
184
|
}
|
|
@@ -207,6 +207,59 @@
|
|
|
207
207
|
opacity: calc(var(--v-focus-opacity) * var(--v-theme-overlay-multiplier));
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/* The ripple, Material 3's pressed state layer, lies under the label too (above), at its 10%: Vuetify's was 25%,
|
|
211
|
+
over the hover layer and over the label, so axe judged no pressed label at all. A pressed button shows the ripple
|
|
212
|
+
alone, as Material 3 shows one state layer at a time; a selected one keeps its selected layer under it. */
|
|
213
|
+
.v-ripple__animation--in {
|
|
214
|
+
opacity: var(--v-pressed-opacity);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.v-btn:active:not(.v-btn--active) > .v-btn__overlay,
|
|
218
|
+
.v-btn--active:active:is(.v-btn--variant-flat, .v-btn--variant-elevated) > .v-btn__overlay {
|
|
219
|
+
opacity: 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.v-btn--active:active:not(.v-btn--variant-flat, .v-btn--variant-elevated) > .v-btn__overlay {
|
|
223
|
+
opacity: calc(var(--v-activated-opacity) * var(--v-theme-overlay-multiplier));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* A tonal button in a colour with a container role draws its label, icons and spinner in that colour's
|
|
227
|
+
on-container role, as Material 3 does on its tonal containers. Vuetify drew them in the colour itself over the
|
|
228
|
+
colour's tint, which a focus or pressed layer (the colour again) took under WCAG's 4.5:1: 4.45:1 for a focused
|
|
229
|
+
tonal error button. The tint and the state layers stay the colour's. */
|
|
230
|
+
.v-btn--variant-tonal.text-primary {
|
|
231
|
+
--jskit-tonal-label: var(--v-theme-on-primary-container);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.v-btn--variant-tonal.text-secondary {
|
|
235
|
+
--jskit-tonal-label: var(--v-theme-on-secondary-container);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.v-btn--variant-tonal.text-tertiary {
|
|
239
|
+
--jskit-tonal-label: var(--v-theme-on-tertiary-container);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.v-btn--variant-tonal.text-error {
|
|
243
|
+
--jskit-tonal-label: var(--v-theme-on-error-container);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.v-btn--variant-tonal.text-success {
|
|
247
|
+
--jskit-tonal-label: var(--v-theme-on-success-container);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.v-btn--variant-tonal.text-warning {
|
|
251
|
+
--jskit-tonal-label: var(--v-theme-on-warning-container);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.v-btn--variant-tonal.text-info {
|
|
255
|
+
--jskit-tonal-label: var(--v-theme-on-info-container);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.v-btn--variant-tonal:is(.text-primary, .text-secondary, .text-tertiary, .text-error, .text-success, .text-warning,
|
|
259
|
+
.text-info):not(.v-btn--disabled) > :is(.v-btn__prepend, .v-btn__content, .v-btn__append, .v-btn__loader) {
|
|
260
|
+
color: rgb(var(--jskit-tonal-label));
|
|
261
|
+
}
|
|
262
|
+
|
|
210
263
|
/* A label stays on one line, as Material 3 draws it; one longer than its button ends in an ellipsis. */
|
|
211
264
|
.v-btn:not(.v-btn--stacked, .v-btn--icon) > .v-btn__content:not(:has(> *)) {
|
|
212
265
|
display: block;
|
package/test/materialWeb.test.js
CHANGED
|
@@ -123,6 +123,17 @@ test("theme variables carry Material 3 state layers and channel strings for bord
|
|
|
123
123
|
assert.equal(light.variables["border-color"], "202, 196, 207");
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
test("every colour's state layers keep Material 3's one opacity: no colour doubles them", () => {
|
|
127
|
+
const { light, dark } = materialThemes("#6750A4", { brand: "#0B57D0" });
|
|
128
|
+
for (const theme of [light, dark]) {
|
|
129
|
+
const roles = Object.keys(theme.colors).filter((role) => !role.startsWith("on-"));
|
|
130
|
+
assert.ok(roles.includes("primary") && roles.includes("error") && roles.includes("brand-container"));
|
|
131
|
+
for (const role of roles) {
|
|
132
|
+
assert.equal(theme.variables[`theme-${role}-overlay-multiplier`], 1, role);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
126
137
|
// A browser's localStorage for one origin; `refuse` makes it throw as blocked or full storage does.
|
|
127
138
|
function browserStorage({ refuse = false } = {}) {
|
|
128
139
|
const items = new Map();
|
|
@@ -234,8 +245,9 @@ test("colours stored under another revision, or that are not a scheme's, are com
|
|
|
234
245
|
assert.equal(JSON.parse(garbage.getItem("jskit:material-themes")).inputs.length, 1);
|
|
235
246
|
});
|
|
236
247
|
|
|
237
|
-
// The colours of each stored revision: one digest of three inputs' light and dark
|
|
238
|
-
|
|
248
|
+
// The colours of each stored revision: one digest of three inputs' light and dark colours, which is what a browser
|
|
249
|
+
// stores (each start builds its themes' variables from them).
|
|
250
|
+
const REVISION_COLOURS = Object.freeze({ 1: "91308426d160318bcfc8363055a003919c691a6dd00da36fe9ff1779827c5caf" });
|
|
239
251
|
|
|
240
252
|
test("the colours a theme input gives change only with the revision browsers store them under", async (t) => {
|
|
241
253
|
const storage = browserStorage();
|
|
@@ -243,7 +255,8 @@ test("the colours a theme input gives change only with the revision browsers sto
|
|
|
243
255
|
const colours = [themes("#6750A4"), themes(...VIBE64_INPUT), themes("#B3261E", { partner: "#0A7D3E", brandAccent: "#FF6D00" })];
|
|
244
256
|
const { revision } = JSON.parse(storage.getItem("jskit:material-themes"));
|
|
245
257
|
// A browser keeps showing the colours it stored until the revision changes.
|
|
246
|
-
|
|
258
|
+
const stored = colours.map(({ light, dark }) => ({ light: light.colors, dark: dark.colors }));
|
|
259
|
+
assert.equal(createHash("sha256").update(JSON.stringify(stored)).digest("hex"), REVISION_COLOURS[revision],
|
|
247
260
|
`The colours differ from revision ${revision}'s: bump THEMES_REVISION in colorSchemes.js and record its digest here.`);
|
|
248
261
|
});
|
|
249
262
|
|