# Error pages

> Tell people what went wrong and what to do next, from a missing page to an outage.

Page: https://uicontext.com/blocks/error-pages

A screen in Errors and empty states. Preview it at https://uicontext.com/blocks/error-pages/preview.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/error-pages
```

With npm: `npx shadcn@latest add checkfu/uicontext/error-pages`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/error-pages`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/error-pages`.

## Components used

- [Button](https://uicontext.com/docs/components/button.md) (`button`): A button, and a link that looks like one, in every tone and three sizes.
- [Input](https://uicontext.com/docs/components/input.md) (`input`): Text inputs, selects and textareas in a labeled field with a hint and an error, and their styles for controls you lay out yourself.
- [Copy Button](https://uicontext.com/docs/components/copy-button.md) (`copy-button`): Copies a value and says whether it worked.

## Source

As written in the repository. `src/blocks/saas/StatusPages.ts` is the screen; the other files are pieces it imports.

```ts title="src/blocks/saas/StatusPages.ts"
import { UiSchema, type View } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { Button, buttonStyle } from "../../Button.ts"
import { CopyButton } from "../../CopyButton.ts"
import { Outcome } from "../../domain/Outcome.ts"
import { FormField, Input, Textarea } from "../../FormControls.ts"
import { sx } from "../../Sx.ts"
import { color, corner, font, space, stroke } from "../../tokens.stylex.ts"
import { Brand, BrandMark, FormAlert } from "./AuthFrame.ts"
import { isPending, outcomeOf } from "./form.ts"
import { Icon, type IconName } from "./Icons.ts"

// The pages people meet when the thing they wanted isn't there: not found, a server error,
// maintenance, offline, and no access. All five share one frame: the product's mark at the top, then
// an icon, what happened in plain words, whose problem it is, and the one or two things to do next.
// A server error carries a reference to quote to support. No access asks the owner for access, with
// an optional note, and says who was asked.

const styles = stylex.create({
	screen: {
		containerType: "inline-size",
		boxSizing: "border-box",
		display: "grid",
		gridTemplateRows: "auto minmax(0, 1fr)",
		minHeight: "100%",
		inlineSize: "100%",
		color: color.fg,
		fontFamily: font.sans,
	},
	top: { display: "flex", paddingInline: { default: space.xl, "@container (min-width: 560px)": space.xxl }, paddingBlockStart: space.xl },
	column: {
		display: "grid",
		justifyItems: "center",
		alignSelf: "center",
		justifySelf: "center",
		gap: space.xl,
		boxSizing: "border-box",
		inlineSize: "100%",
		maxWidth: 480,
		paddingInline: space.xl,
		paddingBlock: { default: 48, "@container (min-width: 560px)": 96 },
		textAlign: "center",
	},
	// the status code, for the people who look for it: small, above the headline
	code: { margin: 0, fontFamily: font.mono, fontSize: font.sm, color: color.muted, fontVariantNumeric: "tabular-nums" },
	badge: { display: "grid", placeItems: "center", width: 56, height: 56, borderRadius: `calc(${corner.card} + 4px)`, borderWidth: stroke.hairline, borderStyle: "solid", borderColor: color.line, backgroundColor: color.panel, color: color.fg },
	text: { display: "grid", gap: space.sm },
	title: { margin: 0, fontSize: { default: font.xl, "@container (min-width: 560px)": 28 }, lineHeight: 1.2, fontWeight: 650, letterSpacing: "-0.025em", textWrap: "balance", overflowWrap: "anywhere" },
	lede: { margin: 0, fontSize: font.base, lineHeight: 1.6, color: color.muted, textWrap: "pretty", overflowWrap: "anywhere" },
	strong: { color: color.fg, fontWeight: 500 },
	actions: { display: "flex", gap: space.sm, flexWrap: "wrap", justifyContent: "center" },
	search: { display: "grid", gridTemplateColumns: "minmax(0, 1fr) auto", gap: space.sm, inlineSize: "100%" },
	ref: { display: "flex", alignItems: "center", justifyContent: "center", gap: space.sm, flexWrap: "wrap", fontSize: font.sm, color: color.muted },
	refCode: { fontFamily: font.mono, fontSize: font.xs, color: color.fg, paddingBlock: 2, paddingInline: space.sm, borderRadius: corner.tag, backgroundColor: color.raised },
	note: { margin: 0, fontSize: font.sm, color: color.muted },
	form: { display: "grid", gap: space.lg, inlineSize: "100%", textAlign: "start" },
	srOnly: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" },
})

const Badge = <M>(h: Html.H<M>, icon: IconName) => h.span.attrs({ "aria-hidden": "true", ...sx(styles.badge) }).children(Icon(h, icon, 26))

/** The frame every page here shares: the product's mark at the top, the page's words in the middle. */
const Frame = <M>(h: Html.H<M>, brand: Brand | undefined, column: View.Children<M, never>) =>
	h.main.attrs(sx(styles.screen)).children(
		h.div.attrs(sx(styles.top)).children(brand !== undefined && BrandMark(h, brand)),
		h.div.attrs(sx(styles.column)).children(column),
	)

// ---------------------------------------------------------------------------
// StatusPage: not found, server error, maintenance, offline
// ---------------------------------------------------------------------------

export const StatusKind = Schema.Literals(["not-found", "server-error", "maintenance", "offline"])
export type StatusKind = typeof StatusKind.Type

export const StatusPageProps = Schema.Struct({
	kind: StatusKind,
	/** the product's mark and name at the top, linking home */
	brand: Schema.optional(Brand),
	homeHref: Schema.String,
	/** a server error's reference, to quote to support */
	reference: Schema.optional(Schema.String),
	/** maintenance: when it ends, formatted by the app: "2:00 PM UTC, in about 25 minutes" */
	until: Schema.optional(Schema.String),
	/** maintenance: what's being done: "We’re moving to faster databases." */
	reason: Schema.optional(Schema.String),
	statusHref: Schema.optional(Schema.String),
	supportHref: Schema.optional(Schema.String),
	/** a retry is in flight (server error, offline) */
	retrying: Schema.optional(Schema.Boolean),
})
export type StatusPageProps = typeof StatusPageProps.Type

export const StatusPageMessage = UiSchema.TaggedEnum({ ClickedRetry: {}, UpdatedQuery: { query: Schema.String }, SubmittedSearch: {} })
export const StatusPageEvents = UiSchema.TaggedEnum({ RequestedRetry: {}, RequestedSearch: { query: Schema.String } })

export const StatusPage = Html.component({
	name: "StatusPage",
	props: StatusPageProps,
	model: Schema.Struct({ query: Schema.String }),
	message: StatusPageMessage,
	events: StatusPageEvents,
}).make({
	init: () => ({ query: "" }),
	update: {
		ClickedRetry: ($) => ($.props.retrying === true ? $.model : $.emit(StatusPageEvents.RequestedRetry())),
		UpdatedQuery: ($, { query }) => $.evolve({ query }),
		SubmittedSearch: ($) => ($.model.query.trim() === "" ? $.model : $.emit(StatusPageEvents.RequestedSearch({ query: $.model.query.trim() }))),
	},
	view: (h, { query }) => {
		const props = h.props
		const home = h.a.attrs({ href: props.homeHref, ...sx(...buttonStyle({ tone: "primary", size: "lg" })) }).children("Go to home")
		const retry = (label: string) =>
			Button(h, { tone: "primary", size: "lg" })
				.attr("aria-disabled", props.retrying === true ? "true" : undefined)
				.on("click", StatusPageMessage.ClickedRetry())
				.children(Icon(h, "refresh", 16), props.retrying === true ? "Trying…" : label)
		const link = (href: string | undefined, label: string) => href !== undefined && h.a.attrs({ href, ...sx(...buttonStyle({ size: "lg", emphasis: "outline" })) }).children(label)
		const body = (() => {
			switch (props.kind) {
				case "not-found":
					return [
						Badge(h, "compass"),
						h.div.attrs(sx(styles.text)).children(
							h.p.attrs(sx(styles.code)).children("404"),
							h.h1.attrs(sx(styles.title)).children("Page not found"),
							h.p.attrs(sx(styles.lede)).children("The link may be broken, or the page was moved or deleted. Search for it, or start from home."),
						),
						h.form.attrs({ role: "search", "aria-label": "Search the workspace", ...sx(styles.search) }).on("submit", StatusPageMessage.SubmittedSearch()).children(
							h.label.attrs({ for: "status-search", ...sx(styles.srOnly) }).children("Search the workspace"),
							Input(h).attrs({ id: "status-search", type: "search", name: "q", placeholder: "Search projects and pages" }).value(query).on("input", ({ value }) => StatusPageMessage.UpdatedQuery({ query: value })),
							Button(h, { type: "submit" }).children(Icon(h, "search", 14), "Search"),
						),
						h.div.attrs(sx(styles.actions)).children(home),
					]
				case "server-error":
					return [
						Badge(h, "alert"),
						h.div.attrs(sx(styles.text)).children(
							h.p.attrs(sx(styles.code)).children("500"),
							h.h1.attrs(sx(styles.title)).children("Something went wrong on our side"),
							h.p.attrs(sx(styles.lede)).children("It’s not you. We’ve been told and are looking into it. Try again in a moment."),
						),
						h.div.attrs(sx(styles.actions)).children(retry("Try again"), link(props.statusHref, "Status page")),
						props.reference !== undefined && h.div.attrs(sx(styles.ref)).children(
							"Reference",
							h.code.attrs(sx(styles.refCode)).children(props.reference),
							CopyButton(h, { props: { value: props.reference, label: "Copy", accessibleName: "Copy error reference" } }),
						),
						props.supportHref !== undefined && h.p.attrs(sx(styles.note)).children("Still broken? ", h.a.attrs({ href: props.supportHref }).children("Contact support"), " and include the reference."),
					]
				case "maintenance":
					return [
						Badge(h, "wrench"),
						h.div.attrs(sx(styles.text)).children(
							h.h1.attrs(sx(styles.title)).children("Down for maintenance"),
							h.p.attrs(sx(styles.lede)).children(
								props.reason ?? "We’re making improvements.",
								" ",
								props.until === undefined ? "We’ll be back shortly." : ["We’ll be back by ", h.strong.attrs(sx(styles.strong)).children(props.until), "."],
								" Your work is saved.",
							),
						),
						h.div.attrs(sx(styles.actions)).children(link(props.statusHref, "Follow updates")),
					]
				case "offline":
					return [
						Badge(h, "offline"),
						h.div.attrs(sx(styles.text)).children(
							h.h1.attrs(sx(styles.title)).children("You’re offline"),
							h.p.attrs(sx(styles.lede)).children("Check your Wi-Fi or network. Changes you made are saved on this device and sync when you’re back."),
						),
						h.div.attrs({ role: "status", ...sx(styles.actions) }).children(retry("Try again")),
					]
			}
		})()
		return Frame(h, props.brand, body)
	},
})

// ---------------------------------------------------------------------------
// NoAccess
// ---------------------------------------------------------------------------

export const NoAccessProps = Schema.Struct({
	/** the product's mark and name at the top, linking home */
	brand: Schema.optional(Brand),
	/** what they tried to open: "Q4 roadmap" */
	resource: Schema.String,
	workspace: Schema.String,
	signedInAs: Schema.String,
	/** who decides: "Marcus Chen" */
	owner: Schema.String,
	/** they asked already, and when: "Requested 2 days ago" */
	requested: Schema.optional(Schema.NullOr(Schema.String)),
	homeHref: Schema.String,
	switchAccountHref: Schema.String,
	/** the app's answer to request `access` */
	outcome: Schema.optional(Schema.NullOr(Outcome)),
})
export type NoAccessProps = typeof NoAccessProps.Type

export const NoAccessMessage = UiSchema.TaggedEnum({ UpdatedNote: { note: Schema.String }, SubmittedRequest: {} })
export const NoAccessEvents = UiSchema.TaggedEnum({ RequestedAccess: { note: Schema.String } })

export const NoAccess = Html.component({
	name: "NoAccess",
	props: NoAccessProps,
	model: Schema.Struct({ note: Schema.String }),
	message: NoAccessMessage,
	events: NoAccessEvents,
}).make({
	init: () => ({ note: "" }),
	update: {
		UpdatedNote: ($, { note }) => $.evolve({ note }),
		SubmittedRequest: ($) => (isPending($.props.outcome) ? $.model : $.emit(NoAccessEvents.RequestedAccess({ note: $.model.note.trim() }))),
	},
	view: (h, { note }) => {
		const props = h.props
		const answer = outcomeOf(props.outcome, "access")
		const sent = answer?._tag === "Accepted" || (props.requested != null && answer === null)
		const strong = (text: string) => h.strong.attrs(sx(styles.strong)).children(text)
		return Frame(h, props.brand, [
			Badge(h, "lock"),
			h.div.attrs(sx(styles.text)).children(
				h.h1.attrs(sx(styles.title)).children(sent ? "Request sent" : `You don’t have access to ${props.resource}`),
				h.p.attrs(sx(styles.lede)).children(
					sent
						? [strong(props.owner), " will get an email. You’ll hear back when they decide.", props.requested != null && answer === null ? ` ${props.requested}.` : ""]
						: ["It belongs to ", strong(props.workspace), ". You’re signed in as ", strong(props.signedInAs), "."],
				),
			),
			!sent && h.form.attrs({ novalidate: "", "aria-label": "Request access", ...sx(styles.form) }).on("submit", NoAccessMessage.SubmittedRequest()).children(
				answer?._tag === "Refused" && FormAlert(h, { tone: "danger", text: answer.reason }),
				FormField(h, { id: "no-access-note", label: `Message to ${props.owner} (optional)` }, (attrs) =>
					Textarea(h).attrs({ ...attrs, rows: "3", maxlength: "500", placeholder: "Why you need it" }).value(note).on("input", ({ value }) => NoAccessMessage.UpdatedNote({ note: value })),
				),
				Button(h, { tone: "primary", size: "lg", type: "submit" }).attr("aria-disabled", isPending(answer) ? "true" : undefined).children(isPending(answer) ? "Sending…" : "Request access"),
			),
			h.div.attrs(sx(styles.actions)).children(
				h.a.attrs({ href: props.homeHref, ...sx(...buttonStyle({ emphasis: "ghost" })) }).children("Go to home"),
				h.a.attrs({ href: props.switchAccountHref, ...sx(...buttonStyle({ emphasis: "ghost" })) }).children("Switch account"),
			),
		])
	},
})
```

```ts title="src/blocks/saas/AuthFrame.ts"
import type { View } from "effect/ui"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { Mark } from "../../Glyph.ts"
import { type Style, sx } from "../../Sx.ts"
import { color, corner, elevation, font, motion, space, stroke, density } from "../../tokens.stylex.ts"
import { Icon, type IconName } from "./Icons.ts"

// The frame every sign-in screen shares: the product's mark above a card, and the legal line under
// it. With an `aside` it splits: the form on one side, a customer's words or a product picture on
// the other, which folds away on narrow screens so the form always comes first.

/** The product a screen belongs to: its name, and one letter for its mark when there's no logo. */
export const Brand = Schema.Struct({
	name: Schema.String,
	/** one letter on the accent; the name's first letter by default */
	letter: Schema.optional(Schema.String),
	/** where the mark links: the marketing site or the app's root */
	href: Schema.optional(Schema.String),
})
export type Brand = typeof Brand.Type

/** A customer's words beside a split screen. */
export const Testimonial = Schema.Struct({
	quote: Schema.String,
	name: Schema.String,
	/** their role and company: "Head of Operations, Northwind Freight" */
	role: Schema.String,
})
export type Testimonial = typeof Testimonial.Type

/** The legal line under the card, with its two links. */
export const LegalLinks = Schema.Struct({ terms: Schema.String, privacy: Schema.String })
export type LegalLinks = typeof LegalLinks.Type

export const authStyles = stylex.create({
	screen: {
		containerType: "inline-size",
		boxSizing: "border-box",
		display: "flex",
		flexDirection: "column",
		minHeight: "100%",
		inlineSize: "100%",
		color: color.fg,
		fontFamily: font.sans,
	},
	// a container can't query itself, so the grid is the screen's child
	layout: { display: "grid", flexGrow: 1, minHeight: "100%" },
	split: {
		gridTemplateColumns: { default: "minmax(0, 1fr)", "@container (min-width: 880px)": "minmax(0, 1fr) minmax(0, 1fr)" },
	},
	column: {
		boxSizing: "border-box",
		display: "flex",
		flexDirection: "column",
		alignItems: "center",
		justifyContent: "center",
		gap: space.xxl,
		minWidth: 0,
		paddingInline: space.xl,
		paddingBlock: { default: 40, "@container (min-width: 560px)": 64 },
	},
	brand: {
		display: "inline-flex",
		alignItems: "center",
		minHeight: 40,
		gap: space.md,
		color: color.fg,
		fontSize: font.lg,
		fontWeight: 600,
		letterSpacing: "-0.01em",
		textDecoration: "none",
		borderRadius: corner.tag,
		outline: { default: "none", ":focus-visible": `2px solid ${color.focusRing}` },
		outlineOffset: 4,
	},
	card: {
		boxSizing: "border-box",
		display: "flex",
		flexDirection: "column",
		gap: space.xl,
		inlineSize: "100%",
		maxInlineSize: 400,
		padding: { default: space.xl, "@container (min-width: 440px)": 32 },
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: color.line,
		borderRadius: `calc(${corner.card} + 4px)`,
		backgroundColor: color.panel,
		boxShadow: elevation.card,
	},
	// on a phone the card's frame would only take width: the form sits on the page
	cardBare: {
		borderColor: { default: "transparent", "@container (min-width: 440px)": color.line },
		backgroundColor: { default: "transparent", "@container (min-width: 440px)": color.panel },
		boxShadow: { default: "none", "@container (min-width: 440px)": elevation.card },
		paddingInline: { default: 0, "@container (min-width: 440px)": 32 },
	},
	wide: { maxInlineSize: 480 },
	head: { display: "flex", flexDirection: "column", gap: space.sm, textAlign: "center", alignItems: "center" },
	headStart: { textAlign: "start", alignItems: "flex-start" },
	badge: {
		display: "grid",
		placeItems: "center",
		width: 44,
		height: 44,
		marginBottom: space.xs,
		borderRadius: corner.card,
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: color.line,
		backgroundColor: color.raised,
		color: color.fg,
	},
	title: { margin: 0, fontSize: font.xl, lineHeight: 1.25, fontWeight: 600, letterSpacing: "-0.02em", textWrap: "balance" },
	lede: { margin: 0, maxWidth: "40ch", fontSize: font.base, lineHeight: 1.55, color: color.muted, textWrap: "pretty", overflowWrap: "anywhere" },
	strong: { color: color.fg, fontWeight: 500 },
	form: { display: "flex", flexDirection: "column", gap: space.xl, margin: 0 },
	stack: { display: "flex", flexDirection: "column", gap: space.md },
	labelRow: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: space.md },
	or: {
		display: "flex",
		alignItems: "center",
		gap: space.lg,
		fontSize: font.sm,
		color: color.muted,
		"::before": { content: '""', flexGrow: 1, height: 1, backgroundColor: color.line },
		"::after": { content: '""', flexGrow: 1, height: 1, backgroundColor: color.line },
	},
	full: { inlineSize: "100%" },
	foot: { margin: 0, textAlign: "center", fontSize: font.sm, color: color.muted },
	legal: { margin: 0, maxWidth: 320, textAlign: "center", fontSize: font.xs, lineHeight: 1.6, color: color.muted, textWrap: "balance" },
	link: {
		padding: 0,
		borderWidth: 0,
		backgroundColor: "transparent",
		color: color.fg,
		fontFamily: "inherit",
		fontSize: "inherit",
		fontWeight: 500,
		textDecoration: "underline",
		textDecorationColor: { default: color.lineStrong, ":hover": { default: null, "@media (hover: hover) and (pointer: fine)": color.fg } },
		textUnderlineOffset: 3,
		cursor: "pointer",
		borderRadius: `calc(${corner.tag} - 4px)`,
		outline: { default: "none", ":focus-visible": `2px solid ${color.focusRing}` },
		outlineOffset: 2,
		transitionProperty: "text-decoration-color",
		transitionDuration: motion.fast,
		transitionTimingFunction: motion.ease,
	},
	quietLink: { color: color.muted, fontWeight: 400 },
	// a link or text button on its own line: a finger gets a 40px target
	tap: { display: { default: null, "@media (pointer: coarse)": "inline-flex" }, alignItems: "center", minHeight: { default: null, "@media (pointer: coarse)": density.control } },
	alert: {
		display: "flex",
		gap: space.md,
		alignItems: "flex-start",
		margin: 0,
		paddingBlock: space.md,
		paddingInline: space.lg,
		borderRadius: `calc(${corner.card} - 4px)`,
		fontSize: font.sm,
		lineHeight: 1.5,
		overflowWrap: "anywhere",
	},
	alertDanger: { color: color.danger, backgroundColor: `color-mix(in srgb, ${color.danger} 8%, ${color.panel})` },
	alertInfo: { color: color.fg, backgroundColor: color.raised },
	alertSuccess: { color: color.success, backgroundColor: `color-mix(in srgb, ${color.success} 9%, ${color.panel})` },
	alertIcon: { marginTop: 1 },
	aside: {
		display: { default: "none", "@container (min-width: 880px)": "flex" },
		flexDirection: "column",
		justifyContent: "space-between",
		gap: space.xxl,
		minWidth: 0,
		padding: 48,
		margin: space.md,
		borderRadius: `calc(${corner.card} + 4px)`,
		// dark in both themes, with a faint grid and a glow, so the words sit on something
		backgroundColor: "#141416",
		backgroundImage: "radial-gradient(60% 50% at 85% 10%, rgb(255 255 255 / 0.10), transparent 70%), linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px)",
		backgroundSize: "auto, 32px 32px, 32px 32px",
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: "rgb(255 255 255 / 0.08)",
		color: "#fafafa",
		overflow: "hidden",
		position: "relative",
	},
	asideTile: {
		display: "grid",
		placeItems: "center",
		width: 28,
		height: 28,
		borderRadius: `calc(${corner.card} - 4px)`,
		backgroundColor: "#fafafa",
		color: "#141416",
		fontSize: font.base,
		fontWeight: 700,
	},
	asideMark: { display: "inline-flex", alignItems: "center", gap: space.md, fontSize: font.lg, fontWeight: 600 },
	asidePicture: { flexGrow: 1, display: "grid", alignContent: "center" },
	quote: { margin: 0, display: "flex", flexDirection: "column", gap: space.xl },
	quoteText: { margin: 0, fontSize: 22, lineHeight: 1.45, fontWeight: 500, letterSpacing: "-0.015em", textWrap: "pretty", maxWidth: "34ch" },
	quoteWho: { display: "flex", flexDirection: "column", gap: space.xxs, fontSize: font.sm, fontStyle: "normal" },
	quoteName: { fontWeight: 600 },
	quoteRole: { opacity: 0.7 },
})

/** The product's mark and name, linked when it has an `href`. */
export const BrandMark = <M>(h: Html.H<M>, brand: Brand) => {
	const content = [Mark(h, brand.letter ?? brand.name.slice(0, 1).toUpperCase(), 28), h.span.children(brand.name)] as const
	return brand.href === undefined
		? h.div.attrs(sx(authStyles.brand)).children(...content)
		: h.a.attrs({ href: brand.href, ...sx(authStyles.brand) }).children(...content)
}

/** The legal line: "By continuing, you agree to the Terms and Privacy Policy." */
export const LegalLine = <M>(h: Html.H<M>, legal: LegalLinks) =>
	h.p.attrs(sx(authStyles.legal)).children(
		"By continuing, you agree to the ",
		h.a.attrs({ href: legal.terms, ...sx(authStyles.link, authStyles.quietLink) }).children("Terms"),
		" and ",
		h.a.attrs({ href: legal.privacy, ...sx(authStyles.link, authStyles.quietLink) }).children("Privacy Policy"),
		".",
	)

/** The quote panel of a split screen. */
const TestimonialPanel = <M>(h: Html.H<M>, brand: Brand, testimonial: Testimonial) =>
	h.aside.attrs({ "aria-label": "What customers say", ...sx(authStyles.aside) }).children(
		h.div.attrs(sx(authStyles.asideMark)).children(h.span.attrs({ "aria-hidden": "true", ...sx(authStyles.asideTile) }).children(brand.letter ?? brand.name.slice(0, 1).toUpperCase()), brand.name),
		h.figure.attrs(sx(authStyles.quote)).children(
			h.blockquote.attrs(sx(authStyles.quoteText)).children(`“${testimonial.quote}”`),
			h.figcaption.attrs(sx(authStyles.quoteWho)).children(
				h.span.attrs(sx(authStyles.quoteName)).children(testimonial.name),
				h.span.attrs(sx(authStyles.quoteRole)).children(testimonial.role),
			),
		),
	)

export interface AuthFrameOptions<M, C extends View.Children<M>> {
	readonly brand: Brand
	/** the legal line under the card */
	readonly legal?: LegalLinks | undefined
	/** splits the screen: a customer's words beside the form */
	readonly testimonial?: Testimonial | undefined
	/** a wider card, for codes and lists */
	readonly wide?: boolean
	/** what sits under the card, before the legal line: "No account? Sign up" */
	readonly footer?: View.Input<M, never>
	/** the card's content */
	readonly children: C
	readonly style?: Style
}

/** A sign-in screen: the mark, the card and the legal line, centered; split when there's a testimonial. */
export const AuthFrame = <M, C extends View.Children<M>>(h: Html.H<M>, options: AuthFrameOptions<M, C>) => {
	const split = options.testimonial !== undefined
	return h.main.attrs(sx(authStyles.screen, options.style)).children(
		h.div.attrs(sx(authStyles.layout, split && authStyles.split)).children(
			h.div.attrs(sx(authStyles.column)).children(
				BrandMark(h, options.brand),
				h.div.attrs(sx(authStyles.card, authStyles.cardBare, options.wide === true && authStyles.wide)).children(options.children),
				options.footer,
				options.legal !== undefined && LegalLine(h, options.legal),
			),
			options.testimonial !== undefined && TestimonialPanel(h, options.brand, options.testimonial),
		),
	)
}

/** The card's title and a sentence under it, with an optional icon tile above. */
export const AuthHeader = <M>(
	h: Html.H<M>,
	options: {
		readonly title: string
		readonly lede?: View.Input<M, never>
		readonly icon?: IconName
		readonly id?: string
		readonly align?: "center" | "start"
	},
) =>
	h.header.attrs(sx(authStyles.head, options.align === "start" && authStyles.headStart)).children(
		options.icon !== undefined && h.span.attrs(sx(authStyles.badge)).children(Icon(h, options.icon, 22)),
		h.h1.attrs({ id: options.id, ...sx(authStyles.title) }).children(options.title),
		options.lede !== undefined && h.p.attrs(sx(authStyles.lede)).children(options.lede),
	)

/** A rule with a word in it, between two ways to do one thing. */
export const OrDivider = <M>(h: Html.H<M>, text = "or") => h.div.attrs({ role: "separator", ...sx(authStyles.or) }).children(text)

/** A message above a form: what went wrong (an alert) or what just happened (a status). */
export const FormAlert = <M>(
	h: Html.H<M>,
	options: { readonly tone: "danger" | "info" | "success"; readonly text: string; readonly id?: string },
) =>
	h.p
		.attrs({
			id: options.id,
			role: options.tone === "danger" ? "alert" : "status",
			...sx(
				authStyles.alert,
				options.tone === "danger" ? authStyles.alertDanger : options.tone === "success" ? authStyles.alertSuccess : authStyles.alertInfo,
			),
		})
		.children(
			h.span.attrs(sx(authStyles.alertIcon)).children(Icon(h, options.tone === "danger" ? "alert" : options.tone === "success" ? "check" : "info", 16)),
			h.span.children(options.text),
		)

/** A button that reads as a link: "Forgot password?", "Use a recovery code". */
export const TextButton = <M>(h: Html.H<M>, quiet = false) =>
	h.button.attrs({ type: "button", ...sx(authStyles.link, quiet && authStyles.quietLink, authStyles.tap) })

/** A link styled as the frame's links; `alone` when it isn't inside a sentence, for a bigger touch target. */
export const TextLink = <M>(h: Html.H<M>, href: string, quiet = false, alone = false) =>
	h.a.attrs({ href, ...sx(authStyles.link, quiet && authStyles.quietLink, alone && authStyles.tap) })
```
