@jskit-ai/auth-web 0.2.15 → 0.2.16
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 +7 -0
- package/fixtures/sign-in/main.js +24 -1
- package/fixtures/sign-in/vite.config.mjs +2 -0
- package/locales/en.json +2 -1
- package/package.json +7 -7
- package/patterns/auth-surface/PATTERN.md +18 -5
- package/patterns/auth-surface/example/src/components/AppBrand.vue +17 -0
- package/patterns/auth-surface/example/src/pages/auth/login.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/reset-password.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/signout.vue +2 -2
- package/patterns/auth-surface/example/src/views/auth/LoginView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/ResetPasswordView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/SignOutView.vue +6 -1
- package/src/client/composables/loginView/constants.js +2 -2
- package/src/client/composables/loginView/useLoginViewState.js +5 -1
- package/src/client/views/AuthProfileWidget.vue +28 -2
- package/src/client/views/AuthScreen.vue +98 -0
- package/src/client/views/DefaultLoginView.vue +294 -290
- package/src/client/views/DefaultResetPasswordView.vue +61 -85
- package/src/client/views/DefaultSignOutView.vue +62 -43
- package/test/authSurfacePatternBrand.test.js +34 -0
- package/test/clientSurface.test.js +29 -26
- package/test/signIn.browser.test.js +214 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The `auth/auth-surface` pattern shows the app's identity on its sign-in, reset and sign-out screens: its pages render the app's view wrappers (`src/views/auth/LoginView.vue`, `ResetPasswordView.vue`, `SignOutView.vue`) instead of the default views, and each wrapper fills the `brand` slot with the new `src/components/AppBrand.vue`, the app's name as `index.html`'s `<title>` spells it (a `text-title-large` wordmark in the wide pane, a `text-title-medium` row on phones, no heading). The foundations' rename step renames it with the `<title>`. Upgrading: an app whose `src/pages/auth/*.vue` render the default views directly makes them render its wrappers, and gives the wrappers its brand.
|
|
6
|
+
- The app bar's account control is the avatar alone, a round icon button named by its `aria-label`, on compact and medium windows (below 840dp), so a long name no longer squeezes the bar's title to "Setti…" beside its actions; on expanded windows the name beside the avatar ends in an ellipsis past 12rem. It reads the shell's window size classes (`useShellWindowSizeClass()`).
|
|
7
|
+
- Sign in and Register are a Material 3 segmented button (`role="radiogroup"`, labelled by the new message key `jskit.auth.login.mode.label`, "Sign in or register"): one `outline`, two equal segments, the selected one on `secondary-container` with a check. It shows only when both are offered; an app or a remembered account with Sign in alone shows no switcher. Register no longer ends with "Already have an account? Back to sign in", which repeated the Sign in segment, so the message key `jskit.auth.login.hasAccount` is gone.
|
|
8
|
+
- The profile menu's activator is a round icon button around the avatar on phones, where the name is hidden, so its state layer is a circle; beside the name, on wider windows, it stays a pill.
|
|
9
|
+
- `DefaultLoginView`, `DefaultResetPasswordView` and `DefaultSignOutView` take a `brand` slot that JSKIT lays out: a pane beside the card on wide windows (`primary-container`) and a compact row above the card on phones, the slot given `{ compact }`. The three share one screen, so the sign-out screen is the whole screen on phones too, and the three cards have one container treatment: a flat `surface-container-low` card on the screen's `surface-container`, with no shadow or outline over it (the reset card's border is gone too). Upgrading: an app that framed the views and overrode `.login-screen`, `.reset-screen` or `.signout-main` moves its brand into the slot and drops those rules.
|
|
10
|
+
- Sign-in has its one `h1`, "Sign in" (new message key `jskit.auth.login.title.login`; an app with other locales adds it with `npx jskit i18n export <locale>`), as every other mode and screen has; the reset and sign-out titles use the same `text-headline-medium` role.
|
|
11
|
+
- The Register tab shows only when the provider lets anyone register (`features.password.selfRegister`), or for an invited person (an `invitationToken` in the address), so an app with `AUTH_LOCAL_SELF_REGISTRATION=false` offers no form that would be refused.
|
|
5
12
|
- While the app has no account (`features.firstAccountSetupCode`), the registration form explains that the first account becomes the owner and asks for the setup code from the server's log or its hosting service, and sends it as `setupCode`. New message keys: `jskit.auth.login.firstAccount.explain` and `jskit.auth.login.field.setupCode`.
|
|
6
13
|
- Email confirmation on the sign-in page: "Confirm your email" has a field for the emailed link or its code, and in development, when the registration's answer carries the link, shows it with a button that confirms it. Opening the emailed link (`/auth/login?confirmation_token=...`) confirms it and takes the code out of the address. Confirming signs the person in and opens the requested page. A sign-in refused with `auth.login.emailUnconfirmed` opens "Confirm your email" instead of an error. New route `POST /api/register/confirm`, which writes the new session's cookies, limited by `config.auth.rateLimits.registerConfirm` (10 a minute); the register answer carries `confirmationUrl` when the provider gives it. New message keys: `jskit.auth.register.confirmed`, `jskit.auth.login.field.confirmationCode`, `jskit.auth.login.confirmEmail.confirm`, `.devLink`, `.useDevLink` and `jskit.auth.login.error.confirmRegistrationFailed`.
|
|
7
14
|
- The auth routes' rate limits apply, per client address: `login`, `register`, `loginOtpRequest` and `loginOtpVerify` 10 a minute; `registerConfirmationResend` and `passwordForgot` 5; `oauthStart`, `oauthComplete`, `passwordRecovery` and `passwordReset` 20; `devLoginAs` 30. A refused request answers 429 with `kernel.http.rateLimited` and `Retry-After`, and the login page shows it.
|
package/fixtures/sign-in/main.js
CHANGED
|
@@ -16,6 +16,9 @@ import DefaultResetPasswordView from "../../src/client/views/DefaultResetPasswor
|
|
|
16
16
|
import DefaultSignOutView from "../../src/client/views/DefaultSignOutView.vue";
|
|
17
17
|
import { AuthWebClientProvider } from "../../src/client/providers/AuthWebClientProvider.js";
|
|
18
18
|
import { useAuthStore } from "../../src/client/stores/useAuthStore.js";
|
|
19
|
+
import PatternLoginPage from "../../patterns/auth-surface/example/src/pages/auth/login.vue";
|
|
20
|
+
import PatternResetPasswordPage from "../../patterns/auth-surface/example/src/pages/auth/reset-password.vue";
|
|
21
|
+
import PatternSignOutPage from "../../patterns/auth-surface/example/src/pages/auth/signout.vue";
|
|
19
22
|
|
|
20
23
|
// The shell's two runtimes as doubles; the auth client above them is the real one the provider builds.
|
|
21
24
|
window.authFixture = { reports: [], bootstrapRefreshes: [], context: {} };
|
|
@@ -67,13 +70,33 @@ const HomePage = {
|
|
|
67
70
|
]);
|
|
68
71
|
}
|
|
69
72
|
};
|
|
73
|
+
// An app's brand in the auth views' brand slot: a pane's wordmark and line on wide windows, a compact row on phones.
|
|
74
|
+
function branded(View) {
|
|
75
|
+
return {
|
|
76
|
+
render: () => h(View, null, {
|
|
77
|
+
brand: ({ compact }) => compact
|
|
78
|
+
? h("div", { class: "text-title-medium", "data-testid": "fixture-brand-row" }, "Racerlog")
|
|
79
|
+
: [
|
|
80
|
+
h("div", { class: "text-title-large", "data-testid": "fixture-brand-pane" }, "Racerlog"),
|
|
81
|
+
h("p", { class: "text-display-medium" }, "Your setup. Every lap.")
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
}
|
|
70
86
|
const router = createRouter({
|
|
71
87
|
history: createWebHistory(),
|
|
72
88
|
routes: [
|
|
73
89
|
{ path: "/home", component: HomePage },
|
|
74
90
|
{ path: "/auth/login", component: DefaultLoginView },
|
|
75
91
|
{ path: "/auth/reset-password", component: DefaultResetPasswordView },
|
|
76
|
-
{ path: "/auth/signout", component: DefaultSignOutView }
|
|
92
|
+
{ path: "/auth/signout", component: DefaultSignOutView },
|
|
93
|
+
{ path: "/auth/branded/login", component: branded(DefaultLoginView) },
|
|
94
|
+
{ path: "/auth/branded/reset-password", component: branded(DefaultResetPasswordView) },
|
|
95
|
+
{ path: "/auth/branded/signout", component: branded(DefaultSignOutView) },
|
|
96
|
+
// The auth-surface pattern's own pages, as an app copies them: its view wrappers show the app's brand.
|
|
97
|
+
{ path: "/auth/pattern/login", component: PatternLoginPage },
|
|
98
|
+
{ path: "/auth/pattern/reset-password", component: PatternResetPasswordPage },
|
|
99
|
+
{ path: "/auth/pattern/signout", component: PatternSignOutPage }
|
|
77
100
|
]
|
|
78
101
|
});
|
|
79
102
|
const app = createApp({ render: () => h(components.VApp, null, { default: () => h(components.VMain, null, { default: () => h(RouterView) }) }) });
|
|
@@ -4,6 +4,8 @@ import vue from "@vitejs/plugin-vue";
|
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
6
|
root: fileURLToPath(new URL("./", import.meta.url)),
|
|
7
|
+
// The auth-surface pattern's pages and view wrappers import the app's own files through "@/", as in an app.
|
|
8
|
+
resolve: { alias: { "@": fileURLToPath(new URL("../../patterns/auth-surface/example/src", import.meta.url)) } },
|
|
7
9
|
plugins: [vue()],
|
|
8
10
|
server: { host: "127.0.0.1", strictPort: true }
|
|
9
11
|
});
|
package/locales/en.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"login": {
|
|
9
9
|
"title": {
|
|
10
|
+
"login": "Sign in",
|
|
10
11
|
"register": "Create your account",
|
|
11
12
|
"forgot": "Reset your password",
|
|
12
13
|
"otp": "Use one-time code",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"confirmEmail": "Continue"
|
|
28
29
|
},
|
|
29
30
|
"mode": {
|
|
31
|
+
"label": "Sign in or register",
|
|
30
32
|
"signIn": "Sign in",
|
|
31
33
|
"register": "Register"
|
|
32
34
|
},
|
|
@@ -67,7 +69,6 @@
|
|
|
67
69
|
"useOtp": "Use one-time code",
|
|
68
70
|
"sendOtp": "Send one-time code",
|
|
69
71
|
"backToSignIn": "Back to sign in",
|
|
70
|
-
"hasAccount": "Already have an account?",
|
|
71
72
|
"rememberedPassword": "Remembered your password?",
|
|
72
73
|
"otherMethod": "Want to use another method?",
|
|
73
74
|
"passwordsMismatch": "Passwords do not match.",
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "
|
|
6
|
+
"test": "jskit test"
|
|
7
7
|
},
|
|
8
8
|
"exports": {
|
|
9
9
|
"./server/controllers/AuthController": "./src/server/controllers/AuthController.js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"./locales/en.json": "./locales/en.json"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@jskit-ai/auth-core": "0.2.
|
|
29
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
30
|
-
"@jskit-ai/kernel": "0.2.
|
|
31
|
-
"@jskit-ai/shell-web": "0.2.
|
|
28
|
+
"@jskit-ai/auth-core": "0.2.11",
|
|
29
|
+
"@jskit-ai/http-runtime": "0.2.11",
|
|
30
|
+
"@jskit-ai/kernel": "0.2.11",
|
|
31
|
+
"@jskit-ai/shell-web": "0.2.14",
|
|
32
32
|
"@tanstack/vue-query": "^5.90.5",
|
|
33
33
|
"pinia": "^4.0.3",
|
|
34
34
|
"vue": "^3.5.44",
|
|
@@ -305,6 +305,6 @@
|
|
|
305
305
|
}
|
|
306
306
|
},
|
|
307
307
|
"devDependencies": {
|
|
308
|
-
"@jskit-ai/material-web": "0.1.
|
|
308
|
+
"@jskit-ai/material-web": "0.1.3"
|
|
309
309
|
}
|
|
310
310
|
}
|
|
@@ -27,8 +27,14 @@ Those choices must be known before adapting the example.
|
|
|
27
27
|
## Framework APIs
|
|
28
28
|
|
|
29
29
|
Use the views, auth guard, HTTP client integration, sign-out runtime, providers,
|
|
30
|
-
and Playwright auth helper exported by `@jskit-ai/auth-web`.
|
|
31
|
-
|
|
30
|
+
and Playwright auth helper exported by `@jskit-ai/auth-web`. The sign-in, reset
|
|
31
|
+
and sign-out screens show the app's identity: the pages render the app's view
|
|
32
|
+
wrappers (`src/views/auth/`), and each wrapper fills the default view's `brand`
|
|
33
|
+
slot (given `{ compact }`) with `src/components/AppBrand.vue`, the app's name
|
|
34
|
+
as `index.html`'s `<title>` spells it. JSKIT lays the slot out as a pane beside
|
|
35
|
+
the card on wide windows and a row above it on phones; never restyle the views'
|
|
36
|
+
own classes. Use auth policies from `@jskit-ai/auth-core` for server
|
|
37
|
+
authorization.
|
|
32
38
|
|
|
33
39
|
Every application with accounts includes the managed-preview login. It is
|
|
34
40
|
standard, not optional: adding this pattern adds it, so a managed host's
|
|
@@ -92,6 +98,10 @@ a user as a side effect.
|
|
|
92
98
|
- Public auth routes do not require an existing session.
|
|
93
99
|
- Protected routes use the framework auth policy rather than page-local checks.
|
|
94
100
|
- Login, sign-out, and reset views use the public auth components/composables.
|
|
101
|
+
- The sign-in, reset and sign-out pages render the app's view wrappers, which
|
|
102
|
+
fill the `brand` slot with the app's identity (`AppBrand.vue`): a person
|
|
103
|
+
always sees which app they are signing in to. Renaming the app renames
|
|
104
|
+
`AppBrand.vue` with `index.html`'s `<title>`; the brand adds no heading.
|
|
95
105
|
- A custom login view must preserve the default view's initial session check:
|
|
96
106
|
already authenticated people return to the validated requested destination.
|
|
97
107
|
Process incoming login callbacks before that redirect, and keep signed-out
|
|
@@ -102,8 +112,9 @@ a user as a side effect.
|
|
|
102
112
|
|
|
103
113
|
## Example files
|
|
104
114
|
|
|
105
|
-
`example/` contains concrete route wrappers, editable view wrappers
|
|
106
|
-
|
|
115
|
+
`example/` contains concrete route wrappers, editable view wrappers that show
|
|
116
|
+
the app's brand (`src/components/AppBrand.vue`), and the client runtime helpers
|
|
117
|
+
needed by an authentication surface. It also contains
|
|
107
118
|
the standard app-owned managed-preview identity executable,
|
|
108
119
|
`tools/preview-identity`. Compose their
|
|
109
120
|
surface and placement declarations into the application's ordinary config and
|
|
@@ -116,7 +127,9 @@ placements, and post-auth destinations while retaining the runtime contracts.
|
|
|
116
127
|
|
|
117
128
|
## Verification
|
|
118
129
|
|
|
119
|
-
|
|
130
|
+
Check that the sign-in, reset and sign-out screens show the app's name, in the
|
|
131
|
+
pane on a wide window and in the row on a phone. Exercise failed and successful
|
|
132
|
+
login, sign-out, reset, protected navigation,
|
|
120
133
|
keyboard interaction, warm-cache return navigation, and browser refresh.
|
|
121
134
|
Open the login route with an existing authenticated session and confirm it
|
|
122
135
|
returns to the requested screen; repeat signed out and confirm the form remains.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// The app's identity on its sign-in, reset and sign-out screens. The auth views place it in their brand slot: a pane
|
|
3
|
+
// beside the card on wide windows, and a row above the card on phones (`compact`). It is the app's name as
|
|
4
|
+
// index.html's <title> spells it, so renaming the app renames both. It holds no heading: each screen's h1 is its own.
|
|
5
|
+
defineProps({
|
|
6
|
+
compact: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
default: false
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const APP_NAME = "Reading Room";
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div :class="compact ? 'text-title-medium' : 'text-title-large'" data-testid="app-brand">{{ APP_NAME }}</div>
|
|
17
|
+
</template>
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
</route>
|
|
10
10
|
|
|
11
11
|
<script setup>
|
|
12
|
-
import
|
|
12
|
+
import LoginView from "@/views/auth/LoginView.vue";
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<
|
|
16
|
+
<LoginView />
|
|
17
17
|
</template>
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
</route>
|
|
10
10
|
|
|
11
11
|
<script setup>
|
|
12
|
-
import
|
|
12
|
+
import ResetPasswordView from "@/views/auth/ResetPasswordView.vue";
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<
|
|
16
|
+
<ResetPasswordView />
|
|
17
17
|
</template>
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
</route>
|
|
10
10
|
|
|
11
11
|
<script setup>
|
|
12
|
-
import
|
|
12
|
+
import SignOutView from "@/views/auth/SignOutView.vue";
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
16
|
-
<
|
|
16
|
+
<SignOutView />
|
|
17
17
|
</template>
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import DefaultLoginView from "@jskit-ai/auth-web/client/views/DefaultLoginView";
|
|
3
|
+
import AppBrand from "@/components/AppBrand.vue";
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
6
|
<template>
|
|
6
|
-
<DefaultLoginView
|
|
7
|
+
<DefaultLoginView>
|
|
8
|
+
<template #brand="{ compact }">
|
|
9
|
+
<AppBrand :compact="compact" />
|
|
10
|
+
</template>
|
|
11
|
+
</DefaultLoginView>
|
|
7
12
|
</template>
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import DefaultResetPasswordView from "@jskit-ai/auth-web/client/views/DefaultResetPasswordView";
|
|
3
|
+
import AppBrand from "@/components/AppBrand.vue";
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
6
|
<template>
|
|
6
|
-
<DefaultResetPasswordView
|
|
7
|
+
<DefaultResetPasswordView>
|
|
8
|
+
<template #brand="{ compact }">
|
|
9
|
+
<AppBrand :compact="compact" />
|
|
10
|
+
</template>
|
|
11
|
+
</DefaultResetPasswordView>
|
|
7
12
|
</template>
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import DefaultSignOutView from "@jskit-ai/auth-web/client/views/DefaultSignOutView";
|
|
3
|
+
import AppBrand from "@/components/AppBrand.vue";
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
6
|
<template>
|
|
6
|
-
<DefaultSignOutView
|
|
7
|
+
<DefaultSignOutView>
|
|
8
|
+
<template #brand="{ compact }">
|
|
9
|
+
<AppBrand :compact="compact" />
|
|
10
|
+
</template>
|
|
11
|
+
</DefaultSignOutView>
|
|
7
12
|
</template>
|
|
@@ -4,9 +4,9 @@ const FORGOT_MODE = "forgot";
|
|
|
4
4
|
const OTP_MODE = "otp";
|
|
5
5
|
const EMAIL_CONFIRMATION_MODE = "confirm-email";
|
|
6
6
|
|
|
7
|
-
// Message keys per mode; an empty entry shows nothing.
|
|
7
|
+
// Message keys per mode; an empty entry shows nothing. Every mode has a title, the page's one h1.
|
|
8
8
|
const AUTH_TITLE_BY_MODE = Object.freeze({
|
|
9
|
-
[LOGIN_MODE]: "",
|
|
9
|
+
[LOGIN_MODE]: "jskit.auth.login.title.login",
|
|
10
10
|
[REGISTER_MODE]: "jskit.auth.login.title.register",
|
|
11
11
|
[FORGOT_MODE]: "jskit.auth.login.title.forgot",
|
|
12
12
|
[OTP_MODE]: "jskit.auth.login.title.otp",
|
|
@@ -80,7 +80,11 @@ export function useLoginViewState({ placementContext }) {
|
|
|
80
80
|
const isOtp = computed(() => mode.value === OTP_MODE);
|
|
81
81
|
const isEmailConfirmationPending = computed(() => mode.value === EMAIL_CONFIRMATION_MODE);
|
|
82
82
|
const canUsePasswordLogin = computed(() => authCapabilities.value.features.password.login === true);
|
|
83
|
-
|
|
83
|
+
// An app whose accounts are by invitation offers registering only to an invited person (or its first account).
|
|
84
|
+
const canRegister = computed(() => {
|
|
85
|
+
const { register, selfRegister } = authCapabilities.value.features.password;
|
|
86
|
+
return register === true && (selfRegister === true || Boolean(String(invitationToken.value || "").trim()));
|
|
87
|
+
});
|
|
84
88
|
const canRequestPasswordRecovery = computed(
|
|
85
89
|
() => authCapabilities.value.features.passwordRecovery.request === true
|
|
86
90
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import ShellOutlet from "@jskit-ai/shell-web/client/components/ShellOutlet";
|
|
4
|
+
import { useShellWindowSizeClass } from "@jskit-ai/shell-web/client/composables/useShellWindowSizeClass";
|
|
4
5
|
import { useWebPlacementContext } from "@jskit-ai/shell-web/client/placement";
|
|
5
6
|
import { useAuthStore } from "../stores/useAuthStore.js";
|
|
6
7
|
import { useJskitText } from "../i18n.js";
|
|
@@ -8,6 +9,11 @@ import { useJskitText } from "../i18n.js";
|
|
|
8
9
|
const auth = useAuthStore();
|
|
9
10
|
const { t } = useJskitText();
|
|
10
11
|
const { context: shellPlacementContext } = useWebPlacementContext();
|
|
12
|
+
// On expanded windows the activator is a pill with the name beside the avatar, the name ending in an ellipsis past
|
|
13
|
+
// 12rem; on medium and compact windows, where the app bar's title and actions need the room, it is a round icon
|
|
14
|
+
// button around the avatar, named by its aria-label.
|
|
15
|
+
const { isExpanded, isLarge } = useShellWindowSizeClass();
|
|
16
|
+
const showsName = computed(() => isExpanded.value || isLarge.value);
|
|
11
17
|
|
|
12
18
|
const shellUser = computed(() => {
|
|
13
19
|
const user = shellPlacementContext.value?.user;
|
|
@@ -65,12 +71,23 @@ const placementContext = computed(() => {
|
|
|
65
71
|
<template>
|
|
66
72
|
<v-menu location="bottom end" offset="10">
|
|
67
73
|
<template #activator="{ props }">
|
|
68
|
-
<v-btn
|
|
74
|
+
<v-btn
|
|
75
|
+
v-if="showsName"
|
|
76
|
+
v-bind="props"
|
|
77
|
+
variant="text"
|
|
78
|
+
class="auth-profile-widget__activator text-none pl-1 pr-2"
|
|
79
|
+
>
|
|
80
|
+
<v-avatar size="32" color="primary" variant="tonal">
|
|
81
|
+
<v-img v-if="avatarUrl" :src="avatarUrl" cover />
|
|
82
|
+
<span v-else class="text-body-small font-weight-medium">{{ initials }}</span>
|
|
83
|
+
</v-avatar>
|
|
84
|
+
<span class="auth-profile-widget__name ml-2 text-body-medium">{{ displayName }}</span>
|
|
85
|
+
</v-btn>
|
|
86
|
+
<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="displayName">
|
|
69
87
|
<v-avatar size="32" color="primary" variant="tonal">
|
|
70
88
|
<v-img v-if="avatarUrl" :src="avatarUrl" cover />
|
|
71
89
|
<span v-else class="text-body-small font-weight-medium">{{ initials }}</span>
|
|
72
90
|
</v-avatar>
|
|
73
|
-
<span class="ml-2 d-none d-sm-inline text-body-medium">{{ displayName }}</span>
|
|
74
91
|
</v-btn>
|
|
75
92
|
</template>
|
|
76
93
|
|
|
@@ -82,3 +99,12 @@ const placementContext = computed(() => {
|
|
|
82
99
|
</v-list>
|
|
83
100
|
</v-menu>
|
|
84
101
|
</template>
|
|
102
|
+
|
|
103
|
+
<style scoped>
|
|
104
|
+
.auth-profile-widget__name {
|
|
105
|
+
max-width: 12rem;
|
|
106
|
+
overflow: hidden;
|
|
107
|
+
text-overflow: ellipsis;
|
|
108
|
+
white-space: nowrap;
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useSlots } from "vue";
|
|
3
|
+
import { useDisplay } from "vuetify";
|
|
4
|
+
|
|
5
|
+
// The screen every auth view fills: the whole window below the shell's banners, its card centred on wide windows
|
|
6
|
+
// and full-bleed on phones. The app's brand, when it gives one, is a pane beside the card on wide windows and a
|
|
7
|
+
// compact row above it on phones; the slot gets { compact } to tell them apart. The page's one h1 is the card's.
|
|
8
|
+
const slots = useSlots();
|
|
9
|
+
const { mobile: compact } = useDisplay({ mobileBreakpoint: 960 });
|
|
10
|
+
const hasBrand = computed(() => Boolean(slots.brand));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div
|
|
15
|
+
class="auth-screen"
|
|
16
|
+
:class="{ 'auth-screen--compact': compact, 'auth-screen--branded': hasBrand }"
|
|
17
|
+
data-testid="auth-screen"
|
|
18
|
+
>
|
|
19
|
+
<aside v-if="hasBrand && !compact" class="auth-screen__brand-pane" data-testid="auth-brand-pane">
|
|
20
|
+
<slot name="brand" :compact="false" />
|
|
21
|
+
</aside>
|
|
22
|
+
<div class="auth-screen__main">
|
|
23
|
+
<div v-if="hasBrand && compact" class="auth-screen__brand-row" data-testid="auth-brand-row">
|
|
24
|
+
<slot name="brand" :compact="true" />
|
|
25
|
+
</div>
|
|
26
|
+
<slot :compact="compact" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<style scoped>
|
|
32
|
+
.auth-screen {
|
|
33
|
+
/* Start below shell banners shown on a surface without an app bar. */
|
|
34
|
+
--auth-screen-height: calc(100dvh - var(--shell-error-banners-inline-height, 0px));
|
|
35
|
+
--auth-screen-top-inset: env(safe-area-inset-top, 0px);
|
|
36
|
+
position: fixed;
|
|
37
|
+
inset: var(--shell-error-banners-inline-height, 0px) 0 0;
|
|
38
|
+
z-index: 1;
|
|
39
|
+
display: flex;
|
|
40
|
+
overflow-y: auto;
|
|
41
|
+
background-color: rgb(var(--v-theme-surface-container));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Phones: the card is the screen, on the card's own surface, with the brand row above it. */
|
|
45
|
+
.auth-screen--compact {
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
background-color: rgb(var(--v-theme-surface-container-low));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.auth-screen--compact.auth-screen--branded {
|
|
51
|
+
--auth-screen-top-inset: 0px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.auth-screen__brand-pane {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex: 0.85 1 0;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
justify-content: space-between;
|
|
59
|
+
gap: 32px;
|
|
60
|
+
min-width: 18rem;
|
|
61
|
+
min-height: var(--auth-screen-height);
|
|
62
|
+
padding: 48px;
|
|
63
|
+
background-color: rgb(var(--v-theme-primary-container));
|
|
64
|
+
color: rgb(var(--v-theme-on-primary-container));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.auth-screen__main {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex: 1.15 1 0;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
min-height: var(--auth-screen-height);
|
|
75
|
+
padding: 32px 24px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.auth-screen--compact .auth-screen__main {
|
|
79
|
+
flex: 1 0 auto;
|
|
80
|
+
align-items: stretch;
|
|
81
|
+
justify-content: flex-start;
|
|
82
|
+
padding: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.auth-screen__brand-row {
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: 12px;
|
|
89
|
+
min-width: 0;
|
|
90
|
+
padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@media (min-width: 1280px) {
|
|
94
|
+
.auth-screen__brand-pane {
|
|
95
|
+
padding: 64px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</style>
|