Skip to content

An open-source, self-hosted system for apps built with web technologies.

Refine authentication surface composition

zohayrslileh18b700df9460
diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsx
index 02b3ad9..2331aef 100644
--- a/source/client/view/structure/authentication/credentials-form.tsx
+++ b/source/client/view/structure/authentication/credentials-form.tsx
@@ -2,19 +2,20 @@ import { type AuthenticationState } from "@server/core/authentication/authentica
import { surfaceLifecyclePose, surfacePresenceTransition } from "../../appearance/surface-presence"
import { useReducedMotion } from "@libs/react-motion"
import { motion } from "motion/react"
-import { Button, Input, Panel, resolveSpacing, useAppearance } from "@phreshos/react-ui"
+import { Button, Heading, Input, resolveSpacing, Surface, Text, useAppearance } from "@phreshos/react-ui"
import Alert from "../../components/alert"
-import { useState, type SyntheticEvent } from "react"
+import { useId, useState, type SyntheticEvent } from "react"
import { ApplicationContext } from "../../contexts"
-import SystemHeader from "../../components/system-header"
+import logo from "@/assets/bundled/logo.png"
-/** The common username-and-password surface for sign-up and sign-in. */
+/** The common username-and-password welcome for sign-up and sign-in: the first thing a System shows. */
export default function CredentialsForm({ title, description, submitLabel, passwordAutocomplete, requirements, error, pending, onEdit, onSubmit }: CredentialsFormProps) {
const reducedMotion = useReducedMotion()
const { transaction, spacing } = useAppearance()
const application = ApplicationContext.useValue()
const [password, setPassword] = useState("")
+ const titleId = useId()
const passwordReady = requirements === undefined || [...password].length >= requirements.password.minimumLength
function submit(event: SyntheticEvent<HTMLFormElement, SubmitEvent>) {
@@ -28,9 +29,11 @@ export default function CredentialsForm({ title, description, submitLabel, passw
onSubmit(String(data.get("username") ?? ""), String(data.get("password") ?? ""))
}
- return <div className="absolute inset-0 grid">
+ // A welcome, not a dialog: the System's mark and words lead, the fields follow, and the version
+ // closes the card quietly. The card rises; its fields are recessed into it.
+ return <div className="absolute inset-0 grid overflow-auto p-4">
- <motion.form
+ <motion.div
initial={reducedMotion ? surfaceLifecyclePose.visible : surfaceLifecyclePose.hidden}
@@ -38,30 +41,41 @@ export default function CredentialsForm({ title, description, submitLabel, passw
transition={surfacePresenceTransition(reducedMotion, transaction)}
- className="pointer-events-auto relative m-auto w-[min(24rem,calc(100%-2rem))]"
+ className="pointer-events-auto relative m-auto w-[min(25rem,100%)]"
- aria-busy={pending}
+ >
- // Authentication owns normalized credential validation. Native
- // interception would prevent its field-specific result reaching this form.
- noValidate
+ <Surface material="full" radius="large" className="w-full" style={{ padding: resolveSpacing("xlarge", spacing) }}>
- onSubmit={submit}
+ <form
- >
+ className="grid"
+
+ style={{ gap: resolveSpacing("xlarge", spacing) }}
+
+ aria-busy={pending}
+
+ aria-labelledby={titleId}
+
+ // Authentication owns normalized credential validation. Native
+ // interception would prevent its field-specific result reaching this form.
+ noValidate
- <Panel material="full">
+ onSubmit={submit}
- <Panel.Header><SystemHeader name={application.displayName} version={application.version} /></Panel.Header>
+ >
- {/* The padding and the gaps inside are Appearance spacing levels by use. */}
- <Panel.Content material="extended" style={{ display: "grid", padding: resolveSpacing("large", spacing), gap: resolveSpacing("xlarge", spacing) }}>
+ <div className="grid justify-items-center text-center" style={{ gap: resolveSpacing("medium", spacing) }}>
- <div className="grid" style={{ gap: resolveSpacing("small", spacing) }}>
+ <img src={logo} alt="" draggable={false} className="size-12 object-contain select-none" />
- <h1 className="text-xl font-semibold">{title}</h1>
+ <div className="grid" style={{ gap: resolveSpacing("small", spacing) }}>
- <p className="text-sm leading-5 opacity-60">{description}</p>
+ <Heading id={titleId} level={1} size="large">{title}</Heading>
+
+ <Text tone="secondary">{description}</Text>
+
+ </div>
</div>
@@ -69,8 +83,7 @@ export default function CredentialsForm({ title, description, submitLabel, passw
{/* A submitted failure belongs to the exact credential values that produced it. */}
<Input
- aria-label="Username"
- placeholder="Username"
+ label="Username"
size="large"
name="username"
type="text"
@@ -86,8 +99,7 @@ export default function CredentialsForm({ title, description, submitLabel, passw
/>
<Input
- aria-label="Password"
- placeholder="Password"
+ label="Password"
size="large"
name="password"
type="password"
@@ -128,11 +140,17 @@ export default function CredentialsForm({ title, description, submitLabel, passw
>{pending ? `${submitLabel}…` : submitLabel}</Button>
- </Panel.Content>
+ <Text size="small" tone="secondary" className="text-center select-none tabular-nums" aria-label={`${application.displayName} version ${application.version}`}>
+
+ {application.displayName} {application.version}
+
+ </Text>
+
+ </form>
- </Panel>
+ </Surface>
- </motion.form>
+ </motion.div>
</div>
}
diff --git a/source/client/view/structure/authentication/sign-in.tsx b/source/client/view/structure/authentication/sign-in.tsx
index 38f4ac0..a58e24f 100644
--- a/source/client/view/structure/authentication/sign-in.tsx
+++ b/source/client/view/structure/authentication/sign-in.tsx
@@ -13,9 +13,9 @@ export default function () {
return <CredentialsForm
- title="Sign in"
+ title="Welcome back."
- description="Enter the credentials for this system's owner."
+ description="Sign in as the owner of this System."
submitLabel="Sign in"
diff --git a/source/client/view/structure/authentication/sign-up.tsx b/source/client/view/structure/authentication/sign-up.tsx
index c77b851..79f78f0 100644
--- a/source/client/view/structure/authentication/sign-up.tsx
+++ b/source/client/view/structure/authentication/sign-up.tsx
@@ -18,11 +18,11 @@ export default function SignUp({ state, onClosed }: SignUpProps) {
return <CredentialsForm
- title="Set up your system"
+ title="Fresh soil."
- description="Create the credentials for this system's sole owner."
+ description="This System is new and has no owner yet. Create the owner account to make it yours."
- submitLabel="Sign up"
+ submitLabel="Create owner account"
passwordAutocomplete="new-password"
diff --git a/tests/panel.test.tsx b/tests/panel.test.tsx
index b6bd454..9c5dc69 100644
--- a/tests/panel.test.tsx
+++ b/tests/panel.test.tsx
@@ -60,17 +60,18 @@ test("panel contract", async () => {
assert.match(passThrough, /inert=""/)
const authentication = markup(<CredentialsForm title="Sign in" description="Welcome" submitLabel="Continue" passwordAutocomplete="current-password" pending={false} onSubmit={() => {}} />)
- panel(authentication, 5)
+ // A welcome card, not a Panel: one raised card holding two recessed fields and the button.
+ assert.equal(authentication.match(/class="[^"]*phreshos-surface[^"]*"/g)?.length, 4)
+ assert.doesNotMatch(authentication, /grid-template-rows:auto minmax\(0, 1fr\)/)
assert.equal(authentication.match(/<form\b/g)?.length, 1)
assert.match(authentication, /<form[^>]*noValidate=""/)
assert.match(authentication, /name="username"/)
assert.match(authentication, /name="password"/)
- assert.match(authentication, /placeholder="Username"/)
- assert.match(authentication, /placeholder="Password"/)
- assert.doesNotMatch(authentication, /<label\b/)
+ assert.match(authentication, /<label[^>]*>Username<\/label>/)
+ assert.match(authentication, /<label[^>]*>Password<\/label>/)
assert.match(authentication, /type="submit"/)
- assert.match(authentication, /<h2[^>]*>Example System<\/h2>/)
- assert.match(authentication, /System version 1.2.3/)
+ assert.match(authentication, /<h1[^>]*>Sign in<\/h1>/)
+ assert.match(authentication, /Example System version 1.2.3/)
assert.doesNotMatch(authentication, /backdrop-blur/)
const authenticationError = markup(<CredentialsForm title="Sign up" description="Welcome" submitLabel="Continue" passwordAutocomplete="new-password" pending={false}