# Hero

> Say what the product does and start a signup on the first screen, with the product and customers’ logos below.

Page: https://uicontext.com/blocks/hero

A screen in Marketing site. Preview it at https://uicontext.com/blocks/hero/preview.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/hero
```

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

## Components used

- [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.
- [Button](https://uicontext.com/docs/components/button.md) (`button`): A button, and a link that looks like one, in every tone and three sizes.

## Source

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

```ts title="src/blocks/marketing/Hero.ts"
import type { View } from "effect/ui"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { sx } from "../../Sx.ts"
import { color, font, space } from "../../tokens.stylex.ts"
import { rhythm } from "./marketing.stylex.ts"
import { type Logo, LogoRow } from "./Proof.ts"
import { type Action, Actions, sectionStyles } from "./Section.ts"

// The top of the page: what the product does in one line, who it's for in the next, and what to do
// now. Centered with the product underneath, or split with the product beside the words from 1024px
// (under it on smaller screens). An email form can stand in for the buttons, and a row of customers'
// logos can sit at its foot. The headline is the page's h1.

export interface HeroOptions<M> {
	/** the headline's id */
	readonly id?: string
	/** a line above the headline that places it: "For product teams" */
	readonly eyebrow?: string
	readonly title: string
	readonly lede: string
	readonly primary?: Action
	readonly secondary?: Action
	/** in place of the buttons: an EmailCapture */
	readonly form?: View.Content<M>
	/** a line under the buttons: "Free for up to 3 people. No card needed." */
	readonly note?: string
	/** the product: a ProductShot */
	readonly media?: View.Content<M>
	/** centered (the default), or the words beside the media */
	readonly layout?: "centered" | "split"
	/** customers' logos at the foot */
	readonly logos?: { readonly label: string; readonly logos: ReadonlyArray<Logo> }
}

const styles = stylex.create({
	root: { overflow: "hidden" },
	inner: { paddingBlockStart: `calc(${rhythm.section} * 0.85)` },
	split: {
		display: "grid",
		alignItems: "center",
		gap: { default: 40, "@container (min-width: 1024px)": 56 },
		gridTemplateColumns: { default: "minmax(0, 1fr)", "@container (min-width: 1024px)": "minmax(0, 5fr) minmax(0, 7fr)" },
	},
	copy: { display: "grid", gap: space.xxl, justifyItems: "start" },
	// beside the product the headline has half the room, so it steps down
	splitTitle: { fontSize: "clamp(2.125rem, 1.5rem + 2.6cqi, 3.5rem)" },
	copyCenter: { justifyItems: "center", textAlign: "center", marginInline: "auto", maxInlineSize: "52rem" },
	words: { display: "grid", gap: { default: space.xl, "@container (min-width: 768px)": 20 }, justifyItems: "inherit" },
	eyebrow: {
		margin: 0,
		display: "inline-flex",
		alignItems: "center",
		gap: space.sm,
		fontSize: font.sm,
		fontWeight: 550,
		color: color.muted,
	},
	dot: { inlineSize: 6, blockSize: 6, borderRadius: "50%", backgroundColor: color.brand },
	ledeCenter: { marginInline: "auto" },
	lede: { fontSize: "clamp(1.0625rem, 1rem + 0.35cqi, 1.25rem)" },
	buttons: { display: "grid", gap: space.lg, justifyItems: "inherit", inlineSize: "100%" },
	actionsFull: { inlineSize: "100%" },
	note: { margin: 0, fontSize: font.sm, color: color.muted },
	// the product sits on the page's tint from its middle down, so it reads as set on a stage
	stage: { position: "relative" },
	stageCenter: { marginBlockStart: { default: 8, "@container (min-width: 768px)": 16 } },
	// in a split hero the shot runs past the column on wide screens, as if the app goes on
	bleed: { marginInlineEnd: { default: 0, "@container (min-width: 1024px)": -96 } },
	logos: { marginBlockStart: { default: 8, "@container (min-width: 768px)": 24 } },
})

export const Hero = <M>(h: Html.H<M>, options: HeroOptions<M>) => {
	const id = options.id ?? "hero-title"
	const split = options.layout === "split"
	const center = !split
	const copy = h.div.attrs(sx(styles.copy, center && styles.copyCenter)).children(
		h.div.attrs(sx(styles.words)).children(
			options.eyebrow !== undefined && h.p.attrs(sx(styles.eyebrow)).children(h.span.attrs({ "aria-hidden": "true", ...sx(styles.dot) }), options.eyebrow),
			h.h1.attrs({ id, ...sx(sectionStyles.display, split && styles.splitTitle) }).children(options.title),
			h.p.attrs(sx(sectionStyles.lede, styles.lede, center && styles.ledeCenter)).children(options.lede),
		),
		h.div.attrs(sx(styles.buttons)).children(
			options.form ?? Actions(h, { primary: options.primary, secondary: options.secondary, center, style: split ? null : styles.actionsFull }),
			options.note !== undefined && h.p.attrs(sx(styles.note)).children(options.note),
		),
	)
	return h.section.attrs({ "aria-labelledby": id, ...sx(sectionStyles.root, styles.root) }).children(
		h.div.attrs(sx(sectionStyles.inner, styles.inner)).children(
			split
				? h.div.attrs(sx(styles.split)).children(copy, options.media !== undefined && h.div.attrs(sx(styles.stage, styles.bleed)).children(options.media))
				: [copy, options.media !== undefined && h.div.attrs(sx(styles.stage, styles.stageCenter)).children(options.media)],
			options.logos !== undefined && LogoRow(h, { ...options.logos, style: styles.logos }),
		),
	)
}
```

```ts title="src/blocks/marketing/EmailCapture.ts"
import { Component, UiSchema } from "effect/ui"
import { Html, HtmlCommand } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { Button } from "../../Button.ts"
import { Outcome } from "../../domain/Outcome.ts"
import { Input } from "../../FormControls.ts"
import { sx } from "../../Sx.ts"
import { color, corner, density, font, motion, space } from "../../tokens.stylex.ts"
import { emailProblem, isPending, outcomeOf } from "../saas/form.ts"
import { Icon } from "../saas/Icons.ts"

// One email and a button: a hero's sign-up, a newsletter, a waitlist. The field checks the address
// once a send was tried, and the app answers the `RequestedSubscribe` it emits with an Outcome: while
// it's pending the button says so and a second press does nothing; accepted, the form gives way to
// a line that says what happens next; refused, the reason shows under the field and the address
// stays to fix. On a phone the button goes under the field, at full width.

export const EmailCaptureProps = Schema.Struct({
	/** names the field for a screen reader: "Work email" */
	label: Schema.String,
	/** the button's words: "Start free", "Subscribe" */
	button: Schema.String,
	placeholder: Schema.optional(Schema.String),
	/** a line under the form: "Free for 14 days. No card needed." */
	note: Schema.optional(Schema.String),
	/** what shows once the app accepted the address; `{email}` stands for it */
	done: Schema.String,
	/** centers the form and its lines, for a centered section */
	center: Schema.optional(Schema.Boolean),
	/** the app's answer to the last `RequestedSubscribe` */
	outcome: Schema.optional(Schema.NullOr(Outcome)),
	/** the field's id, for more than one form on a page */
	id: Schema.optional(Schema.String),
})
export type EmailCaptureProps = typeof EmailCaptureProps.Type

export const EmailCaptureMessage = UiSchema.TaggedEnum({
	UpdatedEmail: { email: Schema.String },
	SubmittedForm: {},
	ClickedChangeEmail: {},
})

export const EmailCaptureEvents = UiSchema.TaggedEnum({
	/** subscribe or sign up this address; answer with an Outcome for `request` */
	RequestedSubscribe: { request: Schema.String, email: Schema.String },
})

const styles = stylex.create({
	root: { containerType: "inline-size", inlineSize: "100%", maxInlineSize: "30rem" },
	center: { marginInline: "auto", textAlign: "center" },
	form: { display: "grid", gap: space.sm },
	row: {
		display: "grid",
		gap: space.md,
		gridTemplateColumns: { default: "minmax(0, 1fr)", "@container (min-width: 360px)": "minmax(0, 1fr) auto" },
	},
	// the field and button share the marketing buttons' height
	input: { blockSize: `calc(${density.control} + 12px)`, fontSize: { default: 16, "@media (pointer: fine)": 15 }, paddingInline: space.lg, borderRadius: `calc(${corner.control} + 4px)` },
	button: { blockSize: `calc(${density.control} + 12px)`, paddingInline: 20, fontSize: 15 },
	error: { margin: 0, display: "flex", alignItems: "center", gap: space.xs, fontSize: font.sm, color: color.danger, textAlign: "start" },
	errorCenter: { justifyContent: "center" },
	note: { margin: 0, fontSize: font.sm, color: color.muted, lineHeight: 1.5 },
	done: {
		display: "flex",
		alignItems: "flex-start",
		gap: space.md,
		margin: 0,
		paddingBlock: space.lg,
		paddingInline: space.xl,
		borderRadius: corner.card,
		backgroundColor: `color-mix(in srgb, ${color.success} 10%, ${color.panel})`,
		color: color.fg,
		fontSize: font.base,
		lineHeight: 1.5,
		textAlign: "start",
		overflowWrap: "anywhere",
		opacity: { default: 1, "@starting-style": 0 },
		transitionProperty: "opacity",
		transitionDuration: motion.enter,
		transitionTimingFunction: motion.easeOut,
	},
	doneIcon: { color: color.success, marginBlockStart: 2 },
	change: {
		padding: 0,
		borderWidth: 0,
		backgroundColor: "transparent",
		color: color.fg,
		fontFamily: "inherit",
		fontSize: "inherit",
		textDecoration: "underline",
		textUnderlineOffset: 3,
		cursor: "pointer",
		borderRadius: corner.tag,
		outline: { default: "none", ":focus-visible": `2px solid ${color.focusRing}` },
		outlineOffset: 2,
	},
	srOnly: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" },
})

const Field = Html.ref("EmailCapture.email", "input")
const silent = () => Component.noop

export const EmailCapture = Html.component({
	name: "EmailCapture",
	props: EmailCaptureProps,
	model: Schema.Struct({ email: Schema.String, tried: Schema.Boolean, attempt: Schema.Number }),
	message: EmailCaptureMessage,
	events: EmailCaptureEvents,
	restore: (model) => ({ ...model, tried: false }),
}).make({
	init: () => ({ email: "", tried: false, attempt: 0 }),
	update: {
		UpdatedEmail: ($, { email }) => $.evolve({ email }),
		SubmittedForm: ($) => {
			if (isPending(outcomeOf($.props.outcome, `subscribe:${$.model.attempt}`))) return $.model
			if (emailProblem($.model.email) !== undefined) return $.evolve({ tried: true }).run(HtmlCommand.focus(Field, silent))
			const attempt = $.model.attempt + 1
			return $.evolve({ tried: true, attempt }).emit(EmailCaptureEvents.RequestedSubscribe({ request: `subscribe:${attempt}`, email: $.model.email.trim() }))
		},
		ClickedChangeEmail: ($) => $.evolve({ tried: false, attempt: (n) => n + 1 }).run(HtmlCommand.focus(Field, silent)),
	},
	view: (h, model) => {
		const props = h.props
		const id = props.id ?? "email-capture"
		const center = props.center === true
		const outcome = outcomeOf(props.outcome, `subscribe:${model.attempt}`)
		if (outcome?._tag === "Accepted") {
			const [before, after = ""] = props.done.split("{email}")
			return h.div.attrs(sx(styles.root, center && styles.center)).children(
				h.p.attrs({ role: "status", ...sx(styles.done) }).children(
					h.span.attrs(sx(styles.doneIcon)).children(Icon(h, "check", 18)),
					h.span.children(
						before,
						props.done.includes("{email}") && h.strong.children(model.email.trim()),
						after,
						" ",
						h.button.attrs({ type: "button", ...sx(styles.change) }).on("click", EmailCaptureMessage.ClickedChangeEmail()).children("Use another email"),
					),
				),
			)
		}
		const problem = model.tried ? emailProblem(model.email) : undefined
		const error = problem ?? (outcome?._tag === "Refused" ? outcome.reason : undefined)
		const pending = outcome?._tag === "Pending"
		return h.div.attrs(sx(styles.root, center && styles.center)).children(
			h.form.attrs({ novalidate: "", ...sx(styles.form) }).on("submit", EmailCaptureMessage.SubmittedForm()).children(
				h.div.attrs(sx(styles.row)).children(
					h.label.attrs({ for: id, ...sx(styles.srOnly) }).children(props.label),
					Input(h, { invalid: error !== undefined, style: styles.input })
						.ref(Field)
						.attrs({
							id,
							type: "email",
							name: "email",
							autocomplete: "email",
							spellcheck: "false",
							autocapitalize: "off",
							placeholder: props.placeholder ?? "name@company.com",
							"aria-invalid": error === undefined ? undefined : "true",
							"aria-describedby": `${id}-error${props.note === undefined ? "" : ` ${id}-note`}`,
						})
						.value(model.email)
						.on("input", ({ value }) => EmailCaptureMessage.UpdatedEmail({ email: value })),
					Button(h, { tone: "primary", size: "lg", type: "submit", style: styles.button })
						.attr("aria-disabled", pending ? "true" : undefined)
						.children(pending ? "Sending…" : props.button),
				),
				h.p.attrs({ id: `${id}-error`, role: "status", ...sx(error === undefined ? styles.srOnly : styles.error, center && styles.errorCenter) }).children(
					error !== undefined && [Icon(h, "alert", 14), error],
				),
				props.note !== undefined && h.p.attrs({ id: `${id}-note`, ...sx(styles.note) }).children(props.note),
			),
		)
	},
})
```

```ts title="src/blocks/marketing/Proof.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { Avatar } from "../../Avatar.ts"
import { type Style, sx } from "../../Sx.ts"
import { color, corner, font, space, stroke } from "../../tokens.stylex.ts"
import { Section, SectionHeader } from "./Section.ts"

// What others say and how much: customers' logos, their words, and the numbers that back them.
// Logos are pictures with their own width and height, so the row never jumps as they load; a logo
// without a picture is drawn as a plain wordmark. Quotes keep their author's name, role and company
// together, and numbers line up on their digits.

/** A customer's logo: a picture at its own size, or the name drawn as a wordmark. */
export const Logo = Schema.Struct({
	name: Schema.String,
	image: Schema.optional(Schema.Struct({ src: Schema.String, width: Schema.Number, height: Schema.Number })),
})
export type Logo = typeof Logo.Type

export const Testimonial = Schema.Struct({
	quote: Schema.String,
	name: Schema.String,
	/** "Head of Operations, Larkspur Studio" */
	role: Schema.String,
	/** a portrait's URL; initials stand in without one */
	avatar: Schema.optional(Schema.String),
})
export type Testimonial = typeof Testimonial.Type

export const Stat = Schema.Struct({
	/** the number as people say it: "38%", "2.4M", "4 hours" */
	value: Schema.String,
	label: Schema.String,
	/** a line on where the number comes from */
	detail: Schema.optional(Schema.String),
})
export type Stat = typeof Stat.Type

const styles = stylex.create({
	logoRow: {
		display: "flex",
		flexWrap: "wrap",
		alignItems: "center",
		justifyContent: "center",
		columnGap: { default: space.xxl, "@container (min-width: 768px)": 48 },
		rowGap: space.xl,
		margin: 0,
		padding: 0,
		listStyle: "none",
	},
	logoLabel: { margin: 0, fontSize: font.sm, color: color.muted, textAlign: "center" },
	logoBlock: { display: "grid", gap: space.xl },
	logo: { display: "flex", alignItems: "center", justifyContent: "center", color: color.muted, minBlockSize: 32 },
	logoImage: { display: "block", blockSize: 28, inlineSize: "auto", maxInlineSize: 140, objectFit: "contain", opacity: 0.8 },
	wordmark: { display: "inline-flex", alignItems: "center", gap: space.sm, fontSize: 17, fontWeight: 650, letterSpacing: "-0.02em", whiteSpace: "nowrap" },
	wordmarkSerif: { fontFamily: "ui-serif, Georgia, serif", fontWeight: 600, letterSpacing: "-0.01em" },
	wordmarkWide: { textTransform: "uppercase", letterSpacing: "0.08em", fontSize: 14, fontWeight: 700 },
	mark: { flexShrink: 0, fill: "currentColor" },
	logoGrid: {
		display: "grid",
		gridTemplateColumns: { default: "repeat(2, minmax(0, 1fr))", "@container (min-width: 560px)": "repeat(3, minmax(0, 1fr))", "@container (min-width: 1024px)": "repeat(6, minmax(0, 1fr))" },
		gap: 1,
		margin: 0,
		padding: 0,
		listStyle: "none",
		overflow: "hidden",
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: color.line,
		borderRadius: `calc(${corner.card} + 4px)`,
		backgroundColor: color.line,
	},
	// a phone shows the first six, three rows of two; wider screens show every logo
	logoExtra: { display: { default: "none", "@container (min-width: 560px)": "grid" } },
	logoCell: { display: "grid", placeItems: "center", blockSize: { default: 88, "@container (min-width: 768px)": 112 }, backgroundColor: color.panel, paddingInline: space.lg },
	// quotes flow in columns, so short and long ones pack without gaps
	quotes: { columnCount: { default: 1, "@container (min-width: 768px)": 2, "@container (min-width: 1024px)": 3 }, columnGap: space.xl, margin: 0, padding: 0, listStyle: "none" },
	quoteItem: { breakInside: "avoid", marginBlockEnd: space.xl },
	quoteCard: {
		display: "grid",
		gap: space.xl,
		margin: 0,
		padding: space.xxl,
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: color.line,
		borderRadius: `calc(${corner.card} + 4px)`,
		backgroundColor: color.panel,
	},
	quoteText: { margin: 0, fontSize: font.lg, lineHeight: 1.55, color: color.fg, textWrap: "pretty" },
	person: { display: "flex", alignItems: "center", gap: space.lg, minInlineSize: 0, margin: 0 },
	personText: { display: "grid", minInlineSize: 0 },
	name: { fontSize: font.base, fontWeight: 600, fontStyle: "normal", overflowWrap: "anywhere" },
	role: { fontSize: font.sm, color: color.muted, overflowWrap: "anywhere" },
	big: { display: "grid", gap: space.xxl, justifyItems: "center", textAlign: "center", maxInlineSize: "52rem", marginBlock: 0, marginInline: "auto" },
	bigText: {
		margin: 0,
		fontSize: "clamp(1.375rem, 1.05rem + 1.5cqi, 2.125rem)",
		lineHeight: 1.3,
		fontWeight: 550,
		letterSpacing: "-0.02em",
		textWrap: "balance",
	},
	bigPerson: { flexDirection: "column", gap: space.md },
	bigPersonText: { justifyItems: "center" },
	stats: {
		display: "grid",
		gridTemplateColumns: { default: "minmax(0, 1fr)", "@container (min-width: 560px)": "repeat(2, minmax(0, 1fr))", "@container (min-width: 1024px)": "repeat(4, minmax(0, 1fr))" },
		columnGap: { default: space.xl, "@container (min-width: 768px)": space.xxl },
		rowGap: { default: space.xxl, "@container (min-width: 768px)": 40 },
		margin: 0,
	},
	stat: {
		display: "flex",
		flexDirection: "column",
		gap: space.sm,
		minInlineSize: 0,
		paddingBlockStart: space.xl,
		borderBlockStartWidth: stroke.hairline,
		borderBlockStartStyle: "solid",
		borderBlockStartColor: color.lineStrong,
	},
	statValue: {
		order: -1,
		margin: 0,
		fontSize: "clamp(2rem, 1.5rem + 2.2cqi, 3.25rem)",
		lineHeight: 1,
		fontWeight: 650,
		letterSpacing: "-0.035em",
		fontVariantNumeric: "tabular-nums",
		overflowWrap: "anywhere",
	},
	statLabel: { margin: 0, fontSize: font.base, fontWeight: 600 },
	statDetail: { margin: 0, fontSize: font.sm, lineHeight: 1.5, color: color.muted, maxInlineSize: "28ch" },
})

const marks = [
	"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0z",
	"M8 0l8 8-8 8-8-8z",
	"M8 1l7.5 14H.5z",
	"M0 8a8 8 0 0 1 16 0v8H0z",
	"M0 2h16v4H0zM0 10h16v4H0z",
	"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zm0 4a4 4 0 1 0 0 8 4 4 0 0 0 0-8z",
] as const
const looks = [null, styles.wordmarkSerif, styles.wordmarkWide] as const

/** One logo: its picture, or a wordmark with a simple mark, drawn in the text color. */
export const LogoMark = <M>(h: Html.H<M>, logo: Logo, index: number) =>
	logo.image !== undefined
		? h.img.attrs({ src: logo.image.src, width: String(logo.image.width), height: String(logo.image.height), alt: logo.name, loading: "lazy", decoding: "async", ...sx(styles.logoImage) })
		: h.span.attrs({ role: "img", "aria-label": logo.name, ...sx(styles.wordmark, looks[index % looks.length]) }).children(
				h.svg.attrs({ width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", ...sx(styles.mark) }).children(h.path.attrs({ d: marks[index % marks.length]! })),
				h.span.attrs({ "aria-hidden": "true" }).children(logo.name),
			)

/** A row of logos under a short line, for a hero's foot. */
export const LogoRow = <M>(h: Html.H<M>, options: { readonly label: string; readonly logos: ReadonlyArray<Logo>; readonly style?: Style }) =>
	h.div.attrs(sx(styles.logoBlock, options.style)).children(
		h.p.attrs(sx(styles.logoLabel)).children(options.label),
		h.ul.attrs({ "aria-label": "Customers", ...sx(styles.logoRow) }).children(
			options.logos.map((logo, i) => h.li.key(logo.name).attrs(sx(styles.logo)).children(LogoMark(h, logo, i))),
		),
	)

/** Customers' logos in a ruled grid, under a heading. */
export const LogoCloud = <M>(h: Html.H<M>, options: { readonly id?: string; readonly title: string; readonly lede?: string; readonly logos: ReadonlyArray<Logo>; readonly muted?: boolean }) => {
	const id = options.id ?? "logos-title"
	return Section(h, {
		labelledBy: id,
		...(options.muted === undefined ? {} : { muted: options.muted }),
		children: [
			SectionHeader(h, { id, title: options.title, align: "center", ...(options.lede === undefined ? {} : { lede: options.lede }) }),
			h.ul.attrs({ "aria-label": "Customers", ...sx(styles.logoGrid) }).children(
				options.logos.map((logo, i) => h.li.key(logo.name).attrs(sx(styles.logoCell, styles.logo, i >= 6 && styles.logoExtra)).children(LogoMark(h, logo, i))),
			),
		],
	})
}

const Person = <M>(h: Html.H<M>, t: Testimonial, big: boolean) =>
	h.figcaption.attrs(sx(styles.person, big && styles.bigPerson)).children(
		Avatar(h, { key: t.name, id: t.name, name: t.name, size: big ? "lg" : "md", decorative: true, ...(t.avatar === undefined ? {} : { image: t.avatar }) }),
		h.span.attrs(sx(styles.personText, big && styles.bigPersonText)).children(
			h.cite.attrs(sx(styles.name)).children(t.name),
			h.span.attrs(sx(styles.role)).children(t.role),
		),
	)

/** One customer's words, large, with who said them. */
const BigQuote = <M>(h: Html.H<M>, testimonial: Testimonial) =>
	h.figure.attrs(sx(styles.big)).children(
		h.blockquote.attrs(sx(styles.bigText)).children(`“${testimonial.quote}”`),
		Person(h, testimonial, true),
	)

/**
 * Customers' words in cards that pack into one, two or three columns, with one customer's words large
 * above them when `featured` is set.
 */
export const Testimonials = <M>(h: Html.H<M>, options: { readonly id?: string; readonly eyebrow?: string; readonly title: string; readonly lede?: string; readonly featured?: Testimonial; readonly testimonials: ReadonlyArray<Testimonial>; readonly muted?: boolean }) => {
	const id = options.id ?? "testimonials-title"
	return Section(h, {
		labelledBy: id,
		...(options.muted === undefined ? {} : { muted: options.muted }),
		children: [
			SectionHeader(h, {
				id,
				title: options.title,
				align: "center",
				...(options.eyebrow === undefined ? {} : { eyebrow: options.eyebrow }),
				...(options.lede === undefined ? {} : { lede: options.lede }),
			}),
			options.featured !== undefined && BigQuote(h, options.featured),
			h.ul.attrs(sx(styles.quotes)).children(
				options.testimonials.map((t) =>
					h.li.key(t.name).attrs(sx(styles.quoteItem)).children(
						h.figure.attrs(sx(styles.quoteCard)).children(
							h.blockquote.attrs(sx(styles.quoteText)).children(`“${t.quote}”`),
							Person(h, t, false),
						),
					),
				),
			),
		],
	})
}

/** Numbers that back the claims, each with what it counts and where it comes from. */
export const Stats = <M>(h: Html.H<M>, options: { readonly id?: string; readonly eyebrow?: string; readonly title: string; readonly lede?: string; readonly stats: ReadonlyArray<Stat>; readonly muted?: boolean }) => {
	const id = options.id ?? "stats-title"
	return Section(h, {
		labelledBy: id,
		...(options.muted === undefined ? {} : { muted: options.muted }),
		children: [
			SectionHeader(h, {
				id,
				title: options.title,
				...(options.eyebrow === undefined ? {} : { eyebrow: options.eyebrow }),
				...(options.lede === undefined ? {} : { lede: options.lede }),
			}),
			h.dl.attrs(sx(styles.stats)).children(
				options.stats.map((stat) =>
					h.div.key(stat.label).attrs(sx(styles.stat)).children(
						h.dt.attrs(sx(styles.statLabel)).children(stat.label),
						h.dd.attrs(sx(styles.statValue)).children(stat.value),
						stat.detail !== undefined && h.dd.attrs(sx(styles.statDetail)).children(stat.detail),
					),
				),
			),
		],
	})
}
```

```ts title="src/blocks/marketing/Section.ts"
import { Mount, type View } from "effect/ui"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Effect, Schema, Stream } from "effect"
import { buttonStyle } from "../../Button.ts"
import { type Style, sx } from "../../Sx.ts"
import { color, corner, density, elevation, font, motion, space, stroke, typography } from "../../tokens.stylex.ts"
import { Icon } from "../saas/Icons.ts"
import { rhythm, type } from "./marketing.stylex.ts"

// What the marketing sections share: the section frame (a container, so every section lays itself
// out by its own width), a header with an optional eyebrow, links drawn as buttons, the product's
// mark, and the frame that shows a real screen of the product, scaled down.

/** A link a section offers: "Start free" to /signup. */
export const Action = Schema.Struct({ label: Schema.String, href: Schema.String })
export type Action = typeof Action.Type

/** The product's name and mark. `letter` draws the mark when there's no logo file. */
export const SiteBrand = Schema.Struct({ name: Schema.String, letter: Schema.String, href: Schema.String })
export type SiteBrand = typeof SiteBrand.Type

export const sectionStyles = stylex.create({
	root: {
		containerType: "inline-size",
		boxSizing: "border-box",
		inlineSize: "100%",
		color: color.fg,
		fontFamily: font.sans,
		backgroundColor: color.panel,
	},
	muted: { backgroundColor: color.app },
	inner: {
		boxSizing: "border-box",
		display: "grid",
		gap: rhythm.header,
		maxInlineSize: `calc(${rhythm.page} + 2 * ${rhythm.gutter})`,
		marginInline: "auto",
		paddingInline: rhythm.gutter,
		paddingBlock: rhythm.section,
	},
	header: { display: "grid", gap: space.lg, justifyItems: "start", maxInlineSize: "44rem" },
	headerCenter: { justifyItems: "center", textAlign: "center", marginInline: "auto" },
	eyebrow: { margin: 0, fontSize: font.sm, fontWeight: 600, color: color.brand, letterSpacing: "0.01em" },
	// headlines take the theme's display face and weight, so a design language carries its own voice
	title: {
		margin: 0,
		fontFamily: typography.displayFamily,
		fontSize: type.title,
		lineHeight: 1.12,
		fontWeight: typography.displayWeight,
		letterSpacing: type.tight,
		textWrap: "balance",
	},
	display: {
		margin: 0,
		fontFamily: typography.displayFamily,
		fontSize: type.display,
		lineHeight: 1.04,
		fontWeight: typography.displayWeight,
		letterSpacing: "-0.035em",
		textWrap: "balance",
	},
	lede: {
		margin: 0,
		maxInlineSize: "38rem",
		fontSize: type.lede,
		lineHeight: 1.55,
		color: color.muted,
		textWrap: "pretty",
	},
	heading: { margin: 0, fontSize: type.heading, lineHeight: 1.3, fontWeight: 600, letterSpacing: "-0.015em", textWrap: "balance" },
	body: { margin: 0, fontSize: font.base, lineHeight: 1.6, color: color.muted, textWrap: "pretty" },
	actions: { display: "flex", flexWrap: "wrap", gap: space.lg, alignItems: "center" },
	actionsCenter: { justifyContent: "center" },
	// marketing buttons sit a step above the app's largest, and stretch to the width on a phone
	action: {
		height: `calc(${density.control} + 12px)`,
		paddingInline: 20,
		fontSize: 15,
		textDecoration: "none",
		flexGrow: { default: 1, "@container (min-width: 560px)": 0 },
	},
	list: { margin: 0, padding: 0, listStyle: "none" },
	srOnly: { position: "absolute", width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)", whiteSpace: "nowrap" },
	focus: { outline: { default: "none", ":focus-visible": `2px solid ${color.focusRing}` }, outlineOffset: 2, borderRadius: corner.tag },
	textLink: {
		display: "inline-flex",
		alignItems: "center",
		gap: space.xs,
		minBlockSize: { default: null, "@media (pointer: coarse)": density.control },
		fontSize: font.base,
		fontWeight: 550,
		color: color.brand,
		textDecoration: { default: "none", ":hover": { default: null, "@media (hover: hover) and (pointer: fine)": "underline" } },
		textUnderlineOffset: 4,
		textDecorationThickness: 1,
	},
	arrow: {
		display: "inline-flex",
		transitionProperty: "transform",
		transitionDuration: motion.fast,
		transitionTimingFunction: motion.easeOut,
		transform: {
			default: null,
			":is(:hover > *)": { default: null, "@media (hover: hover) and (pointer: fine)": `translateX(${motion.shift})` },
		},
	},
	arrowFlip: { display: "inline-flex", transform: { default: null, ":dir(rtl)": "scaleX(-1)" } },
	brand: {
		display: "inline-flex",
		alignItems: "center",
		gap: space.md,
		minBlockSize: 40,
		color: color.fg,
		textDecoration: "none",
		fontSize: font.lg,
		fontWeight: 650,
		letterSpacing: "-0.02em",
		whiteSpace: "nowrap",
	},
	mark: {
		display: "grid",
		placeItems: "center",
		flexShrink: 0,
		inlineSize: 28,
		blockSize: 28,
		borderRadius: corner.control,
		backgroundColor: color.fg,
		color: color.panel,
		fontSize: font.base,
		fontWeight: 700,
		letterSpacing: 0,
	},
})

// a shot in a narrow frame (a phone's) shows the screen's first 520 by 420px, so its text stays legible
const roomy = "@container (min-width: 560px)"
const cropWidth = 520
const cropHeight = 420

const shotStyles = stylex.create({
	frame: {
		position: "relative",
		containerType: "inline-size",
		overflow: "hidden",
		inlineSize: "100%",
		borderWidth: stroke.hairline,
		borderStyle: "solid",
		borderColor: color.lineStrong,
		borderRadius: { default: corner.card, "@container (min-width: 768px)": `calc(${corner.card} + 4px)` },
		backgroundColor: color.app,
		boxShadow: elevation.menu,
		// the screen's own type, whatever the section sets
		fontSize: font.base,
		lineHeight: "normal",
		textAlign: "start",
	},
	bare: { boxShadow: "none", borderRadius: corner.card },
	// a tall screen is cut at the size's height; a short one keeps its own
	clip: { overflow: "hidden" },
	clipDesktop: { maxBlockSize: { default: `calc(100cqi * ${cropHeight} / ${cropWidth})`, [roomy]: "calc(100cqi * 800 / 1280)" } },
	clipLaptop: { maxBlockSize: { default: `calc(100cqi * ${cropHeight} / ${cropWidth})`, [roomy]: "calc(100cqi * 720 / 1024)" } },
	clipTablet: { maxBlockSize: { default: `calc(100cqi * ${cropHeight} / ${cropWidth})`, [roomy]: "calc(100cqi * 680 / 820)" } },
	// the screen laid out at the width it was designed for, then zoomed to the frame: 100cqi over
	// that width. Zoom, unlike a transform, shrinks its box too, so the frame fits the screen. In a
	// frame narrower than 560px the whole screen would shrink past reading, so the frame shows its
	// start instead, at a scale that keeps its text legible. Not every engine divides lengths this way
	// (Safari 26 drops it), so FitScreen measures the frame and sets the zoom the same way.
	screen: { pointerEvents: "none", userSelect: "none" },
	screenDesktop: { inlineSize: 1280, zoom: { default: `tan(atan2(100cqi, ${cropWidth}px))`, [roomy]: "tan(atan2(100cqi, 1280px))" } },
	screenLaptop: { inlineSize: 1024, zoom: { default: `tan(atan2(100cqi, ${cropWidth}px))`, [roomy]: "tan(atan2(100cqi, 1024px))" } },
	screenTablet: { inlineSize: 820, zoom: { default: `tan(atan2(100cqi, ${cropWidth}px))`, [roomy]: "tan(atan2(100cqi, 820px))" } },
})

export type ShotSize = "desktop" | "laptop" | "tablet"

const designWidth = { desktop: 1280, laptop: 1024, tablet: 820 } as const

/** Zooms the screen to its frame: the frame's width over the width the screen was designed at. */
const FitScreen = Mount.makeStream("ProductShot.FitScreen", { args: { width: Schema.Number } }, (node: HTMLElement, args) =>
	Stream.callback<never>(() =>
		Effect.acquireRelease(
			Effect.sync(() => {
				const frame = node.parentElement
				if (frame === null) return () => undefined
				// only a change in width rezooms: the zoom changes the frame's height, which would call this again
				let width = -1
				const sized = new ResizeObserver(([entry]) => {
					if (entry === undefined || entry.contentRect.width === width) return
					width = entry.contentRect.width
					// as the styles above: under 560px the frame shows the screen's start, 520px of it
					node.style.zoom = String(width / (width < 560 ? cropWidth : args.width))
				})
				sized.observe(frame)
				return () => sized.disconnect()
			}),
			(cleanup) => Effect.sync(cleanup),
		),
	),
)

const screenSize = { desktop: shotStyles.screenDesktop, laptop: shotStyles.screenLaptop, tablet: shotStyles.screenTablet }
const clipSize = { desktop: shotStyles.clipDesktop, laptop: shotStyles.clipLaptop, tablet: shotStyles.clipTablet }

export interface ProductShotOptions<M, C extends View.Input<M>> {
	/** What the picture shows, read in place of the screen: "The issue list, with a filter applied". */
	readonly label: string
	/**
	 * The width the screen is laid out at before it's scaled to fit, and the most of its height that
	 * shows: `desktop` 1280 by 800 (by default), `laptop` 1024 by 720, `tablet` 820 by 680. Its
	 * layout is the one people see at that size.
	 */
	readonly size?: ShotSize
	/** No shadow, for a shot inside a card. */
	readonly bare?: boolean
	/** The screen: a live component, or an image with its width and height. */
	readonly children: C
	readonly style?: Style
}

/**
 * A screen of the product at the size it was designed for, scaled down to the frame's width, so a
 * hero or a feature shows the real thing at any width. The screen can't be focused or clicked, and
 * is read as one picture by its label.
 */
export const ProductShot = <M, C extends View.Input<M>>(h: Html.H<M>, options: ProductShotOptions<M, C>) => {
	const size = options.size ?? "desktop"
	return h.div.attrs({ role: "img", "aria-label": options.label, ...sx(shotStyles.frame, options.bare === true && shotStyles.bare, options.style) }).children(
		h.div.attrs(sx(shotStyles.clip, clipSize[size])).children(
			h.div.attrs({ inert: "", "aria-hidden": "true", ...sx(shotStyles.screen, screenSize[size]) }).onMount(FitScreen({ width: designWidth[size] })).children(options.children),
		),
	)
}

export interface SectionOptions<M, C extends View.Input<M>> {
	/** The id of the heading that names the section. */
	readonly labelledBy?: string
	/** The section's name, when it has no heading of its own. */
	readonly label?: string
	/** The page's background in place of the panel's, to set one section apart from the next. */
	readonly muted?: boolean
	readonly id?: string
	readonly children: C
	/** StyleX styles for the section. */
	readonly style?: Style
	/** StyleX styles for the column inside it. */
	readonly innerStyle?: Style
}

/** A page section: a container with the page's gutters and the space above and below. */
export const Section = <M, C extends View.Input<M>>(h: Html.H<M>, options: SectionOptions<M, C>) =>
	h.section
		.attrs({
			id: options.id,
			"aria-labelledby": options.labelledBy,
			"aria-label": options.labelledBy === undefined ? options.label : undefined,
			...sx(sectionStyles.root, options.muted === true && sectionStyles.muted, options.style),
		})
		.children(h.div.attrs(sx(sectionStyles.inner, options.innerStyle)).children(options.children))

export interface SectionHeaderOptions<M> {
	/** The heading's id, which the section points at. */
	readonly id: string
	/** A short line above the headline that says what part of the product this is: "Automations". */
	readonly eyebrow?: string
	readonly title: string
	readonly lede?: string
	/** Centered, or at the start; at the start by default. */
	readonly align?: "start" | "center"
	/** 1 for the page's headline (a hero), 2 by default. */
	readonly level?: 1 | 2
	/** Links under the lede. */
	readonly actions?: View.Content<M> | null
	readonly style?: Style
}

export const SectionHeader = <M>(h: Html.H<M>, options: SectionHeaderOptions<M>) => {
	const center = options.align === "center"
	const heading = options.level === 1 ? h.h1 : h.h2
	return h.header.attrs(sx(sectionStyles.header, center && sectionStyles.headerCenter, options.style)).children(
		options.eyebrow !== undefined && h.p.attrs(sx(sectionStyles.eyebrow)).children(options.eyebrow),
		heading.attrs({ id: options.id, ...sx(options.level === 1 ? sectionStyles.display : sectionStyles.title) }).children(options.title),
		options.lede !== undefined && h.p.attrs(sx(sectionStyles.lede)).children(options.lede),
		options.actions,
	)
}

/** A link drawn as a large button: the section's call to action. */
export const ActionLink = <M>(h: Html.H<M>, action: Action, options: { readonly primary?: boolean; readonly style?: Style } = {}) =>
	h.a
		.attrs({
			href: action.href,
			...sx(...buttonStyle({ size: "lg", tone: options.primary === true ? "primary" : "neutral" }), sectionStyles.action, options.style),
		})
		.children(action.label)

/** One or two links as buttons, the main one first. */
export const Actions = <M>(h: Html.H<M>, options: { readonly primary?: Action | undefined; readonly secondary?: Action | undefined; readonly center?: boolean; readonly style?: Style }) =>
	options.primary === undefined && options.secondary === undefined
		? null
		: h.div.attrs(sx(sectionStyles.actions, options.center === true && sectionStyles.actionsCenter, options.style)).children(
				options.primary !== undefined && ActionLink(h, options.primary, { primary: true }),
				options.secondary !== undefined && ActionLink(h, options.secondary),
			)

/** "Read the changelog →": a link in a sentence's place. */
export const ArrowLink = <M>(h: Html.H<M>, action: Action, style?: Style) =>
	h.a.attrs({ href: action.href, ...sx(sectionStyles.textLink, sectionStyles.focus, style) }).children(
		action.label,
		h.span.attrs(sx(sectionStyles.arrow)).children(h.span.attrs(sx(sectionStyles.arrowFlip)).children(Icon(h, "arrowRight", 16))),
	)

/** The product's mark and name, linking home. */
export const BrandLink = <M>(h: Html.H<M>, brand: SiteBrand, style?: Style) =>
	h.a.attrs({ href: brand.href, ...sx(sectionStyles.brand, sectionStyles.focus, style) }).children(
		h.span.attrs({ "aria-hidden": "true", ...sx(sectionStyles.mark) }).children(brand.letter),
		brand.name,
	)
```
