@jskit-ai/users-web 0.2.106 → 0.2.107
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,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The open section's row in the account settings section list keeps an icon tile on its Material 3 active indicator, the `secondary-container` pill as tall as the row with its label bold and in `on-secondary-container`, which no other row has: the open section's tile is filled `primary` with its icon in `on-primary`, and every other row's stays `primary-container` with its icon in `on-primary-container`. `primary-container` shares the pill's tone (90 in light, 30 in dark), so it would show on the pill only where a seed's hues differ (1.01:1 for the default seed in light); `primary` (40, 80 in dark) stands out of it at least 3:1 for any seed, in light and dark. In 0.2.140 the open section's tile had no fill of its own and its icon was in `on-secondary-container`, so the tile disappeared into the pill (#504). The `users/account-settings` pattern says the same.
|
|
5
6
|
- Account settings' forms follow the guide's edit-form rule (#504). **Behaviour change:** leaving a section's form with edits the person has not saved asks first: its close, Done, another section and the browser's Back open a "Discard unsaved changes?" dialog (Keep editing stays; Discard gives the form its saved values back and goes on; new message keys `jskit.users.accountSettings.discard.title`, `.text`, `.keepEditing` and `.confirm`), and closing or reloading the tab asks through the browser. The runtime answers `hasUnsavedEdits` and `discardEdits()` for its three forms, and each of `profile`, `preferences` and `notifications` its own `hasUnsavedEdits` (a ref; http-web's new `useAddEdit()` `hasUnsavedEdits`). The `users/account-settings` pattern's Profile, Preferences and Notifications sections are edit forms: each calls shell-web's `useShellPageClose()`, so the bar's Up arrow is its close (X), Cancel, which leaves for the list (Sign-in methods, no form, keeps the arrow), and its Save says what it saves (**Save profile**, **Save preferences**, **Save notifications**) and stays off until a field changes. Upgrading: an app's copy of the pattern's sections keeps working and already asks before unsaved edits are left; copy the sections' `useShellPageClose()` call and their Save's `label` and `disabled` for the close and the named Save that waits for a change. The question names the section ("Your changes to Profile will be lost."), its text 16dp under its headline. The section list's account header shows the account as saved (the runtime's new `account.saved` and `account.initials`), not the name the person is typing. On an expanded or large window, the list's own page (`/account`, the first section beside the list) draws the same bar as that section's page: no Up arrow, and Done as the way out, where it had Up to the list's parent and no Done.
|
|
6
7
|
- Each entry of the account settings section list is headed by its icon on a tonal tile (`primary-container`, the icon in `on-primary-container`), on every window. An `account-settings:sections` placement names its icon in `props.icon`, an icon alias such as `"$mail"`; users-web's own sections have theirs (Profile `$person`, Preferences `$tune`, Notifications `$notifications`, Sign-in methods `$key`) and any other section without one has the settings icon, so an app that names none sees a tile on every entry. Under its title each entry says what the section holds, the link's accessible description: a placement names it in `props.summary` (plain text, a message key or `{ key, fallback }`), users-web's own sections have theirs (new message keys `jskit.users.accountSettings.summary.profile`, `.preferences`, `.notifications` and `.signInMethods`), and any other section without one shows its title alone. Where the list is alone, on compact and medium windows, each entry ends in a chevron, as it opens a page. `resolveAccountSettingsSections()` and `normalizeAccountSettingsSectionEntry()` answer each section's `icon` and `summary` (#504).
|
|
7
8
|
- The account settings section list is headed by the account: its avatar in `primary-container` with the account control's initials (auth-web's `personInitials`, so one letter for a one-word name), its name in `text-headline-small` and its email (`data-testid="account-settings-account"`), on every window, lined up with the list's tiles and, on a phone, with the page's margin. The line of copy above the list ("Global profile, preferences, notifications, and account controls.") is gone, and with it the message `jskit.users.accountSettings.subtitle`. The open section's label is bold, and its icon tile joins its `secondary-container` pill, the icon in `on-secondary-container`. Each entry is a Material 3 list item: its title in body-large (it was label-large) and its summary in body-medium, 72px tall with a summary. The account's avatar is a tile's size, 40px, its name on the entries' titles. Beside the list, the open section is headed by its icon tile and its title, an `h2` (`data-testid="account-settings-section-heading"`), its tile lined up with the account's, and its content is at most 600px wide; a section open alone, on compact and medium windows, adds no heading, and the app bar's title is the section's (it was "Account settings", which the list keeps). The `users/account-settings` pattern's sections save from the app bar: each section's Save is a primary `ShellPageAction` (`type="submit"`, `form` naming the section's form) in its own `ShellPageActions`, busy while it saves, in place of a button at the foot of the form. Its profile section shows its avatar in `primary-container` (it was `surface-variant`) with **Change avatar** (**Add avatar** without one, both a filled tonal button in `secondary-container`) and Remove beside it, no "Preview size" caption, a leading icon on Display name (`$person`), and the email as a detail row to read rather than a read-only field: the address first, then "Email" and "Managed by your sign-in account", its icon and text on Display name's keylines. The sections' fields are Material 3's 56dp outlined fields (they were `density="comfortable"`, 48px), and the sections have no side padding of their own (they had 16px), so their content starts at the page's margin. Upgrading: an app's copy of the pattern's sections keeps working; copy the sections' `ShellPageActions` and form ids to move Save to the bar (#504).
|
|
@@ -172,6 +172,9 @@ app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, errorRuntime);
|
|
|
172
172
|
app.use(createPinia());
|
|
173
173
|
app.use(router);
|
|
174
174
|
app.use(VueQueryPlugin, { queryClient: new QueryClient({ defaultOptions: { queries: { retry: false } } }) });
|
|
175
|
-
app
|
|
175
|
+
// The app's seed colour, as an app's theme names it; `?seed=` on the first address gives another, so a test can see
|
|
176
|
+
// the colour schemes any seed generates. Without one, material-web's default seed.
|
|
177
|
+
const seed = new URLSearchParams(window.location.search).get("seed");
|
|
178
|
+
app.use(createVuetify({ components, directives, ...createMaterialVuetifyOptions(seed ? { seed } : {}) }));
|
|
176
179
|
await router.isReady();
|
|
177
180
|
app.mount("#app");
|
package/package.json
CHANGED
|
@@ -76,15 +76,18 @@ a message key or `{ key, fallback }`, beside `value` and `title`; the four
|
|
|
76
76
|
example sections have users-web's (`$person`, `$tune`, `$notifications`, `$key`,
|
|
77
77
|
and a summary each), and a section that names none has the settings icon and
|
|
78
78
|
its title alone. Where the list is alone (compact and medium windows) each entry
|
|
79
|
-
ends in a chevron, as it opens a page. The open section's
|
|
80
|
-
|
|
81
|
-
`on-secondary-container
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
its
|
|
79
|
+
ends in a chevron, as it opens a page. The open section's row carries Material
|
|
80
|
+
3's active indicator, a `secondary-container` pill as tall as the row with its
|
|
81
|
+
label bold and in `on-secondary-container`, and its tile is filled `primary`
|
|
82
|
+
with its icon in `on-primary`: `primary-container`, which every other row's
|
|
83
|
+
tile keeps, shares the pill's tone and would vanish into it for some seeds,
|
|
84
|
+
while `primary` stands out of it at least 3:1 for any. Beside the
|
|
85
|
+
list, the open section is headed by its tile and its title (an `h2`; the app
|
|
86
|
+
bar's title, "Account settings", is the page's `h1`), its tile lined up with
|
|
87
|
+
the account's, and its form keeps a readable width, at most 600px. A section
|
|
88
|
+
open alone (compact and medium windows) adds no heading: the app bar's title is
|
|
89
|
+
the section's, under Up to the list. A section's content starts at the page's
|
|
90
|
+
margin, with no side padding of its own.
|
|
88
91
|
|
|
89
92
|
A section's form is an edit form, as the guide's forms are. Its Save is the app
|
|
90
93
|
bar's primary action: `<ShellPageActions>` holds a
|
|
@@ -173,18 +173,14 @@ onBeforeUnmount(() => window.removeEventListener("beforeunload", warnBeforeUnloa
|
|
|
173
173
|
:aria-labelledby="`settings-section-${section.value}-title`"
|
|
174
174
|
:aria-describedby="section.summary ? `settings-section-${section.value}-summary` : undefined"
|
|
175
175
|
>
|
|
176
|
-
<!-- Each section is headed by its tonal icon tile, as Material 3's finished screen heads a section
|
|
177
|
-
open section's tile
|
|
176
|
+
<!-- Each section is headed by its tonal icon tile, as Material 3's finished screen heads a section. The
|
|
177
|
+
open section's tile is filled primary on its row's secondary-container pill: primary-container
|
|
178
|
+
shares the pill's tone and would vanish into it for some seeds, primary stands out for any. -->
|
|
178
179
|
<template #prepend>
|
|
179
|
-
<v-avatar
|
|
180
|
-
:color="isShown(section) ? undefined : 'primary-container'"
|
|
181
|
-
:class="{ 'settings-section-list__tile--open': isShown(section) }"
|
|
182
|
-
rounded="lg"
|
|
183
|
-
size="40"
|
|
184
|
-
>
|
|
180
|
+
<v-avatar :color="isShown(section) ? 'primary' : 'primary-container'" rounded="lg" size="40">
|
|
185
181
|
<v-icon
|
|
186
182
|
:icon="section.icon"
|
|
187
|
-
:color="isShown(section) ? 'on-
|
|
183
|
+
:color="isShown(section) ? 'on-primary' : 'on-primary-container'"
|
|
188
184
|
size="24"
|
|
189
185
|
/>
|
|
190
186
|
</v-avatar>
|
|
@@ -295,11 +291,6 @@ onBeforeUnmount(() => window.removeEventListener("beforeunload", warnBeforeUnloa
|
|
|
295
291
|
--settings-item-inset: 12px;
|
|
296
292
|
}
|
|
297
293
|
|
|
298
|
-
/* The open section's tile is its pill's: no fill of its own. */
|
|
299
|
-
.settings-section-list__tile--open {
|
|
300
|
-
background: transparent;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
294
|
/* Beside the list, the open section's heading is the account row's height at its top, so the two panes' tiles line
|
|
304
295
|
up; it starts at the pane's edge, as the section's fields do. */
|
|
305
296
|
.settings-section-heading {
|
|
@@ -320,8 +311,9 @@ onBeforeUnmount(() => window.removeEventListener("beforeunload", warnBeforeUnloa
|
|
|
320
311
|
margin: 0;
|
|
321
312
|
}
|
|
322
313
|
|
|
323
|
-
/* The selected section
|
|
324
|
-
its hover and pressed state layers
|
|
314
|
+
/* The selected section's row carries Material 3's active indicator, a pill in secondary-container behind its primary
|
|
315
|
+
tile and its label in on-secondary-container, as the shell's navigation draws it; its hover and pressed state layers
|
|
316
|
+
take the same pill. */
|
|
325
317
|
.settings-section-list__item {
|
|
326
318
|
--v-activated-opacity: 0;
|
|
327
319
|
border-radius: 9999px;
|
|
@@ -464,7 +464,10 @@ test("notifications save, and sign-in methods link through the provider and unli
|
|
|
464
464
|
// after its label at the row's end, and each field has the form's full width, so a long email shows whole.
|
|
465
465
|
// Each section in the list is its title after a tonal icon tile, the placement's icon or users-web's for its own
|
|
466
466
|
// sections, on every window: the list beside the open section on wide windows and the list alone on a phone. The open
|
|
467
|
-
// section
|
|
467
|
+
// section's row carries Material 3's active indicator, a secondary-container pill as tall as the row with its label in
|
|
468
|
+
// on-secondary-container, and no other row has one; its label is bold too, so the pill's colour is not its only mark.
|
|
469
|
+
// Every other row's tile is primary-container with its icon in on-primary-container; the open section's tile is filled
|
|
470
|
+
// primary with its icon in on-primary, so it stands out of its pill (the next test measures how far).
|
|
468
471
|
test("the section list heads each section with its icon on a tonal tile, at every width", options, async () => {
|
|
469
472
|
const symbolPath = (alias) => materialSymbols[alias].slice("svg:".length);
|
|
470
473
|
for (const viewport of [{ width: 390, height: 844 }, { width: 1280, height: 900 }]) {
|
|
@@ -487,16 +490,27 @@ test("the section list heads each section with its icon on a tonal tile, at ever
|
|
|
487
490
|
return color;
|
|
488
491
|
};
|
|
489
492
|
const active = item.classList.contains("v-list-item--active");
|
|
490
|
-
|
|
491
|
-
|
|
493
|
+
// The row's own container: Material 3's active indicator is a secondary-container pill, its corners half the
|
|
494
|
+
// row's height, behind a label in on-secondary-container; a row at rest has no container.
|
|
495
|
+
const row = getComputedStyle(item);
|
|
496
|
+
const title = item.querySelector(".v-list-item-title");
|
|
497
|
+
let indicator = row.backgroundColor === "rgba(0, 0, 0, 0)" ? "none" : row.backgroundColor;
|
|
498
|
+
if (row.backgroundColor === role("secondary-container")) {
|
|
499
|
+
const pill = Number.parseFloat(row.borderTopLeftRadius) >= item.getBoundingClientRect().height / 2;
|
|
500
|
+
const label = getComputedStyle(title).color === role("on-secondary-container");
|
|
501
|
+
indicator = `secondary-container${pill ? " pill" : ""}${label ? ", on-secondary-container label" : ""}`;
|
|
502
|
+
}
|
|
492
503
|
return {
|
|
493
|
-
title:
|
|
504
|
+
title: title.textContent.trim(),
|
|
494
505
|
summary: item.querySelector(".v-list-item-subtitle")?.textContent.trim() || "",
|
|
495
506
|
chevron: item.querySelectorAll(".v-list-item__append .v-icon").length,
|
|
496
507
|
icon: tile?.querySelector(".v-icon path")?.getAttribute("d") || "",
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
508
|
+
// The roles the tile and its icon are drawn in, of the two each may take.
|
|
509
|
+
tile: ["primary", "primary-container"].find((name) => tile && getComputedStyle(tile).backgroundColor === role(name)) || "",
|
|
510
|
+
iconColor: ["on-primary", "on-primary-container"]
|
|
511
|
+
.find((name) => tile && getComputedStyle(tile.querySelector(".v-icon")).color === role(name)) || "",
|
|
512
|
+
weight: getComputedStyle(title).fontWeight,
|
|
513
|
+
indicator,
|
|
500
514
|
active
|
|
501
515
|
};
|
|
502
516
|
}));
|
|
@@ -510,7 +524,17 @@ test("the section list heads each section with its icon on a tonal tile, at ever
|
|
|
510
524
|
// A wide window opens the first section beside the list; a phone shows the list alone, each row opening a page.
|
|
511
525
|
const active = viewport.width >= 840 && title === "Profile";
|
|
512
526
|
const chevron = viewport.width >= 840 ? 0 : 1;
|
|
513
|
-
return {
|
|
527
|
+
return {
|
|
528
|
+
title,
|
|
529
|
+
summary,
|
|
530
|
+
chevron,
|
|
531
|
+
icon: symbolPath(alias),
|
|
532
|
+
tile: active ? "primary" : "primary-container",
|
|
533
|
+
iconColor: active ? "on-primary" : "on-primary-container",
|
|
534
|
+
weight: active ? "700" : "400",
|
|
535
|
+
indicator: active ? "secondary-container pill, on-secondary-container label" : "none",
|
|
536
|
+
active
|
|
537
|
+
};
|
|
514
538
|
}), at);
|
|
515
539
|
// Material 3's list item: the title in body-large, the summary under it in body-medium, a two-line row 72dp tall.
|
|
516
540
|
const rows = await page.locator(".settings-section-list__item").evaluateAll((items) => items.map((item) => {
|
|
@@ -530,6 +554,73 @@ test("the section list heads each section with its icon on a tonal tile, at ever
|
|
|
530
554
|
}
|
|
531
555
|
});
|
|
532
556
|
|
|
557
|
+
// primary-container and secondary-container share a tone (90 in light, 30 in dark), so a tile in one on the other shows
|
|
558
|
+
// only where a seed's hues happen to differ. The open section's tile is primary (tone 40, 80 in dark) on its row's
|
|
559
|
+
// secondary-container pill: at least 3:1 against the pill, as a graphic object needs, and its icon, on-primary, at
|
|
560
|
+
// least 3:1 against the tile, for material-web's default seed and another, in light and dark.
|
|
561
|
+
test("the open section's tile stands out of its row's active indicator for any seed, in light and dark", options, async (t) => {
|
|
562
|
+
for (const seed of ["", "#006A6A"]) {
|
|
563
|
+
for (const theme of ["light", "dark"]) {
|
|
564
|
+
const at = `${seed || "default seed"}, ${theme}`;
|
|
565
|
+
const api = await openApp({
|
|
566
|
+
routes: { "GET /api/settings": document(settings({ preferences: { ...settings().preferences, theme } })) }
|
|
567
|
+
});
|
|
568
|
+
const { page } = api;
|
|
569
|
+
await page.goto(seed ? `/account?seed=${encodeURIComponent(seed)}` : "/account");
|
|
570
|
+
// The account's saved theme preference decides the scheme.
|
|
571
|
+
await expect(page.locator(`.v-application.v-theme--${theme}`), at).toHaveCount(1);
|
|
572
|
+
const open = page.locator(".settings-section-list__item.v-list-item--active");
|
|
573
|
+
await expect(open, at).toHaveAccessibleName("Profile");
|
|
574
|
+
const measure = () => open.evaluate((item) => {
|
|
575
|
+
const role = (name) => {
|
|
576
|
+
const probe = item.appendChild(document.createElement("span"));
|
|
577
|
+
probe.style.color = `rgb(var(--v-theme-${name}))`;
|
|
578
|
+
const color = getComputedStyle(probe).color;
|
|
579
|
+
probe.remove();
|
|
580
|
+
return color;
|
|
581
|
+
};
|
|
582
|
+
// WCAG's relative luminance and contrast ratio of two opaque colours.
|
|
583
|
+
const luminance = (color) => {
|
|
584
|
+
const [red, green, blue] = color.match(/[\d.]+/gu).slice(0, 3).map((channel) => {
|
|
585
|
+
const value = Number(channel) / 255;
|
|
586
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
587
|
+
});
|
|
588
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
589
|
+
};
|
|
590
|
+
const contrast = (one, two) => {
|
|
591
|
+
const [light, dark] = [luminance(one), luminance(two)].sort((a, b) => b - a);
|
|
592
|
+
return (light + 0.05) / (dark + 0.05);
|
|
593
|
+
};
|
|
594
|
+
const tile = item.querySelector(".v-list-item__prepend .v-avatar");
|
|
595
|
+
const pill = getComputedStyle(item).backgroundColor;
|
|
596
|
+
const fill = getComputedStyle(tile).backgroundColor;
|
|
597
|
+
const icon = getComputedStyle(tile.querySelector(".v-icon")).color;
|
|
598
|
+
const tileOnPill = contrast(fill, pill);
|
|
599
|
+
const iconOnTile = contrast(icon, fill);
|
|
600
|
+
return {
|
|
601
|
+
pill: pill === role("secondary-container"),
|
|
602
|
+
tile: fill === role("primary"),
|
|
603
|
+
icon: icon === role("on-primary"),
|
|
604
|
+
tileStandsOut: tileOnPill >= 3,
|
|
605
|
+
iconStandsOut: iconOnTile >= 3,
|
|
606
|
+
// The ratios themselves, which a failure shows.
|
|
607
|
+
ratios: `tile ${tileOnPill.toFixed(2)}:1 on its pill, icon ${iconOnTile.toFixed(2)}:1 on its tile`
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
// Read until the scheme has settled (a tile's colour moves with the theme), then judge.
|
|
611
|
+
await expect.poll(measure, { message: at }).toMatchObject({
|
|
612
|
+
pill: true,
|
|
613
|
+
tile: true,
|
|
614
|
+
icon: true,
|
|
615
|
+
tileStandsOut: true,
|
|
616
|
+
iconStandsOut: true
|
|
617
|
+
});
|
|
618
|
+
t.diagnostic(`${at}: ${(await measure()).ratios}`);
|
|
619
|
+
await finish(api);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
|
|
533
624
|
// The page says whose account it is: the list is headed by the account's avatar, in a container colour, its name and
|
|
534
625
|
// its email, with no line of copy above it. The profile section's avatar takes the same colour, its fields their
|
|
535
626
|
// leading icons, and the email, which the sign-in account manages, is a detail row to read; no developer caption shows.
|