commit db96892aa2aa6898486768035a4fe7fefcb21e8e
parent f7f0e121f65a92e0c19fd3021788b53241a5b895
Author: finwo <finwo@pm.me>
Date: Mon, 16 Nov 2026 21:46:13 +0100
login: migrate auth/consent/error onto CSS framework classes
Diffstat:
4 files changed, 292 insertions(+), 415 deletions(-)
diff --git a/app/login/src/assets/login.css b/app/login/src/assets/login.css
@@ -1,367 +0,0 @@
-.auth-page {
- --auth-surface: #fff;
- min-height: 100vh;
- min-height: 100svh;
- display: grid;
- place-items: center;
- padding: env(safe-area-inset-top) env(safe-area-inset-right)
- calc(1rem + env(safe-area-inset-bottom)) env(safe-area-inset-left);
- background: var(--auth-surface);
-}
-
-.auth-card,
-.auth-status-panel {
- width: min(calc(100% - 2rem), 24rem);
- padding: 2rem;
- border-radius: 0;
- background: var(--auth-surface);
- color: var(--text);
-}
-
-.auth-card-consent,
-.auth-status-panel {
- width: min(calc(100% - 2rem), 28rem);
-}
-
-.auth-logo {
- max-width: 8rem;
- margin-bottom: 1rem;
-}
-
-.auth-card h1,
-.auth-status-panel h1 {
- margin: 0 0 1rem;
- font-size: 1.5rem;
- font-weight: 400;
- line-height: 1.3;
-}
-
-.auth-card-consent h1 {
- margin-bottom: 0.5rem;
-}
-
-.auth-realm {
- margin: 0 0 0.375rem;
- color: var(--muted);
- font-size: 0.75rem;
- font-weight: 600;
- letter-spacing: 0.08em;
- text-transform: uppercase;
-}
-
-.auth-note {
- margin: 0 0 1rem;
- color: var(--muted);
- font-size: 0.875rem;
- line-height: 1.6;
-}
-
-.auth-card-consent .auth-note {
- margin-bottom: 0;
-}
-
-.auth-field {
- position: relative;
- padding-top: 1rem;
-}
-
-.auth-input {
- width: 100%;
- padding: 0.5rem 0;
- border: 0;
- border-bottom: 1pt solid var(--field-line);
- border-radius: 0;
- background: transparent;
- color: var(--text);
- font: inherit;
- font-size: 1rem;
- line-height: 1.5;
- outline: none;
-}
-
-.auth-input:focus {
- border-bottom-color: var(--accent);
-}
-
-.auth-field label {
- position: absolute;
- top: 1.5em;
- left: 0;
- color: var(--muted);
- font-size: 1rem;
- line-height: 1.5;
- pointer-events: none;
- transform-origin: left top;
- transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, opacity 0.15s ease;
-}
-
-.auth-input:focus + label,
-.auth-input:not(:placeholder-shown) + label {
- top: 0;
- color: var(--text);
- font-size: 0.85em;
- font-weight: 500;
- opacity: 0.8;
-}
-
-.auth-identifier {
- margin: 0 0 0.5rem;
- color: var(--muted);
- font-size: 0.875rem;
- line-height: 1.5;
-}
-
-.auth-choice {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- min-height: 2.75rem;
- margin-top: 1rem;
- font-size: 0.875rem;
- line-height: 1.5;
- cursor: pointer;
- touch-action: manipulation;
-}
-
-.auth-choice input {
- width: 1rem;
- height: 1rem;
- accent-color: var(--accent);
-}
-
-.auth-accounts {
- display: grid;
- gap: 0.5rem;
- margin-top: 1rem;
-}
-
-.auth-account {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: center;
- gap: 0.125rem;
- width: 100%;
- min-height: 2.75rem;
- padding: 0.75rem 0;
- border: 0;
- border-bottom: 1pt solid var(--field-line);
- border-radius: 0;
- background: none;
- color: inherit;
- font: inherit;
- text-align: left;
- cursor: pointer;
- touch-action: manipulation;
-}
-
-.auth-account:hover,
-.auth-account:focus-visible,
-.auth-account:active {
- border-bottom-color: var(--accent);
-}
-
-.auth-account:disabled {
- opacity: 0.5;
- cursor: default;
-}
-
-.auth-account-name {
- font-size: 1rem;
- line-height: 1.5;
-}
-
-.auth-account-username {
- color: var(--muted);
- font-size: 0.875rem;
- line-height: 1.5;
-}
-
-.auth-error {
- margin: 1rem 0 0;
- color: var(--danger-text);
- font-size: 0.875rem;
- line-height: 1.6;
-}
-
-.auth-actions {
- display: grid;
- gap: 1rem;
- margin-top: 1.5rem;
-}
-
-.auth-actions > .button,
-.auth-actions > .auth-link {
- justify-content: center;
- min-height: 2.75rem;
- text-align: center;
-}
-
-.auth-back {
- margin-right: auto;
-}
-
-.auth-link {
- display: inline-flex;
- align-items: center;
- padding: 0.75rem 1rem;
- border: 0;
- background: none;
- color: var(--accent-text);
- font: inherit;
- font-size: 1rem;
- cursor: pointer;
- touch-action: manipulation;
-}
-
-.auth-link:hover {
- color: var(--accent-text-hover);
-}
-
-.auth-link:active {
- color: var(--accent-text-active);
-}
-
-.auth-spinner {
- width: 2rem;
- height: 2rem;
- margin-bottom: 1rem;
- border: 0.1875rem solid var(--skeleton);
- border-top-color: var(--text);
- border-radius: 50%;
- animation: auth-spin 1s linear infinite;
-}
-
-@keyframes auth-spin {
- to {
- transform: rotate(360deg);
- }
-}
-
-.auth-status-icon {
- width: 2rem;
- height: 2rem;
- margin-bottom: 1rem;
-}
-
-.auth-consent-account {
- display: flex;
- align-items: center;
- gap: 0.75rem;
- margin-top: 1.5rem;
- padding: 0.75rem;
- background: var(--row);
-}
-
-.auth-consent-account svg {
- flex: none;
- width: 1.5rem;
- height: 1.5rem;
-}
-
-.auth-consent-account-body {
- display: grid;
- gap: 0.125rem;
- min-width: 0;
-}
-
-.auth-consent-account-name {
- font-size: 0.875rem;
- font-weight: 500;
- line-height: 1.4;
-}
-
-.auth-consent-account-meta {
- overflow-wrap: anywhere;
- color: var(--muted);
- font-size: 0.75rem;
- line-height: 1.4;
-}
-
-.auth-consent-account .auth-link {
- flex: none;
- margin-left: auto;
- font-size: 0.8125rem;
-}
-
-.auth-consent-title {
- margin: 1.5rem 0 0;
- font-size: 0.875rem;
- font-weight: 500;
- line-height: 1.5;
-}
-
-.auth-consent-scopes {
- display: grid;
- gap: 0.5rem;
- margin: 0.75rem 0 0;
- padding: 0;
- list-style: none;
-}
-
-.auth-consent-scope {
- display: flex;
- align-items: flex-start;
- gap: 0.5rem;
- color: var(--muted);
- font-size: 0.875rem;
- line-height: 1.5;
-}
-
-.auth-consent-scope svg {
- flex: none;
- width: 1rem;
- height: 1rem;
- margin-top: 0.125rem;
-}
-
-.auth-consent-footer {
- margin: 1.5rem 0 0;
- color: var(--muted);
- font-size: 0.8125rem;
- line-height: 1.6;
-}
-
-@media (min-width: 35em) {
- .auth-page {
- background-color: var(--auth-surface);
- background-image: var(--hex);
- background-position: center;
- background-repeat: no-repeat;
- background-size: cover;
- }
-
- .auth-card,
- .auth-status-panel {
- box-shadow: var(--shadow);
- }
-
- .auth-actions {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- gap: 1.5rem;
- }
-
- .auth-actions > .button,
- .auth-actions > .auth-link {
- width: auto;
- min-height: 2.75rem;
- }
-}
-
-@media (prefers-reduced-motion: reduce) {
- .auth-spinner {
- animation: none;
- }
-}
-
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme]) .auth-page {
- --auth-surface: #222;
- }
-}
-
-:root[data-theme="dark"] .auth-page {
- --auth-surface: #222;
-}
diff --git a/app/login/src/main.ts b/app/login/src/main.ts
@@ -2,7 +2,7 @@ import m from 'mithril';
import { Login } from './screen/login';
import '@style/global.css';
-import './assets/login.css';
+import './style/login.css';
const routes: m.RouteDefs = {
'/oidc/:clientId/login': {
diff --git a/app/login/src/screen/login.tsx b/app/login/src/screen/login.tsx
@@ -75,9 +75,9 @@ function applyAccent(branding?: { primary_color?: string }) {
const TextField: m.Component<TextFieldAttrs> = {
view({ attrs }) {
return (
- <div class="auth-field">
+ <div class="field auth-field">
<input
- class="auth-input"
+ class="field-control auth-input"
id={attrs.id}
type={attrs.type || 'text'}
value={attrs.value}
@@ -87,7 +87,7 @@ const TextField: m.Component<TextFieldAttrs> = {
oninput={(e: Event) => attrs.oninput((e.target as HTMLInputElement).value)}
oncreate={attrs.autofocus ? ({ dom }: any) => dom.focus() : undefined}
/>
- <label for={attrs.id}>{attrs.label}</label>
+ <label class="field-label auth-label" for={attrs.id}>{attrs.label}</label>
</div>
);
},
@@ -282,13 +282,13 @@ export const Login: m.Component<{ clientId?: string }> = {
if (!this.discovery) {
if (this.error) {
return (
- <div class="auth-page">
- <div class="auth-status-panel">
- {Icon(CircleAlert, { class: 'auth-status-icon' })}
+ <div class="status-page auth-page">
+ <div class="card auth-card auth-card-wide">
+ {Icon(CircleAlert, { class: 'auth-icon' })}
<h1>Sign-in unavailable</h1>
- <p class="auth-error">{this.error.message}</p>
- <div class="auth-actions">
- <a class="button" href={window.location.href}>Try again</a>
+ <p class="alert auth-error" role="alert">{this.error.message}</p>
+ <div class="stack auth-actions">
+ <a class="button button-primary" href={window.location.href}>Try again</a>
</div>
</div>
</div>
@@ -296,11 +296,11 @@ export const Login: m.Component<{ clientId?: string }> = {
}
return (
- <div class="auth-page" aria-busy="true">
- <div class="auth-card">
- <div class="auth-spinner" aria-hidden="true"></div>
+ <div class="status-page auth-page" aria-busy="true">
+ <div class="card auth-card">
+ <div class="spinner auth-spinner" aria-hidden="true"></div>
<h1>Signing in</h1>
- <p class="auth-note">Loading your sign-in options.</p>
+ <p class="note">Loading your sign-in options.</p>
</div>
</div>
);
@@ -316,8 +316,8 @@ export const Login: m.Component<{ clientId?: string }> = {
: 'Sign in';
return (
- <div class="auth-page">
- <div class={`auth-card${this.step === 'consent' ? ' auth-card-consent' : ''}`}>
+ <div class="status-page auth-page">
+ <div class={this.step === 'consent' ? 'card auth-card auth-card-wide' : 'card auth-card'}>
{typeof branding.logo_url === 'string' && branding.logo_url ? (
<img
class="auth-logo"
@@ -345,8 +345,8 @@ export const Login: m.Component<{ clientId?: string }> = {
renderAccounts(this: any) {
return (
<div>
- <p class="auth-note">Choose an account to continue.</p>
- <div class="auth-accounts">
+ <p class="note">Choose an account to continue.</p>
+ <div class="stack auth-accounts">
{this.accounts.map((account: SessionAccount) => {
const name = account.user.display_name || account.user.username;
const secondary =
@@ -366,9 +366,9 @@ export const Login: m.Component<{ clientId?: string }> = {
);
})}
</div>
- {this.error ? <p class="auth-error">{this.error.message}</p> : null}
- <div class="auth-actions">
- <button class="auth-link" type="button" onclick={() => this.differentAccount()}>
+ {this.error ? <p class="alert auth-error" role="alert">{this.error.message}</p> : null}
+ <div class="stack auth-actions">
+ <button class="link" type="button" onclick={() => this.differentAccount()}>
Different account
</button>
</div>
@@ -385,7 +385,7 @@ export const Login: m.Component<{ clientId?: string }> = {
}}
>
{this.reauth ? (
- <p class="auth-note">Confirm your password to continue.</p>
+ <p class="note">Confirm your password to continue.</p>
) : null}
<TextField
id="identifier"
@@ -398,14 +398,14 @@ export const Login: m.Component<{ clientId?: string }> = {
this.identifier = value;
}}
/>
- {this.error ? <p class="auth-error">{this.error.message}</p> : null}
- <div class="auth-actions">
+ {this.error ? <p class="alert auth-error" role="alert">{this.error.message}</p> : null}
+ <div class="stack auth-actions">
{!this.reauth && this.accounts.length >= 2 ? (
- <button class="auth-link auth-back" type="button" onclick={() => this.backToAccounts()}>
+ <button class="link auth-back" type="button" onclick={() => this.backToAccounts()}>
Back to accounts
</button>
) : null}
- <button class="button" type="submit" disabled={this.pending || !this.identifier.trim()}>
+ <button class="button button-primary" type="submit" disabled={this.pending || !this.identifier.trim()}>
{this.pending ? 'Checking' : 'Next'}
</button>
</div>
@@ -421,7 +421,7 @@ export const Login: m.Component<{ clientId?: string }> = {
if (!this.pending) this.submitPassword();
}}
>
- <p class="auth-identifier">{this.identifier}</p>
+ <p class="note">{this.identifier}</p>
<TextField
id="password"
label="Password"
@@ -435,7 +435,7 @@ export const Login: m.Component<{ clientId?: string }> = {
}}
/>
{this.discovery?.allow_session_duration_choice !== false ? (
- <label class="auth-choice">
+ <label class="checkbox auth-choice">
<input
type="checkbox"
checked={this.longSession}
@@ -447,12 +447,12 @@ export const Login: m.Component<{ clientId?: string }> = {
<span>Keep me signed in</span>
</label>
) : null}
- {this.error ? <p class="auth-error">{this.error.message}</p> : null}
- <div class="auth-actions">
- <button class="auth-link auth-back" type="button" onclick={() => this.back()}>
+ {this.error ? <p class="alert auth-error" role="alert">{this.error.message}</p> : null}
+ <div class="stack auth-actions">
+ <button class="link auth-back" type="button" onclick={() => this.back()}>
Back
</button>
- <button class="button" type="submit" disabled={this.pending || !this.password}>
+ <button class="button button-primary" type="submit" disabled={this.pending || !this.password}>
{this.pending ? 'Signing in' : 'Sign in'}
</button>
</div>
@@ -464,17 +464,17 @@ export const Login: m.Component<{ clientId?: string }> = {
const provider = this.provider;
return (
<div>
- <p class="auth-identifier">{this.identifier}</p>
- <p class="auth-note">
+ <p class="note">{this.identifier}</p>
+ <p class="note">
{provider
? `This account signs in with ${provider.display_name}.`
: 'This account signs in with an identity provider.'}
</p>
- <div class="auth-actions">
- <button class="auth-link auth-back" type="button" onclick={() => this.back()}>
+ <div class="stack auth-actions">
+ <button class="link auth-back" type="button" onclick={() => this.back()}>
Back
</button>
- <button class="button" type="button" disabled>
+ <button class="button button-primary" type="button" disabled>
Continue
</button>
</div>
@@ -485,7 +485,7 @@ export const Login: m.Component<{ clientId?: string }> = {
renderConsent(this: any) {
const request = this.consentRequest;
if (!request) {
- return <p class="auth-note">Loading request</p>;
+ return <p class="note">Loading request</p>;
}
const realmName = request.realm?.display_name || 'account';
@@ -497,18 +497,18 @@ export const Login: m.Component<{ clientId?: string }> = {
return (
<div>
- <p class="auth-note">
+ <p class="note">
{request.client.name} is requesting access to your {realmName} account.
</p>
<div class="auth-consent-account">
{Icon(CircleUserRound)}
- <span class="auth-consent-account-body">
+ <span class="stack auth-consent-account-body">
<span class="auth-consent-account-name">{name}</span>
<span class="auth-consent-account-meta">{secondary}</span>
</span>
<button
- class="auth-link"
+ class="link auth-not-you"
type="button"
disabled={this.pending}
onclick={() => this.differentConsentAccount()}
@@ -520,7 +520,7 @@ export const Login: m.Component<{ clientId?: string }> = {
<p class="auth-consent-title">
This will allow {request.client.name} to:
</p>
- <ul class="auth-consent-scopes">
+ <ul class="stack auth-consent-scopes">
{request.scopes.map((scope: string) => (
<li class="auth-consent-scope">
{Icon(Check)}
@@ -529,14 +529,14 @@ export const Login: m.Component<{ clientId?: string }> = {
))}
</ul>
- <p class="auth-consent-footer">
+ <p class="note auth-consent-footer">
You can revoke access at any time from your account settings.
</p>
- {this.error ? <p class="auth-error">{this.error.message}</p> : null}
+ {this.error ? <p class="alert auth-error" role="alert">{this.error.message}</p> : null}
- <div class="auth-actions">
+ <div class="stack auth-actions">
<button
- class="auth-link"
+ class="link"
type="button"
disabled={this.pending}
onclick={() => this.decideConsent('deny')}
@@ -544,7 +544,7 @@ export const Login: m.Component<{ clientId?: string }> = {
Deny
</button>
<button
- class="button"
+ class="button button-primary"
type="button"
disabled={this.pending}
onclick={() => this.decideConsent('allow')}
@@ -560,7 +560,7 @@ export const Login: m.Component<{ clientId?: string }> = {
const user = this.signedIn;
return (
<div>
- <p class="auth-note">Signed in as {user?.display_name || user?.username}</p>
+ <p class="note">Signed in as {user?.display_name || user?.username}</p>
</div>
);
},
diff --git a/app/login/src/style/login.css b/app/login/src/style/login.css
@@ -0,0 +1,244 @@
+@layer apps {
+ /* auth page: flat surface on small screens, hex field once there is room */
+ .auth-page {
+ min-height: 100vh;
+ min-height: 100svh;
+ display: grid;
+ place-items: center;
+ padding: env(safe-area-inset-top) env(safe-area-inset-right)
+ calc(var(--space-4) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
+ background-color: var(--surface);
+ }
+
+ /* auth card: one size, one padding, centered at every width */
+ .auth-card {
+ width: min(calc(100% - var(--space-4) * 2), var(--auth-card-w, 24rem));
+ box-shadow: none;
+ }
+
+ .auth-card-wide {
+ --auth-card-w: 28rem;
+ }
+
+ .auth-logo {
+ width: min(100%, 8rem);
+ height: auto;
+ margin-block-end: var(--space-4);
+ }
+
+ .auth-realm {
+ margin: 0 0 var(--space-1);
+ color: var(--muted);
+ font-size: var(--font-xs);
+ font-weight: 600;
+ letter-spacing: .08em;
+ text-transform: uppercase;
+ }
+
+ /* floating-label field: label rides the control and lifts when filled */
+ .auth-field {
+ position: relative;
+ padding-block-start: var(--space-4);
+ }
+
+ .auth-input {
+ padding-inline: 0;
+ background: transparent;
+ font-size: var(--font-md);
+ }
+
+ .auth-label {
+ position: absolute;
+ top: 1.5em;
+ left: 0;
+ font-size: var(--font-md);
+ line-height: var(--lh-base);
+ pointer-events: none;
+ transition:
+ top var(--dur-2) var(--ease),
+ font-size var(--dur-2) var(--ease),
+ color var(--dur-2) var(--ease),
+ opacity var(--dur-2) var(--ease);
+ }
+
+ .auth-input:focus + .auth-label,
+ .auth-input:not(:placeholder-shown) + .auth-label {
+ top: 0;
+ color: var(--text);
+ font-size: var(--font-sm);
+ font-weight: 500;
+ opacity: .8;
+ }
+
+ .auth-choice {
+ cursor: pointer;
+ touch-action: manipulation;
+ }
+
+ .auth-choice input {
+ accent-color: var(--accent);
+ }
+
+ .auth-accounts {
+ --stack-gap: var(--space-2);
+ margin-block-start: var(--space-4);
+ }
+
+ .auth-account {
+ display: grid;
+ justify-items: start;
+ gap: var(--space-1);
+ width: 100%;
+ padding: var(--space-3) 0;
+ border: 0;
+ border-bottom: 1pt solid var(--field-line);
+ background: none;
+ color: inherit;
+ text-align: left;
+ cursor: pointer;
+ touch-action: manipulation;
+ }
+
+ .auth-account:hover,
+ .auth-account:focus-visible,
+ .auth-account:active {
+ border-bottom-color: var(--accent);
+ }
+
+ .auth-account:disabled {
+ opacity: .5;
+ cursor: default;
+ }
+
+ .auth-account-name {
+ font-size: var(--font-md);
+ line-height: var(--lh-base);
+ }
+
+ .auth-account-username {
+ color: var(--muted);
+ font-size: var(--font-base);
+ line-height: var(--lh-base);
+ }
+
+ .auth-error {
+ margin-block-start: var(--space-4);
+ }
+
+ .auth-actions {
+ margin-block-start: var(--space-6);
+ text-align: center;
+ }
+
+ .auth-back {
+ margin-inline-end: auto;
+ }
+
+ .auth-spinner {
+ margin-block-end: var(--space-4);
+ }
+
+ .auth-icon {
+ width: var(--space-8);
+ height: var(--space-8);
+ margin-block-end: var(--space-4);
+ }
+
+ .auth-consent-account {
+ display: flex;
+ align-items: center;
+ gap: var(--space-3);
+ margin-block-start: var(--space-6);
+ padding: var(--space-3);
+ background: var(--line-strong);
+ }
+
+ .auth-consent-account svg {
+ flex: none;
+ width: var(--space-6);
+ height: var(--space-6);
+ }
+
+ .auth-consent-account-body {
+ --stack-gap: var(--space-1);
+ }
+
+ .auth-consent-account-name {
+ font-size: var(--font-base);
+ font-weight: 500;
+ line-height: var(--lh-snug);
+ }
+
+ .auth-consent-account-meta {
+ overflow-wrap: anywhere;
+ color: var(--muted);
+ font-size: var(--font-xs);
+ line-height: var(--lh-snug);
+ }
+
+ .auth-not-you {
+ flex: none;
+ margin-inline-start: auto;
+ font-size: var(--font-sm);
+ }
+
+ .auth-consent-title {
+ margin: var(--space-6) 0 0;
+ font-size: var(--font-base);
+ font-weight: 500;
+ line-height: var(--lh-base);
+ }
+
+ .auth-consent-scopes {
+ --stack-gap: var(--space-2);
+ margin: var(--space-3) 0 0;
+ padding: 0;
+ list-style: none;
+ }
+
+ .auth-consent-scope {
+ display: flex;
+ align-items: flex-start;
+ gap: var(--space-2);
+ color: var(--muted);
+ font-size: var(--font-base);
+ line-height: var(--lh-base);
+ }
+
+ .auth-consent-scope svg {
+ flex: none;
+ width: var(--space-4);
+ height: var(--space-4);
+ margin-block-start: var(--space-1);
+ }
+
+ .auth-consent-footer {
+ margin-block-start: var(--space-6);
+ }
+
+ @media (min-width: 35em) {
+ .auth-page {
+ background-image: var(--hex);
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: cover;
+ }
+
+ .auth-card {
+ box-shadow: var(--shadow);
+ }
+
+ .auth-actions {
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ gap: var(--space-6);
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .auth-label {
+ transition: none;
+ }
+ }
+}