auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

commit 75d38b8e1b292c5d1324cb0beeee7cad4bf90944
parent 86d739d17a8a70b7fab4159a6d9ad57efaf013d3
Author: finwo <finwo@pm.me>
Date:   Sun,  1 Nov 2026 20:26:55 +0100

Added realm settings and mobile responsiveness

Diffstat:
Mapp/account/esbuild.cjs | 5+++--
Mapp/account/src/assets/account.css | 7++++++-
Mapp/admin/esbuild.cjs | 5+++--
Mapp/admin/src/assets/admin.css | 40++++++++++++++++++++++++++++++++++++++++
Mapp/admin/src/main.ts | 6++++++
Mapp/admin/src/screen/admin.tsx | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mapp/admin/src/screen/clients.tsx | 4++--
Mapp/admin/src/screen/global-user.tsx | 12++++++++----
Aapp/admin/src/screen/settings.tsx | 279+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapp/admin/src/screen/user.tsx | 20++++++++++++--------
Mapp/admin/src/screen/users.tsx | 12++++++------
Mapp/admin/src/util/api.ts | 13+++++++++++++
Mapp/admin/src/util/auth.ts | 27+++++++++++++++++++++++++++
Mapp/login/esbuild.cjs | 5+++--
Mapp/login/src/assets/login.css | 47+++++++++++++++++++++++++++++++++++++++--------
Mapp/shared/api/oidc.ts | 2+-
Mapp/shared/component/modal.tsx | 16++++++++++++++--
Mapp/shared/component/nav.tsx | 2++
Mapp/shared/style/global.css | 348+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mmockup/plain/account.html | 15++++++++++++---
Mmockup/plain/admin-client-detail.html | 17++++++++---------
Mmockup/plain/admin-clients.html | 33++++++++++++++++-----------------
Mmockup/plain/admin-dashboard.html | 17++++++++---------
Amockup/plain/admin-settings.html | 308+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mmockup/plain/admin-user-detail.html | 49++++++++++++++++++++++++-------------------------
Mmockup/plain/admin-user-global-detail.html | 33++++++++++++++++-----------------
Mmockup/plain/admin-users.html | 49++++++++++++++++++++++++-------------------------
Mmockup/plain/consent.html | 38++++++++++++++++++++++++++++++--------
Mmockup/plain/error-pages.html | 32+++++++++++++++++++++++++++-----
Mmockup/plain/global.css | 371++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mmockup/plain/login.html | 41++++++++++++++++++++++++++++++++++-------
Mmockup/template-poc/index.html | 2+-
Mmockup/template-poc/templates/system/style/account-base.css | 13+++++++++++--
Mmockup/template-poc/templates/system/style/base.css | 66+++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mmockup/template-poc/templates/system/style/login-base.css | 52+++++++++++++++++++++++++++++++++++++++++++---------
Aserver/src/controller/admin/settings.js | 39+++++++++++++++++++++++++++++++++++++++
Aserver/src/lib/admin-settings.js | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/test/http.test.js | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 files changed, 2061 insertions(+), 254 deletions(-)

diff --git a/app/account/esbuild.cjs b/app/account/esbuild.cjs @@ -77,10 +77,11 @@ esbuild } fs.writeFileSync(config.outdir + `/index.html`, `<!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> - <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> + <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> + <meta name="theme-color" content="#000"> <title>auth</title> ${styles.map(name => `<style>/* ${name} */ ${fs.readFileSync(`${config.outdir}/${name}`, 'utf8')}</style>`).join('\n ')} </head> diff --git a/app/account/src/assets/account.css b/app/account/src/assets/account.css @@ -18,7 +18,8 @@ user-select: none; } -.summary-row:hover { +.summary-row:hover, +.summary-row:active { background: var(--row-hover); } @@ -95,6 +96,9 @@ } .danger-link { + display: inline-flex; + align-items: center; + min-height: 2.75rem; padding: 0.5rem 0; border: 0; background: none; @@ -102,6 +106,7 @@ font: inherit; font-size: 0.875rem; cursor: pointer; + touch-action: manipulation; } .danger-link:hover:not(:disabled) { diff --git a/app/admin/esbuild.cjs b/app/admin/esbuild.cjs @@ -77,10 +77,11 @@ esbuild } fs.writeFileSync(config.outdir + `/index.html`, `<!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> - <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> + <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> + <meta name="theme-color" content="#000"> <title>auth</title> ${styles.map(name => `<style>/* ${name} */ ${fs.readFileSync(`${config.outdir}/${name}`, 'utf8')}</style>`).join('\n ')} </head> diff --git a/app/admin/src/assets/admin.css b/app/admin/src/assets/admin.css @@ -1,4 +1,6 @@ .realm-select { + min-width: 0; + max-width: 100%; display: grid; gap: 0.25rem; } @@ -11,6 +13,8 @@ .realm-select select { width: 100%; + min-width: 0; + max-width: 100%; padding: 0.5rem 0.75rem; border: 0; border-bottom: 1pt solid var(--field-line); @@ -219,6 +223,31 @@ margin-top: 0; } +.settings-form { + display: grid; + width: 100%; + min-width: 0; + max-width: 100%; + gap: 1rem; + margin-top: 1rem; +} + +.settings-form .form-field { + margin-bottom: 0; +} + +.settings-actions { + display: flex; + flex-wrap: wrap; + justify-content: flex-start; + gap: 0.5rem; + margin-top: 1rem; +} + +.settings-actions .button { + max-width: 100%; +} + .field-grid { display: grid; grid-template-columns: minmax(0, 1fr); @@ -227,6 +256,7 @@ .form-field { min-width: 0; + max-width: 100%; display: grid; gap: 0.25rem; } @@ -240,6 +270,8 @@ .field-control, .field-textarea { width: 100%; + min-width: 0; + max-width: 100%; padding: 0.5rem 0.75rem; border: 0; border-bottom: 1pt solid var(--field-line); @@ -256,6 +288,14 @@ resize: vertical; } +@media (pointer: coarse) { + .field-control, + .field-textarea, + .realm-select select { + font-size: 1rem; + } +} + .field-control:focus, .field-textarea:focus { outline: 2pt solid var(--accent); diff --git a/app/admin/src/main.ts b/app/admin/src/main.ts @@ -40,6 +40,12 @@ const routes: m.RouteDefs = { '/users/:realm/:userId': { render: () => m(Admin, {}), }, + '/settings': { + render: () => m(Admin, {}), + }, + '/settings/:realm': { + render: () => m(Admin, {}), + }, '/callback': { render: () => m(AdminCallback, {}), }, diff --git a/app/admin/src/screen/admin.tsx b/app/admin/src/screen/admin.tsx @@ -1,4 +1,4 @@ -import { Activity, AppWindow, LayoutGrid, Users } from 'lucide'; +import { Activity, AppWindow, LayoutGrid, Settings, Users } from 'lucide'; import m from 'mithril'; import { AppShell } from '@component/app-shell'; import { Nav, type NavItem } from '@component/nav'; @@ -24,6 +24,7 @@ import { ClientsPage } from './clients'; import { GlobalUserPage } from './global-user'; import { UserPage } from './user'; import { UsersPage } from './users'; +import { SettingsPage } from './settings'; function currentPath() { return (m.route.get() || '/').split('?')[0]; @@ -105,6 +106,19 @@ function globalUserDetailPath() { } } +function settingsRealm() { + const path = currentPath(); + if (path !== '/settings' && !path.startsWith('/settings/')) return null; + const suffix = path.slice('/settings/'.length); + if (!suffix) return null; + const slug = suffix.split('/')[0]; + try { + return decodeURIComponent(slug); + } catch { + return null; + } +} + export const Admin: m.Component = { user: null as UserInfo | null, systemAdmin: false, @@ -187,11 +201,26 @@ export const Admin: m.Component = { await this.login(); }, + async reloadRealms(this: any) { + try { + this.realms = await loadAdminRealms(); + this.realmsError = null; + } catch (e: any) { + if (e?.status === 401 || e?.status === 400) { + await this.login(); + return; + } + this.realmsError = e as Error; + } + m.redraw(); + }, + updateTitle(this: any) { const path = currentPath(); const clients = path === '/clients' || path.startsWith('/clients/'); const sessions = path === '/sessions' || path.startsWith('/sessions/'); const users = path === '/users' || path.startsWith('/users/'); + const settings = path === '/settings' || path.startsWith('/settings/'); const title = clients ? path.includes('/edit/') ? 'Edit client | Administration' @@ -202,7 +231,9 @@ export const Admin: m.Component = { ? userDetailPath() || globalUserDetailPath() ? 'User | Administration' : 'Users | Administration' - : 'Administration'; + : settings + ? 'Realm settings | Administration' + : 'Administration'; document.title = title; }, @@ -216,9 +247,11 @@ export const Admin: m.Component = { const sessions = path === '/sessions' || path.startsWith('/sessions/'); const clients = path === '/clients' || path.startsWith('/clients/'); const users = path === '/users' || path.startsWith('/users/'); + const settings = path === '/settings' || path.startsWith('/settings/'); const realmSlug = sessionsRealm(); const clientRealmSlug = clientsRealm(); const userRealmSlug = usersRealm(); + const settingsRealmSlug = settingsRealm(); const clientEdit = clientEditPath(); const userDetail = userDetailPath(); const globalUser = globalUserDetailPath(); @@ -231,13 +264,14 @@ export const Admin: m.Component = { ? `/clients/${encodeURIComponent(firstRealm)}` : '/clients'; const usersHref = firstRealm ? `/users/${encodeURIComponent(firstRealm)}` : '/users'; + const settingsHref = firstRealm ? `/settings/${encodeURIComponent(firstRealm)}` : '/settings'; const navItems: NavItem[] = [ { href: appUrl('/'), label: 'Overview', icon: LayoutGrid, - active: !sessions && !clients && !users, + active: !sessions && !clients && !users && !settings, onclick: (event: Event) => { event.preventDefault(); m.route.set('/'); @@ -273,6 +307,16 @@ export const Admin: m.Component = { m.route.set(usersHref); }, }, + { + href: appUrl(settingsHref), + label: 'Settings', + icon: Settings, + active: settings, + onclick: (event: Event) => { + event.preventDefault(); + m.route.set(settingsHref); + }, + }, ]; return ( @@ -348,6 +392,14 @@ export const Admin: m.Component = { isSystemAdmin={Boolean(this.systemAdmin)} isGlobal={isGlobalUsers} /> + ) : settings ? ( + <SettingsPage + realmSlug={settingsRealmSlug} + realms={this.realms} + realmsError={this.realmsError} + onAuthExpired={() => this.authExpired()} + onRealmsChanged={() => this.reloadRealms()} + /> ) : sessions ? ( <SessionsPage realmSlug={realmSlug} diff --git a/app/admin/src/screen/clients.tsx b/app/admin/src/screen/clients.tsx @@ -322,7 +322,7 @@ export const ClientsPage: m.Component<ClientsAttrs> = { m.route.set(href); }} > - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> {client.logo_url ? ( <img src={client.logo_url} alt="" /> @@ -348,7 +348,7 @@ export const ClientsPage: m.Component<ClientsAttrs> = { <span class="data-table-status">Disabled</span> )} </td> - <td>{ACCESS_MODE_LABELS[client.access_mode]}</td> + <td data-label="Access">{ACCESS_MODE_LABELS[client.access_mode]}</td> </tr> ); })} diff --git a/app/admin/src/screen/global-user.tsx b/app/admin/src/screen/global-user.tsx @@ -189,15 +189,19 @@ export const GlobalUserPage: m.Component<GlobalUserAttrs> = { <strong>{membership.display_name}</strong> <span class="data-table-sub">{membership.slug}</span> </td> - <td>{membership.relationship === 'home' ? 'Home' : 'Guest'}</td> - <td> + <td data-label="Relationship"> + {membership.relationship === 'home' ? 'Home' : 'Guest'} + </td> + <td data-label="Membership"> {membership.membership_status} {membership.banned ? ( <span class="data-table-status">Banned</span> ) : null} </td> - <td>{membership.roles.length ? membership.roles.join(', ') : 'None'}</td> - <td> + <td data-label="Roles"> + {membership.roles.length ? membership.roles.join(', ') : 'None'} + </td> + <td data-label="Action"> <a class="button-secondary" href={appUrl(href)} diff --git a/app/admin/src/screen/settings.tsx b/app/admin/src/screen/settings.tsx @@ -0,0 +1,279 @@ +import m from 'mithril'; +import { PageHeader } from '@component/page-header'; +import { RealmSelector } from '../component/realm-selector'; +import { loadAdminRealmSettings, updateAdminRealmSettings } from '../util/auth'; +import type { AdminRealm, AdminRealmSettings } from '../util/api'; + +interface SettingsAttrs { + realmSlug: string | null; + realms: AdminRealm[] | null; + realmsError: Error | null; + onAuthExpired: () => void; + onRealmsChanged: () => Promise<void>; +} + +interface SettingsFormValue { + display_name: string; + allow_session_duration_choice: boolean; +} + +function formFromSettings(settings: AdminRealmSettings): SettingsFormValue { + return { + display_name: settings.display_name, + allow_session_duration_choice: settings.allow_session_duration_choice, + }; +} + +function validateForm(value: SettingsFormValue): string | null { + const displayName = value.display_name.trim(); + + if (!displayName) { + return 'Display name is required.'; + } + if (/[\r\n]/.test(value.display_name)) { + return 'Display name must be a single line.'; + } + if (displayName.length > 100) { + return 'Display name must be 100 characters or fewer.'; + } + + return null; +} + +export const SettingsPage: m.Component<SettingsAttrs> = { + attrs: null as SettingsAttrs | null, + loadedRealm: null as string | null, + loading: false, + redirecting: false, + settings: null as AdminRealmSettings | null, + form: { display_name: '', allow_session_duration_choice: true } as SettingsFormValue, + error: null as Error | null, + formError: null as Error | string | null, + notice: null as string | null, + pending: false, + + oninit(this: any, vnode: m.Vnode<SettingsAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + onupdate(this: any, vnode: m.Vnode<SettingsAttrs>) { + this.attrs = vnode.attrs; + this.ensure(); + }, + + ensure(this: any) { + const { realms, realmSlug } = this.attrs; + if (!realms) return; + + if (realms.length === 0) { + this.loadedRealm = null; + this.settings = null; + this.loading = false; + this.error = null; + return; + } + + const selected = realmSlug && realms.some((realm) => realm.slug === realmSlug); + if (!selected) { + if (!this.redirecting) { + this.redirecting = true; + m.route.set(`/settings/${encodeURIComponent(realms[0].slug)}`, null, { + replace: true, + }); + } + return; + } + + this.redirecting = false; + if (this.loadedRealm !== realmSlug) { + this.load(realmSlug!); + } + }, + + async load(this: any, realmSlug: string) { + this.loadedRealm = realmSlug; + this.loading = true; + this.error = null; + this.formError = null; + this.notice = null; + this.settings = null; + this.form = { display_name: '', allow_session_duration_choice: true }; + m.redraw(); + + try { + const settings = await loadAdminRealmSettings(realmSlug); + if (this.loadedRealm !== realmSlug) return; + + this.settings = settings; + this.form = formFromSettings(settings); + } catch (e: any) { + if (this.loadedRealm !== realmSlug) return; + if (e?.status === 401 || e?.status === 400) { + this.attrs.onAuthExpired(); + return; + } + this.error = e as Error; + } finally { + if (this.loadedRealm === realmSlug) this.loading = false; + m.redraw(); + } + }, + + async submit(this: any) { + const { realmSlug } = this.attrs; + if (!realmSlug) return; + + const validationError = validateForm(this.form); + if (validationError) { + this.formError = validationError; + this.notice = null; + m.redraw(); + return; + } + + this.pending = true; + this.formError = null; + this.notice = null; + m.redraw(); + + try { + const settings = await updateAdminRealmSettings(realmSlug, { + display_name: this.form.display_name.trim(), + allow_session_duration_choice: this.form.allow_session_duration_choice, + }); + + if (this.loadedRealm !== realmSlug) return; + + this.settings = settings; + this.form = formFromSettings(settings); + this.notice = 'Realm settings saved.'; + await this.attrs.onRealmsChanged(); + } catch (e: any) { + if (e?.status === 401 || e?.status === 400) { + this.attrs.onAuthExpired(); + return; + } + this.formError = e as Error; + } finally { + this.pending = false; + m.redraw(); + } + }, + + view(this: any) { + const { realms, realmsError, realmSlug } = this.attrs; + const selected = + realms?.find((realm) => realm.slug === realmSlug) || realms?.[0] || null; + + return ( + <div> + <PageHeader row title="Realm settings" subtitle="Realm name and login behavior."> + <RealmSelector + realms={realms} + selected={selected} + onchange={(slug: string) => { + m.route.set(`/settings/${encodeURIComponent(slug)}`); + }} + /> + </PageHeader> + + {realmsError ? ( + <div class="alert" role="alert"> + {realmsError.message} + </div> + ) : null} + + {this.error ? ( + <div class="alert" role="alert"> + <p>{this.error.message}</p> + <button + class="button-secondary" + type="button" + onclick={() => { + if (realmSlug) { + this.load(realmSlug); + } + }} + > + Try again + </button> + </div> + ) : null} + + {this.notice ? ( + <div class="notice" role="status"> + {this.notice} + </div> + ) : null} + + {!realms ? ( + <div class="loading">Loading realms</div> + ) : realms.length === 0 ? ( + <div class="empty"> + <p>No realms are available for this account.</p> + </div> + ) : this.loading || this.redirecting ? ( + <div class="panel" aria-busy="true"> + <div class="skeleton skeleton-title"></div> + <div class="skeleton"></div> + <div class="skeleton skeleton-short"></div> + </div> + ) : this.settings ? ( + <section class="panel"> + <h2>Realm details</h2> + <form class="settings-form" onsubmit={(event: Event) => { + event.preventDefault(); + this.submit(); + }}> + {this.formError ? ( + <div class="alert" role="alert"> + {typeof this.formError === 'string' ? this.formError : this.formError.message} + </div> + ) : null} + + <div class="form-field"> + <span class="field-label">Realm ID</span> + <input class="field-control" value={this.settings.slug} disabled /> + </div> + + <div class="form-field"> + <span class="field-label">Display name</span> + <input + class="field-control" + value={this.form.display_name} + maxlength="100" + disabled={this.pending} + aria-invalid={Boolean(this.formError)} + oninput={(event: Event) => { + this.form.display_name = (event.target as HTMLInputElement).value; + }} + /> + </div> + + <label class="checkbox-row"> + <input + type="checkbox" + checked={this.form.allow_session_duration_choice} + disabled={this.pending} + onchange={(event: Event) => { + this.form.allow_session_duration_choice = ( + event.target as HTMLInputElement + ).checked; + }} + /> + <span>Show "Keep me signed in" on login</span> + </label> + + <div class="settings-actions"> + <button class="button" type="submit" disabled={this.pending}> + {this.pending ? 'Saving' : 'Save changes'} + </button> + </div> + </form> + </section> + ) : null} + </div> + ); + }, +}; diff --git a/app/admin/src/screen/user.tsx b/app/admin/src/screen/user.tsx @@ -559,8 +559,10 @@ export const UserPage: m.Component<UserAttrs> = { <strong>{consent.client_name || 'Unknown client'}</strong> <span class="data-table-sub">{consent.client_id}</span> </td> - <td>{consent.scopes.length ? consent.scopes.join(', ') : 'None'}</td> - <td> + <td data-label="Scopes"> + {consent.scopes.length ? consent.scopes.join(', ') : 'None'} + </td> + <td data-label="Granted"> {grantedLabel(consent)} {consent.client_consent_mode ? ( <span class="data-table-sub"> @@ -568,14 +570,14 @@ export const UserPage: m.Component<UserAttrs> = { </span> ) : null} </td> - <td> + <td data-label="Status"> {consent.active ? 'Active' : 'Revoked'} {!consent.active ? ( <span class="data-table-status">Revoked</span> ) : null} </td> - <td>{formatTime(consent.updated_at)}</td> - <td> + <td data-label="Updated">{formatTime(consent.updated_at)}</td> + <td data-label="Action"> {consent.active ? ( <button class="button-secondary" @@ -647,9 +649,11 @@ export const UserPage: m.Component<UserAttrs> = { <span class="data-table-sub">{ban.client_id}</span> ) : null} </td> - <td>{ban.created_by_username || 'Unknown'}</td> - <td>{formatTime(ban.created_at)}</td> - <td> + <td data-label="Banned by"> + {ban.created_by_username || 'Unknown'} + </td> + <td data-label="Created">{formatTime(ban.created_at)}</td> + <td data-label="Action"> <button class="button-secondary" type="button" diff --git a/app/admin/src/screen/users.tsx b/app/admin/src/screen/users.tsx @@ -338,9 +338,9 @@ export const UsersPage: m.Component<UsersAttrs> = { m.route.set(href); }} > - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> - Icon(Users) + {Icon(Users)} </span> </td> <td class="data-table-primary"> @@ -359,14 +359,14 @@ export const UsersPage: m.Component<UsersAttrs> = { {user.email ? <span class="data-table-sub">{user.username}</span> : null} </td> {isGlobal ? ( - <td> + <td data-label="Home realm"> {(user as AdminGlobalUser).home_realm_slug || 'None'} {(user as AdminGlobalUser).is_system_admin ? ( <span class="data-table-status">System admin</span> ) : null} </td> ) : ( - <td> + <td data-label="Membership"> {relationshipLabel(user as AdminRealmUser)} {(user as AdminRealmUser).roles.includes('realm-admin') ? ( <span class="data-table-status">Realm admin</span> @@ -377,9 +377,9 @@ export const UsersPage: m.Component<UsersAttrs> = { </td> )} {isGlobal ? ( - <td>{(user as AdminGlobalUser).membership_count}</td> + <td data-label="Realms">{(user as AdminGlobalUser).membership_count}</td> ) : null} - <td> + <td data-label="Status"> {isGlobal ? globalStatusLabel(user as AdminGlobalUser) : realmStatus(user as AdminRealmUser)} diff --git a/app/admin/src/util/api.ts b/app/admin/src/util/api.ts @@ -10,6 +10,19 @@ export interface AdminRealm { display_name: string; } +export interface AdminRealmSettings { + slug: string; + display_name: string; + allow_session_duration_choice: boolean; + created_at: number; + updated_at: number; +} + +export interface AdminRealmSettingsInput { + display_name: string; + allow_session_duration_choice: boolean; +} + export interface AdminRole { slug: string; name: string; diff --git a/app/admin/src/util/auth.ts b/app/admin/src/util/auth.ts @@ -13,6 +13,8 @@ import { type AdminGlobalUserDetail, type AdminMeUser, type AdminRealm, + type AdminRealmSettings, + type AdminRealmSettingsInput, type AdminRealmUser, type AdminRole, type AdminSession, @@ -278,3 +280,28 @@ export async function updateAdminRealmUserRoles( } ); } + +export async function loadAdminRealmSettings( + realmSlug: string +): Promise<AdminRealmSettings> { + const realm = encodeURIComponent(realmSlug); + const response = await adminJson<{ settings: AdminRealmSettings }>( + `/api/v1/admin/realms/${realm}/settings` + ); + return response.settings; +} + +export async function updateAdminRealmSettings( + realmSlug: string, + input: AdminRealmSettingsInput +): Promise<AdminRealmSettings> { + const realm = encodeURIComponent(realmSlug); + const response = await adminJson<{ ok: boolean; settings: AdminRealmSettings }>( + `/api/v1/admin/realms/${realm}/settings`, + { + method: 'PATCH', + body: JSON.stringify(input), + } + ); + return response.settings; +} diff --git a/app/login/esbuild.cjs b/app/login/esbuild.cjs @@ -77,10 +77,11 @@ esbuild } fs.writeFileSync(config.outdir + `/index.html`, `<!DOCTYPE html> -<html> +<html lang="en"> <head> <meta charset="utf-8"> - <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> + <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> + <meta name="theme-color" content="#000"> <title>auth</title> ${styles.map(name => `<style>/* ${name} */ ${fs.readFileSync(`${config.outdir}/${name}`, 'utf8')}</style>`).join('\n ')} </head> diff --git a/app/login/src/assets/login.css b/app/login/src/assets/login.css @@ -10,6 +10,11 @@ box-sizing: border-box; } +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + html, body { margin: 0; @@ -18,9 +23,11 @@ body { .auth-page { min-height: 100vh; + min-height: 100svh; display: grid; place-items: center; - padding: 0; + 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); } @@ -103,10 +110,12 @@ body { 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 { @@ -125,8 +134,10 @@ body { 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 rgba(0, 0, 0, 0.16); @@ -136,10 +147,12 @@ body { font: inherit; text-align: left; cursor: pointer; + touch-action: manipulation; } .auth-account:hover, -.auth-account:focus-visible { +.auth-account:focus-visible, +.auth-account:active { border-bottom-color: var(--realm-primary); } @@ -167,13 +180,18 @@ body { } .auth-actions { - display: flex; - justify-content: flex-end; - align-items: center; + display: grid; gap: 1rem; margin-top: 1.5rem; } +.auth-actions .auth-button, +.auth-actions .auth-link { + width: 100%; + min-height: 2.75rem; + text-align: center; +} + .auth-button { padding: 0.75rem 1.5rem; border: 0; @@ -181,7 +199,7 @@ body { background: var(--realm-primary); color: #fff; font: inherit; - font-size: 0.875rem; + font-size: 1rem; letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer; @@ -201,12 +219,12 @@ body { } .auth-link { - padding: 0.5rem 0; + padding: 0.75rem 1rem; border: 0; background: none; color: var(--realm-primary); font: inherit; - font-size: 0.875rem; + font-size: 1rem; cursor: pointer; } @@ -250,6 +268,7 @@ body { .auth-consent-account .auth-link { flex: none; + min-width: 2.75rem; margin-left: auto; font-size: 0.8125rem; } @@ -337,6 +356,18 @@ body { .auth-card { box-shadow: 0 0.125em 0.25em #0008; } + + .auth-actions { + display: flex; + justify-content: flex-end; + align-items: center; + gap: 1.5rem; + } + + .auth-actions .auth-button, + .auth-actions .auth-link { + width: auto; + } } @media (min-width: 35em) and (prefers-color-scheme: dark) { diff --git a/app/shared/api/oidc.ts b/app/shared/api/oidc.ts @@ -225,7 +225,7 @@ export function createOidcAuth(options: OidcAuthOptions) { } async function completeLogin(search: string) { - const params = new URLSearchParams(search); + const params = new URLSearchParams((search || '').split('#')[0]); const error = params.get('error'); if (error) { throw new Error(params.get('error_description') || options.deniedMessage); diff --git a/app/shared/component/modal.tsx b/app/shared/component/modal.tsx @@ -7,19 +7,31 @@ export interface ModalAttrs { onClose: () => void; } +let openModalCount = 0; + export const Modal: m.Component<ModalAttrs> = { oncreate(this: any, vnode: m.Vnode<ModalAttrs>) { this.focusBefore = document.activeElement; + if (openModalCount === 0) { + document.documentElement.classList.add('modal-open'); + } + openModalCount += 1; this.onKeydown = (event: KeyboardEvent) => { if (event.key === 'Escape') vnode.attrs.onClose(); }; window.addEventListener('keydown', this.onKeydown); - const target = vnode.dom?.querySelector('[data-modal-autofocus]') as HTMLElement | null; - target?.focus(); + if (window.matchMedia('(pointer: fine)').matches) { + const target = vnode.dom?.querySelector('[data-modal-autofocus]') as HTMLElement | null; + target?.focus(); + } }, onremove(this: any) { window.removeEventListener('keydown', this.onKeydown); + openModalCount = Math.max(0, openModalCount - 1); + if (openModalCount === 0) { + document.documentElement.classList.remove('modal-open'); + } (this.focusBefore as HTMLElement | null)?.focus?.(); }, diff --git a/app/shared/component/nav.tsx b/app/shared/component/nav.tsx @@ -24,7 +24,9 @@ export const Nav: m.Component<NavAttrs> = { <a class={`nav-item${item.active ? ' is-active' : ''}`} href={item.href} + aria-label={item.label} aria-current={item.active ? 'page' : undefined} + title={item.label} onclick={item.onclick} > {Icon(item.icon)} diff --git a/app/shared/style/global.css b/app/shared/style/global.css @@ -32,6 +32,11 @@ box-sizing: border-box; } +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + html, body { margin: 0; @@ -44,6 +49,10 @@ body { -webkit-font-smoothing: antialiased; } +html.modal-open body { + overflow: hidden; +} + button, input, select, @@ -53,6 +62,7 @@ textarea { .app-shell { min-height: 100vh; + min-height: 100svh; } .topbar { @@ -64,7 +74,8 @@ textarea { justify-content: space-between; gap: 1rem; min-height: 3.5rem; - padding: 0 1.5rem; + padding: env(safe-area-inset-top) max(1.5rem, env(safe-area-inset-right)) 0 + max(1.5rem, env(safe-area-inset-left)); background: var(--topbar); color: rgba(255, 255, 255, 0.76); font-size: 0.875rem; @@ -95,6 +106,7 @@ textarea { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .sidebar { @@ -108,8 +120,14 @@ textarea { .nav { display: flex; flex-direction: row; - flex-wrap: wrap; + flex-wrap: nowrap; + overflow-x: auto; padding: 0.75rem 0; + scrollbar-width: none; +} + +.nav::-webkit-scrollbar { + display: none; } .nav-label { @@ -128,19 +146,30 @@ textarea { align-items: center; justify-content: center; gap: 0.75rem; - width: auto; - flex: none; - padding: 0.6875rem 1.5rem; + min-width: 4rem; + flex: 1 0 auto; + padding: 0.6875rem 0.5rem; color: rgba(255, 255, 255, 0.82); font-size: 0.875rem; line-height: 1.4; + text-align: center; text-decoration: none; cursor: pointer; + touch-action: manipulation; user-select: none; + -webkit-tap-highlight-color: transparent; } .nav-item span { - display: none; + position: absolute; + width: 1pt; + height: 1pt; + padding: 0; + margin: -1pt; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; } .nav-item svg { @@ -149,13 +178,15 @@ textarea { height: 1.125rem; } -.nav-item:hover { +.nav-item:hover, +.nav-item:active { background: var(--menu-hover); color: #fff; } .nav-item.is-active { background: var(--sidebar-active); + box-shadow: inset 0 0.25rem 0 var(--accent); color: #fff; } @@ -169,7 +200,7 @@ textarea { width: 100%; max-width: 72rem; margin: 0 auto; - padding: 1.75rem clamp(1rem, 4vw, 2rem) 3rem; + padding: 1.75rem clamp(1rem, 4vw, 2rem) calc(3rem + env(safe-area-inset-bottom)); } .page-header { @@ -205,6 +236,7 @@ textarea { .panel { min-width: 0; + max-width: 100%; padding: 1.5rem; background: var(--surface); box-shadow: var(--shadow); @@ -424,7 +456,8 @@ textarea { top: 2.75rem; right: 0; z-index: 10; - width: 15rem; + width: min(15rem, calc(100vw - 2rem)); + max-width: calc(100vw - 2rem); background: var(--sidebar); color: #fff; box-shadow: var(--shadow); @@ -478,7 +511,8 @@ textarea { height: 1.125rem; } -.user-menu-item:hover { +.user-menu-item:hover, +.user-menu-item:active { background: var(--menu-hover); color: #fff; } @@ -493,7 +527,9 @@ textarea { display: grid; place-items: center; min-height: 100vh; - padding: 0; + min-height: 100svh; + 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(--surface); color: var(--text); } @@ -555,13 +591,18 @@ textarea { } .status-actions { - display: flex; - justify-content: flex-end; - align-items: center; + display: grid; gap: 1rem; margin-top: 1.5rem; } +.status-actions > .button, +.status-actions > .button-secondary, +.status-actions > .button-danger { + justify-content: center; + text-align: center; +} + .sr-only { position: absolute; width: 1pt; @@ -575,17 +616,17 @@ textarea { } .table-panel { - background: var(--surface); color: var(--text); - box-shadow: var(--shadow); } .table-toolbar { display: flex; flex-direction: column; gap: 1rem; - padding: 1rem 1.5rem; - border-bottom: 1pt solid var(--row); + margin-bottom: 1rem; + padding: 1rem; + background: var(--surface); + box-shadow: var(--shadow); } .table-search { @@ -619,23 +660,66 @@ textarea { } .data-table-wrap { - overflow-x: auto; + overflow: visible; } .data-table { + display: block; + min-width: 0; width: 100%; border-collapse: collapse; font-size: 0.875rem; } +.data-table thead { + display: none; +} + +.data-table tbody, +.data-table tbody tr, +.data-table td { + display: block; + width: 100%; +} + +.data-table tbody tr, +.data-table-static tbody tr { + min-height: 2.75rem; + margin-bottom: 1rem; + padding: 1rem; + background: var(--surface); + box-shadow: var(--shadow); +} + +.data-table tbody tr:last-child, +.data-table-static tbody tr:last-child { + margin-bottom: 0; +} + .data-table th, .data-table td { - padding: 0.75rem 1.5rem; - border-bottom: 1pt solid var(--row); + display: block; + padding: 0.5rem 0; + border: 0; text-align: left; vertical-align: middle; } +.data-table td[data-label]::before { + content: attr(data-label); + display: block; + margin-bottom: 0.25rem; + color: var(--muted); + font-size: 0.75rem; + font-weight: 500; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.data-table td:last-child { + padding-bottom: 0; +} + .data-table th { color: var(--muted); font-size: 0.75rem; @@ -657,22 +741,23 @@ textarea { outline-offset: -2pt; } -.data-table-static tbody tr, -.data-table-static tbody tr:hover { +.data-table-static tbody tr { cursor: default; - background: transparent; } .data-table tbody tr:last-child td { border-bottom: 0; } -.table-icon-column { - width: 1%; +.data-table .table-icon-column { + display: none; } .data-table-primary { - min-width: 16rem; + min-width: 0; + margin-bottom: 0.75rem; + padding-bottom: 0.75rem; + border-bottom: 1pt solid var(--row); } .data-table-sub { @@ -718,15 +803,19 @@ textarea { inset: 0; z-index: 100; display: grid; - place-items: center; - padding: 1rem; + place-items: end center; + padding: 0; background: rgba(0, 0, 0, 0.58); + touch-action: manipulation; } .modal { - width: min(100%, 32rem); - max-height: calc(100vh - 2rem); + width: 100%; + max-height: 100vh; + max-height: calc(100dvh - env(safe-area-inset-top)); overflow: auto; + overscroll-behavior: contain; + border-top: 0.25rem solid var(--accent); background: var(--surface); color: var(--text); box-shadow: var(--shadow); @@ -737,7 +826,7 @@ textarea { align-items: flex-start; justify-content: space-between; gap: 1rem; - padding: 1.5rem 1.5rem 0; + padding: 1rem 1rem 0; } .modal-header h2 { @@ -770,7 +859,7 @@ textarea { } .modal-body { - padding: 1.5rem; + padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); } .modal-note { @@ -781,10 +870,24 @@ textarea { } .modal-actions { + position: sticky; + bottom: 0; display: flex; + flex-wrap: wrap; justify-content: flex-end; - gap: 1rem; - margin-top: 1.5rem; + gap: 0.5rem; + margin: 1rem -1rem calc(-1rem - env(safe-area-inset-bottom)); + padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); + background: var(--surface); + border-top: 1pt solid var(--row); +} + +.modal-actions > .button, +.modal-actions > .button-secondary, +.modal-actions > .button-danger { + flex: 1; + justify-content: center; + text-align: center; } a:focus-visible, @@ -807,16 +910,107 @@ select:focus-visible { .status-panel { box-shadow: var(--shadow); } + + .status-actions { + display: flex; + justify-content: flex-end; + align-items: center; + } + + .status-actions > .button, + .status-actions > .button-secondary, + .status-actions > .button-danger { + flex: 0 auto; + } } @media (min-width: 40em) { + .table-panel { + background: var(--surface); + box-shadow: var(--shadow); + } + .table-toolbar { flex-direction: row; align-items: center; + margin-bottom: 0; + padding: 1rem 1.5rem; + background: transparent; + box-shadow: none; + border-bottom: 1pt solid var(--row); + } + + .data-table-wrap { + overflow-x: auto; + } + + .data-table { + display: table; + font-size: 0.875rem; + } + + .data-table thead { + display: table-header-group; + } + + .data-table tbody { + display: table-row-group; + } + + .data-table tbody tr, + .data-table-static tbody tr { + display: table-row; + min-height: 0; + margin-bottom: 0; + padding: 0; + background: transparent; + box-shadow: none; + } + + .data-table tbody tr:hover { + background: var(--row-hover); + } + + .data-table-static tbody tr:hover { + background: transparent; + } + + .data-table th, + .data-table td { + display: table-cell; + padding: 0.75rem 1.5rem; + border-bottom: 1pt solid var(--row); + } + + .data-table td[data-label]::before { + content: none; + } + + .data-table-primary { + min-width: 16rem; + margin-bottom: 0; + padding-bottom: 0; + border-bottom: 0; + } + + .data-table .table-icon-column { + display: table-cell; + width: 1%; + } + + .nav-item { + padding-inline: 1rem; } .nav-item span { + position: static; + width: auto; + height: auto; + margin: 0; + overflow: visible; + clip-path: none; display: inline; + white-space: normal; } .details > div { @@ -826,6 +1020,42 @@ select:focus-visible { .page-header-row { grid-template-columns: minmax(0, 1fr) auto; } + + .modal-overlay { + place-items: center; + padding: 1rem; + } + + .modal { + width: min(100%, 32rem); + max-height: calc(100vh - 2rem); + max-height: calc(100dvh - 2rem); + border-top: 0; + } + + .modal-header { + padding: 1.5rem 1.5rem 0; + } + + .modal-body { + padding: 1.5rem; + } + + .modal-actions { + position: static; + flex-wrap: nowrap; + gap: 1rem; + margin: 1.5rem 0 0; + padding: 0; + background: transparent; + border-top: 0; + } + + .modal-actions > .button, + .modal-actions > .button-secondary, + .modal-actions > .button-danger { + flex: 0 auto; + } } @media (min-width: 60em) { @@ -836,10 +1066,12 @@ select:focus-visible { .sidebar { min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .nav { flex: 1; + overflow: visible; flex-direction: column; flex-wrap: nowrap; } @@ -849,8 +1081,12 @@ select:focus-visible { } .nav-item { + min-width: 0; width: 100%; + flex: none; + padding-inline: 1.5rem; justify-content: flex-start; + text-align: left; } .grid { @@ -858,6 +1094,48 @@ select:focus-visible { } } +@media (pointer: coarse) { + .button, + .button-secondary, + .button-danger, + .auth-button, + .auth-link, + .nav-item, + .summary-row, + .surface-row, + .user-menu-item { + min-height: 2.75rem; + touch-action: manipulation; + } + + .user-menu summary, + .modal-close { + min-width: 2.75rem; + width: 2.75rem; + height: 2.75rem; + touch-action: manipulation; + } + + .table-search input, + .field-control, + .field-textarea, + .realm-select select, + .checkbox-row, + .auth-choice { + min-height: 2.75rem; + padding-block: 0.5rem; + touch-action: manipulation; + } + + .user-menu summary:hover, + .user-menu summary:active, + .user-menu-item:hover, + .user-menu-item:active { + background: var(--menu-hover); + color: #fff; + } +} + @media (prefers-reduced-motion: reduce) { .spinner { animation: none; diff --git a/mockup/plain/account.html b/mockup/plain/account.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Account mockup</title> <link rel="stylesheet" href="./global.css" /> <style> @@ -19,14 +19,17 @@ grid-template-columns: 1.5rem minmax(0, 1fr); align-items: center; gap: 1rem; + min-height: 2.75rem; padding: 0.875rem 0.75rem; color: inherit; text-decoration: none; cursor: pointer; + touch-action: manipulation; user-select: none; } - .summary-row:hover { + .summary-row:hover, + .summary-row:active { background: var(--row-hover); } @@ -73,8 +76,10 @@ grid-template-columns: 1.5rem minmax(0, 1fr); align-items: center; gap: 1rem; + min-height: 2.75rem; padding: 1rem 0.75rem; background: var(--row); + touch-action: manipulation; } .surface-row svg { @@ -103,13 +108,17 @@ } .danger-link { + display: inline-flex; + align-items: center; + min-height: 2.75rem; padding: 0.5rem 0; border: 0; background: none; - color: var(--danger); + color: var(--danger-text, var(--danger)); font: inherit; font-size: 0.875rem; cursor: pointer; + touch-action: manipulation; } .danger-link:hover { diff --git a/mockup/plain/admin-client-detail.html b/mockup/plain/admin-client-detail.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin client detail mockup</title> <link rel="stylesheet" href="./global.css" /> </head> @@ -91,14 +91,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item" href="./admin-users.html"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -106,6 +98,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> diff --git a/mockup/plain/admin-clients.html b/mockup/plain/admin-clients.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin clients mockup</title> <link rel="stylesheet" href="./global.css" /> </head> @@ -91,14 +91,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item" href="./admin-users.html"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -106,6 +98,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> @@ -147,7 +146,7 @@ </thead> <tbody id="client-rows"> <tr data-row-href="./admin-client-detail.html" data-search="internal app internal-app internal"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <rect x="2" y="4" width="20" height="16" rx="2" /> @@ -161,10 +160,10 @@ <a href="./admin-client-detail.html">Internal App</a> <span class="data-table-sub">internal-app</span> </td> - <td>Internal</td> + <td data-label="Access">Internal</td> </tr> <tr data-row-href="./admin-client-detail.html" data-search="members portal members-app members"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> @@ -178,10 +177,10 @@ <a href="./admin-client-detail.html">Members Portal</a> <span class="data-table-sub">members-app</span> </td> - <td>Members</td> + <td data-label="Access">Members</td> </tr> <tr data-row-href="./admin-client-detail.html" data-search="public site public-app public"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="10" /> @@ -195,10 +194,10 @@ <a href="./admin-client-detail.html">Public Site</a> <span class="data-table-sub">public-app</span> </td> - <td>Public</td> + <td data-label="Access">Public</td> </tr> <tr data-row-href="./admin-client-detail.html" data-search="secure service secure-app members disabled confidential"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <rect x="3" y="11" width="18" height="11" rx="2" /> @@ -211,7 +210,7 @@ <span class="data-table-sub">secure-app</span> <span class="data-table-status">Disabled</span> </td> - <td>Members</td> + <td data-label="Access">Members</td> </tr> </tbody> </table> diff --git a/mockup/plain/admin-dashboard.html b/mockup/plain/admin-dashboard.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin dashboard mockup</title> <link rel="stylesheet" href="./global.css" /> <style> @@ -126,14 +126,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item" href="./admin-users.html"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -141,6 +133,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> diff --git a/mockup/plain/admin-settings.html b/mockup/plain/admin-settings.html @@ -0,0 +1,308 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> + <title>Admin realm settings mockup</title> + <link rel="stylesheet" href="./global.css" /> + <style> + .settings-form { + display: grid; + width: 100%; + min-width: 0; + max-width: 100%; + gap: 1rem; + margin-top: 1rem; + } + + .settings-form .form-field { + margin-bottom: 0; + } + + .settings-form .checkbox-row { + min-width: 0; + } + + .settings-actions { + display: flex; + flex-wrap: wrap; + justify-content: flex-start; + gap: 0.5rem; + margin-top: 1rem; + } + + .settings-actions .button { + max-width: 100%; + } + + .state-preview { + margin-top: 2rem; + } + + .state-preview > h2 { + margin-bottom: 0.75rem; + } + </style> + </head> + <body> + <header class="topbar"> + <a class="brand" href="./admin-dashboard.html"> + <svg class="brand-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" /> + </svg> + <span class="brand-name">Auth</span> + </a> + <details class="user-menu"> + <summary aria-label="Account menu"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <circle cx="12" cy="12" r="10" /> + <circle cx="12" cy="10" r="3" /> + <path d="M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662" /> + </svg> + </summary> + <div class="user-panel"> + <div class="user-summary"> + <span class="user-name">System Admin</span> + <span class="user-meta">admin@system.test</span> + </div> + <div class="user-menu-list"> + <a class="user-menu-item" href="#"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Account settings</span> + </a> + <button class="user-menu-item" type="button" data-user-theme> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <circle cx="12" cy="12" r="4" /> + <path d="M12 2v2" /> + <path d="M12 20v2" /> + <path d="m4.93 4.93 1.41 1.41" /> + <path d="m17.66 17.66 1.41 1.41" /> + <path d="M2 12h2" /> + <path d="M20 12h2" /> + <path d="m6.34 17.66-1.41 1.41" /> + <path d="m19.07 4.93-1.41 1.41" /> + </svg> + <span>Theme</span> + <span class="user-menu-value" data-user-theme-value>Auto</span> + </button> + <a class="user-menu-item" href="#"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" /> + <path d="m16 17 5-5-5-5" /> + <path d="M21 12H9" /> + </svg> + <span>Sign out</span> + </a> + </div> + </div> + </details> + </header> + + <div class="app"> + <aside class="sidebar"> + <nav class="nav" aria-label="Administration"> + <p class="nav-label">Administration</p> + <a class="nav-item" href="./admin-dashboard.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <rect x="3" y="3" width="7" height="7" /> + <rect x="14" y="3" width="7" height="7" /> + <rect x="3" y="14" width="7" height="7" /> + <rect x="14" y="14" width="7" height="7" /> + </svg> + <span>Overview</span> + </a> + <a class="nav-item" href="./admin-clients.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <rect x="2" y="4" width="20" height="16" rx="2" /> + <path d="M10 4v4" /> + <path d="M2 8h20" /> + <path d="M6 4v4" /> + </svg> + <span>Clients</span> + </a> + <a class="nav-item" href="#"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M22 12h-4l-3 8-6-16-3 8H2" /> + </svg> + <span>Sessions</span> + </a> + <a class="nav-item" href="./admin-users.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> + <circle cx="12" cy="7" r="4" /> + </svg> + <span>Users</span> + </a> + <a class="nav-item is-active" href="./admin-settings.html" aria-current="page"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> + </nav> + </aside> + + <div class="main"> + <main class="content"> + <div class="page-header page-header-row"> + <div> + <h1>Realm settings</h1> + <p>Realm name and login behavior.</p> + </div> + <label class="realm-select"> + <span>Realm</span> + <select> + <option selected>Acme</option> + <option>Globex</option> + </select> + </label> + </div> + + <section class="panel"> + <h2>Realm details</h2> + <form class="settings-form"> + <div class="form-field"> + <span class="field-label">Realm ID</span> + <input class="field-control" value="acme" disabled /> + </div> + + <div class="form-field"> + <span class="field-label">Display name</span> + <input class="field-control" value="Acme" maxlength="100" /> + </div> + + <label class="checkbox-row"> + <input type="checkbox" checked /> + <span>Show "Keep me signed in" on login</span> + </label> + + <div class="settings-actions"> + <button class="button" type="submit">Save changes</button> + </div> + </form> + </section> + + <section class="state-preview"> + <h2>Loading state</h2> + <div class="panel" aria-busy="true"> + <div class="skeleton skeleton-title"></div> + <div class="skeleton"></div> + <div class="skeleton skeleton-short"></div> + </div> + </section> + + <section class="state-preview"> + <h2>Saved state</h2> + <div class="notice" role="status">Realm settings saved.</div> + <section class="panel"> + <h2>Realm details</h2> + <form class="settings-form"> + <div class="form-field"> + <span class="field-label">Realm ID</span> + <input class="field-control" value="acme" disabled /> + </div> + + <div class="form-field"> + <span class="field-label">Display name</span> + <input class="field-control" value="Acme Inc" maxlength="100" /> + </div> + + <label class="checkbox-row"> + <input type="checkbox" /> + <span>Show "Keep me signed in" on login</span> + </label> + + <div class="settings-actions"> + <button class="button" type="submit">Save changes</button> + </div> + </form> + </section> + </section> + + <section class="state-preview"> + <h2>Validation error</h2> + <div class="alert" role="alert">Display name is required.</div> + <section class="panel"> + <h2>Realm details</h2> + <form class="settings-form"> + <div class="form-field"> + <span class="field-label">Realm ID</span> + <input class="field-control" value="acme" disabled /> + </div> + + <div class="form-field"> + <span class="field-label">Display name</span> + <input class="field-control" value="" aria-invalid="true" maxlength="100" /> + </div> + + <label class="checkbox-row"> + <input type="checkbox" checked /> + <span>Show "Keep me signed in" on login</span> + </label> + + <div class="settings-actions"> + <button class="button" type="submit">Save changes</button> + </div> + </form> + </section> + </section> + </main> + </div> + </div> + + <div class="mockup-controls" aria-label="Mockup theme"> + <span class="mockup-label">Mockup</span> + <button class="mockup-button is-active" type="button" data-theme-target="auto">Auto</button> + <button class="mockup-button" type="button" data-theme-target="light">Light</button> + <button class="mockup-button" type="button" data-theme-target="dark">Dark</button> + </div> + + <script> + const root = document.documentElement; + const themeButtons = document.querySelectorAll('[data-theme-target]'); + const userThemeButton = document.querySelector('[data-user-theme]'); + const userThemeValue = document.querySelector('[data-user-theme-value]'); + let currentTheme = 'auto'; + + function setTheme(value) { + currentTheme = value; + if (value === 'auto') { + root.removeAttribute('data-theme'); + } else { + root.setAttribute('data-theme', value); + } + themeButtons.forEach((button) => { + button.classList.toggle('is-active', button.dataset.themeTarget === value); + }); + if (userThemeValue) { + userThemeValue.textContent = value.charAt(0).toUpperCase() + value.slice(1); + } + } + + const queryTheme = new URLSearchParams(window.location.search).get('theme'); + if (queryTheme === 'light' || queryTheme === 'dark') { + setTheme(queryTheme); + } + + themeButtons.forEach((button) => { + button.addEventListener('click', () => setTheme(button.dataset.themeTarget)); + }); + + userThemeButton?.addEventListener('click', () => { + const themes = ['auto', 'light', 'dark']; + setTheme(themes[(themes.indexOf(currentTheme) + 1) % themes.length]); + }); + + const userMenu = document.querySelector('.user-menu'); + document.addEventListener('click', (event) => { + if (userMenu && userMenu.open && !userMenu.contains(event.target)) { + userMenu.open = false; + } + }); + </script> + </body> +</html> diff --git a/mockup/plain/admin-user-detail.html b/mockup/plain/admin-user-detail.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin user detail mockup</title> <link rel="stylesheet" href="./global.css" /> </head> @@ -91,14 +91,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item is-active" href="./admin-users.html" aria-current="page"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -106,6 +98,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> @@ -227,14 +226,14 @@ <strong>Internal App</strong> <span class="data-table-sub">internal-app</span> </td> - <td>openid, profile, email</td> - <td> + <td data-label="Scopes">openid, profile, email</td> + <td data-label="Granted"> User consent <span class="data-table-sub">remembered</span> </td> - <td>Active</td> - <td>2026-10-24 16:02</td> - <td> + <td data-label="Status">Active</td> + <td data-label="Updated">2026-10-24 16:02</td> + <td data-label="Action"> <button class="button-secondary" type="button" data-dialog-open="consent-revoke-dialog">Revoke</button> </td> </tr> @@ -243,17 +242,17 @@ <strong>Secure Service</strong> <span class="data-table-sub">secure-app</span> </td> - <td>None</td> - <td> + <td data-label="Scopes">None</td> + <td data-label="Granted"> User consent <span class="data-table-sub">remembered</span> </td> - <td> + <td data-label="Status"> Revoked <span class="data-table-status">Revoked</span> </td> - <td>2026-10-25 09:18</td> - <td>None</td> + <td data-label="Updated">2026-10-25 09:18</td> + <td data-label="Action">None</td> </tr> </tbody> </table> @@ -283,9 +282,9 @@ <td class="data-table-primary"> <strong>All apps</strong> </td> - <td>acme-it</td> - <td>2026-10-25 09:18</td> - <td> + <td data-label="Banned by">acme-it</td> + <td data-label="Created">2026-10-25 09:18</td> + <td data-label="Action"> <button class="button-secondary" type="button" data-dialog-open="all-apps-unban-dialog">Unban</button> </td> </tr> @@ -294,9 +293,9 @@ <strong>Internal App</strong> <span class="data-table-sub">internal-app</span> </td> - <td>acme-it</td> - <td>2026-10-25 09:20</td> - <td> + <td data-label="Banned by">acme-it</td> + <td data-label="Created">2026-10-25 09:20</td> + <td data-label="Action"> <button class="button-secondary" type="button" data-dialog-open="app-unban-dialog">Unban</button> </td> </tr> diff --git a/mockup/plain/admin-user-global-detail.html b/mockup/plain/admin-user-global-detail.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin global user detail mockup</title> <link rel="stylesheet" href="./global.css" /> </head> @@ -91,14 +91,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item is-active" href="./admin-users.html" aria-current="page"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -106,6 +98,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> @@ -189,10 +188,10 @@ <strong>Acme</strong> <span class="data-table-sub">acme</span> </td> - <td>Home</td> - <td>active</td> - <td>None</td> - <td> + <td data-label="Relationship">Home</td> + <td data-label="Membership">active</td> + <td data-label="Roles">None</td> + <td data-label="Action"> <a class="button-secondary" href="./admin-user-detail.html">Manage access</a> </td> </tr> @@ -201,10 +200,10 @@ <strong>Globex</strong> <span class="data-table-sub">globex</span> </td> - <td>Guest</td> - <td>active</td> - <td>None</td> - <td> + <td data-label="Relationship">Guest</td> + <td data-label="Membership">active</td> + <td data-label="Roles">None</td> + <td data-label="Action"> <a class="button-secondary" href="./admin-user-detail.html">Manage access</a> </td> </tr> diff --git a/mockup/plain/admin-users.html b/mockup/plain/admin-users.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Admin users mockup</title> <link rel="stylesheet" href="./global.css" /> </head> @@ -91,14 +91,6 @@ </svg> <span>Sessions</span> </a> - <a class="nav-item" href="#"> - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> - <circle cx="12" cy="12" r="9" /> - <path d="M3 12h18" /> - <path d="M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18" /> - </svg> - <span>Realms</span> - </a> <a class="nav-item is-active" href="./admin-users.html" aria-current="page"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -106,6 +98,13 @@ </svg> <span>Users</span> </a> + <a class="nav-item" href="./admin-settings.html"> + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> + <circle cx="12" cy="12" r="3" /> + </svg> + <span>Settings</span> + </a> </nav> </aside> @@ -150,7 +149,7 @@ </thead> <tbody id="user-rows"> <tr data-row-href="./admin-user-detail.html" data-search="alice alice alice@acme.test home realm user active"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -163,12 +162,12 @@ <span class="data-table-sub">alice@acme.test</span> <span class="data-table-sub">alice</span> </td> - <td>Home</td> - <td>None</td> - <td>Active</td> + <td data-label="Membership">Home</td> + <td data-label="Roles">None</td> + <td data-label="Status">Active</td> </tr> <tr data-row-href="./admin-user-detail.html" data-search="acme it acme-it it@acme.test home realm-admin active"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -181,12 +180,12 @@ <span class="data-table-sub">it@acme.test</span> <span class="data-table-sub">acme-it</span> </td> - <td>Home</td> - <td><span class="data-table-status">Realm admin</span></td> - <td>Active</td> + <td data-label="Membership">Home</td> + <td data-label="Roles"><span class="data-table-status">Realm admin</span></td> + <td data-label="Status">Active</td> </tr> <tr data-row-href="./admin-user-detail.html" data-search="guest user guest guest@personal.test guest active"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -199,12 +198,12 @@ <span class="data-table-sub">guest@personal.test</span> <span class="data-table-sub">guest</span> </td> - <td>Guest</td> - <td>None</td> - <td>Active</td> + <td data-label="Membership">Guest</td> + <td data-label="Roles">None</td> + <td data-label="Status">Active</td> </tr> <tr data-row-href="./admin-user-detail.html" data-search="carol carol carol@example.test guest realm user active"> - <td> + <td class="table-icon-column"> <span class="table-icon" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> @@ -217,9 +216,9 @@ <span class="data-table-sub">carol@example.test</span> <span class="data-table-sub">carol</span> </td> - <td>Guest</td> - <td>None</td> - <td>Active</td> + <td data-label="Membership">Guest</td> + <td data-label="Roles">None</td> + <td data-label="Status">Active</td> </tr> </tbody> </table> diff --git a/mockup/plain/consent.html b/mockup/plain/consent.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Consent mockup</title> <link rel="stylesheet" href="./global.css" /> <style> @@ -10,7 +10,9 @@ display: grid; place-items: center; min-height: 100vh; - padding: 0; + min-height: 100svh; + padding: env(safe-area-inset-top) env(safe-area-inset-right) + calc(1rem + env(safe-area-inset-bottom)) env(safe-area-inset-left); background-color: var(--surface); } @@ -127,22 +129,29 @@ } .consent-actions { - display: flex; - flex-wrap: wrap; - justify-content: flex-end; - align-items: center; + display: grid; gap: 1rem; margin-top: 1.5rem; } + .consent-actions > .button, + .consent-actions > .link-button { + justify-content: center; + min-height: 2.75rem; + text-align: center; + } + .link-button { - padding: 0.5rem 0; + display: inline-flex; + align-items: center; + padding: 0.75rem 1rem; border: 0; background: none; color: var(--accent-text); font: inherit; - font-size: 0.875rem; + font-size: 1rem; cursor: pointer; + touch-action: manipulation; } .link-button:hover { @@ -164,6 +173,19 @@ .consent-card { box-shadow: var(--shadow); } + + .consent-actions { + display: flex; + flex-wrap: nowrap; + justify-content: flex-end; + align-items: center; + gap: 1.5rem; + } + + .consent-actions > .button, + .consent-actions > .link-button { + width: auto; + } } </style> diff --git a/mockup/plain/error-pages.html b/mockup/plain/error-pages.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Error pages mockup</title> <link rel="stylesheet" href="./global.css" /> <style> @@ -10,7 +10,9 @@ display: grid; place-items: center; min-height: 100vh; - padding: 0; + min-height: 100svh; + padding: env(safe-area-inset-top) env(safe-area-inset-right) + calc(1rem + env(safe-area-inset-bottom)) env(safe-area-inset-left); background-color: var(--surface); } @@ -88,13 +90,19 @@ } .status-actions { - display: flex; - justify-content: flex-end; - align-items: center; + display: grid; gap: 1rem; margin-top: 1.5rem; } + .status-actions > .button, + .status-actions > .button-secondary, + .status-actions > .button-danger { + justify-content: center; + min-height: 2.75rem; + text-align: center; + } + .field { display: grid; gap: 0.125rem; @@ -126,6 +134,20 @@ .login-card { box-shadow: var(--shadow); } + + .status-actions { + display: flex; + justify-content: flex-end; + align-items: center; + gap: 1rem; + } + + .status-actions > .button, + .status-actions > .button-secondary, + .status-actions > .button-danger { + flex: 0 auto; + width: auto; + } } @media (prefers-reduced-motion: reduce) { diff --git a/mockup/plain/global.css b/mockup/plain/global.css @@ -32,6 +32,11 @@ box-sizing: border-box; } +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + html, body { margin: 0; @@ -57,7 +62,8 @@ body { justify-content: space-between; gap: 1rem; min-height: 3.5rem; - padding: 0 1.5rem; + padding: env(safe-area-inset-top) max(1.5rem, env(safe-area-inset-right)) 0 + max(1.5rem, env(safe-area-inset-left)); background: var(--topbar); color: rgba(255, 255, 255, 0.76); font-size: 0.875rem; @@ -88,6 +94,7 @@ body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .sidebar { @@ -101,8 +108,14 @@ body { .nav { display: flex; flex-direction: row; - flex-wrap: wrap; + flex-wrap: nowrap; + overflow-x: auto; padding: 0.75rem 0; + scrollbar-width: none; +} + +.nav::-webkit-scrollbar { + display: none; } .nav-label { @@ -121,19 +134,30 @@ body { align-items: center; justify-content: center; gap: 0.75rem; - width: auto; - flex: 1; - padding: 0.6875rem 1.5rem; + min-width: 4rem; + flex: 1 0 auto; + padding: 0.6875rem 0.5rem; color: rgba(255, 255, 255, 0.82); font-size: 0.875rem; line-height: 1.4; + text-align: center; text-decoration: none; cursor: pointer; + touch-action: manipulation; user-select: none; + -webkit-tap-highlight-color: transparent; } .nav-item span { - display: none; + position: absolute; + width: 1pt; + height: 1pt; + padding: 0; + margin: -1pt; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; } .nav-item svg { @@ -142,13 +166,15 @@ body { height: 1.125rem; } -.nav-item:hover { +.nav-item:hover, +.nav-item:active { background: var(--menu-hover); color: #fff; } .nav-item.is-active { background: var(--sidebar-active); + box-shadow: inset 0 0.25rem 0 var(--accent); color: #fff; } @@ -162,7 +188,7 @@ body { width: 100%; max-width: 72rem; margin: 0 auto; - padding: 1.75rem 2rem 3rem; + padding: 1.75rem clamp(1rem, 4vw, 2rem) calc(3rem + env(safe-area-inset-bottom)); } .page-header { @@ -210,6 +236,8 @@ body { } .panel { + min-width: 0; + max-width: 100%; padding: 1.5rem; background: var(--surface); box-shadow: var(--shadow); @@ -338,7 +366,8 @@ body { top: 2.75rem; right: 0; z-index: 10; - width: 15rem; + width: min(15rem, calc(100vw - 2rem)); + max-width: calc(100vw - 2rem); background: var(--sidebar); color: #fff; box-shadow: var(--shadow); @@ -405,8 +434,8 @@ body { .mockup-controls { position: fixed; - right: 1rem; - bottom: 1rem; + right: max(1rem, env(safe-area-inset-right)); + bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-wrap: wrap; @@ -496,6 +525,8 @@ body { } .realm-select { + min-width: 0; + max-width: 100%; display: grid; gap: 0.25rem; } @@ -508,6 +539,8 @@ body { .realm-select select { width: 100%; + min-width: 0; + max-width: 100%; padding: 0.5rem 0.75rem; border: 0; border-bottom: 1pt solid var(--field-line); @@ -532,17 +565,17 @@ body { } .table-panel { - background: var(--surface); color: var(--text); - box-shadow: var(--shadow); } .table-toolbar { display: flex; flex-direction: column; gap: 1rem; - padding: 1rem 1.5rem; - border-bottom: 1pt solid var(--row); + margin-bottom: 1rem; + padding: 1rem; + background: var(--surface); + box-shadow: var(--shadow); } .table-search { @@ -576,19 +609,47 @@ body { } .data-table-wrap { - overflow-x: auto; + overflow: visible; } .data-table { + display: block; + min-width: 0; width: 100%; border-collapse: collapse; font-size: 0.875rem; } +.data-table thead { + display: none; +} + +.data-table tbody, +.data-table tbody tr, +.data-table td { + display: block; + width: 100%; +} + +.data-table tbody tr, +.data-table-static tbody tr { + min-height: 2.75rem; + margin-bottom: 1rem; + padding: 1rem; + background: var(--surface); + box-shadow: var(--shadow); +} + +.data-table tbody tr:last-child, +.data-table-static tbody tr:last-child { + margin-bottom: 0; +} + .data-table th, .data-table td { - padding: 0.75rem 1.5rem; - border-bottom: 1pt solid var(--row); + display: block; + padding: 0.5rem 0; + border: 0; text-align: left; vertical-align: middle; } @@ -601,6 +662,21 @@ body { text-transform: uppercase; } +.data-table td[data-label]::before { + content: attr(data-label); + display: block; + margin-bottom: 0.25rem; + color: var(--muted); + font-size: 0.75rem; + font-weight: 500; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.data-table td:last-child { + padding-bottom: 0; +} + .data-table tbody tr { cursor: pointer; } @@ -613,18 +689,23 @@ body { border-bottom: 0; } -.data-table-static tbody tr, -.data-table-static tbody tr:hover { +.data-table-static tbody tr { cursor: default; - background: transparent; } -.table-icon-column { - width: 1%; +.data-table-static tbody tr:hover { + background: var(--surface); +} + +.data-table .table-icon-column { + display: none; } .data-table-primary { - min-width: 16rem; + min-width: 0; + margin-bottom: 0.75rem; + padding-bottom: 0.75rem; + border-bottom: 1pt solid var(--row); } .data-table-primary a { @@ -726,15 +807,19 @@ body { inset: 0; z-index: 100; display: grid; - place-items: center; - padding: 1rem; + place-items: end center; + padding: 0; background: rgba(0, 0, 0, 0.58); + touch-action: manipulation; } .modal { - width: min(100%, 32rem); - max-height: calc(100vh - 2rem); + width: 100%; + max-height: 100vh; + max-height: calc(100dvh - env(safe-area-inset-top)); overflow: auto; + overscroll-behavior: contain; + border-top: 0.25rem solid var(--accent); background: var(--surface); color: var(--text); box-shadow: var(--shadow); @@ -745,7 +830,7 @@ body { align-items: flex-start; justify-content: space-between; gap: 1rem; - padding: 1.5rem 1.5rem 0; + padding: 1rem 1rem 0; } .modal-header h2 { @@ -777,7 +862,7 @@ body { } .modal-body { - padding: 1.5rem; + padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); } .modal-note { @@ -788,14 +873,29 @@ body { } .modal-actions { + position: sticky; + bottom: 0; display: flex; + flex-wrap: wrap; justify-content: flex-end; - gap: 1rem; - margin-top: 1.5rem; + gap: 0.5rem; + margin: 1rem -1rem calc(-1rem - env(safe-area-inset-bottom)); + padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); + background: var(--surface); + border-top: 1pt solid var(--row); +} + +.modal-actions > .button, +.modal-actions > .button-secondary, +.modal-actions > .button-danger { + flex: 1; + justify-content: center; + text-align: center; } .form-field { display: grid; + min-width: 0; gap: 0.25rem; margin-bottom: 1rem; } @@ -808,6 +908,8 @@ body { .field-control { width: 100%; + min-width: 0; + max-width: 100%; padding: 0.5rem 0.75rem; border: 0; border-bottom: 1pt solid var(--field-line); @@ -860,6 +962,49 @@ select.field-control, height: 1rem; } +.alert { + margin: 0 0 1rem; + color: var(--danger-text); + font-size: 0.875rem; + line-height: 1.5; +} + +.alert p { + margin: 0 0 0.5rem; +} + +.notice { + margin: 0 0 1rem; + padding: 0.75rem 1rem; + background: var(--row); + color: var(--text); + font-size: 0.875rem; + line-height: 1.5; +} + +.loading { + color: var(--muted); + font-size: 0.875rem; +} + +.skeleton { + height: 0.75rem; + background: var(--skeleton); +} + +.skeleton + .skeleton { + margin-top: 0.75rem; +} + +.skeleton-title { + width: 8rem; + height: 1rem; +} + +.skeleton-short { + width: 35%; +} + a:focus-visible, button:focus-visible, summary:focus-visible { @@ -867,23 +1012,180 @@ summary:focus-visible { outline-offset: 2pt; } +@media (pointer: coarse) { + .button, + .button-secondary, + .button-danger, + .auth-button, + .auth-link, + .nav-item, + .summary-row, + .surface-row, + .user-menu-item { + min-height: 2.75rem; + touch-action: manipulation; + } + + .user-menu summary, + .modal-close { + min-width: 2.75rem; + width: 2.75rem; + height: 2.75rem; + touch-action: manipulation; + } + + .table-search input, + .field-control, + .field-textarea, + .realm-select select, + .checkbox-row, + .auth-choice { + min-height: 2.75rem; + padding-block: 0.5rem; + touch-action: manipulation; + } + + .user-menu summary:hover, + .user-menu summary:active, + .user-menu-item:hover, + .user-menu-item:active { + background: var(--menu-hover); + color: #fff; + } +} + @media (min-width: 40em) { .page-header-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; } + .modal-overlay { + place-items: center; + padding: 1rem; + } + + .modal { + width: min(100%, 32rem); + max-height: calc(100vh - 2rem); + max-height: calc(100dvh - 2rem); + border-top: 0; + } + + .modal-header { + padding: 1.5rem 1.5rem 0; + } + + .modal-body { + padding: 1.5rem; + } + + .modal-actions { + position: static; + flex-wrap: nowrap; + gap: 1rem; + margin: 1.5rem 0 0; + padding: 0; + background: transparent; + border-top: 0; + } + + .modal-actions > .button, + .modal-actions > .button-secondary, + .modal-actions > .button-danger { + flex: 0 auto; + } + + .table-panel { + background: var(--surface); + box-shadow: var(--shadow); + } + .table-toolbar { flex-direction: row; align-items: center; + margin-bottom: 0; + padding: 1rem 1.5rem; + background: transparent; + box-shadow: none; + border-bottom: 1pt solid var(--row); + } + + .data-table-wrap { + overflow-x: auto; + } + + .data-table { + display: table; + font-size: 0.875rem; + } + + .data-table thead { + display: table-header-group; + } + + .data-table tbody { + display: table-row-group; + } + + .data-table tbody tr, + .data-table-static tbody tr { + display: table-row; + min-height: 0; + margin-bottom: 0; + padding: 0; + background: transparent; + box-shadow: none; + } + + .data-table tbody tr:hover { + background: var(--row-hover); + } + + .data-table-static tbody tr:hover { + background: transparent; + } + + .data-table th, + .data-table td { + display: table-cell; + padding: 0.75rem 1.5rem; + border-bottom: 1pt solid var(--row); + } + + .data-table td[data-label]::before { + content: none; + } + + .data-table-primary { + min-width: 16rem; + margin-bottom: 0; + padding-bottom: 0; + border-bottom: 0; + } + + .data-table .table-icon-column { + display: table-cell; + width: 1%; } .realm-select select { width: auto; } + .nav-item { + padding-inline: 1rem; + } + .nav-item span { + position: static; + width: auto; + height: auto; + margin: 0; + overflow: visible; + clip-path: none; display: inline; + white-space: normal; } .details > div { @@ -899,10 +1201,12 @@ summary:focus-visible { .sidebar { min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .nav { flex: 1; + overflow: visible; flex-direction: column; flex-wrap: nowrap; } @@ -912,9 +1216,12 @@ summary:focus-visible { } .nav-item { + min-width: 0; width: 100%; flex: none; + padding-inline: 1.5rem; justify-content: flex-start; + text-align: left; } .grid { diff --git a/mockup/plain/login.html b/mockup/plain/login.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>Login mockup</title> <link rel="stylesheet" href="./global.css" /> <style> @@ -11,7 +11,9 @@ display: grid; place-items: center; min-height: 100vh; - padding: 0; + min-height: 100svh; + 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); } @@ -116,10 +118,12 @@ 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 { @@ -138,8 +142,10 @@ 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); @@ -175,25 +181,33 @@ } .auth-actions { - display: flex; - justify-content: flex-end; - align-items: center; + 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 { - padding: 0.5rem 0; + display: inline-flex; + align-items: center; + padding: 0.75rem 1rem; border: 0; background: none; color: var(--accent-text); font: inherit; - font-size: 0.875rem; + font-size: 1rem; cursor: pointer; + touch-action: manipulation; } .auth-link:hover { @@ -327,6 +341,19 @@ .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) { diff --git a/mockup/template-poc/index.html b/mockup/template-poc/index.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> + <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <title>Template runtime PoC</title> <style> html { diff --git a/mockup/template-poc/templates/system/style/account-base.css b/mockup/template-poc/templates/system/style/account-base.css @@ -11,14 +11,17 @@ grid-template-columns: 1.5rem minmax(0, 1fr); align-items: center; gap: 1rem; + min-height: 2.75rem; padding: 0.875rem 0.75rem; color: inherit; text-decoration: none; cursor: pointer; + touch-action: manipulation; user-select: none; } -.summary-row:hover { +.summary-row:hover, +.summary-row:active { background: var(--row-hover); } @@ -65,8 +68,10 @@ grid-template-columns: 1.5rem minmax(0, 1fr); align-items: center; gap: 1rem; + min-height: 2.75rem; padding: 1rem 0.75rem; background: var(--row); + touch-action: manipulation; } .surface-row svg { @@ -95,13 +100,17 @@ } .danger-link { + display: inline-flex; + align-items: center; + min-height: 2.75rem; padding: 0.5rem 0; border: 0; background: none; - color: var(--danger); + color: var(--danger-text, var(--danger)); font: inherit; font-size: 0.875rem; cursor: pointer; + touch-action: manipulation; } .danger-link:hover { diff --git a/mockup/template-poc/templates/system/style/base.css b/mockup/template-poc/templates/system/style/base.css @@ -20,6 +20,7 @@ --row-hover: #0000000d; --skeleton: #00000012; --danger: #c9190b; + --danger-text: #c9190b; --field-line: rgba(0, 0, 0, 0.42); --shadow: 0 0.125em 0.25em #0008; --hex: url('template://asset/hex-grid-light.svg'); @@ -31,6 +32,11 @@ box-sizing: border-box; } +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + html, body { margin: 0; @@ -56,7 +62,8 @@ body { justify-content: space-between; gap: 1rem; min-height: 3.5rem; - padding: 0 1.5rem; + padding: env(safe-area-inset-top) max(1.5rem, env(safe-area-inset-right)) 0 + max(1.5rem, env(safe-area-inset-left)); background: var(--topbar); color: rgba(255, 255, 255, 0.76); font-size: 0.875rem; @@ -87,6 +94,7 @@ body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .sidebar { @@ -100,8 +108,14 @@ body { .nav { display: flex; flex-direction: row; - flex-wrap: wrap; + flex-wrap: nowrap; + overflow-x: auto; padding: 0.75rem 0; + scrollbar-width: none; +} + +.nav::-webkit-scrollbar { + display: none; } .nav-label { @@ -120,19 +134,30 @@ body { align-items: center; justify-content: center; gap: 0.75rem; - width: auto; - flex: 1; - padding: 0.6875rem 1.5rem; + min-width: 4rem; + flex: 1 0 auto; + padding: 0.6875rem 0.5rem; color: rgba(255, 255, 255, 0.82); font-size: 0.875rem; line-height: 1.4; + text-align: center; text-decoration: none; cursor: pointer; + touch-action: manipulation; user-select: none; + -webkit-tap-highlight-color: transparent; } .nav-item span { - display: none; + position: absolute; + width: 1pt; + height: 1pt; + padding: 0; + margin: -1pt; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; } .nav-item svg { @@ -141,13 +166,15 @@ body { height: 1.125rem; } -.nav-item:hover { +.nav-item:hover, +.nav-item:active { background: var(--menu-hover); color: #fff; } .nav-item.is-active { background: var(--sidebar-active); + box-shadow: inset 0 0.25rem 0 var(--accent); color: #fff; } @@ -161,7 +188,7 @@ body { width: 100%; max-width: 72rem; margin: 0 auto; - padding: 1.75rem 2rem 3rem; + padding: 1.75rem clamp(1rem, 4vw, 2rem) calc(3rem + env(safe-area-inset-bottom)); } .page-header { @@ -189,6 +216,8 @@ body { } .panel { + min-width: 0; + max-width: 100%; padding: 1.5rem; background: var(--surface); box-shadow: var(--shadow); @@ -301,7 +330,8 @@ body { top: 2.75rem; right: 0; z-index: 10; - width: 15rem; + width: min(15rem, calc(100vw - 2rem)); + max-width: calc(100vw - 2rem); background: var(--sidebar); color: #fff; box-shadow: var(--shadow); @@ -427,8 +457,19 @@ summary:focus-visible { } @media (min-width: 40em) { + .nav-item { + padding-inline: 1rem; + } + .nav-item span { + position: static; + width: auto; + height: auto; + margin: 0; + overflow: visible; + clip-path: none; display: inline; + white-space: normal; } .details > div { @@ -444,10 +485,12 @@ summary:focus-visible { .sidebar { min-height: calc(100vh - 3.5rem); + min-height: calc(100svh - 3.5rem); } .nav { flex: 1; + overflow: visible; flex-direction: column; flex-wrap: nowrap; } @@ -457,9 +500,12 @@ summary:focus-visible { } .nav-item { + min-width: 0; width: 100%; flex: none; + padding-inline: 1.5rem; justify-content: flex-start; + text-align: left; } .grid { @@ -484,6 +530,7 @@ summary:focus-visible { --row-hover: #ffffff14; --skeleton: #ffffff14; --danger: #f28b82; + --danger-text: #f28b82; --field-line: rgba(255, 255, 255, 0.42); --hex: url('template://asset/hex-grid-dark.svg'); color-scheme: dark; @@ -506,6 +553,7 @@ summary:focus-visible { --row-hover: #ffffff14; --skeleton: #ffffff14; --danger: #f28b82; + --danger-text: #f28b82; --field-line: rgba(255, 255, 255, 0.42); --hex: url('template://asset/hex-grid-dark.svg'); color-scheme: dark; diff --git a/mockup/template-poc/templates/system/style/login-base.css b/mockup/template-poc/templates/system/style/login-base.css @@ -10,6 +10,11 @@ box-sizing: border-box; } +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + html, body { margin: 0; @@ -20,7 +25,9 @@ body { display: grid; place-items: center; min-height: 100vh; - padding: 0; + min-height: 100svh; + 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); } @@ -116,10 +123,12 @@ body { 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 { @@ -138,8 +147,10 @@ body { 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 rgba(0, 0, 0, 0.16); @@ -149,10 +160,12 @@ body { font: inherit; text-align: left; cursor: pointer; + touch-action: manipulation; } .auth-account:hover, -.auth-account:focus-visible { +.auth-account:focus-visible, +.auth-account:active { border-bottom-color: var(--realm-primary); } @@ -180,13 +193,19 @@ body { } .auth-actions { - display: flex; - justify-content: flex-end; - align-items: center; + display: grid; gap: 1rem; margin-top: 1.5rem; } +.auth-actions > .auth-button, +.auth-actions > .auth-link { + width: 100%; + min-height: 2.75rem; + justify-content: center; + text-align: center; +} + .auth-button { padding: 0.75rem 1.5rem; border: 0; @@ -194,7 +213,7 @@ body { background: var(--realm-primary); color: #fff; font: inherit; - font-size: 0.875rem; + font-size: 1rem; letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer; @@ -214,17 +233,20 @@ body { } .auth-link { - padding: 0.5rem 0; + display: inline-flex; + align-items: center; + padding: 0.75rem 1rem; border: 0; background: none; color: var(--realm-primary); font: inherit; - font-size: 0.875rem; + font-size: 1rem; cursor: pointer; + touch-action: manipulation; } .auth-card-consent { - width: min(28rem, 100%); + width: min(calc(100% - 2rem), 28rem); } .auth-consent-account { @@ -350,6 +372,18 @@ body { .auth-card { box-shadow: 0 0.125em 0.25em #0008; } + + .auth-actions { + display: flex; + justify-content: flex-end; + align-items: center; + gap: 1.5rem; + } + + .auth-actions > .auth-button, + .auth-actions > .auth-link { + width: auto; + } } @media (min-width: 35em) and (prefers-color-scheme: dark) { diff --git a/server/src/controller/admin/settings.js b/server/src/controller/admin/settings.js @@ -0,0 +1,39 @@ +import { app } from '../../app.js'; +import { authenticateAdminRequest } from '../../lib/admin-auth.js'; +import { + getAdminRealmSettings, + updateAdminRealmSettings, +} from '../../lib/admin-settings.js'; + +export default [ + { + method: 'get', + path: '/api/v1/admin/realms/:realm/settings', + name: 'admin.settings.get', + async handler(req) { + const auth = await authenticateAdminRequest(req, { + realmSlug: req.params.realm, + }); + const settings = await getAdminRealmSettings(auth.realmDb, auth.realm.slug); + + return new app.HttpOk({ settings }, { 'cache-control': 'no-store' }); + }, + }, + { + method: 'patch', + path: '/api/v1/admin/realms/:realm/settings', + name: 'admin.settings.update', + async handler(req) { + const auth = await authenticateAdminRequest(req, { + realmSlug: req.params.realm, + }); + const settings = await updateAdminRealmSettings({ + realmDb: auth.realmDb, + realmSlug: auth.realm.slug, + body: req.body || {}, + }); + + return new app.HttpOk({ ok: true, settings }, { 'cache-control': 'no-store' }); + }, + }, +]; diff --git a/server/src/lib/admin-settings.js b/server/src/lib/admin-settings.js @@ -0,0 +1,131 @@ +import { HttpError } from './http/http-error.js'; + +const DISPLAY_NAME_MAX_LENGTH = 100; +const ALLOWED_FIELDS = new Set(['display_name', 'allow_session_duration_choice']); + +function invalidRequest(message) { + return new HttpError(400, 'invalid_request', message); +} + +function isPlainObject(value) { + return value !== null && typeof value === 'object' && !Array.isArray(value); +} + +function validateDisplayName(value) { + if (typeof value !== 'string') { + throw invalidRequest('display_name must be a string'); + } + + const displayName = value.trim(); + if (!displayName) { + throw invalidRequest('display_name must not be empty'); + } + if (displayName.length > DISPLAY_NAME_MAX_LENGTH) { + throw invalidRequest( + `display_name must be at most ${DISPLAY_NAME_MAX_LENGTH} characters` + ); + } + if (/[\r\n]/.test(displayName)) { + throw invalidRequest('display_name must be a single line'); + } + + return displayName; +} + +function validateAllowSessionDurationChoice(value) { + if (typeof value !== 'boolean') { + throw invalidRequest('allow_session_duration_choice must be a boolean'); + } + return value; +} + +function serializeSettings(row, realmSlug) { + return { + slug: realmSlug, + display_name: row.display_name, + allow_session_duration_choice: Boolean(row.allow_session_duration_choice), + created_at: row.created_at, + updated_at: row.updated_at, + }; +} + +async function loadSettingsRow(realmDb, realmSlug) { + const row = await realmDb.get( + `SELECT slug, display_name, allow_session_duration_choice, created_at, updated_at + FROM realm_settings + WHERE id = 1` + ); + + if (!row || row.slug !== realmSlug) { + throw new HttpError(404, 'realm_not_found', 'Realm settings not found'); + } + + return row; +} + +export function normalizeAdminRealmSettingsPatch(body) { + if (!isPlainObject(body)) { + throw invalidRequest('Request body must be a JSON object'); + } + + for (const field of Object.keys(body)) { + if (!ALLOWED_FIELDS.has(field)) { + throw invalidRequest(`Unknown field: ${field}`); + } + } + + if (Object.keys(body).length === 0) { + throw invalidRequest('At least one setting must be provided'); + } + + const input = {}; + + if (Object.hasOwn(body, 'display_name')) { + input.display_name = validateDisplayName(body.display_name); + } + if (Object.hasOwn(body, 'allow_session_duration_choice')) { + input.allow_session_duration_choice = validateAllowSessionDurationChoice( + body.allow_session_duration_choice + ); + } + + return input; +} + +export async function getAdminRealmSettings(realmDb, realmSlug) { + const row = await loadSettingsRow(realmDb, realmSlug); + return serializeSettings(row, realmSlug); +} + +export async function updateAdminRealmSettings({ + realmDb, + realmSlug, + body, + now = Date.now(), +}) { + const input = normalizeAdminRealmSettingsPatch(body); + const current = await loadSettingsRow(realmDb, realmSlug); + + const displayName = Object.hasOwn(input, 'display_name') + ? input.display_name + : current.display_name; + const allowSessionDurationChoice = Object.hasOwn(input, 'allow_session_duration_choice') + ? input.allow_session_duration_choice + : Boolean(current.allow_session_duration_choice); + + await realmDb.run( + `UPDATE realm_settings + SET display_name = {displayName}, + allow_session_duration_choice = {allowSessionDurationChoice}, + updated_at = {now} + WHERE id = 1`, + { + displayName, + allowSessionDurationChoice: allowSessionDurationChoice ? 1 : 0, + now, + } + ); + + const updated = await loadSettingsRow(realmDb, realmSlug); + return serializeSettings(updated, realmSlug); +} diff --git a/server/test/http.test.js b/server/test/http.test.js @@ -3928,6 +3928,107 @@ test('HTTP realm, login, OIDC and logout flows', async (t) => { clearUserRealmSessions(env, acmeItId); } }); + + await t.test('admin realm settings update name and login behavior', async () => { + const acmeAdmin = await adminToken('it@acme.test'); + const systemAdmin = await adminToken(); + let original = null; + + try { + const initial = await adminRequest(acmeAdmin, { + path: '/api/v1/admin/realms/acme/settings', + }); + assert.equal(initial.status, 200); + assert.equal(initial.json.settings.slug, 'acme'); + assert.equal(typeof initial.json.settings.created_at, 'number'); + original = initial.json.settings; + + const crossRealm = await adminRequest(acmeAdmin, { + path: '/api/v1/admin/realms/globex/settings', + }); + assert.equal(crossRealm.status, 403); + + const renamed = await adminRequest(acmeAdmin, { + method: 'PATCH', + path: '/api/v1/admin/realms/acme/settings', + body: { display_name: ' Acme Inc ' }, + }); + assert.equal(renamed.status, 200); + assert.equal(renamed.json.ok, true); + assert.equal(renamed.json.settings.display_name, 'Acme Inc'); + assert.equal(renamed.json.settings.allow_session_duration_choice, true); + + const realms = await adminRequest(systemAdmin, { + path: '/api/v1/admin/realms', + }); + assert.ok( + realms.json.realms.some( + (realm) => realm.slug === 'acme' && realm.display_name === 'Acme Inc' + ) + ); + + const publicRenamed = await acme({ path: '/api/v1/realm' }); + assert.equal(publicRenamed.json.display_name, 'Acme Inc'); + assert.equal(publicRenamed.json.allow_session_duration_choice, true); + + const disabledChoice = await adminRequest(systemAdmin, { + method: 'PATCH', + path: '/api/v1/admin/realms/acme/settings', + body: { allow_session_duration_choice: false }, + }); + assert.equal(disabledChoice.status, 200); + assert.equal(disabledChoice.json.settings.display_name, 'Acme Inc'); + assert.equal(disabledChoice.json.settings.allow_session_duration_choice, false); + + const publicDisabledChoice = await acme({ path: '/api/v1/realm' }); + assert.equal(publicDisabledChoice.json.display_name, 'Acme Inc'); + assert.equal(publicDisabledChoice.json.allow_session_duration_choice, false); + + const emptyPatch = await adminRequest(acmeAdmin, { + method: 'PATCH', + path: '/api/v1/admin/realms/acme/settings', + body: {}, + }); + assert.equal(emptyPatch.status, 400); + assert.equal(emptyPatch.json.error.code, 'invalid_request'); + + for (const body of [ + { slug: 'globex' }, + { status: 'disabled' }, + { display_name: ' ' }, + { display_name: 'A'.repeat(101) }, + { display_name: 'Acme\nInc' }, + { allow_session_duration_choice: 'false' }, + ]) { + const invalid = await adminRequest(acmeAdmin, { + method: 'PATCH', + path: '/api/v1/admin/realms/acme/settings', + body, + }); + assert.equal(invalid.status, 400); + assert.equal(invalid.json.error.code, 'invalid_request'); + } + + const stored = withRealmDatabase(env, 'acme', (database) => + database + .prepare('SELECT slug, status FROM realm_settings WHERE id = 1') + .get() + ); + assert.equal(stored.slug, 'acme'); + assert.equal(stored.status, 'active'); + } finally { + if (original) { + await adminRequest(systemAdmin, { + method: 'PATCH', + path: '/api/v1/admin/realms/acme/settings', + body: { + display_name: original.display_name, + allow_session_duration_choice: original.allow_session_duration_choice, + }, + }); + } + } + }); } finally { if (server) { server.kill('SIGTERM');