Two Step Order 2
Takes a free-plus-shipping book order in two steps. A sunlit photo breaks into the order card, and a receipt reads the free book plus shipping at a glance. Step 1 then folds into one editable line above payment, the add-on and the order button.
Use it in a prompt
Use checkout/two-step-order-2 from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/checkout/two-step-order-2.tsx. - Import it and pass your copy and images (Props tab):
import { TwoStepOrder2 } from "@/components/funneldna/checkout/two-step-order-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/checkout/two-step-order-2/component.tsx 1002 lines
// layout: ledger-receipt
// Takes a free-plus-shipping book order in two steps. A sunlit photo breaks into the order card, and a receipt reads the free book plus shipping at a glance. Step 1 then folds into one editable line above payment, the add-on and the order button.
// Theme notes: official payment-network SVG marks (Visa, Mastercard, American Express, Discover) keep their brand colours (theme-contract mark exception). Solid status badges draw a white glyph through --status-glyph. The add-on box reads --bump, --bump-strip and --bump-ink.
'use client'
import * as React from 'react'
import { AlertCircle, BookOpen, CalendarDays, Check, CreditCard, Headphones, Loader2, Lock, Mail, MapPin, ShieldCheck, Truck, User, type LucideIcon } from 'lucide-react'
import { AmericanExpress, Discover, Mastercard, Visa } from 'react-svg-credit-card-payment-icons/icons/flat-rounded'
export type BookOrderField = {
/** Key in the submitted values; also picks the field icon and the default placeholder. */
name: string
label: string
type?: string
autoComplete?: string
/** Realistic example answer; known field names fall back to a built-in example. */
placeholder?: string
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode']
/** Columns out of 12 on wider screens (default 12). */
span?: number
/** Columns out of 12 on phones (default 12). */
spanPhone?: number
}
/** One step tab: a short label and a line under it (the line hides on phones). */
export type BookOrderStep = { label: string; sub?: string }
export type BookOrderBump = {
/** Strip line beside the checkbox; {price} is replaced with the add-on price. */
label: string
/** {price} is replaced with the add-on price. */
body?: string
/** Supplied add-on price, shown as given and added to the total when ticked. */
price: string
/** Receipt line shown when the add-on is ticked. */
summaryLabel?: string
/** Add-on cut-out on a transparent background (slot: item-1). */
image?: string
imageAlt?: string
}
export type CardMark = 'visa' | 'mastercard' | 'amex' | 'discover'
export type TwoStepOrder2State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
const COPY = {
stepsLabel: 'Checkout steps',
stepPrefix: 'Step {n}: ',
doneSuffix: ', done',
lockedSuffix: ', finish step 1 first',
ledgerLabel: 'Your order',
free: 'FREE',
retailNote: 'Retail {price}, covered by us',
totalLabel: 'Total today',
totalNote: 'one-time payment',
summary: 'Shipping to {who}',
summaryEmpty: 'Shipping details saved',
editLabel: 'Edit',
editAria: 'Edit shipping details',
weAccept: 'We accept',
cardNames: { visa: 'Visa', mastercard: 'Mastercard', amex: 'American Express', discover: 'Discover' } as Record<CardMark, string>,
bumpAdded: 'Added to your order. Your total is now {total}.',
bumpRemoved: 'Removed from your order. Your total is now {total}.',
addOnFallback: 'Add-on',
loading: 'Processing your order…',
completeNote: 'Fill in every field to continue.',
alert: 'Please fix {count} {fields} to continue.',
fieldWord: 'field',
fieldsWord: 'fields',
required: 'Enter your {label}.',
email: 'Enter a valid email address, like you@example.com.',
card: 'Enter the full number on your card.',
expiry: 'Enter the expiry as MM / YY.',
cvc: 'Enter the 3 or 4 digit code on your card.',
submitError: 'We couldn’t complete your order. Please try again.',
}
export type TwoStepOrder2Copy = typeof COPY
export type TwoStepOrder2Props = {
productName?: string
/** Small line under the book in the receipt. */
productNote?: string
/** Real retail price, shown as the amount the seller covers. Omit when there is none. */
retailPrice?: string
/** Supplied shipping cost; always visible and used for the total. */
shipping?: string
shippingLabel?: string
/** Book cut-out on a transparent background (slot: product). */
productImage?: string
productImageAlt?: string
/** Full-bleed lifestyle photo across the top (slot: scene). */
sceneImage?: string
sceneImageAlt?: string
/** object-position of the photo, so the book stays above the card. */
scenePosition?: string
/** {shipping} and {product} are replaced. */
headline?: string
/** Phrase inside the headline set in the accent colour. */
highlight?: string
/** {product} and {shipping} are replaced. */
lead?: string
/** Accent-coloured mid-copy subhead. Empty hides it. */
whyHeading?: string
whyBody?: string
steps?: [BookOrderStep, BookOrderStep]
/** Step 1 fields: name, email and shipping address. */
fields?: BookOrderField[]
/** Step 2 card fields. */
paymentFields?: BookOrderField[]
/** {shipping} and {product} are replaced. */
step1Heading?: string
/** {shipping} and {product} are replaced. */
step2Heading?: string
nextLabel?: string
/** Line under the step 1 button; {shipping} is replaced. */
nextNote?: string
/** Question asked right above the order button, which answers it. Empty hides it. */
question?: string
/** {total} and {shipping} are replaced. */
orderLabel?: string
/** Line under the order button with a lock; {total} and {shipping} are replaced. */
orderNote?: string
backLabel?: string
/** Optional add-on, always unchecked at first. Supply it only with a real price. */
bump?: BookOrderBump | null
/** Guarantee line under the order button. Null hides it. */
guarantee?: string | null
acceptedCards?: CardMark[]
/** ISO currency code used to format the total. */
currency?: string
/** Interface copy. Templates replace {n}, {price}, {who}, {total}, {count}, {fields} and {label} as text. */
copy?: Partial<TwoStepOrder2Copy>
/** active opens step 2 (payment), hover previews the button hover, error shows step 1 with inline errors, disabled locks every control. */
state?: TwoStepOrder2State
initialStep?: 1 | 2
/** Prefilled values keyed by field name. */
defaultValues?: Record<string, string>
/** Locks every control, same as state disabled. */
disabled?: boolean
/** Keeps the step 1 button disabled until every field has a value. */
requireComplete?: boolean
/** Called with the validated step 1 values when the buyer moves to payment. */
onContinue?: (values: Readonly<Record<string, string>>) => void
/** Receives validated values and the add-on choice; never sends data or charges money itself. A returned promise shows the processing label; a rejection shows copy.submitError. */
onSubmit?: (values: Readonly<Record<string, string>>, bumpSelected: boolean) => void | Promise<void>
className?: string
}
export function TwoStepOrder2({
productName = 'The Quiet Kitchen',
productNote = 'Hardcover edition',
retailPrice,
shipping = '$7.95',
shippingLabel = 'Shipping & handling',
productImage,
productImageAlt = 'The Quiet Kitchen hardcover cookbook',
sceneImage,
sceneImageAlt = 'The Quiet Kitchen hardcover on a sunlit kitchen table',
scenePosition = '50% 45%',
headline = 'The book is free. You just pay {shipping} shipping.',
highlight = 'free',
lead = 'We cover your hardcover copy of {product}. You cover the postage, and it ships straight to your door.',
whyHeading = 'Why is the book free?',
whyBody = 'Because we’d rather see it open on your counter than sitting on our shelf. We cover the book. Your shipping covers the box, the postage and the packing.',
steps = DEFAULT_STEPS,
fields = SHIPPING_FIELDS,
paymentFields = PAYMENT_FIELDS,
step1Heading = 'Where should we send your copy?',
step2Heading = 'Last step: cover the {shipping} shipping',
nextLabel = 'Ship My Free Copy Here',
nextNote = 'Next, you cover {shipping} shipping. The book is on us.',
question = 'Ready for quieter weeknight dinners?',
orderLabel = 'Yes, Send Me The Book',
orderNote = '{total} today · Secure checkout',
backLabel = 'Back',
bump = null,
guarantee = null,
acceptedCards = ALL_CARDS,
currency = 'USD',
copy: copyOverrides,
state,
initialStep = 1,
defaultValues,
disabled: disabledProp = false,
requireComplete = false,
onContinue,
onSubmit,
className = '',
}: TwoStepOrder2Props) {
const copy: TwoStepOrder2Copy = { ...COPY, ...defined<TwoStepOrder2Copy>(copyOverrides) }
const uid = 'tso2' + React.useId().replace(/[^a-zA-Z0-9]/g, '')
const disabled = state === 'disabled' || disabledProp
const startStep: 1 | 2 = state === 'active' ? 2 : state === 'error' ? 1 : initialStep
const [step, setStep] = React.useState<1 | 2>(startStep)
const [values, setValues] = React.useState<Record<string, string>>(() => ({ ...(defaultValues ?? {}) }))
const [errors, setErrors] = React.useState<Record<string, string>>(() => (state === 'error' ? validate(fields, defaultValues ?? {}, copy) : {}))
const [alertOn, setAlertOn] = React.useState(state === 'error')
const [bumpOn, setBumpOn] = React.useState(false)
const [busy, setBusy] = React.useState(false)
const [submitFailed, setSubmitFailed] = React.useState(false)
const [foldFrom, setFoldFrom] = React.useState<number | null>(null)
const [announce, setAnnounce] = React.useState('')
const run = React.useRef(0)
const frame = React.useRef<number | undefined>(undefined)
const moved = React.useRef(false)
const seenState = React.useRef(state)
const formRef = React.useRef<HTMLFormElement>(null)
const cellRef = React.useRef<HTMLDivElement>(null)
const step1Ref = React.useRef<HTMLDivElement>(null)
const headRef = React.useRef<HTMLHeadingElement>(null)
const locked = disabled || busy
React.useEffect(
() => () => {
run.current++
if (frame.current !== undefined) cancelAnimationFrame(frame.current)
},
[]
)
React.useEffect(() => {
if (seenState.current === state) return
seenState.current = state
run.current++
moved.current = false
const next: 1 | 2 = state === 'active' ? 2 : state === 'error' ? 1 : initialStep
const prefill = { ...(defaultValues ?? {}) }
setStep(next)
setValues(prefill)
setErrors(state === 'error' ? validate(fields, prefill, copy) : {})
setAlertOn(state === 'error')
setBusy(false)
setSubmitFailed(false)
setFoldFrom(null)
setBumpOn(false)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
React.useEffect(() => {
if (!moved.current) return
moved.current = false
const reduce = typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
const cell = cellRef.current
if (cell && cell.getBoundingClientRect().top < 0) cell.scrollIntoView({ behavior: reduce ? 'auto' : 'smooth', block: 'start' })
headRef.current?.focus({ preventScroll: true })
}, [step])
const shipAmt = toNum(shipping)
const bumpAmt = bump ? toNum(bump.price) : 0
const total = shipAmt + (bump && bumpOn ? bumpAmt : 0)
const totalText = money(total, currency)
const totalParts = moneyParts(total, currency)
const step1Filled = fields.every((f) => (values[f.name] ?? '').trim() !== '')
const nextDisabled = locked || (requireComplete && !step1Filled)
const stepFields = step === 1 ? fields : paymentFields
const stepErrorCount = stepFields.filter((f) => errors[f.name]).length
const first = (values.name ?? '').trim().split(' ').filter(Boolean)[0] ?? ''
const place = [values.city, values.state].map((v) => (v ?? '').trim()).filter(Boolean).join(' ')
const who = [first, place].filter(Boolean).join(', ')
const summaryText = who ? fill(copy.summary, { who }) : copy.summaryEmpty
const bookNote = [productNote, retailPrice ? fill(copy.retailNote, { price: retailPrice }) : ''].filter(Boolean).join(' · ')
const focusFirst = (errs: Record<string, string>, list: BookOrderField[]) => {
const target = list.find((f) => errs[f.name])
if (!target) return
if (frame.current !== undefined) cancelAnimationFrame(frame.current)
frame.current = requestAnimationFrame(() => {
const el = formRef.current?.elements.namedItem(target.name)
if (el instanceof HTMLInputElement) el.focus()
})
}
const setField = (f: BookOrderField, raw: string) => {
const next = shape(kindOf(f), raw)
setValues((prev) => ({ ...prev, [f.name]: next }))
if (errors[f.name]) setErrors((prev) => withError(prev, f.name, validateField(f, next, copy)))
}
const blurField = (f: BookOrderField) => {
if (locked) return
setErrors((prev) => withError(prev, f.name, validateField(f, values[f.name], copy)))
}
const toPayment = () => {
if (locked) return
const errs = validate(fields, values, copy)
setErrors(errs)
if (Object.keys(errs).length) {
setAlertOn(true)
focusFirst(errs, fields)
return
}
setAlertOn(false)
setFoldFrom(step1Ref.current ? step1Ref.current.offsetHeight : null)
moved.current = true
setStep(2)
onContinue?.(pick(values, fields))
}
const toShipping = () => {
if (locked) return
setErrors({})
setAlertOn(false)
setSubmitFailed(false)
setFoldFrom(null)
moved.current = true
setStep(1)
}
const toggleBump = () => {
if (!bump || locked) return
const on = !bumpOn
setBumpOn(on)
setAnnounce(fill(on ? copy.bumpAdded : copy.bumpRemoved, { total: money(shipAmt + (on ? bumpAmt : 0), currency) }))
}
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (locked) return
if (step === 1) {
if (!nextDisabled) toPayment()
return
}
const errs = validate(paymentFields, values, copy)
setErrors(errs)
if (Object.keys(errs).length) {
setAlertOn(true)
focusFirst(errs, paymentFields)
return
}
setAlertOn(false)
setSubmitFailed(false)
if (!onSubmit) return
const id = ++run.current
try {
const result = onSubmit(pick(values, [...fields, ...paymentFields]), Boolean(bump && bumpOn))
if (result && typeof (result as Promise<void>).then === 'function') {
setBusy(true)
await result
if (id === run.current) setBusy(false)
}
} catch {
if (id === run.current) {
setBusy(false)
setSubmitFailed(true)
}
}
}
const renderField = (f: BookOrderField) => {
const id = uid + '-' + safeId(f.name)
const errId = id + '-err'
const err = errors[f.name]
const kind = kindOf(f)
const Icon = FIELD_ICONS[f.name] ?? (kind === 'email' ? Mail : undefined)
return (
<div key={f.name} className='tso2-field' style={{ '--span': String(f.span ?? 12), '--span-sm': String(f.spanPhone ?? 12) } as React.CSSProperties}>
<label htmlFor={id}>{f.label}</label>
<div className={'tso2-control' + (Icon ? ' has-icon' : '')}>
{Icon ? <Icon className='tso2-ficon' strokeWidth={2.5} aria-hidden='true' /> : null}
<input
id={id}
name={f.name}
className='tso2-input'
type={f.type ?? 'text'}
autoComplete={f.autoComplete}
inputMode={f.inputMode}
placeholder={f.placeholder ?? PLACEHOLDERS[f.name] ?? 'Type your answer'}
value={values[f.name] ?? ''}
onChange={(e) => setField(f, e.target.value)}
onBlur={() => blurField(f)}
disabled={locked}
required
aria-invalid={err ? true : undefined}
aria-describedby={err ? errId : undefined}
/>
</div>
{err ? (
<p className='tso2-err' id={errId}>
<AlertCircle className='tso2-inl' strokeWidth={2.5} aria-hidden='true' />
{err}
</p>
) : null}
</div>
)
}
const alertBox =
alertOn && stepErrorCount > 0 ? (
<p className='tso2-alert' role='alert'>
<AlertCircle className='tso2-inl' strokeWidth={2.5} aria-hidden='true' />
{fill(copy.alert, { count: String(stepErrorCount), fields: stepErrorCount === 1 ? copy.fieldWord : copy.fieldsWord })}
</p>
) : null
const bumpBox = bump ? (
<div className={'tso2-bump' + (bumpOn ? ' is-on' : '')}>
<label className='tso2-bump-strip' htmlFor={uid + '-bump'}>
<input
id={uid + '-bump'}
type='checkbox'
className='tso2-bump-input'
checked={bumpOn}
onChange={toggleBump}
disabled={locked}
aria-describedby={bump.body ? uid + '-bumpd' : undefined}
/>
<span className='tso2-box' aria-hidden='true'>
<Check strokeWidth={3} />
</span>
<span className='tso2-bump-label'>{fill(bump.label, { price: bump.price })}</span>
</label>
{bump.body || bump.image ? (
<div className={'tso2-bump-body' + (bump.image ? '' : ' no-img')}>
{bump.image ? <img src={bump.image} alt={bump.imageAlt ?? ''} width={72} height={72} loading='lazy' decoding='async' /> : null}
{bump.body ? <p id={uid + '-bumpd'}>{fill(bump.body, { price: bump.price })}</p> : null}
</div>
) : null}
</div>
) : null
return (
<section className={'cf-two-step-order-2' + (state === 'hover' ? ' is-hover' : '') + (className ? ' ' + className : '')} aria-labelledby={uid + '-h'}>
<style dangerouslySetInnerHTML={{ __html: CSS }} />
<div className='tso2-photo'>
{sceneImage ? <img src={sceneImage} alt={sceneImageAlt} width={1536} height={1024} decoding='async' style={{ objectPosition: scenePosition }} /> : null}
</div>
<div className='tso2-wrap'>
<div className='tso2-card'>
<div className='tso2-offer'>
<h2 className='tso2-h' id={uid + '-h'}>
{emphasise(fill(headline, { shipping, product: productName }), highlight)}
</h2>
{lead ? <p className='tso2-lead'>{fill(lead, { product: productName, shipping })}</p> : null}
<div className='tso2-receipt'>
<ul className='tso2-rows' aria-label={copy.ledgerLabel}>
<li className='tso2-row'>
<span className='tso2-thumb'>
{productImage ? <img src={productImage} alt={productImageAlt} width={48} height={48} decoding='async' /> : <BookOpen className='tso2-ticon' strokeWidth={2.5} aria-hidden='true' />}
</span>
<div className='tso2-rowmain'>
<p className='tso2-line'>
<span className='tso2-name'>{productName}</span>
<span className='tso2-leader' aria-hidden='true' />
<span className='tso2-free'>{copy.free}</span>
</p>
{bookNote ? <p className='tso2-note'>{bookNote}</p> : null}
</div>
</li>
<li className='tso2-row'>
<span className='tso2-thumb'>
<Truck className='tso2-ticon' strokeWidth={2.5} aria-hidden='true' />
</span>
<div className='tso2-rowmain'>
<p className='tso2-line'>
<span className='tso2-name'>{shippingLabel}</span>
<span className='tso2-leader' aria-hidden='true' />
<span className='tso2-amt'>{shipping}</span>
</p>
</div>
</li>
{bump && bumpOn ? (
<li className='tso2-row tso2-rowin'>
<span className='tso2-thumb'>
{bump.image ? <img src={bump.image} alt='' width={48} height={48} decoding='async' /> : <Headphones className='tso2-ticon' strokeWidth={2.5} aria-hidden='true' />}
</span>
<div className='tso2-rowmain'>
<p className='tso2-line'>
<span className='tso2-name'>{bump.summaryLabel ?? copy.addOnFallback}</span>
<span className='tso2-leader' aria-hidden='true' />
<span className='tso2-amt'>{bump.price}</span>
</p>
</div>
</li>
) : null}
</ul>
<div className='tso2-total'>
<p className='tso2-total-line'>
<span className='tso2-total-label'>{copy.totalLabel}</span>
<span className='tso2-fig' key={totalText} aria-hidden='true'>
<span className='tso2-cur'>{totalParts.symbol}</span>
{totalParts.amount}
</span>
<span className='tso2-vh'>{totalText}</span>
</p>
{copy.totalNote ? <p className='tso2-total-note'>{copy.totalNote}</p> : null}
</div>
</div>
</div>
{whyHeading || whyBody ? (
<div className='tso2-why'>
{whyHeading ? <h3 className='tso2-sub'>{whyHeading}</h3> : null}
{whyBody ? <p>{whyBody}</p> : null}
</div>
) : null}
<div className='tso2-formcell' ref={cellRef}>
<form ref={formRef} className='tso2-form' noValidate onSubmit={handleSubmit} aria-labelledby={uid + '-step'}>
<ol className='tso2-tabs' aria-label={copy.stepsLabel}>
{steps.slice(0, 2).map((s, i) => {
const n = i + 1
const active = step === n
const done = n === 1 && step === 2
const isLocked = n === 2 && step === 1 && !step1Filled
const upcoming = n === 2 && step === 1 && step1Filled
const cls = 'tso2-tab' + (active ? ' is-active' : '') + (done ? ' is-done' : '') + (isLocked ? ' is-locked' : '') + (upcoming ? ' is-next' : '')
return (
<li key={n}>
<button
type='button'
className={cls}
aria-current={active ? 'step' : undefined}
disabled={locked || isLocked}
onClick={done ? toShipping : upcoming ? toPayment : undefined}
>
<span className='tso2-tabdisc' aria-hidden='true'>
{done ? <Check strokeWidth={3} /> : isLocked ? <Lock strokeWidth={2.5} /> : n}
</span>
<span className='tso2-tabtext'>
<span className='tso2-vh'>{fill(copy.stepPrefix, { n: String(n) })}</span>
<b>{s.label}</b>
{s.sub ? <small>{s.sub}</small> : null}
{done || isLocked ? <span className='tso2-vh'>{done ? copy.doneSuffix : copy.lockedSuffix}</span> : null}
</span>
</button>
</li>
)
})}
</ol>
{step === 1 ? (
<div className='tso2-panel' key='s1' ref={step1Ref}>
<h3 className='tso2-steph' id={uid + '-step'} ref={headRef} tabIndex={-1}>
{fill(step1Heading, { shipping, product: productName })}
</h3>
{alertBox}
<div className='tso2-grid'>{fields.map(renderField)}</div>
<button type='submit' className='tso2-cta tso2-cta-next' disabled={nextDisabled}>
{nextLabel}
</button>
<p className='tso2-under'>{requireComplete && !step1Filled && !disabled ? copy.completeNote : fill(nextNote, { shipping })}</p>
</div>
) : (
<div className='tso2-panel' key='s2'>
<div className={'tso2-done' + (foldFrom ? ' is-folding' : '')} style={foldFrom ? ({ '--tso2-fold-from': foldFrom + 'px' } as React.CSSProperties) : undefined}>
<span className='tso2-badge' aria-hidden='true'>
<Check strokeWidth={3} />
</span>
<p className='tso2-done-text'>{summaryText}</p>
<button type='button' className='tso2-edit' onClick={toShipping} disabled={locked} aria-label={copy.editAria}>
{copy.editLabel}
</button>
</div>
<h3 className='tso2-steph' id={uid + '-step'} ref={headRef} tabIndex={-1}>
{fill(step2Heading, { shipping, product: productName })}
</h3>
{acceptedCards.length ? (
<div className='tso2-marks'>
<span>{copy.weAccept}</span>
{acceptedCards.map((c) => (
<span key={c} className='tso2-mark' role='img' aria-label={copy.cardNames[c] ?? c}>
<CardMarkIcon mark={c} />
</span>
))}
</div>
) : null}
{alertBox}
<div className='tso2-grid'>{paymentFields.map(renderField)}</div>
{bumpBox}
{submitFailed ? (
<p className='tso2-alert tso2-alert-submit' role='alert'>
<AlertCircle className='tso2-inl' strokeWidth={2.5} aria-hidden='true' />
{copy.submitError}
</p>
) : null}
{question ? <p className='tso2-q'>{question}</p> : null}
<div className='tso2-actions'>
<button type='button' className='tso2-back' onClick={toShipping} disabled={locked}>
{backLabel}
</button>
<button type='submit' className='tso2-cta' disabled={locked} aria-busy={busy || undefined}>
{busy ? (
<>
<Loader2 className='tso2-spin' strokeWidth={2.5} aria-hidden='true' />
{copy.loading}
</>
) : (
fill(orderLabel, { total: totalText, shipping })
)}
</button>
</div>
{orderNote ? (
<p className='tso2-under'>
<Lock className='tso2-inl' strokeWidth={2.5} aria-hidden='true' />
{fill(orderNote, { total: totalText, shipping })}
</p>
) : null}
{guarantee ? (
<p className='tso2-under'>
<ShieldCheck className='tso2-inl' strokeWidth={2.5} aria-hidden='true' />
{guarantee}
</p>
) : null}
</div>
)}
</form>
<p className='tso2-vh' aria-live='polite'>
{announce}
</p>
</div>
</div>
</div>
</section>
)
}
export default TwoStepOrder2
type Kind = 'text' | 'email' | 'card' | 'expiry' | 'cvc'
const DEFAULT_STEPS: [BookOrderStep, BookOrderStep] = [
{ label: 'Shipping', sub: 'Where we send it' },
{ label: 'Payment', sub: 'Cover the postage' },
]
const SHIPPING_FIELDS: BookOrderField[] = [
{ name: 'name', label: 'Full name', autoComplete: 'name', placeholder: 'Jane Smith' },
{ name: 'email', label: 'Email address', type: 'email', inputMode: 'email', autoComplete: 'email', placeholder: 'you@example.com' },
{ name: 'address', label: 'Street address', autoComplete: 'shipping street-address', placeholder: '123 Main Street' },
{ name: 'city', label: 'City', autoComplete: 'shipping address-level2', placeholder: 'Portland', span: 5, spanPhone: 12 },
{ name: 'state', label: 'State', autoComplete: 'shipping address-level1', placeholder: 'OR', span: 3, spanPhone: 5 },
{ name: 'zip', label: 'ZIP code', autoComplete: 'shipping postal-code', inputMode: 'numeric', placeholder: '97205', span: 4, spanPhone: 7 },
]
const PAYMENT_FIELDS: BookOrderField[] = [
{ name: 'card', label: 'Card number', autoComplete: 'cc-number', inputMode: 'numeric', placeholder: '1234 5678 9012 3456' },
{ name: 'expiry', label: 'Expiry', autoComplete: 'cc-exp', inputMode: 'numeric', placeholder: 'MM / YY', span: 6, spanPhone: 6 },
{ name: 'cvc', label: 'Security code', autoComplete: 'cc-csc', inputMode: 'numeric', placeholder: '123', span: 6, spanPhone: 6 },
]
const ALL_CARDS: CardMark[] = ['visa', 'mastercard', 'amex', 'discover']
const FIELD_ICONS: Record<string, LucideIcon | undefined> = {
name: User,
fullName: User,
email: Mail,
address: MapPin,
card: CreditCard,
expiry: CalendarDays,
cvc: Lock,
}
const PLACEHOLDERS: Record<string, string | undefined> = {
name: 'Jane Smith',
fullName: 'Jane Smith',
firstName: 'Jane',
lastName: 'Smith',
email: 'you@example.com',
phone: '(555) 123-4567',
address: '123 Main Street',
address2: 'Apt 4B',
city: 'Portland',
state: 'OR',
zip: '97205',
country: 'United States',
card: '1234 5678 9012 3456',
expiry: 'MM / YY',
cvc: '123',
}
function CardMarkIcon({ mark }: { mark: CardMark }) {
if (mark === 'visa') return <Visa aria-hidden='true' />
if (mark === 'mastercard') return <Mastercard aria-hidden='true' />
if (mark === 'amex') return <AmericanExpress aria-hidden='true' />
return <Discover aria-hidden='true' />
}
function emphasise(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text
const at = text.toLowerCase().indexOf(phrase.toLowerCase())
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='tso2-em'>{text.slice(at, at + phrase.length)}</span>
{text.slice(at + phrase.length)}
</>
)
}
function fill(template: string, vars: Record<string, string>): string {
return template.replace(/[{]([a-zA-Z0-9_]+)[}]/g, (match, key: string) => (vars[key] !== undefined ? vars[key] : match))
}
function defined<T>(overrides?: Partial<T>): Partial<T> {
return Object.fromEntries(Object.entries(overrides ?? {}).filter(([, v]) => v !== undefined)) as Partial<T>
}
function safeId(name: string) {
return name.replace(/[^a-zA-Z0-9_-]/g, '')
}
function kindOf(f: BookOrderField): Kind {
const ac = f.autoComplete ?? ''
if (f.type === 'email' || f.name === 'email' || ac.endsWith('email')) return 'email'
if (f.name === 'card' || ac === 'cc-number') return 'card'
if (f.name === 'expiry' || ac === 'cc-exp') return 'expiry'
if (f.name === 'cvc' || ac === 'cc-csc') return 'cvc'
return 'text'
}
function shape(kind: Kind, raw: string): string {
if (kind === 'card') return raw.replace(/[^0-9]/g, '').slice(0, 19).replace(/([0-9]{4})(?=[0-9])/g, '$1 ')
if (kind === 'expiry') {
const d = raw.replace(/[^0-9]/g, '').slice(0, 4)
return d.length > 2 ? d.slice(0, 2) + ' / ' + d.slice(2) : d
}
if (kind === 'cvc') return raw.replace(/[^0-9]/g, '').slice(0, 4)
return raw
}
function validateField(f: BookOrderField, raw: string | undefined, copy: TwoStepOrder2Copy): string | undefined {
const value = (raw ?? '').trim()
const kind = kindOf(f)
if (!value) return fill(copy.required, { label: f.label.toLowerCase() })
if (kind === 'email' && !/^[^ @]+@[^ @]+[.][^ @]{2,}$/.test(value)) return copy.email
if (kind === 'card') {
const digits = value.replace(/[^0-9]/g, '')
if (digits.length < 13 || digits.length > 19) return copy.card
}
if (kind === 'expiry') {
const m = value.replace(/ /g, '').match(/^([0-9]{2})[/]([0-9]{2})$/)
if (!m || Number(m[1]) < 1 || Number(m[1]) > 12) return copy.expiry
}
if (kind === 'cvc' && !/^[0-9]{3,4}$/.test(value)) return copy.cvc
return undefined
}
function validate(list: BookOrderField[], values: Record<string, string>, copy: TwoStepOrder2Copy): Record<string, string> {
const out: Record<string, string> = {}
for (const f of list) {
const e = validateField(f, values[f.name], copy)
if (e) out[f.name] = e
}
return out
}
function withError(prev: Record<string, string>, name: string, message?: string): Record<string, string> {
if (message) return prev[name] === message ? prev : { ...prev, [name]: message }
if (!(name in prev)) return prev
const next = { ...prev }
delete next[name]
return next
}
function pick(values: Record<string, string>, list: BookOrderField[]): Readonly<Record<string, string>> {
const out: Record<string, string> = {}
for (const f of list) out[f.name] = (values[f.name] ?? '').trim()
return out
}
function toNum(s?: string): number {
if (!s) return 0
const n = parseFloat(s.replace(/[^0-9.]/g, ''))
return Number.isFinite(n) ? n : 0
}
function fmtOpts(n: number, currency: string): Intl.NumberFormatOptions {
const whole = Math.abs(n - Math.round(n)) < 0.005
return { style: 'currency', currency, minimumFractionDigits: whole ? 0 : 2, maximumFractionDigits: whole ? 0 : 2 }
}
function money(n: number, currency: string): string {
try {
return new Intl.NumberFormat('en-US', fmtOpts(n, currency)).format(n)
} catch {
return '$' + n.toFixed(2)
}
}
function moneyParts(n: number, currency: string): { symbol: string; amount: string } {
try {
const parts = new Intl.NumberFormat('en-US', fmtOpts(n, currency)).formatToParts(n)
return {
symbol: parts.filter((p) => p.type === 'currency').map((p) => p.value).join(''),
amount: parts.filter((p) => p.type !== 'currency' && p.type !== 'literal').map((p) => p.value).join(''),
}
} catch {
return { symbol: '$', amount: n.toFixed(2) }
}
}
const R = '.cf-two-step-order-2'
const SH = 'var(--shadow, oklch(0.22 0.03 256))'
const BG = 'var(--button-bg, var(--cta))'
const BG2 = 'var(--button-bg-2, var(--cta-2))'
const FOCUS = 'var(--field-focus, var(--accent))'
const HAIR = 'oklch(from var(--ink) l c h / 0.12)'
const BTN_GRAD = `linear-gradient(oklch(from ${BG} calc(l + 0.04) c h), oklch(from ${BG2} calc(l - 0.02) c h))`
const BTN_GRAD_HOVER = `linear-gradient(oklch(from ${BG} calc(l - 0.01) c h), oklch(from ${BG2} calc(l - 0.07) c h))`
const BTN_SHADOW = `var(--button-shadow, inset 0 1px 0 oklch(from ${BG} calc(l + 0.14) c h / 0.7), inset 0 -3px 0 oklch(from ${BG} calc(l - 0.16) c h), 0 1px 2px oklch(from ${SH} l c h / 0.3), 0 8px 16px -6px oklch(from ${SH} l c h / 0.4))`
const BTN_SHADOW_HOVER = `inset 0 1px 0 oklch(from ${BG} calc(l + 0.1) c h / 0.7), inset 0 -3px 0 oklch(from ${BG} calc(l - 0.2) c h), 0 1px 2px oklch(from var(--tso2-sh) l c h / 0.34), 0 10px 20px -6px oklch(from var(--tso2-sh) l c h / 0.48)`
const EASE = 'cubic-bezier(.2,.7,.2,1)'
const CSS = `
${R}{--tso2-sh:var(--shadow, oklch(0.22 0.03 256));position:relative;isolation:isolate;background:var(--surface);color:var(--ink);font-family:var(--font-body);font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;padding-bottom:clamp(64px,8.5vw,120px);overflow-x:clip}
${R} *,${R} *::before,${R} *::after{box-sizing:border-box}
${R} :where(h2,h3,p,ul,ol,li){margin:0;padding:0}
${R} :where(ul,ol){list-style:none}
${R} :where(button,input){font:inherit;color:inherit}
${R} img{display:block;max-width:100%}
${R} .tso2-vh{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
${R} .tso2-photo{position:relative;height:clamp(320px,39vw,560px);overflow:hidden;background:var(--band)}
${R} .tso2-photo img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:50% 45%}
${R} .tso2-photo::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(to top, oklch(from var(--tso2-sh) l c h / 0.32), oklch(from var(--tso2-sh) l c h / 0) 42%)}
${R} .tso2-wrap{position:relative;z-index:1;width:min(1120px, calc(100% - 2 * clamp(16px,5vw,48px)));margin:calc(-1 * clamp(88px,11vw,176px)) auto 0}
${R} .tso2-card{display:grid;grid-template-columns:minmax(0,.92fr) minmax(0,1fr);grid-template-areas:'offer form' 'why form';grid-template-rows:auto 1fr;background:var(--card);color:var(--ink);border:1px solid var(--card-border, ${HAIR});border-radius:var(--card-radius, var(--radius, 14px));box-shadow:var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(from ${SH} l c h / 0.22), 0 12px 24px -8px oklch(from ${SH} l c h / 0.32)))}
${R} .tso2-offer{grid-area:offer;min-width:0;padding:clamp(20px,3vw,32px) clamp(20px,3vw,32px) 0}
${R} .tso2-why{grid-area:why;min-width:0;padding:28px clamp(20px,3vw,32px) clamp(24px,3vw,32px)}
${R} .tso2-formcell{grid-area:form;min-width:0;padding:clamp(16px,2.4vw,28px) clamp(20px,3vw,32px) clamp(24px,3vw,32px);border-inline-start:1px solid ${HAIR}}
${R} .tso2-h{margin:0 0 16px;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance;color:var(--ink)}
${R} .tso2-em{color:var(--accent)}
${R} .tso2-lead{max-width:60ch;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .tso2-receipt{margin-top:24px;padding:20px clamp(16px,2vw,24px) 22px;border-radius:10px;background:color-mix(in oklch, var(--ink) 4%, var(--card))}
${R} .tso2-rows{display:grid;gap:14px}
${R} .tso2-row{display:grid;grid-template-columns:48px minmax(0,1fr);gap:14px;align-items:start}
${R} .tso2-thumb{width:48px;height:48px;display:grid;place-items:center}
${R} .tso2-thumb img{width:48px;height:48px;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--tso2-sh) l c h / 0.3)) drop-shadow(0 6px 8px oklch(from var(--tso2-sh) l c h / 0.18))}
${R} .tso2-ticon{width:24px;height:24px;color:var(--ink)}
${R} .tso2-rowmain{min-width:0;min-height:48px;display:flex;flex-direction:column;justify-content:center}
${R} .tso2-line{display:flex;align-items:baseline;gap:8px}
${R} .tso2-name{min-width:0;font-size:1.0625rem;font-weight:700;line-height:1.3;text-wrap:pretty}
${R} .tso2-leader{flex:1 1 24px;min-width:16px;align-self:flex-end;height:2px;margin-bottom:.42em;background:radial-gradient(circle, oklch(from var(--ink) l c h / 0.4) 0 1px, transparent 1.2px) left center / 6px 2px repeat-x}
${R} .tso2-amt{flex:none;font-size:1.0625rem;font-weight:800;font-variant-numeric:tabular-nums}
${R} .tso2-free{flex:none;display:inline-flex;align-items:center;height:28px;padding:0 12px;border-radius:999px;background:var(--success-soft);color:var(--success);font-size:.875rem;font-weight:800;letter-spacing:.06em;line-height:1}
${R} .tso2-note{margin-top:4px;font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted);text-wrap:pretty}
${R} .tso2-total{margin-top:20px}
${R} .tso2-total-line{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:8px 16px}
${R} .tso2-total-label{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-.01em}
${R} .tso2-fig{display:inline-block;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;letter-spacing:-.03em;font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--ink)}
${R} .tso2-cur{position:relative;top:-.85em;margin-inline-end:.06em;font-size:.46em;letter-spacing:0}
${R} .tso2-total-note{margin-top:12px;text-align:end;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted)}
${R} .tso2-sub{margin-bottom:8px;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-.01em;color:var(--accent);text-wrap:balance}
${R} .tso2-why p{max-width:64ch;color:var(--ink);text-wrap:pretty}
${R} .tso2-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;margin-bottom:24px;border-bottom:1px solid ${HAIR}}
${R} .tso2-tabs li{min-width:0}
${R} .tso2-tab{position:relative;width:100%;min-height:64px;display:flex;align-items:center;gap:12px;padding:8px 12px 12px;border:0;border-radius:10px 10px 0 0;background:transparent;color:var(--muted);text-align:start;cursor:default}
${R} .tso2-tab::after{content:'';position:absolute;inset-inline:0;bottom:-1px;height:3px;border-radius:3px 3px 0 0;background:transparent}
${R} .tso2-tab.is-active{color:var(--ink)}
${R} .tso2-tab.is-active::after{background:var(--accent-fill, var(--accent))}
${R} .tso2-tab.is-done::after{background:var(--success)}
${R} .tso2-tab.is-done,${R} .tso2-tab.is-next{cursor:pointer;color:var(--ink)}
${R} .tso2-tab.is-done:hover:not(:disabled),${R} .tso2-tab.is-next:hover:not(:disabled){background:color-mix(in oklch, var(--ink) 4%, var(--card))}
${R} .tso2-tab.is-done:active:not(:disabled),${R} .tso2-tab.is-next:active:not(:disabled){background:color-mix(in oklch, var(--ink) 8%, var(--card))}
${R} .tso2-tab:disabled{cursor:not-allowed}
${R} .tso2-tab:focus-visible{outline:3px solid ${FOCUS};outline-offset:-3px}
${R} .tso2-tabdisc{flex:none;width:32px;height:32px;display:grid;place-items:center;border-radius:999px;background:color-mix(in oklch, var(--ink) 8%, var(--card));color:var(--ink);font-family:var(--font-display);font-size:.9375rem;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}
${R} .tso2-tab.is-active .tso2-tabdisc{background:var(--accent-fill, var(--accent));color:var(--accent-fill-ink, var(--card))}
${R} .tso2-tab.is-done .tso2-tabdisc{background:var(--success);color:var(--status-glyph, #fff)}
${R} .tso2-tab.is-locked .tso2-tabdisc{color:var(--muted)}
${R} .tso2-tabdisc svg{width:16px;height:16px}
${R} .tso2-tabtext{display:grid;gap:2px;min-width:0}
${R} .tso2-tabtext b{font-family:var(--font-display);font-size:1.0625rem;font-weight:800;line-height:1.2}
${R} .tso2-tabtext small{font-size:.875rem;font-weight:600;line-height:1.2;color:var(--muted)}
${R} .tso2-steph{margin-bottom:20px;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-.01em;text-wrap:balance;outline:none}
${R} .tso2-alert{margin-bottom:20px;padding:12px 16px;border-radius:10px;background:var(--danger-soft);color:var(--danger);font-size:.9375rem;font-weight:700;line-height:1.4;text-wrap:pretty}
${R} .tso2-alert-submit{margin:20px 0 0}
${R} .tso2-inl{display:inline-block;width:16px;height:16px;vertical-align:-.15em;margin-inline-end:.4em}
${R} .tso2-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:16px 12px;align-items:start}
${R} .tso2-field{grid-column:span var(--span,12);min-width:0}
${R} .tso2-field label{display:block;margin-bottom:8px;font-size:1rem;font-weight:700;line-height:1.25;color:var(--label-ink, var(--ink))}
${R} .tso2-control{position:relative}
${R} .tso2-ficon{position:absolute;top:50%;inset-inline-start:16px;width:18px;height:18px;margin-top:-9px;color:color-mix(in oklch, var(--field-ink) 55%, var(--field));pointer-events:none}
${R} .tso2-input{display:block;width:100%;height:56px;padding:0 16px;border:1px solid var(--field-border, color-mix(in oklch, var(--ink) 22%, transparent));border-radius:var(--field-radius, var(--radius, 12px));background:var(--field);color:var(--field-ink);font-family:var(--font-body);font-size:1.0625rem;box-shadow:inset 0 1px 2px oklch(from var(--tso2-sh) l c h / 0.08);-webkit-appearance:none;appearance:none}
${R} .tso2-control.has-icon .tso2-input{padding-inline-start:44px}
${R} .tso2-input::placeholder{color:color-mix(in oklch, var(--field-ink) 65%, var(--field));opacity:1}
${R} .tso2-input:hover:not(:disabled){border-color:color-mix(in oklch, var(--ink) 38%, transparent)}
${R} .tso2-input:focus{outline:none;border-color:var(--field-focus, var(--accent));box-shadow:0 0 0 3px oklch(from var(--field-focus, var(--accent)) l c h / 0.35)}
${R} .tso2-input[aria-invalid='true']{border-color:var(--danger)}
${R} .tso2-input[aria-invalid='true']:focus{box-shadow:0 0 0 3px oklch(from var(--danger) l c h / 0.3)}
${R} .tso2-input:disabled{cursor:not-allowed;background:color-mix(in oklch, var(--field-ink) 6%, var(--field))}
${R} .tso2-err{margin-top:8px;font-size:.9375rem;font-weight:600;line-height:1.35;color:var(--danger);text-wrap:pretty}
${R} .tso2-cta{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:64px;padding:0 28px;border:0;border-radius:var(--button-radius, var(--radius, 12px));background:${BTN_GRAD};color:var(--button-ink, var(--cta-ink));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight,800);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-transform:var(--button-case,none);text-shadow:var(--button-text-shadow,none);text-align:center;cursor:pointer;box-shadow:${BTN_SHADOW}}
${R} .tso2-cta svg{flex:none;width:20px;height:20px}
${R} .tso2-cta-next{min-height:56px;margin-top:24px}
${R} .tso2-cta:hover:not(:disabled),${R}.is-hover .tso2-cta:not(:disabled){background:${BTN_GRAD_HOVER};box-shadow:${BTN_SHADOW_HOVER}}
${R} .tso2-cta:active:not(:disabled){transform:translateY(1px);box-shadow:inset 0 2px 4px oklch(from ${BG} calc(l - 0.22) c h / 0.55), inset 0 -2px 0 oklch(from ${BG} calc(l - 0.16) c h), 0 1px 1px oklch(from var(--tso2-sh) l c h / 0.25)}
${R} .tso2-cta:focus-visible{outline:3px solid ${FOCUS};outline-offset:3px}
${R} .tso2-cta:disabled{cursor:not-allowed;background:var(--secondary);color:var(--secondary-ink);text-shadow:none;box-shadow:none}
${R} .tso2-cta[aria-busy='true']:disabled{cursor:progress;background:${BTN_GRAD};color:var(--button-ink, var(--cta-ink));text-shadow:var(--button-text-shadow,none);box-shadow:${BTN_SHADOW}}
${R} .tso2-back{flex:none;display:inline-flex;align-items:center;justify-content:center;min-height:64px;padding:0 24px;border:1px solid var(--button-2-border, transparent);border-radius:var(--button-radius, var(--radius, 12px));background:var(--button-2-bg, var(--secondary));color:var(--button-2-ink, var(--secondary-ink));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight,800);font-size:1.125rem;line-height:1.15;text-transform:var(--button-case,none);box-shadow:var(--button-2-shadow, var(--shadow-sm));cursor:pointer}
${R} .tso2-back:hover:not(:disabled){background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.04) c h)}
${R} .tso2-back:active:not(:disabled){transform:translateY(1px);background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.07) c h)}
${R} .tso2-back:focus-visible{outline:3px solid ${FOCUS};outline-offset:3px}
${R} .tso2-back:disabled{cursor:not-allowed;opacity:.6}
${R} .tso2-actions{display:flex;align-items:stretch;gap:12px;margin-top:24px}
${R} .tso2-q + .tso2-actions{margin-top:0}
${R} .tso2-actions .tso2-cta{flex:1 1 auto;width:auto;min-width:0}
${R} .tso2-q{margin:24px 0 12px;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-.01em;text-wrap:balance}
${R} .tso2-under{margin-top:12px;text-align:center;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);text-wrap:pretty}
${R} .tso2-under + .tso2-under{margin-top:4px}
${R} .tso2-done{display:flex;align-items:center;gap:12px;min-height:56px;margin-bottom:20px;padding:6px 6px 6px 14px;border:0;border-radius:10px;background:color-mix(in oklch, var(--ink) 4%, var(--card));overflow:hidden}
${R} .tso2-badge{flex:none;width:28px;height:28px;display:grid;place-items:center;border-radius:999px;background:var(--success);color:var(--status-glyph, #fff)}
${R} .tso2-badge svg{width:16px;height:16px}
${R} .tso2-done-text{flex:1 1 auto;min-width:0;font-size:1.0625rem;font-weight:700;line-height:1.3;text-wrap:pretty}
${R} .tso2-edit{flex:none;display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 18px;border:1px solid var(--button-2-border, transparent);border-radius:min(var(--button-radius, var(--radius, 12px)), 8px);background:var(--button-2-bg, var(--secondary));color:var(--button-2-ink, var(--secondary-ink));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight,800);font-size:1rem;line-height:1;text-transform:var(--button-case,none);box-shadow:var(--button-2-shadow, var(--shadow-sm));cursor:pointer}
${R} .tso2-edit:hover:not(:disabled){background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.04) c h)}
${R} .tso2-edit:active:not(:disabled){transform:translateY(1px);background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.07) c h)}
${R} .tso2-edit:focus-visible{outline:3px solid ${FOCUS};outline-offset:2px}
${R} .tso2-edit:disabled{cursor:not-allowed;opacity:.6}
${R} .tso2-marks{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:-8px 0 20px;font-size:.9375rem;font-weight:600;color:var(--muted)}
${R} .tso2-marks > span:first-child{margin-inline-end:4px}
${R} .tso2-mark{display:inline-flex}
${R} .tso2-mark svg{display:block;width:38px;height:auto}
${R} .tso2-bump{position:relative;margin-top:24px;border:2px solid oklch(from var(--bump-strip) calc(l - 0.22) c h / 0.75);border-radius:var(--radius, 12px);background:var(--bump);color:var(--bump-ink);overflow:hidden}
${R} .tso2-bump.is-on{border-color:var(--success);box-shadow:var(--shadow-md)}
${R} .tso2-bump-strip{position:relative;display:flex;align-items:center;gap:14px;min-height:56px;padding:12px 16px;background:var(--bump-strip);color:var(--bump-ink);cursor:pointer}
${R} .tso2-bump-strip:hover{background:oklch(from var(--bump-strip) calc(l - 0.03) c h)}
${R} .tso2-bump-strip:has(.tso2-bump-input:disabled){cursor:not-allowed}
${R} .tso2-bump-input{position:absolute;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
${R} .tso2-box{flex:none;width:26px;height:26px;display:grid;place-items:center;border:2px solid oklch(from var(--bump-ink) l c h / 0.6);border-radius:6px;background:var(--field);color:transparent}
${R} .tso2-box svg{width:16px;height:16px;opacity:0}
${R} .tso2-bump-input:checked + .tso2-box{border-color:var(--success);background:var(--success);color:var(--status-glyph, #fff)}
${R} .tso2-bump-input:checked + .tso2-box svg{opacity:1}
${R} .tso2-bump-input:focus-visible + .tso2-box{outline:3px solid ${FOCUS};outline-offset:2px}
${R} .tso2-bump-label{font-size:1.0625rem;font-weight:800;line-height:1.3;text-wrap:pretty}
${R} .tso2-bump-body{display:grid;grid-template-columns:72px minmax(0,1fr);gap:14px;align-items:start;padding:14px 16px 16px}
${R} .tso2-bump-body.no-img{grid-template-columns:minmax(0,1fr)}
${R} .tso2-bump-body img{width:72px;height:72px;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--tso2-sh) l c h / 0.3)) drop-shadow(0 6px 8px oklch(from var(--tso2-sh) l c h / 0.18))}
${R} .tso2-bump-body p{font-size:1.0625rem;line-height:1.45;text-wrap:pretty}
@media (prefers-reduced-motion: no-preference){
@keyframes tso2-rise{from{opacity:.82;transform:translateY(8px)}}
@keyframes tso2-pop{from{transform:scale(.9)}}
@keyframes tso2-settle{from{transform:scale(1.035)}}
@keyframes tso2-fold{from{min-height:var(--tso2-fold-from,56px);background:color-mix(in oklch, var(--ink) 8%, var(--card))}}
@keyframes tso2-spin{to{transform:rotate(360deg)}}
${R} .tso2-cta,${R} .tso2-back,${R} .tso2-edit{transition:background .16s ease, box-shadow .16s ease, transform .16s ease}
${R} .tso2-input{transition:border-color .16s ease, box-shadow .16s ease}
${R} .tso2-tab,${R} .tso2-tab::after,${R} .tso2-bump,${R} .tso2-bump-strip,${R} .tso2-box{transition:background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease}
${R} .tso2-photo img{animation:tso2-settle 1.2s ${EASE} both}
${R} .tso2-panel > *{animation:tso2-rise .45s ${EASE} both}
${R} .tso2-panel > :nth-child(2){animation-delay:.07s}
${R} .tso2-panel > :nth-child(3){animation-delay:.14s}
${R} .tso2-panel > :nth-child(4){animation-delay:.21s}
${R} .tso2-panel > :nth-child(n+5){animation-delay:.28s}
${R} .tso2-done.is-folding{animation:tso2-fold .5s ${EASE} both}
${R} .tso2-done.is-folding .tso2-badge{animation:tso2-pop .3s ${EASE} .32s both}
${R} .tso2-rowin{animation:tso2-rise .45s ${EASE} both}
${R} .tso2-fig{animation:tso2-pop .3s ${EASE}}
${R} .tso2-bump-input:checked + .tso2-box svg{animation:tso2-pop .3s ${EASE}}
${R} .tso2-spin{animation:tso2-spin .8s linear infinite}
}
@media (prefers-reduced-motion: reduce){
${R} .tso2-cta:active:not(:disabled),${R} .tso2-back:active:not(:disabled),${R} .tso2-edit:active:not(:disabled){transform:none}
}
@media (max-width: 960px){
${R} .tso2-card{grid-template-columns:minmax(0,1fr);grid-template-areas:'offer' 'form' 'why';grid-template-rows:auto}
${R} .tso2-offer{padding-bottom:28px}
${R} .tso2-formcell{border-inline-start:0;border-block:1px solid ${HAIR}}
}
@media (max-width: 640px){
${R} .tso2-photo{height:clamp(180px,52vw,240px)}
${R} .tso2-wrap{width:calc(100% - 20px);margin-top:-40px}
${R} .tso2-field{grid-column:span var(--span-sm,12)}
${R} .tso2-tab{min-height:56px;gap:10px;padding:8px 8px 10px}
${R} .tso2-tabtext small{display:none}
${R} .tso2-receipt{padding:16px 16px 18px}
${R} .tso2-row{grid-template-columns:40px minmax(0,1fr);gap:12px}
${R} .tso2-thumb,${R} .tso2-thumb img{width:40px;height:40px}
${R} .tso2-rowmain{min-height:40px}
${R} .tso2-leader{display:none}
${R} .tso2-line{justify-content:space-between;align-items:flex-start;gap:12px}
${R} .tso2-name{font-size:1rem}
${R} .tso2-free{height:26px;padding:0 10px}
}
@media (max-width: 480px){
${R} .tso2-actions{flex-direction:column-reverse}
${R} .tso2-actions .tso2-cta{width:100%}
${R} .tso2-back{width:100%;min-height:56px}
${R} .tso2-bump-body{grid-template-columns:56px minmax(0,1fr)}
${R} .tso2-bump-body.no-img{grid-template-columns:minmax(0,1fr)}
${R} .tso2-bump-body img{width:56px;height:56px}
}
`
pieces/checkout/two-step-order-2/specimen.tsx 68 lines
import __studioImagec8e3ca53 from "../assets/20821595090047a7.webp";
import __studioImage93cb400b from "../assets/b5760f8bbbefee49.webp";
import __studioImagea2922997 from "../assets/858d060b1e32e559.webp";
// Specimen: The Quiet Kitchen free-plus-shipping cookbook order on the photo-overlap two-step card.
import * as React from 'react'
import { TwoStepOrder2, type TwoStepOrder2State } from '../two-step-order-2'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
const DANA: Record<string, string> = {
name: 'Dana Reyes',
email: 'dana.reyes@example.com',
address: '1420 SE Alder Street',
city: 'Portland',
state: 'OR',
zip: '97214',
}
const DANA_PARTIAL: Record<string, string> = {
name: 'Dana Reyes',
email: 'dana.reyes@example',
city: 'Portland',
}
export default function TwoStepOrder2Specimen({ state = 'default' }: { state?: TwoStepOrder2State }) {
const prefill = state === 'active' ? DANA : state === 'error' ? DANA_PARTIAL : undefined
return (
<TwoStepOrder2
state={state}
productName='The Quiet Kitchen'
productNote='Hardcover · 160 pages'
retailPrice='$24.95'
shipping='$7.95'
headline='The book is free. You just pay {shipping} shipping.'
highlight='free'
lead='We cover your hardcover copy of The Quiet Kitchen: 60 slow, simple weeknight dinners. You cover the postage.'
whyHeading='Why is the book free?'
whyBody='Because a cookbook earns its keep open on the counter, not on a shelf. Cook three dinners from it this week and you’ll know if our kitchen belongs in yours.'
question='Ready for quieter weeknight dinners?'
orderLabel='Yes, Send Me The Book'
guarantee={defaults.sample.guarantee}
sceneImage={slot(
'scene',
__studioImagec8e3ca53
)}
sceneImageAlt='The Quiet Kitchen hardcover on a sunlit kitchen table beside lemons and a cup of tea'
productImage={slot(
'product',
__studioImage93cb400b
)}
productImageAlt='The Quiet Kitchen hardcover cookbook'
bump={{
label: 'Yes! Add the audiobook for just {price}',
price: '$17',
summaryLabel: 'Audiobook edition',
body: 'Hear every recipe story read aloud while you chop and stir. It downloads today and plays on any phone.',
image: slot(
'item-1',
__studioImagea2922997
),
imageAlt: 'The Quiet Kitchen audiobook on a phone beside headphones',
}}
defaultValues={prefill}
/>
)
}
| Name | Type | Details |
|---|---|---|
productName OptionalTwoStepOrder2 |
string |
Default 'The Quiet Kitchen'
|
productNote OptionalTwoStepOrder2 |
string |
Default 'Hardcover edition'
|
retailPrice OptionalTwoStepOrder2 |
string |
|
shipping OptionalTwoStepOrder2 |
string |
Default '$7.95'
|
shippingLabel OptionalTwoStepOrder2 |
string |
Default 'Shipping & handling'
|
productImage OptionalTwoStepOrder2 |
string |
|
productImageAlt OptionalTwoStepOrder2 |
string |
Default 'The Quiet Kitchen hardcover cookbook'
|
sceneImage OptionalTwoStepOrder2 |
string |
|
sceneImageAlt OptionalTwoStepOrder2 |
string |
Default 'The Quiet Kitchen hardcover on a sunlit kitchen table'
|
scenePosition OptionalTwoStepOrder2 |
string |
Default '50% 45%'
|
headline OptionalTwoStepOrder2 |
string |
Default 'The book is free. You just pay {shipping} shipping.'
|
highlight OptionalTwoStepOrder2 |
string |
Default 'free'
|
lead OptionalTwoStepOrder2 |
string |
Default 'We cover your hardcover copy of {product}. You cover the postage, and it ships straight to your door.'
|
whyHeading OptionalTwoStepOrder2 |
string |
Default 'Why is the book free?'
|
whyBody OptionalTwoStepOrder2 |
string |
Default 'Because we’d rather see it open on your counter than sitting on our shelf. We cover the book. Your shipping covers the box, the postage and the packing.'
|
steps OptionalTwoStepOrder2 |
[BookOrderStep, BookOrderStep] |
Default DEFAULT_STEPS
|
fields OptionalTwoStepOrder2 |
BookOrderField[] |
Default SHIPPING_FIELDS
|
paymentFields OptionalTwoStepOrder2 |
BookOrderField[] |
Default PAYMENT_FIELDS
|
step1Heading OptionalTwoStepOrder2 |
string |
Default 'Where should we send your copy?'
|
step2Heading OptionalTwoStepOrder2 |
string |
Default 'Last step: cover the {shipping} shipping'
|
nextLabel OptionalTwoStepOrder2 |
string |
Default 'Ship My Free Copy Here'
|
nextNote OptionalTwoStepOrder2 |
string |
Default 'Next, you cover {shipping} shipping. The book is on us.'
|
question OptionalTwoStepOrder2 |
string |
Default 'Ready for quieter weeknight dinners?'
|
orderLabel OptionalTwoStepOrder2 |
string |
Default 'Yes, Send Me The Book'
|
orderNote OptionalTwoStepOrder2 |
string |
Default '{total} today · Secure checkout'
|
backLabel OptionalTwoStepOrder2 |
string |
Default 'Back'
|
bump OptionalTwoStepOrder2 |
BookOrderBump | null |
Default null
|
guarantee OptionalTwoStepOrder2 |
string | null |
Default null
|
acceptedCards OptionalTwoStepOrder2 |
CardMark[] |
Default ALL_CARDS
|
currency OptionalTwoStepOrder2 |
string |
Default 'USD'
|
copy OptionalTwoStepOrder2 |
Partial<TwoStepOrder2Copy> |
|
state OptionalTwoStepOrder2 |
TwoStepOrder2State |
|
initialStep OptionalTwoStepOrder2 |
1 | 2 |
Default 1
|
defaultValues OptionalTwoStepOrder2 |
Record<string, string> |
|
disabled OptionalTwoStepOrder2 |
boolean |
Default false
|
requireComplete OptionalTwoStepOrder2 |
boolean |
Default false
|
onContinue OptionalTwoStepOrder2 |
(values: Readonly<Record<string, string>>) => void |
|
onSubmit OptionalTwoStepOrder2 |
(values: Readonly<Record<string, string>>, bumpSelected: boolean) => void | Promise<void> |
|
className OptionalTwoStepOrder2 |
string |
Default ''
|
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-border--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
item-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
product- The main product shot or cover (ebook, kit, bottle).
scene- A wide atmosphere photo behind or beside the copy.
-
20821595090047a7.webp
image/webp · 48.5 KB
-
858d060b1e32e559.webp
image/webp · 50.7 KB
-
b5760f8bbbefee49.webp
image/webp · 138 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB