@jskit-ai/material-web 0.1.10 → 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 +14 -0
- package/README.md +31 -4
- package/package.json +1 -1
- package/src/client/colorSchemes.js +5 -0
- package/src/client/defaults.js +23 -0
- package/src/client/material.css +128 -6
- package/test/accessibility.browser.test.js +31 -0
- package/test/chips.browser.test.js +71 -0
- package/test/fixtures/chips/index.html +2 -0
- package/test/fixtures/chips/main.js +27 -0
- package/test/fixtures/chips/vite.config.js +7 -0
- package/test/materialWeb.test.js +18 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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
|
+
|
|
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.
|
|
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.
|
|
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:
|
|
14
|
+
- A tonal card of the default colour has `on-surface` text, tinted with `on-surface`: the `VCard` default `color` (`surface-container-low`) was its text colour, 1.04:1 on the page. Outlined, text and plain cards on the default colour get the same text colour.
|
|
15
|
+
- A filled or elevated button has no activated state layer (Material 3 gives it none): Vuetify's, the label's colour at 10% over the container, took a primary button's label to 4.11:1, under WCAG's 4.5:1, for as long as it stayed active. Hovered or focused, it shows that state's layer alone; a selected segmented button stays `secondary-container`.
|
|
16
|
+
- A disabled chip's label is Material 3's disabled colour (1.8:1), which WCAG 1.4.3 exempts as part of an inactive control, but Vuetify marks the chip disabled only with a `disabled` attribute on a span, which axe does not read: an app's contrast check names it as an exemption. So is an outlined field's text under its own outline (Vuetify's outline boxes are transparent but for their borders).
|
|
17
|
+
shell-web's `colorContrast.browser.test.js` runs axe on its fixture's pages at 390 and 1280: a deliberately unreadable line must be the one failure, and nothing else may stay unjudged.
|
|
18
|
+
|
|
5
19
|
- An app's start reuses the Material 3 colours an earlier start computed for the same theme. `materialThemes` (which `createMaterialVuetifyOptions` calls at every start) computed both schemes at every call: 30 ms in Chromium, 120 ms at 4x CPU slowdown, for a seed and two app colours (medians). The colours are now computed once per input, the seed (in any case) and the app's colours with their order and `blend`: a page or process reuses them, and a browser keeps the last four inputs' colours in `localStorage` (`jskit:material-themes`), so a later start takes 1.4 ms (6.6 ms at 4x). Computing them is quicker too, 23 ms (84 ms at 4x): it built three tonal-spot schemes where two are needed, one only to list the role names, and ran `customColor` once per scheme where one call gives both. The colours are the same, byte for byte (one sha256 of three inputs' light and dark themes before and after). A changed seed or colour is another input and is computed again. Stored colours that are not a complete set of hex roles, the scheme's and the input's app colours', or were stored under an earlier revision of the generator (`THEMES_REVISION` in `colorSchemes.js`, raised whenever the same input gives other colours) are computed again, and a browser that refuses storage computes them at each start, as a server does. materialWeb.test.js holds each revision's digest of the colours and fails when they change without a new revision. Measured with Chromium and Node 26 on a 20-thread test host under load, Vibe64's theme input; a seed alone went from 34 to 22 ms on a first visit and 27 to 1.3 ms on a later start.
|
|
6
20
|
|
|
7
21
|
- 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.
|
package/README.md
CHANGED
|
@@ -97,13 +97,24 @@ export const theme = {
|
|
|
97
97
|
character counters, radio group labels, checkbox, radio and switch
|
|
98
98
|
descriptions, and list item and card subtitles in on-surface-variant
|
|
99
99
|
at full strength (an invalid field's counter in error, as its messages),
|
|
100
|
-
one-line labels that
|
|
100
|
+
one-line button and chip labels that
|
|
101
101
|
end in an ellipsis, 12dp card corners, 28dp dialogs on
|
|
102
102
|
`surface-container-high` at level 3 and bottom sheets with a square card on
|
|
103
103
|
`surface-container-low`, square full-screen dialogs on `surface`, a 48dp touch target on clickable chips,
|
|
104
|
-
inverse-surface tooltips
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
inverse-surface tooltips, and every other overlay (menu, dialog, snackbar),
|
|
105
|
+
hidden whole while their content is (Vuetify keeps a mounted overlay around
|
|
106
|
+
its hidden content: a hidden tooltip was an empty tooltip to assistive
|
|
107
|
+
technology, and a closed eager menu lay over the whole page, so axe judged the
|
|
108
|
+
contrast of no text under it), state layers and tints under the label on
|
|
109
|
+
buttons, chips, list items, cards and avatars (axe judges the label's
|
|
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
|
|
117
|
+
default colour, 40dp outlined segmented buttons and outlined
|
|
107
118
|
filter chips that lead with a check when selected (chips with
|
|
108
119
|
`aria-pressed` too), fixed tabs that share the width or else scroll, dialog
|
|
109
120
|
actions 24dp from the edges, a menu's own list as its container
|
|
@@ -155,6 +166,22 @@ Each one comes off when the upstream fix ships; its test says when.
|
|
|
155
166
|
would make an inline style). shell-web's browser test "a virtual-scroll list
|
|
156
167
|
in a dialog reaches its last item after the page around it re-renders"
|
|
157
168
|
guards it; it fails with `VDialog: { VCard: {} }` in the defaults.
|
|
169
|
+
- **Vuetify 4.3.2 (measured): a tooltip opened by focus stays open when its
|
|
170
|
+
activator loses focus to nothing.** Its activator ignores a blur with no
|
|
171
|
+
`relatedTarget` (as `blur()` gives), which it keeps for a click on an empty
|
|
172
|
+
area inside an open menu, so the tooltip a keyboard user opened stayed over
|
|
173
|
+
the page, and neither hovering nor leaving its button closed it. JSKIT's
|
|
174
|
+
`VTooltip` default `activatorProps` listens for the `focusout` that follows
|
|
175
|
+
(an event Vuetify's activator does not use) and hands Vuetify's handler the
|
|
176
|
+
blur it acts on, with the page as where focus went, unless the pointer is on
|
|
177
|
+
the tooltip itself. It first sets the tooltip's click-outside record
|
|
178
|
+
(`lastMousedownWasOutside`, as a click elsewhere does), so the closing
|
|
179
|
+
overlay leaves the focus where `blur()` put it instead of handing it back to
|
|
180
|
+
the activator. material-web's browser test "a tooltip opened by focus closes
|
|
181
|
+
when its button loses focus to nothing" guards both; it fails without the
|
|
182
|
+
default, and without the record the button is focused again. Drop the default once a Vuetify release passes that test
|
|
183
|
+
without it. A tooltip given its own `activator-props` replaces the default
|
|
184
|
+
and keeps Vuetify's behaviour.
|
|
158
185
|
- **Vuetify 4.3.2 and 4.3.3 (measured): idle loaders read layout as they
|
|
159
186
|
mount.** Every field built on `VField` (`v-text-field`, `v-select`,
|
|
160
187
|
`v-textarea` and the others) mounts an idle `VProgressLinear` in its loader
|
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/defaults.js
CHANGED
|
@@ -7,6 +7,28 @@
|
|
|
7
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
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
9
|
// its match (https://github.com/vuetifyjs/vuetify/issues/23366; README, Upstream workarounds).
|
|
10
|
+
// A tooltip opened by focus closes when its activator loses focus to nothing, as blur() takes it. Vuetify 4.3.2's
|
|
11
|
+
// activator ignores a blur with no relatedTarget, which it keeps for a click on an empty area inside an open menu, so
|
|
12
|
+
// the tooltip stayed over the page, and neither hovering nor leaving its activator closed it. On the focusout that
|
|
13
|
+
// follows (an event Vuetify's activator does not use, so this adds a listener rather than replacing or merging with
|
|
14
|
+
// Vuetify's own), Vuetify's handler gets the blur it acts on, with the page as where focus went, unless the pointer is
|
|
15
|
+
// on the tooltip itself (an interactive tooltip being clicked). The tooltip's overlay first records the focus as gone,
|
|
16
|
+
// as its click-outside record does after a click elsewhere, so closing leaves the focus where blur() put it: an overlay
|
|
17
|
+
// opened from its focused activator otherwise hands the focus back to the activator when it closes with the focus on
|
|
18
|
+
// the page.
|
|
19
|
+
function closeTooltipOnFocusLoss(event) {
|
|
20
|
+
if (event.relatedTarget || !event.isTrusted) return;
|
|
21
|
+
const activator = event.currentTarget;
|
|
22
|
+
const tooltips = String(activator.getAttribute("aria-describedby") || "").split(/\s+/u)
|
|
23
|
+
.filter(Boolean).map((id) => document.getElementById(id)).filter((element) => element?.classList.contains("v-tooltip"));
|
|
24
|
+
if (tooltips.some((tooltip) => tooltip.matches(":hover"))) return;
|
|
25
|
+
for (const tooltip of tooltips) {
|
|
26
|
+
const clickOutside = tooltip.querySelector(":scope > .v-overlay__content")?._clickOutside;
|
|
27
|
+
if (clickOutside) clickOutside.lastMousedownWasOutside = true;
|
|
28
|
+
}
|
|
29
|
+
activator.dispatchEvent(new FocusEvent("blur", { relatedTarget: document.body }));
|
|
30
|
+
}
|
|
31
|
+
|
|
10
32
|
const materialDefaults = Object.freeze({
|
|
11
33
|
VAppBar: {
|
|
12
34
|
color: "surface",
|
|
@@ -135,6 +157,7 @@ const materialDefaults = Object.freeze({
|
|
|
135
157
|
color: "surface"
|
|
136
158
|
},
|
|
137
159
|
VTooltip: {
|
|
160
|
+
activatorProps: { onFocusout: closeTooltipOnFocusLoss },
|
|
138
161
|
location: "bottom"
|
|
139
162
|
}
|
|
140
163
|
});
|
package/src/client/material.css
CHANGED
|
@@ -166,6 +166,100 @@
|
|
|
166
166
|
border-radius: inherit;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
/* A control's state layer and container tint lie under its content, as Material 3 orders them. Vuetify draws a
|
|
170
|
+
button's, chip's, list item's, card's and avatar's overlay and underlay over the label, so axe found a layer over
|
|
171
|
+
every label and judged the contrast of none (color-contrast incomplete, bgOverlap). Each control is its own
|
|
172
|
+
stacking context with its layers at z-index -1 in it, and its content parts are positioned: axe-core 4.14 reads
|
|
173
|
+
the first, 4.11 the second, and each still found layers over labels with only one of the two. */
|
|
174
|
+
:is(.v-btn, .v-chip, .v-list-item, .v-card, .v-avatar) {
|
|
175
|
+
isolation: isolate;
|
|
176
|
+
}
|
|
177
|
+
|
|
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
|
+
.v-avatar > .v-avatar__underlay {
|
|
183
|
+
z-index: -1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.v-btn > :is(.v-btn__prepend, .v-btn__content, .v-btn__append),
|
|
187
|
+
.v-chip > :is(.v-chip__filter, .v-chip__prepend, .v-chip__content, .v-chip__append, .v-chip__close),
|
|
188
|
+
.v-list-item > :is(.v-list-item__prepend, .v-list-item__content, .v-list-item__append),
|
|
189
|
+
.v-card > :is(.v-card-item, .v-card-title, .v-card-subtitle, .v-card-text, .v-card-actions),
|
|
190
|
+
.v-avatar > :not(.v-avatar__underlay) {
|
|
191
|
+
position: relative;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* A filled or elevated button has no activated state layer: Material 3 gives these buttons none (a selected
|
|
195
|
+
segment is secondary-container), and Vuetify's, the label's colour at 10% over the container, took a primary
|
|
196
|
+
button's white label under WCAG's 4.5:1 (4.11:1 in JSKIT's fixture theme) for as long as the button stayed
|
|
197
|
+
active, as one whose route is current does. Hovered or focused, it shows that state's layer alone. */
|
|
198
|
+
.v-btn--active:is(.v-btn--variant-flat, .v-btn--variant-elevated) > .v-btn__overlay {
|
|
199
|
+
opacity: 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.v-btn--active:is(.v-btn--variant-flat, .v-btn--variant-elevated):hover > .v-btn__overlay {
|
|
203
|
+
opacity: calc(var(--v-hover-opacity) * var(--v-theme-overlay-multiplier));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.v-btn--active:is(.v-btn--variant-flat, .v-btn--variant-elevated):focus-visible > .v-btn__overlay {
|
|
207
|
+
opacity: calc(var(--v-focus-opacity) * var(--v-theme-overlay-multiplier));
|
|
208
|
+
}
|
|
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
|
+
|
|
169
263
|
/* A label stays on one line, as Material 3 draws it; one longer than its button ends in an ellipsis. */
|
|
170
264
|
.v-btn:not(.v-btn--stacked, .v-btn--icon) > .v-btn__content:not(:has(> *)) {
|
|
171
265
|
display: block;
|
|
@@ -174,6 +268,17 @@
|
|
|
174
268
|
text-overflow: ellipsis;
|
|
175
269
|
}
|
|
176
270
|
|
|
271
|
+
/* So does a chip's: a chip is at most as wide as its container and its label stays on one line, but Vuetify's
|
|
272
|
+
inline-flex content cannot shrink, so a longer label was cut mid-word at the chip's edge (or drawn past it on a
|
|
273
|
+
chip you press, which the touch target unclips). A label holding elements of its own (an icon or avatar in the
|
|
274
|
+
chip's default slot) keeps Vuetify's inline-flex content, which lays them out. */
|
|
275
|
+
.v-chip > .v-chip__content:not(:has(> *)) {
|
|
276
|
+
display: block;
|
|
277
|
+
min-width: 0;
|
|
278
|
+
overflow: hidden;
|
|
279
|
+
text-overflow: ellipsis;
|
|
280
|
+
}
|
|
281
|
+
|
|
177
282
|
/* Outlined buttons and outlined chips draw the outline role. */
|
|
178
283
|
.v-btn--variant-outlined:not([class*=" text-"]) {
|
|
179
284
|
border-color: rgb(var(--v-theme-outline));
|
|
@@ -282,12 +387,16 @@
|
|
|
282
387
|
padding: 4px 8px;
|
|
283
388
|
}
|
|
284
389
|
|
|
285
|
-
/* A hidden tooltip is hidden whole. Vuetify
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
390
|
+
/* A hidden overlay (tooltip, menu, dialog, snackbar) is hidden whole. Vuetify hides only an overlay's content when
|
|
391
|
+
it closes, and keeps the overlay around it whenever the content stays mounted: a tooltip, which Vuetify 4.3 mounts
|
|
392
|
+
before it first shows, or an eager menu, such as ShellLayout's overflow menu holding the app bar's own items on a
|
|
393
|
+
phone. A hidden tooltip's role="tooltip" overlay was an empty tooltip to assistive technology (axe
|
|
394
|
+
aria-tooltip-name), and its activator's aria-describedby read nothing, since hidden text counts only when the
|
|
395
|
+
element the activator names is hidden itself. A closed menu's overlay lay over the whole window at z-index 2000,
|
|
396
|
+
so axe found it over every text on the page and judged the contrast of none (color-contrast incomplete,
|
|
397
|
+
bgOverlap), letting text no one can read pass. The overlay hides only once its content has, so an opening or
|
|
398
|
+
closing one still animates. */
|
|
399
|
+
.v-overlay:has(> .v-overlay__content[style*="display: none"]) {
|
|
291
400
|
display: none;
|
|
292
401
|
}
|
|
293
402
|
|
|
@@ -680,6 +789,19 @@
|
|
|
680
789
|
color: rgb(var(--v-theme-on-surface-container-high));
|
|
681
790
|
}
|
|
682
791
|
|
|
792
|
+
/* A tonal card (or an outlined, text or plain one) draws its text and its tint in its colour, which for the default
|
|
793
|
+
surface-container-low colour was near-white on the near-white page: a tonal card's text read 1.04:1. Such a card
|
|
794
|
+
has on-surface text, tinted with on-surface, and on-surface-variant supporting text. A card given its own colour
|
|
795
|
+
keeps it. */
|
|
796
|
+
.v-card.text-surface-container-low {
|
|
797
|
+
color: rgb(var(--v-theme-on-surface));
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.v-card.text-surface-container-low > .v-card-subtitle:not([class*=" text-"]),
|
|
801
|
+
.v-card.text-surface-container-low > .v-card-item > .v-card-item__content > .v-card-subtitle:not([class*=" text-"]) {
|
|
802
|
+
color: rgb(var(--v-theme-on-surface-variant));
|
|
803
|
+
}
|
|
804
|
+
|
|
683
805
|
.text-on-background {
|
|
684
806
|
color: rgb(var(--v-theme-on-background));
|
|
685
807
|
}
|
|
@@ -101,6 +101,37 @@ test("a hidden tooltip leaves no tooltip without a name and still describes its
|
|
|
101
101
|
await expect(button).toHaveAccessibleDescription("Delete this report");
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
// A tooltip opened by focus closes when its button loses focus, wherever focus goes, and leaves the focus there.
|
|
105
|
+
// Vuetify 4.3.2 kept it open when blur() took the focus nowhere, as it keeps a menu open for a click on an empty area
|
|
106
|
+
// inside it, so the tooltip stayed over the page, and neither hovering nor leaving the button closed it. A click on an
|
|
107
|
+
// empty part of the page closes it as a click outside.
|
|
108
|
+
test("a tooltip opened by focus closes when its button loses focus to nothing", {
|
|
109
|
+
skip: SKIP,
|
|
110
|
+
timeout: 120_000
|
|
111
|
+
}, async (t) => {
|
|
112
|
+
const { vite, browser } = await open(t);
|
|
113
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, reducedMotion: "reduce" });
|
|
114
|
+
t.after(() => page.close());
|
|
115
|
+
const button = page.getByTestId("tooltip-activator");
|
|
116
|
+
const tooltip = page.getByRole("tooltip", { name: "Delete this report" });
|
|
117
|
+
// Each way of losing focus on a fresh page: Vuetify ignores focus for 50ms after a tooltip closes.
|
|
118
|
+
const losses = [
|
|
119
|
+
["a click on an empty part of the page", () => page.mouse.click(4, 4)],
|
|
120
|
+
["the button's blur()", () => button.evaluate((element) => element.blur())]
|
|
121
|
+
];
|
|
122
|
+
for (const [loss, loseFocus] of losses) {
|
|
123
|
+
await page.goto("/");
|
|
124
|
+
await expect(button).toBeVisible();
|
|
125
|
+
await page.keyboard.press("Tab");
|
|
126
|
+
await expect(button).toBeFocused();
|
|
127
|
+
await expect(tooltip).toBeVisible();
|
|
128
|
+
await loseFocus();
|
|
129
|
+
await expect(tooltip, `closed after ${loss}`).toBeHidden();
|
|
130
|
+
// Closing leaves the focus where it went, rather than handing it back to the button.
|
|
131
|
+
await expect(button, `not focused again once closed after ${loss}`).not.toBeFocused();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
104
135
|
// A card's subtitle is its supporting text, at full strength: on-surface-variant on a surface card or one without a
|
|
105
136
|
// 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
137
|
// medium-emphasis opacity it measured 4.35:1 on JSKIT's default surface-container-low card, under WCAG's 4.5:1.
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
|
|
7
|
+
const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
|
|
8
|
+
const open = sharedBrowserFixture({
|
|
9
|
+
fixtureRoot: fileURLToPath(new URL("./fixtures/chips", import.meta.url)),
|
|
10
|
+
configFile: "vite.config.js"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Where a chip, its content and its label's text are drawn (left, top, right, bottom, to a tenth of a pixel), and how
|
|
14
|
+
// its content lays out and clips.
|
|
15
|
+
function chipGeometry(locator) {
|
|
16
|
+
return locator.evaluate((chip) => {
|
|
17
|
+
const content = chip.querySelector(":scope > .v-chip__content");
|
|
18
|
+
const text = document.createRange();
|
|
19
|
+
text.selectNodeContents(content);
|
|
20
|
+
const box = (rect) => [rect.left, rect.top, rect.right, rect.bottom].map((value) => Math.round(value * 10) / 10);
|
|
21
|
+
const style = getComputedStyle(content);
|
|
22
|
+
return {
|
|
23
|
+
chip: box(chip.getBoundingClientRect()),
|
|
24
|
+
content: box(content.getBoundingClientRect()),
|
|
25
|
+
text: box(text.getBoundingClientRect()),
|
|
26
|
+
display: style.display,
|
|
27
|
+
overflow: style.overflowX,
|
|
28
|
+
textOverflow: style.textOverflow,
|
|
29
|
+
clipped: content.scrollWidth > content.clientWidth
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Vuetify's own chip content (inline-flex, unclipped), unlayered so it wins over material.css's layers.
|
|
35
|
+
const VUETIFY_CHIP_CONTENT = ".v-chip > .v-chip__content { display: inline-flex; min-width: auto; overflow: visible; text-overflow: clip; }";
|
|
36
|
+
|
|
37
|
+
// A chip is at most as wide as its container, and its label stays on one line, so a label longer than the chip was cut
|
|
38
|
+
// mid-word at the chip's edge, or drawn past it on a chip you press. It ends in an ellipsis inside the chip, as a
|
|
39
|
+
// button's does; a chip whose label holds elements of its own keeps Vuetify's layout, and a short label is unchanged.
|
|
40
|
+
test("a chip's label longer than its chip ends in an ellipsis inside it; a short label and one holding an element are drawn as before", {
|
|
41
|
+
skip: SKIP,
|
|
42
|
+
timeout: 120_000
|
|
43
|
+
}, async (t) => {
|
|
44
|
+
const { vite, browser } = await open(t);
|
|
45
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 390, height: 844 }, reducedMotion: "reduce" });
|
|
46
|
+
t.after(() => page.close());
|
|
47
|
+
await page.goto("/");
|
|
48
|
+
await page.getByTestId("slot-chip").waitFor();
|
|
49
|
+
const column = await page.getByTestId("column").evaluate((element) => element.getBoundingClientRect().right);
|
|
50
|
+
|
|
51
|
+
for (const testId of ["long-chip", "long-pressable-chip"]) {
|
|
52
|
+
const drawn = await chipGeometry(page.getByTestId(testId));
|
|
53
|
+
assert.ok(drawn.chip[2] <= column, `${testId} ends at ${drawn.chip[2]}, inside its ${column}px column`);
|
|
54
|
+
assert.ok(drawn.content[2] <= drawn.chip[2], `${testId}'s label ends at ${drawn.content[2]}, inside the chip (${drawn.chip[2]})`);
|
|
55
|
+
assert.deepEqual([drawn.overflow, drawn.textOverflow, drawn.clipped], ["hidden", "ellipsis", true],
|
|
56
|
+
`${testId}'s label is clipped with an ellipsis`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const unchanged = ["short-chip", "icon-chip", "slot-chip"];
|
|
60
|
+
const ours = [];
|
|
61
|
+
for (const testId of unchanged) ours.push(await chipGeometry(page.getByTestId(testId)));
|
|
62
|
+
// Vuetify's inline-flex content, as the chip's flex item, computes to flex; material.css's text-only content is block.
|
|
63
|
+
assert.deepEqual(ours.map(({ display }) => display), ["block", "block", "flex"],
|
|
64
|
+
"a text-only label is clipped as a block; one holding an element keeps Vuetify's inline-flex content");
|
|
65
|
+
await page.addStyleTag({ content: VUETIFY_CHIP_CONTENT });
|
|
66
|
+
for (const [index, testId] of unchanged.entries()) {
|
|
67
|
+
const theirs = await chipGeometry(page.getByTestId(testId));
|
|
68
|
+
const where = ({ chip, content, text }) => ({ chip, content, text });
|
|
69
|
+
assert.deepEqual(where(ours[index]), where(theirs), `${testId} is drawn as with Vuetify's own chip content`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createApp, h } from "vue";
|
|
2
|
+
import { createVuetify } from "vuetify";
|
|
3
|
+
import { VApp } from "vuetify/components/VApp";
|
|
4
|
+
import { VChip } from "vuetify/components/VChip";
|
|
5
|
+
import { VIcon } from "vuetify/components/VIcon";
|
|
6
|
+
import { VMain } from "vuetify/components/VMain";
|
|
7
|
+
import "vuetify/styles";
|
|
8
|
+
import "../../../src/client/material.css";
|
|
9
|
+
import { createMaterialVuetifyOptions } from "../../../src/client/index.js";
|
|
10
|
+
|
|
11
|
+
// Chips in a column narrower than a long label, with JSKIT's Material 3 options and stylesheet, as an app draws them
|
|
12
|
+
// (chips.browser.test.js): a long label on a chip and on a chip you press (whose touch target unclips it), a short one,
|
|
13
|
+
// a short one with a leading icon, and one whose label holds an element of its own (an icon in its default slot).
|
|
14
|
+
const LONG = "Quarterly invoices for the North Atlantic shipping project, second half";
|
|
15
|
+
const chips = [
|
|
16
|
+
{ testId: "long-chip", props: { text: LONG } },
|
|
17
|
+
{ testId: "long-pressable-chip", props: { text: LONG, link: true } },
|
|
18
|
+
{ testId: "short-chip", props: { text: "Draft" } },
|
|
19
|
+
{ testId: "icon-chip", props: { text: "Shared", prependIcon: "$info" } },
|
|
20
|
+
{ testId: "slot-chip", props: {}, label: () => [h(VIcon, { icon: "$info", start: true }), "Shared"] }
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const App = () => h(VApp, () => h(VMain, { class: "pa-6" }, () => h("div", { style: "width: 240px", "data-testid": "column" }, (
|
|
24
|
+
chips.map(({ testId, props, label }) => h("div", { class: "mb-2" }, h(VChip, { ...props, "data-testid": testId }, label)))
|
|
25
|
+
))));
|
|
26
|
+
|
|
27
|
+
createApp(App).use(createVuetify(createMaterialVuetifyOptions())).mount("#app");
|
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
|
|
|
@@ -485,8 +498,8 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
|
|
|
485
498
|
css,
|
|
486
499
|
/\.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
|
|
487
500
|
);
|
|
488
|
-
//
|
|
489
|
-
assert.match(css, /\.v-
|
|
501
|
+
// An overlay (a tooltip, a closed eager menu) is hidden whole while its content is.
|
|
502
|
+
assert.match(css, /\.v-overlay:has\(> \.v-overlay__content\[style\*="display: none"\]\) \{\s*display: none;\s*\}/u);
|
|
490
503
|
// A disabled container button is on-surface 12% and 38%, unlayered over its colour class.
|
|
491
504
|
assert.match(
|
|
492
505
|
css,
|