@jskit-ai/users-web 0.2.104 → 0.2.106

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,7 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- - Account settings read again (an `account.settings.changed` event, the window regaining focus, Retry) keep what the person changed and has not saved in each section, and take every other field. Before, each read and each section's save wrote all three forms, so a live update, or saving one section, replaced unsaved edits in every section. Each form now takes the settings through its own `useAddEdit()` runtime (http-web's `applyLoaded`), and a section's save answer becomes the settings read (`setQueryData`), which every form takes the same way. The runtime's `profile`, `preferences` and `notifications` each have `conflicts` (a ref of `{ key, value }`, the fields whose server value changed under the person's change), `acceptServerValue(key)` and `keepOwnValue(key)`, and the account-settings pattern's sections show them after their Save button with http-web's `EditConflictNotice`; their fields stay editable while the settings are read again. The pattern now requires `@jskit-ai/http-web`. Upgrading: an app's copy of the pattern's sections keeps working and now keeps edits; to say when the server changed a field and to keep fields open during the read, copy the sections' `conflictItems` and `<EditConflictNotice>` and drop `isRefreshing` from the fields' `readonly` and `disabled`.
5
+ - 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
+ - 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
+ - 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).
8
+
9
+ - Account settings read again (an `account.settings.changed` event, the window regaining focus, Retry) keep what the person changed and has not saved in each section, and take every other field. Before, each read and each section's save wrote all three forms, so a live update, or saving one section, replaced unsaved edits in every section. Each form now takes the settings through its own `useAddEdit()` runtime (http-web's `applyLoaded`), and a section's save answer becomes the settings read (`setQueryData`), which every form takes the same way. The runtime's `profile`, `preferences` and `notifications` each have `conflicts` (a ref of `{ key, value }`, the fields whose server value changed under the person's change), `acceptServerValue(key)` and `keepOwnValue(key)`, and the account-settings pattern's sections show them at the end of their form with http-web's `EditConflictNotice`; their fields stay editable while the settings are read again. The pattern now requires `@jskit-ai/http-web`. Upgrading: an app's copy of the pattern's sections keeps working and now keeps edits; to say when the server changed a field and to keep fields open during the read, copy the sections' `conflictItems` and `<EditConflictNotice>` and drop `isRefreshing` from the fields' `readonly` and `disabled`.
6
10
  - The account-settings pattern's Save buttons keep keyboard focus while their section saves and then reloads (shell-web's `v-pending`), instead of becoming disabled for the reload, which dropped focus to the page body.
7
11
  - Account settings read their operations from users-core's `userProfileContract` and `userSettingsContract`.
8
12
  - Account settings sections are pages in Material 3's list-detail layout (shell-web's `ShellListDetail`): `/account` lists the sections and `/account/<section>` opens one, instead of `?section=` on one page. `AccountSettingsClientElement` reads the route's `section` param and links each section to its path, keeping `returnTo`; on compact and medium windows it shows the list or one section, whose Up returns to the list, and on expanded and large windows the list beside the open section (or the first section on the list's own page), where Done replaces Up as the way out. The `users/account-settings` pattern adds `src/pages/account/[section].vue`, with parent `"/"`. Upgrading: add that page beside `src/pages/account/index.vue`, and change links to `/account?section=<value>` into `/account/<value>`.
package/locales/en.json CHANGED
@@ -3,12 +3,17 @@
3
3
  "users": {
4
4
  "accountSettings": {
5
5
  "title": "Account settings",
6
- "subtitle": "Global profile, preferences, notifications, and account controls.",
7
6
  "done": "Done",
8
7
  "loadFailedTitle": "Unable to load account settings",
9
8
  "loadFailed": "Unable to load settings.",
10
9
  "retry": "Retry",
11
10
  "noSections": "No account settings sections are registered.",
11
+ "discard": {
12
+ "title": "Discard unsaved changes?",
13
+ "text": "Your changes to {section} will be lost.",
14
+ "keepEditing": "Keep editing",
15
+ "confirm": "Discard"
16
+ },
12
17
  "profile": {
13
18
  "title": "Profile",
14
19
  "previewSizePrefix": "Preview size:",
@@ -69,6 +74,12 @@
69
74
  "signInMethods": {
70
75
  "unlinked": "Sign-in method removed.",
71
76
  "unlinkFailed": "Unable to remove the sign-in method."
77
+ },
78
+ "summary": {
79
+ "profile": "Name, avatar and email",
80
+ "preferences": "Theme, language and formats",
81
+ "notifications": "Updates and alerts we send you",
82
+ "signInMethods": "Password and linked accounts"
72
83
  }
73
84
  },
74
85
  "homeTools": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-web",
3
- "version": "0.2.104",
3
+ "version": "0.2.106",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@jskit-ai/uploads-image-web": "0.2.38",
17
- "@jskit-ai/users-core": "0.2.80"
17
+ "@jskit-ai/users-core": "0.2.81"
18
18
  },
19
19
  "peerDependencies": {
20
- "@jskit-ai/auth-web": "0.2.75",
20
+ "@jskit-ai/auth-web": "0.2.77",
21
21
  "@jskit-ai/http-runtime": "0.2.39",
22
- "@jskit-ai/http-web": "0.2.77",
22
+ "@jskit-ai/http-web": "0.2.79",
23
23
  "@jskit-ai/kernel": "0.2.38",
24
- "@jskit-ai/shell-web": "0.2.67",
24
+ "@jskit-ai/shell-web": "0.2.69",
25
25
  "@tanstack/vue-query": "^5.90.5",
26
26
  "vue": "^3.5.13",
27
27
  "vue-router": "^5.0.4",
@@ -230,6 +230,6 @@
230
230
  }
231
231
  },
232
232
  "devDependencies": {
233
- "@jskit-ai/material-web": "0.1.17"
233
+ "@jskit-ai/material-web": "0.1.19"
234
234
  }
235
235
  }
@@ -44,8 +44,8 @@ section keeps what the person changed and has not saved, and takes every other
44
44
  field; its fields stay editable while the read runs. A section's `conflicts`
45
45
  (a ref) lists the fields whose server value changed under the person's change,
46
46
  as `{ key, value }` with the server's value; `acceptServerValue(key)` takes it
47
- and `keepOwnValue(key)` keeps theirs. The example sections show them after
48
- their Save button with `EditConflictNotice` from
47
+ and `keepOwnValue(key)` keeps theirs. The example sections show them at the
48
+ end of their form with `EditConflictNotice` from
49
49
  `@jskit-ai/http-web/client/components/EditConflictNotice`, which takes
50
50
  `{ key, label, value }` items, `value` the server's value as the field shows it.
51
51
 
@@ -56,11 +56,58 @@ Sections are pages of the account surface, in Material 3's list-detail layout
56
56
  `/account/preferences`), both rendering `AccountSettingsClientElement`, which
57
57
  reads the section from the route's `section` param. The section page's parent
58
58
  is the list, the surface's `"/"`. A phone or medium window shows the list or one
59
- section, and Up returns from the section to the list; an expanded or large
59
+ section, and the bar returns from the section to the list (a form's close, a
60
+ section that is no form its Up arrow); an expanded or large
60
61
  window shows the list beside the open section, or beside the first section on
61
- the list's own page. A link to a section is its path, `/account/invites`, with
62
+ the list's own page, and both draw the same bar, with Done as the way out. A link to a section is its path, `/account/invites`, with
62
63
  `returnTo` in the query for Done.
63
64
 
65
+ The section list is headed by the account as saved (`runtime.account.saved`,
66
+ while the profile form holds what the person types): its avatar in
67
+ `primary-container`, a tile's size, with the account control's initials (one
68
+ letter for a one-word name), its name in a headline role and its email, the avatar lined up with the
69
+ list's tiles and the name with their titles and, on a phone, with the page's
70
+ margin. Each entry of the list is a Material 3 list item headed by its icon on a
71
+ tonal tile: its title in body-large, with a line under it in body-medium saying
72
+ what the section holds (the link's description; its name is the title), 72dp
73
+ tall. A section's placement names them in
74
+ `props.icon`, an icon alias such as `"$mail"`, and `props.summary`, plain text,
75
+ a message key or `{ key, fallback }`, beside `value` and `title`; the four
76
+ example sections have users-web's (`$person`, `$tune`, `$notifications`, `$key`,
77
+ and a summary each), and a section that names none has the settings icon and
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 label is bold, and
80
+ its tile joins its `secondary-container` pill, its icon in
81
+ `on-secondary-container`. Beside the list, the open section is headed by its
82
+ tile and its title (an `h2`; the app bar's title, "Account settings", is the
83
+ page's `h1`), its tile lined up with the account's, and its form keeps a
84
+ readable width, at most 600px. A section open alone (compact and medium
85
+ windows) adds no heading: the app bar's title is the section's, under Up to the
86
+ list. A section's content starts at the page's margin, with no side padding of
87
+ its own.
88
+
89
+ A section's form is an edit form, as the guide's forms are. Its Save is the app
90
+ bar's primary action: `<ShellPageActions>` holds a
91
+ `<ShellPageAction primary label="Save profile" type="submit" form="…">` that
92
+ submits the section's form by its id, with `loading` and `pending` while it
93
+ saves. Save says what it saves and stays off until a field changes: each form
94
+ in the runtime has `hasUnsavedEdits` (a ref), true while a field differs from
95
+ what the form last took from the server. The section calls
96
+ `useShellPageClose({ label: "Cancel", close: () => navigation.finish() })`, so
97
+ the bar's Up arrow is its close (X), which leaves for the list; Sign-in methods,
98
+ no form, keeps the arrow. Leaving a form with unsaved edits asks first: its
99
+ close, Done, another section and the browser's Back open
100
+ `AccountSettingsClientElement`'s "Discard unsaved changes?" dialog (Keep
101
+ editing stays; Discard gives the form its saved values back and goes on), and
102
+ closing or reloading the tab asks through the browser. The runtime's
103
+ `hasUnsavedEdits` and `discardEdits()` cover its three forms; a section with a
104
+ form of its own asks the same way only through its own guard. The example profile section shows the
105
+ avatar in `primary-container` with **Change avatar** (**Add avatar** without
106
+ one), a filled tonal button in `secondary-container`, beside it, Display name
107
+ with its leading icon in Material 3's 56dp outlined field, and the email, which
108
+ the sign-in account manages, as a detail row to read: the address first, then
109
+ "Email" and who manages it, its icon and text on the field's keylines.
110
+
64
111
  `runtime.signInMethods.methods` lists the auth provider's OAuth sign-in
65
112
  methods as `{ provider, label, linked, canLink, canUnlink }`, read from the
66
113
  settings security status. `link(provider)` leaves for the provider through
@@ -82,10 +129,10 @@ provider offers provider linking (`providerLinking` in its capabilities).
82
129
  - The route and placement owner agree.
83
130
  - The account surface renders in its own layout, `src/pages/account.vue`
84
131
  (`ShellLayout` around `<RouterView />`, `meta.jskit.surface: "account"`), so
85
- the settings page's title and Up arrow are in the top app bar. Up is the
86
- page's only way out; `AccountSettingsClientElement` adds a Done action only
87
- where Up can't go back (no parent, a section beside the list on a wide
88
- window, or a returnTo on another origin).
132
+ the settings page's title and Up arrow are in the top app bar. Up (a form's
133
+ close) is the page's only way out; `AccountSettingsClientElement` adds a Done
134
+ action only where Up can't go back (no parent, a wide window, where a section
135
+ shows beside the list, or a returnTo on another origin).
89
136
  With no navigation items, the surface shows no navigation bar, rail or drawer.
90
137
  - Each section has its own address, `/account/<section>`, served by
91
138
  `src/pages/account/[section].vue` with parent `"/"`; nothing selects a
@@ -108,8 +155,10 @@ notification vocabulary while keeping server-owned validation authoritative.
108
155
  Navigate away and back with warm cache, exercise browser back/forward, save and
109
156
  clear fields, verify toast errors, inspect skeleton geometry, and test keyboard
110
157
  operation at compact and expanded widths. At 390 px check that the list and a
111
- section show one at a time and Up returns from the section to the list; at
112
- 1280 px that the list shows beside the open section, with no Up.
158
+ section show one at a time and the bar's close (X) returns from a form section
159
+ to the list; at 1280 px that the list shows beside the open section, with no Up.
160
+ Check that Save stays off until a field changes, and that leaving a changed form
161
+ by its close, another section, Back or closing the tab asks first.
113
162
 
114
163
  ## Avoid
115
164
 
@@ -1,7 +1,10 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import EditConflictNotice from "@jskit-ai/http-web/client/components/EditConflictNotice";
4
- import { vPending } from "@jskit-ai/shell-web/client/directives/vPending";
4
+ import ShellPageAction from "@jskit-ai/shell-web/client/components/ShellPageAction";
5
+ import ShellPageActions from "@jskit-ai/shell-web/client/components/ShellPageActions";
6
+ import { useShellPageClose } from "@jskit-ai/shell-web/client/composables/useShellPageClose";
7
+ import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
5
8
 
6
9
  const props = defineProps({
7
10
  runtime: {
@@ -12,6 +15,11 @@ const props = defineProps({
12
15
 
13
16
  const notifications = props.runtime.notifications;
14
17
 
18
+ // An edit form, as the guide's forms are: the app bar's Up arrow is its close (X), Cancel, which leaves for the list;
19
+ // the settings ask first when the form has unsaved edits.
20
+ const navigation = useShellNavigation();
21
+ useShellPageClose({ label: "Cancel", close: () => navigation.finish() });
22
+
15
23
  // The settings read again (another session saved them) keep what the person switched; the notice names each switch
16
24
  // whose server value changed meanwhile.
17
25
  const FIELD_LABELS = Object.freeze({ productUpdates: "Product updates", accountActivity: "Account activity alerts" });
@@ -23,7 +31,20 @@ const conflictItems = computed(() =>
23
31
  <template>
24
32
  <div class="account-settings-section">
25
33
  <div class="account-settings-section__body">
26
- <v-form @submit.prevent="notifications.submit" novalidate>
34
+ <!-- Save is the app bar's primary action, as Material 3 puts a form's Save; it submits this form by its id. It says
35
+ what it saves, and stays off until a field changes. -->
36
+ <ShellPageActions>
37
+ <ShellPageAction
38
+ primary
39
+ label="Save notifications"
40
+ type="submit"
41
+ form="account-settings-notifications-form"
42
+ :loading="notifications.isSaving.value"
43
+ :pending="notifications.isSaving.value || notifications.isRefreshing.value"
44
+ :disabled="!notifications.hasUnsavedEdits.value"
45
+ />
46
+ </ShellPageActions>
47
+ <v-form id="account-settings-notifications-form" @submit.prevent="notifications.submit" novalidate>
27
48
  <v-switch
28
49
  v-model="notifications.form.productUpdates"
29
50
  label="Product updates"
@@ -47,15 +68,6 @@ const conflictItems = computed(() =>
47
68
  hide-details
48
69
  disabled
49
70
  />
50
- <v-btn
51
- type="submit"
52
- color="primary"
53
- class="mt-4"
54
- :loading="notifications.isSaving.value"
55
- v-pending="notifications.isSaving.value || notifications.isRefreshing.value"
56
- >
57
- Save notification settings
58
- </v-btn>
59
71
  <EditConflictNotice
60
72
  :items="conflictItems"
61
73
  @accept="notifications.acceptServerValue"
@@ -71,7 +83,8 @@ const conflictItems = computed(() =>
71
83
  overflow: hidden;
72
84
  }
73
85
 
86
+ /* The section starts at the page's margin, under the bar's Up arrow: no side padding of its own. */
74
87
  .account-settings-section__body {
75
- padding: 1rem;
88
+ padding: 1rem 0;
76
89
  }
77
90
  </style>
@@ -1,7 +1,10 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import EditConflictNotice from "@jskit-ai/http-web/client/components/EditConflictNotice";
4
- import { vPending } from "@jskit-ai/shell-web/client/directives/vPending";
4
+ import ShellPageAction from "@jskit-ai/shell-web/client/components/ShellPageAction";
5
+ import ShellPageActions from "@jskit-ai/shell-web/client/components/ShellPageActions";
6
+ import { useShellPageClose } from "@jskit-ai/shell-web/client/composables/useShellPageClose";
7
+ import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
5
8
 
6
9
  const props = defineProps({
7
10
  runtime: {
@@ -12,6 +15,11 @@ const props = defineProps({
12
15
 
13
16
  const preferences = props.runtime.preferences;
14
17
 
18
+ // An edit form, as the guide's forms are: the app bar's Up arrow is its close (X), Cancel, which leaves for the list;
19
+ // the settings ask first when the form has unsaved edits.
20
+ const navigation = useShellNavigation();
21
+ useShellPageClose({ label: "Cancel", close: () => navigation.finish() });
22
+
15
23
  // The settings read again (another session saved them) keep what the person chose; the notice names each field whose
16
24
  // server value changed meanwhile, with that value as its list shows it.
17
25
  const FIELDS = Object.freeze({
@@ -35,7 +43,20 @@ const conflictItems = computed(() =>
35
43
  <template>
36
44
  <div class="account-settings-section">
37
45
  <div class="account-settings-section__body">
38
- <v-form @submit.prevent="preferences.submit" novalidate>
46
+ <!-- Save is the app bar's primary action, as Material 3 puts a form's Save; it submits this form by its id. It says
47
+ what it saves, and stays off until a field changes. -->
48
+ <ShellPageActions>
49
+ <ShellPageAction
50
+ primary
51
+ label="Save preferences"
52
+ type="submit"
53
+ form="account-settings-preferences-form"
54
+ :loading="preferences.isSaving.value"
55
+ :pending="preferences.isSaving.value || preferences.isRefreshing.value"
56
+ :disabled="!preferences.hasUnsavedEdits.value"
57
+ />
58
+ </ShellPageActions>
59
+ <v-form id="account-settings-preferences-form" @submit.prevent="preferences.submit" novalidate>
39
60
  <v-row>
40
61
  <v-col cols="12" md="4">
41
62
  <!-- readable-check: allow selection-field - data: the account settings runtime holds these as fixed lists, so nothing loads -->
@@ -46,7 +67,6 @@ const conflictItems = computed(() =>
46
67
  item-title="title"
47
68
  item-value="value"
48
69
  variant="outlined"
49
- density="comfortable"
50
70
  :disabled="preferences.isSaving.value"
51
71
  :error-messages="preferences.fieldErrors.theme"
52
72
  />
@@ -61,7 +81,6 @@ const conflictItems = computed(() =>
61
81
  item-title="title"
62
82
  item-value="value"
63
83
  variant="outlined"
64
- density="comfortable"
65
84
  :disabled="preferences.isSaving.value"
66
85
  :error-messages="preferences.fieldErrors.locale"
67
86
  />
@@ -74,7 +93,6 @@ const conflictItems = computed(() =>
74
93
  label="Time zone"
75
94
  :items="preferences.options.timeZone"
76
95
  variant="outlined"
77
- density="comfortable"
78
96
  :disabled="preferences.isSaving.value"
79
97
  :error-messages="preferences.fieldErrors.timeZone"
80
98
  />
@@ -89,7 +107,6 @@ const conflictItems = computed(() =>
89
107
  item-title="title"
90
108
  item-value="value"
91
109
  variant="outlined"
92
- density="comfortable"
93
110
  :disabled="preferences.isSaving.value"
94
111
  :error-messages="preferences.fieldErrors.dateFormat"
95
112
  />
@@ -104,7 +121,6 @@ const conflictItems = computed(() =>
104
121
  item-title="title"
105
122
  item-value="value"
106
123
  variant="outlined"
107
- density="comfortable"
108
124
  :disabled="preferences.isSaving.value"
109
125
  :error-messages="preferences.fieldErrors.numberFormat"
110
126
  />
@@ -117,7 +133,6 @@ const conflictItems = computed(() =>
117
133
  label="Currency"
118
134
  :items="preferences.options.currency"
119
135
  variant="outlined"
120
- density="comfortable"
121
136
  :disabled="preferences.isSaving.value"
122
137
  :error-messages="preferences.fieldErrors.currencyCode"
123
138
  />
@@ -130,22 +145,12 @@ const conflictItems = computed(() =>
130
145
  label="Avatar size"
131
146
  :items="preferences.options.avatarSize"
132
147
  variant="outlined"
133
- density="comfortable"
134
148
  :disabled="preferences.isSaving.value"
135
149
  :error-messages="preferences.fieldErrors.avatarSize"
136
150
  />
137
151
  </v-col>
138
152
  </v-row>
139
153
 
140
- <v-btn
141
- type="submit"
142
- color="primary"
143
- class="mt-4"
144
- :loading="preferences.isSaving.value"
145
- v-pending="preferences.isSaving.value || preferences.isRefreshing.value"
146
- >
147
- Save preferences
148
- </v-btn>
149
154
  <EditConflictNotice
150
155
  :items="conflictItems"
151
156
  @accept="preferences.acceptServerValue"
@@ -161,7 +166,8 @@ const conflictItems = computed(() =>
161
166
  overflow: hidden;
162
167
  }
163
168
 
169
+ /* The section starts at the page's margin, under the bar's Up arrow: no side padding of its own. */
164
170
  .account-settings-section__body {
165
- padding: 1rem;
171
+ padding: 1rem 0;
166
172
  }
167
173
  </style>
@@ -1,7 +1,10 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import EditConflictNotice from "@jskit-ai/http-web/client/components/EditConflictNotice";
4
- import { vPending } from "@jskit-ai/shell-web/client/directives/vPending";
4
+ import ShellPageAction from "@jskit-ai/shell-web/client/components/ShellPageAction";
5
+ import ShellPageActions from "@jskit-ai/shell-web/client/components/ShellPageActions";
6
+ import { useShellPageClose } from "@jskit-ai/shell-web/client/composables/useShellPageClose";
7
+ import { useShellNavigation } from "@jskit-ai/shell-web/client/navigation/useShellNavigation";
5
8
 
6
9
  const props = defineProps({
7
10
  runtime: {
@@ -12,6 +15,11 @@ const props = defineProps({
12
15
 
13
16
  const profile = props.runtime.profile;
14
17
 
18
+ // An edit form, as the guide's forms are: the app bar's Up arrow is its close (X), Cancel, which leaves for the list;
19
+ // the settings ask first when the form has unsaved edits.
20
+ const navigation = useShellNavigation();
21
+ useShellPageClose({ label: "Cancel", close: () => navigation.finish() });
22
+
15
23
  // The settings read again (another session saved them) keep what the person typed; the notice names each field whose
16
24
  // server value changed meanwhile.
17
25
  const FIELD_LABELS = Object.freeze({ displayName: "Display name", email: "Email" });
@@ -23,25 +31,36 @@ const conflictItems = computed(() =>
23
31
  <template>
24
32
  <div class="account-settings-section">
25
33
  <div class="account-settings-section__body">
26
- <v-form @submit.prevent="profile.submit" novalidate>
27
- <v-row class="mb-2">
28
- <v-col cols="12" md="4" class="d-flex flex-column align-center justify-center">
29
- <v-avatar :size="profile.avatar.size" color="surface-variant" rounded="circle" class="mb-3">
30
- <v-img v-if="profile.avatar.effectiveUrl" :src="profile.avatar.effectiveUrl" cover />
31
- <span v-else class="text-title-large">{{ profile.initials.value }}</span>
32
- </v-avatar>
33
- <div class="text-body-small on-surface-variant">Preview size: {{ profile.avatar.size }} px</div>
34
- </v-col>
34
+ <!-- Save is the app bar's primary action, as Material 3 puts a form's Save; it submits this form by its id. It says
35
+ what it saves, and stays off until a field changes. -->
36
+ <ShellPageActions>
37
+ <ShellPageAction
38
+ primary
39
+ label="Save profile"
40
+ type="submit"
41
+ form="account-settings-profile-form"
42
+ :loading="profile.isSaving.value"
43
+ :pending="profile.isSaving.value || profile.isRefreshing.value"
44
+ :disabled="!profile.hasUnsavedEdits.value || profile.isDeletingAvatar.value"
45
+ />
46
+ </ShellPageActions>
47
+ <v-form id="account-settings-profile-form" @submit.prevent="profile.submit" novalidate>
48
+ <!-- The avatar in a container colour, at the size the person chose, with its actions beside it. -->
49
+ <div class="d-flex flex-wrap align-center ga-4 mb-6">
50
+ <v-avatar :size="profile.avatar.size" color="primary-container" rounded="circle">
51
+ <v-img v-if="profile.avatar.effectiveUrl" :src="profile.avatar.effectiveUrl" cover />
52
+ <span v-else class="text-title-large">{{ profile.initials.value }}</span>
53
+ </v-avatar>
35
54
 
36
- <v-col cols="12" md="8">
37
- <div class="d-flex flex-wrap ga-2 mb-2">
55
+ <div>
56
+ <div class="d-flex flex-wrap ga-2">
38
57
  <v-btn
39
- variant="tonal"
40
- color="secondary"
58
+ variant="flat"
59
+ color="secondary-container"
41
60
  :disabled="profile.isSaving.value || profile.isDeletingAvatar.value || profile.isRefreshing.value"
42
61
  @click="profile.openAvatarEditor"
43
62
  >
44
- Replace avatar
63
+ {{ profile.avatar.hasUploadedAvatar ? "Change avatar" : "Add avatar" }}
45
64
  </v-btn>
46
65
  <v-btn
47
66
  v-if="profile.avatar.hasUploadedAvatar"
@@ -55,48 +74,32 @@ const conflictItems = computed(() =>
55
74
  </v-btn>
56
75
  </div>
57
76
 
58
- <div v-if="profile.selectedAvatarFileName.value" class="text-body-small on-surface-variant mb-2">
77
+ <div v-if="profile.selectedAvatarFileName.value" class="text-body-small on-surface-variant mt-2">
59
78
  Selected file: {{ profile.selectedAvatarFileName.value }}
60
79
  </div>
61
- </v-col>
62
- </v-row>
80
+ </div>
81
+ </div>
63
82
 
64
- <v-row>
65
- <v-col cols="12">
66
- <v-text-field
67
- v-model="profile.form.displayName"
68
- label="Display name"
69
- variant="outlined"
70
- density="comfortable"
71
- autocomplete="nickname"
72
- :readonly="profile.isSaving.value"
73
- :error-messages="profile.fieldErrors.displayName"
74
- />
75
- </v-col>
83
+ <v-text-field
84
+ v-model="profile.form.displayName"
85
+ label="Display name"
86
+ variant="outlined"
87
+ autocomplete="nickname"
88
+ prepend-inner-icon="$person"
89
+ :readonly="profile.isSaving.value"
90
+ :error-messages="profile.fieldErrors.displayName"
91
+ />
76
92
 
77
- <v-col cols="12">
78
- <v-text-field
79
- v-model="profile.form.email"
80
- label="Email"
81
- variant="outlined"
82
- density="comfortable"
83
- readonly
84
- hint="Managed by your sign-in account"
85
- persistent-hint
86
- />
87
- </v-col>
88
- </v-row>
89
-
90
- <v-btn
91
- type="submit"
92
- color="primary"
93
- class="mt-4"
94
- :loading="profile.isSaving.value"
95
- v-pending="profile.isSaving.value || profile.isRefreshing.value"
96
- :disabled="profile.isDeletingAvatar.value"
97
- >
98
- Save profile
99
- </v-btn>
93
+ <!-- The sign-in account manages the email: a detail row to read, not a field to type in. The address is its
94
+ title, what it is and who manages it the lines under it, on the field's icon and text keylines above. -->
95
+ <div class="account-email" data-testid="account-email">
96
+ <v-icon icon="$mail" color="on-surface-variant" />
97
+ <div class="account-email__text">
98
+ <div class="account-email__value text-body-large">{{ profile.form.email }}</div>
99
+ <div class="text-body-medium on-surface-variant">Email</div>
100
+ <div class="text-body-medium on-surface-variant">Managed by your sign-in account</div>
101
+ </div>
102
+ </div>
100
103
  <EditConflictNotice :items="conflictItems" @accept="profile.acceptServerValue" @keep="profile.keepOwnValue" />
101
104
  </v-form>
102
105
  </div>
@@ -108,7 +111,24 @@ const conflictItems = computed(() =>
108
111
  overflow: hidden;
109
112
  }
110
113
 
114
+ /* The section starts at the page's margin, under the bar's Up arrow: no side padding of its own. */
111
115
  .account-settings-section__body {
112
- padding: 1rem;
116
+ padding: 1rem 0;
117
+ }
118
+
119
+ .account-email {
120
+ display: flex;
121
+ align-items: flex-start;
122
+ gap: 6px;
123
+ padding-inline: 12px;
124
+ }
125
+
126
+ .account-email__text {
127
+ min-width: 0;
128
+ }
129
+
130
+ /* A long address wraps rather than hiding its end. */
131
+ .account-email__value {
132
+ overflow-wrap: anywhere;
113
133
  }
114
134
  </style>
@@ -11,7 +11,7 @@ const signInMethods = props.runtime.signInMethods;
11
11
 
12
12
  <template>
13
13
  <div class="account-settings-section">
14
- <v-list lines="two" class="py-0">
14
+ <v-list lines="two" class="account-settings-section__methods py-0">
15
15
  <v-list-item
16
16
  v-for="method in signInMethods.methods.value"
17
17
  :key="method.provider"
@@ -55,7 +55,12 @@ const signInMethods = props.runtime.signInMethods;
55
55
  overflow: hidden;
56
56
  }
57
57
 
58
+ /* The methods and the hint start at the page's margin, as every section's content does. */
59
+ .account-settings-section__methods .v-list-item {
60
+ padding-inline: 0;
61
+ }
62
+
58
63
  .account-settings-section__hint {
59
- padding: 0 1rem 1rem;
64
+ padding: 0 0 1rem;
60
65
  }
61
66
  </style>