Two Step Order 4
Takes a subscription-box order in two steps under a route that fills as each field turns valid, while the colour block future-paces what the buyer unpacks in their first box.
Use it in a prompt
Use checkout/two-step-order-4 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-4.tsx. - Import it and pass your copy and images (Props tab):
import { TwoStepOrder4 } from "@/components/funneldna/checkout/two-step-order-4"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/checkout/two-step-order-4/component.tsx 944 lines
// layout: clipboard-checklist
// Takes a subscription-box order in two steps under a route that fills as each field turns valid, while the colour block future-paces what the buyer unpacks in their first box.
// Theme notes: official payment-network SVG marks keep their brand colours (theme-contract mark exception). Solid success ticks use a white glyph through --status-glyph. The first-box add-on uses --bump, --bump-strip and --bump-ink.
'use client'
import * as React from 'react'
import { AlertCircle, Building2, CalendarDays, Check, CreditCard, Loader2, Lock, Mail, MapPin, Package, Repeat, ShoppingCart, User, type LucideIcon } from 'lucide-react'
import { AmericanExpress, Discover, Mastercard, Visa } from 'react-svg-credit-card-payment-icons/icons/flat-rounded'
export type FirstBoxField = {
/** Key in the submitted values; also picks the icon, the check and the default placeholder. */
name: string
label: string
type?: string
autoComplete?: string
/** Realistic example answer; a default per field kind is shown when omitted. */
placeholder?: string
inputMode?: 'text' | 'email' | 'numeric' | 'tel'
/** full (default), half or quarter of the row on desktop; halves go full and quarters pair up on phones. */
size?: 'full' | 'half' | 'quarter'
}
/** One thing packed in the first box. */
export type FirstBoxItem = { name: string; detail?: string }
export type FirstBoxBump = {
/** Used in copy.bumpCheck and copy.bumpIncluded, e.g. glazed ceramic planter. */
title: string
/** Supplied one-time price, added to today’s total only. */
price: string
body?: string
/** Cut-out on a transparent background (slot: item-1). */
image?: string
imageAlt?: string
}
export type CardMark = 'visa' | 'mastercard' | 'amex' | 'discover'
export type TwoStepOrder4State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
const COPY = {
routeLabel: 'Your route to your first box',
progressLabel: 'Route progress',
progressText: '{done} of {total} details ready',
stepWord: 'Step {n}: ',
completed: ', completed.',
editDetails: 'Edit your details',
destinationTo: 'Heading to {city}',
deliveringTo: 'Delivering to',
weAccept: 'We accept',
bumpCheck: 'Yes! Add the {title} to my first box',
bumpPrice: '+{price} one time',
bumpTerms: 'One-time add-on for your first box only. Your monthly price stays the same.',
bumpIncluded: 'Includes the {title}, {price} one time',
dueToday: 'Due today:',
psLabel: 'P.S.',
loading: 'Adding to cart…',
alert: 'Please fix {count} {fields} to continue.',
fieldWord: 'field',
fieldsWord: 'fields',
required: 'Enter your {label}.',
email: 'Enter a valid email, like you@example.com.',
postal: 'Enter a valid ZIP or postal code.',
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 add your box to the cart. Please try again.',
}
export type TwoStepOrder4Copy = typeof COPY
export type TwoStepOrder4Props = {
/** Headline on the colour block. */
headline?: string
/** Subhead under the headline. */
lead?: string
productName?: string
/** Caption line under the box image. */
productNote?: string
/** Open box cut-out on a transparent background (slot: product). Hidden on phones. */
productImage?: string
productImageAlt?: string
/** Supplied first-box contents, listed as the ticked packing checklist. Empty hides it. */
contents?: FirstBoxItem[]
/** Future-pacing line above the contents. */
pacingLine?: string
/** Supplied recurring price; used for today’s total. */
price?: string
/** Small line under the big price; {price} is replaced with the recurring price. */
cadenceNote?: string
/** Full billing terms shown above the order button. Supply the real terms. */
billing?: string | null
/** Labels of the three route stops; the third is the destination, not a step. */
stops?: [string, string, string]
/** Line under the destination stop until a city is entered. */
destinationNote?: string
/** Step 1 delivery fields. */
fields?: FirstBoxField[]
/** Step 2 card fields. */
paymentFields?: FirstBoxField[]
step1Heading?: string
step1Lead?: string
step2Heading?: string
step2Lead?: string
nextLabel?: string
/** Small line under the step 1 button. */
nextNote?: string
/** Order button label; {total} is replaced with today’s total. */
orderLabel?: string
/** Line under the order button, shown with a lock. */
orderNote?: string
backLabel?: string
/** Optional first-box-only add-on, always unchecked at first. Supply only with a real price. */
bump?: FirstBoxBump | null
/** P.S. line under the action (without the P.S. label). Null hides it. */
ps?: string | null
acceptedCards?: CardMark[]
/** ISO currency code used to format prices. */
currency?: string
/** Interface copy. Templates replace {done}, {total}, {n}, {city}, {title}, {price}, {count}, {fields} and {label} as text. */
copy?: Partial<TwoStepOrder4Copy>
/** active opens step 2 (payment); hover previews the button hover; error shows step 1 with inline errors; disabled locks every control. */
state?: TwoStepOrder4State
initialStep?: 1 | 2
/** Prefilled values keyed by field name. */
defaultValues?: Record<string, string>
/** Locks every control, same as state disabled. */
disabled?: 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. A returned promise shows the loading label, a rejection shows copy.submitError. */
onSubmit?: (values: Readonly<Record<string, string>>, bumpSelected: boolean) => void | Promise<void>
className?: string
}
export function TwoStepOrder4({
headline = 'Your first box is two quick steps away',
lead = 'Tell us where it goes, add your payment, and your first box is booked.',
productName = 'Your monthly box',
productNote,
productImage,
productImageAlt = 'An open subscription box',
contents = [],
pacingLine = 'When your first box lands, you’ll unpack:',
price = '$47',
cadenceNote = 'Due today, then {price} every month',
billing = null,
stops = ['Your details', 'Payment', 'Your first box'],
destinationNote = 'Straight to your door',
fields = SHIP_FIELDS,
paymentFields = PAY_FIELDS,
step1Heading = 'Where should we deliver your first box?',
step1Lead,
step2Heading = 'Lock in your first box',
step2Lead,
nextLabel = 'Continue to Payment',
nextNote = 'You’ll see your total before you pay.',
orderLabel = 'Add To Cart · {total}',
orderNote = 'Secure checkout',
backLabel = 'Back',
bump = null,
ps = null,
acceptedCards = ALL_CARDS,
currency = 'USD',
copy: copyOverrides,
state,
initialStep = 1,
defaultValues,
disabled: disabledProp = false,
onContinue,
onSubmit,
className = '',
}: TwoStepOrder4Props) {
const copy: TwoStepOrder4Copy = { ...COPY, ...defined<TwoStepOrder4Copy>(copyOverrides) }
const uid = 't4' + 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' ? validateAll(startStep === 2 ? paymentFields : fields, defaultValues ?? {}, copy) : {}
)
const [touched, setTouched] = React.useState<Record<string, boolean>>(() =>
Object.fromEntries(Object.keys(defaultValues ?? {}).map((k) => [k, true]))
)
const [alertOn, setAlertOn] = React.useState(state === 'error')
const [bumpOn, setBumpOn] = React.useState(false)
const [status, setStatus] = React.useState<'idle' | 'loading' | 'failed'>('idle')
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 headRef = React.useRef<HTMLHeadingElement>(null)
React.useEffect(
() => () => {
run.current++
if (frame.current !== undefined) cancelAnimationFrame(frame.current)
},
[]
)
React.useEffect(() => {
if (seenState.current === state) return
seenState.current = state
run.current++
const next: 1 | 2 = state === 'active' ? 2 : state === 'error' ? 1 : initialStep
setStep(next)
setStatus('idle')
setErrors(state === 'error' ? validateAll(next === 2 ? paymentFields : fields, values, copy) : {})
setAlertOn(state === 'error')
}, [state])
React.useEffect(() => {
if (!moved.current) return
headRef.current?.focus()
}, [step])
const loading = status === 'loading'
const locked = disabled || loading
const activeFields = step === 1 ? fields : paymentFields
const ok1 = countOk(fields, values, copy)
const ok2 = countOk(paymentFields, values, copy)
const p =
step === 1
? fields.length ? (0.5 * ok1) / fields.length : 0
: 0.5 + (paymentFields.length ? (0.5 * ok2) / paymentFields.length : 0.5)
const ready = step === 2 && p >= 1
const doneCount = step === 1 ? ok1 : fields.length + ok2
const totalCount = fields.length + paymentFields.length
const base = toNum(price)
const bumpAmt = bump ? toNum(bump.price) : 0
const total = base + (bump && bumpOn ? bumpAmt : 0)
const money = (n: number) => formatMoney(n, currency)
const parts = priceParts(total, currency)
const cityField = fields.find((f) => kindOf(f) === 'city')
const cityValue = cityField ? (values[cityField.name] ?? '').trim() : ''
const destSub = cityField && cityValue && !check(cityField, cityValue, copy) ? fill(copy.destinationTo, { city: cityValue }) : destinationNote
const nameField = fields.find((f) => kindOf(f) === 'name')
const who = nameField ? (values[nameField.name] ?? '').trim() : ''
const addr = fields
.filter((f) => ['address', 'city', 'region', 'postal'].includes(kindOf(f)))
.map((f) => (values[f.name] ?? '').trim())
.filter(Boolean)
.join(', ')
const errCount = Object.keys(errors).length
const showAlert = alertOn && errCount > 0
const setOne = (name: string, err: string) =>
setErrors((prev) => {
const next = { ...prev }
if (err) next[name] = err
else delete next[name]
return next
})
const update = (f: FirstBoxField, raw: string) => {
const v = shape(kindOf(f), raw)
setValues((prev) => ({ ...prev, [f.name]: v }))
if (errors[f.name]) setOne(f.name, check(f, v, copy))
if (status === 'failed') setStatus('idle')
}
const leave = (f: FirstBoxField) => {
const v = values[f.name] ?? ''
if (!v.trim()) return
setTouched((prev) => ({ ...prev, [f.name]: true }))
setOne(f.name, check(f, v, copy))
}
const focusFirst = (errs: Record<string, string>) => {
const k = Object.keys(errs)[0]
if (!k) return
frame.current = requestAnimationFrame(() => {
const inputs = formRef.current?.querySelectorAll<HTMLInputElement>('input')
Array.from(inputs ?? []).find((input) => input.name === k)?.focus()
})
}
const goTo = (s: 1 | 2) => {
moved.current = true
run.current++
setStep(s)
setErrors({})
setAlertOn(false)
setStatus('idle')
}
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (locked) return
const errs = validateAll(activeFields, values, copy)
setErrors(errs)
setTouched((prev) => ({ ...prev, ...Object.fromEntries(activeFields.map((f) => [f.name, true])) }))
if (Object.keys(errs).length) {
setAlertOn(true)
focusFirst(errs)
return
}
setAlertOn(false)
const picked = pick([...fields, ...paymentFields], values)
if (step === 1) {
onContinue?.(picked)
goTo(2)
return
}
const id = ++run.current
const result = onSubmit?.(picked, Boolean(bump && bumpOn))
if (!result || typeof (result as Promise<void>).then !== 'function') return
setStatus('loading')
try {
await result
if (run.current === id) setStatus('idle')
} catch {
if (run.current === id) setStatus('failed')
}
}
const ctaClass = 't4-cta' + (state === 'hover' ? ' is-hover' : '')
const heading = step === 1 ? step1Heading : step2Heading
const subLead = step === 1 ? step1Lead : step2Lead
return (
<section className={('cf-two-step-order-4 ' + className).trim()} aria-labelledby={uid + '-h'}>
<style>{CSS}</style>
<div className='t4-wrap'>
<div className='t4-stage'>
<h2 id={uid + '-h'} className='t4-h t4-in'>{headline}</h2>
{lead ? <p className='t4-lead t4-in'>{lead}</p> : null}
{productImage ? (
<figure className='t4-shot t4-in'>
<img src={productImage} alt={productImageAlt} width={880} height={880} decoding='async' />
{productName || productNote ? (
<figcaption>
{productName ? <b>{productName}</b> : null}
{productNote}
</figcaption>
) : null}
</figure>
) : null}
{contents.length > 0 ? (
<div className='t4-pack t4-in'>
<p className='t4-pace'>{pacingLine}</p>
<ul className='t4-list'>
{contents.map((item, i) => (
<li key={item.name + i}>
<span className='t4-tick' aria-hidden='true'>
<Check size={16} strokeWidth={3} />
</span>
<span>
<b>{item.name}</b>
{item.detail ? <span className='t4-det'>{item.detail}</span> : null}
</span>
</li>
))}
</ul>
</div>
) : null}
</div>
<div className='t4-order'>
<form ref={formRef} className='t4-card' noValidate onSubmit={handleSubmit}>
<div className='t4-route' style={{ '--p': String(p) } as React.CSSProperties}>
<div
className='t4-track'
role='progressbar'
aria-label={copy.progressLabel}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={Math.round(p * 100)}
aria-valuetext={fill(copy.progressText, { done: doneCount, total: totalCount })}
>
<span className='t4-bar' />
<span className='t4-head' />
</div>
<ol className='t4-stops' aria-label={copy.routeLabel}>
<li className={'t4-stop ' + (step === 2 ? 'is-done' : 'is-active')} aria-current={step === 1 ? 'step' : undefined}>
{step === 2 ? (
<button type='button' className='t4-node' onClick={() => goTo(1)} disabled={locked}>
<span className='t4-dot' aria-hidden='true'>
<Check size={18} strokeWidth={3} />
</span>
<span className='t4-label'>
<span className='t4-sr'>{fill(copy.stepWord, { n: 1 })}</span>
{stops[0]}
<span className='t4-sr'>{copy.completed + ' ' + copy.editDetails}</span>
</span>
</button>
) : (
<span className='t4-node'>
<span className='t4-dot' aria-hidden='true'>1</span>
<span className='t4-label'>
<span className='t4-sr'>{fill(copy.stepWord, { n: 1 })}</span>
{stops[0]}
</span>
</span>
)}
</li>
<li className={'t4-stop ' + (step === 2 ? 'is-active' : 'is-next')} aria-current={step === 2 ? 'step' : undefined}>
<span className='t4-node'>
<span className='t4-dot' aria-hidden='true'>2</span>
<span className='t4-label'>
<span className='t4-sr'>{fill(copy.stepWord, { n: 2 })}</span>
{stops[1]}
</span>
</span>
</li>
<li className={'t4-stop ' + (ready ? 'is-ready' : 'is-dest')}>
<span className='t4-node'>
<span className='t4-dot' aria-hidden='true'>
<Package className='t4-dotico' size={18} strokeWidth={2.5} />
</span>
<span className='t4-label'>
{stops[2]}
{destSub ? <span className='t4-sub'>{destSub}</span> : null}
</span>
</span>
</li>
</ol>
</div>
<div className='t4-body' key={step}>
<div className='t4-intro'>
<h3 ref={headRef} tabIndex={-1} className='t4-title'>{heading}</h3>
{subLead ? <p className='t4-sublead'>{subLead}</p> : null}
</div>
{showAlert ? (
<p className='t4-alert' role='alert'>
<AlertCircle className='t4-inl' size={16} strokeWidth={2.5} aria-hidden='true' />
{fill(copy.alert, { count: errCount, fields: errCount === 1 ? copy.fieldWord : copy.fieldsWord })}
</p>
) : null}
<fieldset className='t4-fs' disabled={locked}>
<legend className='t4-sr'>{heading}</legend>
{step === 2 ? (
<div className='t4-well'>
<MapPin className='t4-well-ico' size={20} strokeWidth={2.5} aria-hidden='true' />
<p className='t4-well-text'>
<span className='t4-micro'>{copy.deliveringTo}</span>
{who ? <span className='t4-who'>{who}</span> : null}
{addr ? <span className='t4-addr'>{addr}</span> : null}
</p>
<button type='button' className='t4-back' onClick={() => goTo(1)}>
{backLabel}
</button>
</div>
) : null}
{step === 2 && acceptedCards.length > 0 ? (
<p className='t4-marks'>
<span>{copy.weAccept}</span>
{acceptedCards.map((m) => {
const Mark = MARKS[m].Icon
return (
<span key={m} className='t4-mk' role='img' aria-label={MARKS[m].label}>
<Mark aria-hidden='true' />
</span>
)
})}
</p>
) : null}
<div className='t4-grid'>
{activeFields.map((f) => (
<FieldRow
key={f.name}
f={f}
id={uid + '-' + f.name}
value={values[f.name] ?? ''}
error={errors[f.name]}
ok={Boolean(touched[f.name]) && !check(f, values[f.name] ?? '', copy)}
onChange={(v) => update(f, v)}
onBlur={() => leave(f)}
/>
))}
</div>
{step === 2 && bump ? (
<div className={'t4-bump' + (bumpOn ? ' is-on' : '')}>
<label className='t4-strip'>
<input
type='checkbox'
className='t4-check'
checked={bumpOn}
onChange={(e) => setBumpOn(e.target.checked)}
aria-describedby={uid + '-bt'}
/>
<span className='t4-box' aria-hidden='true'>
<Check size={16} strokeWidth={3} />
</span>
<span className='t4-btitle'>{fill(copy.bumpCheck, { title: bump.title })}</span>
<span className='t4-bprice'>{fill(copy.bumpPrice, { price: money(bumpAmt) })}</span>
</label>
<div className='t4-bbody'>
{bump.image ? <img src={bump.image} alt={bump.imageAlt ?? ''} width={144} height={144} loading='lazy' decoding='async' /> : null}
<div>
{bump.body ? <p>{bump.body}</p> : null}
<p className='t4-bterms' id={uid + '-bt'}>{copy.bumpTerms}</p>
</div>
</div>
</div>
) : null}
</fieldset>
{step === 1 ? (
<div className='t4-next'>
<button type='submit' className={ctaClass} disabled={locked}>
<span>{nextLabel}</span>
</button>
{nextNote ? <p className='t4-note'>{nextNote}</p> : null}
</div>
) : (
<div className='t4-close'>
<div className='t4-due'>
<p className='t4-figure'>
<span className='t4-sr'>{copy.dueToday + ' ' + money(total)}</span>
<span className='t4-price t4-pop' key={total} aria-hidden='true'>
<span className='t4-cur'>{parts.cur}</span>
<span>{parts.int}</span>
{parts.cents ? <span className='t4-cents'>{parts.cents}</span> : null}
</span>
</p>
<p className='t4-cad'>{fill(cadenceNote, { price: money(base) })}</p>
{bump && bumpOn ? <p className='t4-cad is-add'>{fill(copy.bumpIncluded, { title: bump.title, price: money(bumpAmt) })}</p> : null}
</div>
{billing ? (
<p className='t4-terms'>
<Repeat className='t4-inl' size={16} strokeWidth={2.5} aria-hidden='true' />
{billing}
</p>
) : null}
{status === 'failed' ? (
<p className='t4-alert' role='alert'>
<AlertCircle className='t4-inl' size={16} strokeWidth={2.5} aria-hidden='true' />
{copy.submitError}
</p>
) : null}
<button type='submit' className={ctaClass} disabled={locked} aria-busy={loading ? true : undefined}>
{loading ? (
<>
<Loader2 className='t4-spin' size={20} strokeWidth={2.5} aria-hidden='true' />
<span>{copy.loading}</span>
</>
) : (
<>
<ShoppingCart size={20} strokeWidth={2.5} aria-hidden='true' />
<span>{fill(orderLabel, { total: money(total) })}</span>
</>
)}
</button>
{orderNote ? (
<p className='t4-secure'>
<Lock className='t4-inl' size={16} strokeWidth={2.5} aria-hidden='true' />
{orderNote}
</p>
) : null}
{ps ? (
<p className='t4-ps'>
<strong>{copy.psLabel}</strong> {ps}
</p>
) : null}
</div>
)}
</div>
</form>
</div>
</div>
</section>
)
}
export default TwoStepOrder4
function FieldRow({
f,
id,
value,
error,
ok,
onChange,
onBlur,
}: {
f: FirstBoxField
id: string
value: string
error?: string
ok: boolean
onChange: (v: string) => void
onBlur: () => void
}) {
const kind = kindOf(f)
const Icon = ICONS[kind]
const errId = id + '-err'
const numeric = kind === 'card' || kind === 'expiry' || kind === 'cvc'
return (
<div className={'t4-f is-' + (f.size ?? 'full') + (error ? ' is-bad' : '')}>
<label htmlFor={id} className='t4-lab'>{f.label}</label>
<div className={'t4-ctl' + (Icon ? ' has-icon' : '')}>
{Icon ? <Icon className='t4-ico' size={18} strokeWidth={2.5} aria-hidden='true' /> : null}
<input
id={id}
name={f.name}
type={f.type ?? (kind === 'email' ? 'email' : 'text')}
autoComplete={f.autoComplete}
inputMode={f.inputMode ?? (numeric ? 'numeric' : kind === 'email' ? 'email' : undefined)}
placeholder={f.placeholder ?? PLACEHOLDERS[kind]}
value={value}
onChange={(e) => onChange(e.target.value)}
onBlur={onBlur}
aria-invalid={error ? true : undefined}
aria-describedby={error ? errId : undefined}
/>
{ok && !error ? <Check className='t4-okico' size={18} strokeWidth={2.5} aria-hidden='true' /> : null}
</div>
{error ? (
<p id={errId} className='t4-err'>
<AlertCircle className='t4-inl' size={16} strokeWidth={2.5} aria-hidden='true' />
{error}
</p>
) : null}
</div>
)
}
type Kind = 'name' | 'email' | 'address' | 'city' | 'region' | 'postal' | 'card' | 'expiry' | 'cvc' | 'text'
function kindOf(f: FirstBoxField): Kind {
const k = (f.name + ' ' + (f.autoComplete ?? '') + ' ' + (f.type ?? '')).toLowerCase()
const has = (...words: string[]) => words.some((w) => k.includes(w))
if (has('cc-number', 'card')) return 'card'
if (has('cc-exp', 'expir')) return 'expiry'
if (has('cc-csc', 'cvc', 'cvv', 'security')) return 'cvc'
if (has('email')) return 'email'
if (has('postal', 'zip')) return 'postal'
if (has('address-level2', 'city')) return 'city'
if (has('address-level1', 'state', 'region')) return 'region'
if (has('address', 'street')) return 'address'
if (has('name')) return 'name'
return 'text'
}
function check(f: FirstBoxField, raw: string, copy: TwoStepOrder4Copy): string {
const v = (raw ?? '').trim()
const kind = kindOf(f)
const required = fill(copy.required, { label: f.label.toLowerCase() })
if (kind === 'email') return /^[^ @]+@[^ @]+[.][^ @]{2,}$/.test(v) ? '' : v ? copy.email : required
if (kind === 'postal') return /^[A-Za-z0-9][A-Za-z0-9 -]{2,9}$/.test(v) ? '' : copy.postal
if (kind === 'card') {
const d = v.replace(/[^0-9]/g, '')
return d.length >= 13 && d.length <= 19 ? '' : copy.card
}
if (kind === 'expiry') {
const m = /^([0-9]{2}) ?[/] ?([0-9]{2})$/.exec(v)
return m && Number(m[1]) >= 1 && Number(m[1]) <= 12 ? '' : copy.expiry
}
if (kind === 'cvc') return /^[0-9]{3,4}$/.test(v) ? '' : copy.cvc
return v ? '' : required
}
function validateAll(list: FirstBoxField[], vals: Record<string, string>, copy: TwoStepOrder4Copy): Record<string, string> {
const out: Record<string, string> = {}
for (const f of list) {
const err = check(f, vals[f.name] ?? '', copy)
if (err) out[f.name] = err
}
return out
}
function countOk(list: FirstBoxField[], vals: Record<string, string>, copy: TwoStepOrder4Copy): number {
return list.filter((f) => !check(f, vals[f.name] ?? '', copy)).length
}
function pick(list: FirstBoxField[], vals: Record<string, string>): Record<string, string> {
return Object.fromEntries(list.map((f) => [f.name, (vals[f.name] ?? '').trim()]))
}
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 toNum(s?: string): number {
return parseFloat((s ?? '').replace(/[^0-9.]/g, '')) || 0
}
function formatMoney(n: number, currency: string): string {
try {
return new Intl.NumberFormat('en-US', { style: 'currency', currency, minimumFractionDigits: Number.isInteger(n) ? 0 : 2, maximumFractionDigits: 2 }).format(n)
} catch {
return '$' + n
}
}
function priceParts(n: number, currency: string): { cur: string; int: string; cents: string } {
try {
const parts = new Intl.NumberFormat('en-US', { style: 'currency', currency, minimumFractionDigits: 2, maximumFractionDigits: 2 }).formatToParts(n)
const cur = parts.filter((x) => x.type === 'currency').map((x) => x.value).join('')
const int = parts.filter((x) => x.type === 'integer' || x.type === 'group').map((x) => x.value).join('')
const frac = parts.find((x) => x.type === 'fraction')?.value ?? ''
return { cur, int, cents: Number.isInteger(n) ? '' : frac }
} catch {
return { cur: '$', int: String(Math.floor(n)), cents: '' }
}
}
function fill(t: string, vars: Record<string, string | number>): string {
return t.replace(/[{]([a-zA-Z0-9]+)[}]/g, (m, k: string) => (k in vars ? String(vars[k]) : m))
}
function defined<T>(o?: Partial<T>): Partial<T> {
const out: Partial<T> = {}
if (!o) return out
for (const k of Object.keys(o) as (keyof T)[]) if (o[k] !== undefined) out[k] = o[k]
return out
}
const SHIP_FIELDS: FirstBoxField[] = [
{ name: 'name', label: 'Full name', autoComplete: 'name', size: 'half' },
{ name: 'email', label: 'Email address', type: 'email', autoComplete: 'email', inputMode: 'email', size: 'half' },
{ name: 'address', label: 'Street address', autoComplete: 'shipping address-line1' },
{ name: 'city', label: 'City', autoComplete: 'shipping address-level2', size: 'half' },
{ name: 'state', label: 'State', autoComplete: 'shipping address-level1', size: 'quarter' },
{ name: 'zip', label: 'ZIP code', autoComplete: 'shipping postal-code', inputMode: 'numeric', size: 'quarter' },
]
const PAY_FIELDS: FirstBoxField[] = [
{ name: 'card', label: 'Card number', autoComplete: 'cc-number', inputMode: 'numeric' },
{ name: 'expiry', label: 'Expiry', autoComplete: 'cc-exp', inputMode: 'numeric', size: 'half' },
{ name: 'cvc', label: 'Security code', autoComplete: 'cc-csc', inputMode: 'numeric', size: 'half' },
]
const ALL_CARDS: CardMark[] = ['visa', 'mastercard', 'amex', 'discover']
const MARKS: Record<CardMark, { label: string; Icon: React.ElementType }> = {
visa: { label: 'Visa', Icon: Visa },
mastercard: { label: 'Mastercard', Icon: Mastercard },
amex: { label: 'American Express', Icon: AmericanExpress },
discover: { label: 'Discover', Icon: Discover },
}
const ICONS: Partial<Record<Kind, LucideIcon>> = {
name: User,
email: Mail,
address: MapPin,
city: Building2,
card: CreditCard,
expiry: CalendarDays,
cvc: Lock,
}
const PLACEHOLDERS: Record<Kind, string> = {
name: 'Jane Smith',
email: 'you@example.com',
address: '12 Elm Street',
city: 'Austin',
region: 'TX',
postal: '78701',
card: '1234 5678 9012 3456',
expiry: 'MM / YY',
cvc: '123',
text: 'Type your answer',
}
const R = '.cf-two-step-order-4'
const CSS = `
${R}{--t4-gap:clamp(32px,5vw,72px);--t4-top:clamp(56px,8vw,112px);--t4-bottom:clamp(64px,8.5vw,120px);--t4-rp:clamp(20px,3vw,32px);--t4-ink:var(--ink,oklch(0.21 0.034 263));--t4-muted:var(--muted,oklch(0.45 0.03 258));--t4-card:var(--card,oklch(1 0 0));--t4-band:var(--band,oklch(0.27 0.067 256));--t4-band-ink:var(--band-ink,oklch(1 0 0));--t4-accent:var(--accent,oklch(0.5 0.17 257));--t4-fill:var(--accent-fill,var(--accent,oklch(0.5 0.17 257)));--t4-success:var(--success,oklch(0.5 0.138 150));--t4-danger:var(--danger,oklch(0.5 0.17 27));--t4-danger-soft:var(--danger-soft,oklch(0.93 0.024 27));--t4-secondary:var(--secondary,oklch(0.93 0.015 263));--t4-secondary-ink:var(--secondary-ink,oklch(0.21 0.034 263));--t4-field:var(--field,oklch(1 0 0));--t4-field-ink:var(--field-ink,oklch(0.21 0.034 263));--t4-sh:var(--shadow,oklch(0.22 0.03 256));--t4-bg:var(--button-bg,var(--cta,oklch(0.58 0.21 29)));--t4-bg2:var(--button-bg-2,var(--cta-2,oklch(0.51 0.2 29)));--t4-line:oklch(from var(--t4-ink) l c h / 0.14);position:relative;isolation:isolate;overflow-x:hidden;overflow-x:clip;box-sizing:border-box;padding:var(--t4-top) clamp(16px,5vw,48px) var(--t4-bottom);background:var(--surface,oklch(1 0 0));color:var(--t4-ink);font-family:var(--font-body,system-ui,sans-serif);font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5}
${R} *,${R} *::before,${R} *::after{box-sizing:border-box}
${R} :where(h2,h3,p,ul,ol,figure,fieldset,legend){margin:0;padding:0}
${R} :where(ul,ol){list-style:none}
${R} .t4-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
${R} .t4-inl{display:inline-block;vertical-align:-0.15em;margin-inline-end:0.4em;flex:none}
${R} .t4-wrap{position:relative;max-width:1120px;margin:0 auto;display:grid;grid-template-columns:minmax(0,5fr) minmax(0,6fr);gap:var(--t4-gap);align-items:start}
${R} .t4-stage{--t4-reach:calc(var(--t4-gap) + 56px);position:relative;z-index:0;align-self:stretch;min-width:0;margin:calc(-1 * var(--t4-top)) calc(-1 * var(--t4-reach)) calc(-1 * var(--t4-bottom)) -100vw;padding:var(--t4-top) var(--t4-reach) var(--t4-bottom) 100vw;background:var(--t4-band);color:var(--t4-band-ink)}
${R} .t4-h{font-family:var(--font-display,inherit);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;margin-bottom:16px}
${R} .t4-lead{font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;text-wrap:pretty}
${R} .t4-shot{margin-top:32px}
${R} .t4-shot img{display:block;width:100%;max-width:360px;height:auto;aspect-ratio:1;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--t4-sh) l c h / 0.45)) drop-shadow(0 16px 20px oklch(from var(--t4-sh) l c h / 0.38))}
${R} .t4-shot figcaption{max-width:360px;margin-top:12px;font-size:15px;line-height:1.4;font-weight:500;text-wrap:pretty}
${R} .t4-shot figcaption b{display:block;font-size:17px;font-weight:800}
${R} .t4-pack{margin-top:32px}
${R} .t4-pace{font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance;margin-bottom:16px}
${R} .t4-list{display:grid;gap:16px}
${R} .t4-list li{display:grid;grid-template-columns:28px minmax(0,1fr);gap:12px;align-items:start}
${R} .t4-tick{width:28px;height:28px;border-radius:50%;display:grid;place-items:center;background:var(--t4-success);color:var(--status-glyph,#fff)}
${R} .t4-list b{display:block;font-size:17px;font-weight:800;line-height:1.3}
${R} .t4-det{display:block;margin-top:2px;font-size:15px;font-weight:500;line-height:1.4;text-wrap:pretty}
${R} .t4-order{position:sticky;top:24px;z-index:1;min-width:0;align-self:start}
${R} .t4-card{background:var(--t4-card);color:var(--t4-ink);border:1px solid var(--card-border,oklch(from var(--t4-ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px oklch(from var(--t4-sh) l c h / 0.22),0 12px 24px -8px oklch(from var(--t4-sh) l c h / 0.32)))}
${R} .t4-route{position:relative;padding:24px var(--t4-rp) 20px;border-bottom:1px solid var(--t4-line)}
${R} .t4-track{position:absolute;top:40px;left:calc(var(--t4-rp) + 18px);right:calc(var(--t4-rp) + 18px);height:4px;border-radius:999px;background:color-mix(in oklch,var(--t4-ink) 10%,var(--t4-card))}
${R} .t4-bar{position:absolute;left:0;top:0;bottom:0;width:calc(var(--p,0) * 100%);border-radius:inherit;background:var(--t4-fill);transition:width 0.45s cubic-bezier(0.2,0.7,0.2,1)}
${R} .t4-head{position:absolute;top:50%;left:calc(var(--p,0) * 100%);width:14px;height:14px;margin:-7px 0 0 -7px;border-radius:50%;background:var(--t4-fill);outline:3px solid var(--t4-card);box-shadow:0 1px 2px oklch(from var(--t4-sh) l c h / 0.35);transition:left 0.45s cubic-bezier(0.2,0.7,0.2,1)}
${R} .t4-stops{position:relative;z-index:1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
${R} .t4-stop{display:flex;flex-direction:column;align-items:center;text-align:center;min-width:0}
${R} .t4-stop:first-child{align-items:flex-start;text-align:left}
${R} .t4-stop:last-child{align-items:flex-end;text-align:right}
${R} .t4-node{display:flex;flex-direction:column;align-items:inherit;gap:8px;min-width:0;max-width:100%;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:inherit}
${R} button.t4-node{cursor:pointer;border-radius:12px}
${R} button.t4-node:focus-visible{outline:3px solid var(--field-focus,var(--t4-accent));outline-offset:4px}
${R} button.t4-node:disabled{cursor:not-allowed}
${R} .t4-dot{width:36px;height:36px;flex:0 0 auto;border-radius:50%;display:grid;place-items:center;background:var(--t4-secondary);color:var(--t4-secondary-ink);font-family:var(--font-display,inherit);font-weight:800;font-size:15px;line-height:1;font-variant-numeric:tabular-nums;transition:background-color 0.16s ease,color 0.16s ease,box-shadow 0.16s ease,transform 0.16s ease}
${R} .is-active .t4-dot{background:var(--t4-card);color:var(--t4-accent);box-shadow:inset 0 0 0 2px var(--t4-accent);outline:4px solid color-mix(in oklch,var(--t4-accent) 16%,var(--t4-card))}
${R} .is-done .t4-dot{background:var(--t4-success);color:var(--status-glyph,#fff)}
${R} button.t4-node:hover:not(:disabled) .t4-dot{background:oklch(from var(--t4-success) calc(l - 0.06) c h)}
${R} button.t4-node:active:not(:disabled) .t4-dot{transform:scale(0.94)}
${R} .is-ready .t4-dot{background:color-mix(in oklch,var(--t4-accent) 14%,var(--t4-card));color:var(--t4-accent);box-shadow:inset 0 0 0 2px oklch(from var(--t4-accent) l c h / 0.45)}
${R} .t4-label{display:block;max-width:100%;font-size:15px;font-weight:700;line-height:1.25;color:var(--t4-muted);overflow-wrap:anywhere}
${R} .is-active .t4-label,${R} .is-ready .t4-label{color:var(--t4-ink)}
${R} button.t4-node:hover:not(:disabled) .t4-label{color:var(--t4-ink);text-decoration:underline;text-underline-offset:0.18em}
${R} .t4-sub{display:block;margin-top:2px;font-size:14px;font-weight:500;color:var(--t4-muted)}
${R} .t4-body{padding:var(--t4-rp);animation:t4-rise 0.45s cubic-bezier(0.2,0.7,0.2,1) both}
${R} .t4-intro{margin-bottom:24px}
${R} .t4-title{font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;text-wrap:balance;outline:none}
${R} .t4-sublead{margin-top:8px;color:var(--t4-muted);font-size:17px;line-height:1.5;text-wrap:pretty}
${R} .t4-alert{margin:0 0 20px;padding:12px 16px;border-radius:10px;background:var(--t4-danger-soft);color:var(--t4-danger);font-size:15px;font-weight:600;line-height:1.4;text-wrap:pretty}
${R} .t4-fs{border:0;min-width:0;display:grid;gap:20px}
${R} .t4-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:16px}
${R} .t4-f{grid-column:span 12;min-width:0}
${R} .t4-f.is-half{grid-column:span 6}
${R} .t4-f.is-quarter{grid-column:span 3}
${R} .t4-lab{display:block;margin-bottom:8px;font-size:16px;font-weight:700;line-height:1.25;color:var(--label-ink,var(--t4-ink))}
${R} .t4-ctl{position:relative}
${R} .t4-ico{position:absolute;left:16px;top:50%;transform:translateY(-50%);color:color-mix(in oklch,var(--t4-field-ink) 55%,var(--t4-field));pointer-events:none}
${R} .t4-okico{position:absolute;right:14px;top:50%;transform:translateY(-50%);color:var(--t4-success);pointer-events:none}
${R} .t4-ctl input{display:block;width:100%;height:56px;padding:0 44px 0 16px;border:1px solid var(--field-border,color-mix(in oklch,var(--t4-ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));background:var(--t4-field);color:var(--t4-field-ink);font:inherit;font-size:17px;line-height:1.2;-webkit-appearance:none;appearance:none;transition:border-color 0.16s ease,box-shadow 0.16s ease}
${R} .t4-ctl.has-icon input{padding-left:46px}
${R} .t4-ctl input::placeholder{color:color-mix(in oklch,var(--t4-field-ink) 65%,var(--t4-field));opacity:1}
${R} .t4-ctl input:hover{border-color:color-mix(in oklch,var(--t4-ink) 40%,transparent)}
${R} .t4-ctl input:focus{outline:none;border-color:var(--field-focus,var(--t4-accent));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--t4-accent)) l c h / 0.35)}
${R} .is-bad .t4-ctl input{border-color:var(--t4-danger)}
${R} .is-bad .t4-ctl input:focus{border-color:var(--t4-danger);box-shadow:0 0 0 3px oklch(from var(--t4-danger) l c h / 0.3)}
${R} .t4-ctl input:disabled{cursor:not-allowed;background:color-mix(in oklch,var(--t4-field-ink) 5%,var(--t4-field))}
${R} .t4-err{margin-top:8px;font-size:15px;font-weight:600;line-height:1.4;color:var(--t4-danger);text-wrap:pretty}
${R} .t4-well{display:flex;flex-wrap:wrap;align-items:flex-start;gap:12px 16px;padding:14px 16px;border-radius:10px;background:color-mix(in oklch,var(--t4-ink) 4%,var(--t4-card))}
${R} .t4-well-ico{flex:none;margin-top:2px;color:var(--t4-accent)}
${R} .t4-well-text{flex:1 1 180px;min-width:0;font-size:15px;line-height:1.4;font-weight:500;color:var(--t4-ink)}
${R} .t4-micro{display:block;margin-bottom:4px;font-size:14px;font-weight:800;line-height:1.2;color:var(--t4-muted)}
${R} .t4-who{display:block;font-size:16px;font-weight:800}
${R} .t4-addr{display:block;overflow-wrap:anywhere}
${R} .t4-back{flex:none;min-height:44px;padding:0 18px;border:1px solid var(--button-2-border,transparent);border-radius:var(--button-radius,var(--radius,12px));background:var(--button-2-bg,var(--t4-secondary));color:var(--button-2-ink,var(--t4-secondary-ink));box-shadow:var(--button-2-shadow,var(--shadow-sm,0 1px 2px oklch(from var(--t4-sh) l c h / 0.2)));font-family:var(--button-font,var(--font-display,inherit));font-weight:var(--button-weight,800);text-transform:var(--button-case,none);font-size:15px;line-height:1;cursor:pointer;transition:background-color 0.16s ease,transform 0.16s ease}
${R} .t4-back:hover:not(:disabled){background:oklch(from var(--button-2-bg,var(--t4-secondary)) calc(l - 0.04) c h)}
${R} .t4-back:active:not(:disabled){transform:translateY(1px)}
${R} .t4-back:focus-visible{outline:3px solid var(--field-focus,var(--t4-accent));outline-offset:2px}
${R} .t4-back:disabled{cursor:not-allowed;opacity:0.6}
${R} .t4-marks{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:15px;font-weight:600;line-height:1.2;color:var(--t4-muted)}
${R} .t4-marks > span:first-child{margin-inline-end:4px}
${R} .t4-mk{display:inline-flex;line-height:0}
${R} .t4-mk svg{width:38px;height:auto}
${R} .t4-bump{border-radius:12px;overflow:hidden;border:1px solid oklch(from var(--bump-ink,var(--t4-ink)) l c h / 0.18);background:var(--bump,oklch(0.975 0.04 95));color:var(--bump-ink,var(--t4-ink));transition:box-shadow 0.16s ease}
${R} .t4-bump.is-on{outline:2px solid var(--t4-success);outline-offset:-1px}
${R} .t4-strip{position:relative;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:start;gap:12px;padding:14px 16px;background:var(--bump-strip,oklch(0.93 0.11 95));cursor:pointer;transition:background-color 0.16s ease}
${R} .t4-strip:hover{background:oklch(from var(--bump-strip,oklch(0.93 0.11 95)) calc(l - 0.03) c h)}
${R} .t4-check{position:absolute;left:16px;top:14px;width:24px;height:24px;margin:0;opacity:0;cursor:pointer}
${R} .t4-box{width:24px;height:24px;border-radius:6px;display:grid;place-items:center;background:var(--t4-field);border:2px solid oklch(from var(--bump-ink,var(--t4-ink)) l c h / 0.6);color:transparent;transition:background-color 0.16s ease,border-color 0.16s ease}
${R} .t4-check:checked + .t4-box{background:var(--t4-success);border-color:var(--t4-success);color:var(--status-glyph,#fff)}
${R} .t4-check:focus-visible + .t4-box{outline:3px solid var(--field-focus,var(--t4-accent));outline-offset:2px}
${R} .t4-check:disabled,${R} .t4-check:disabled ~ *{cursor:not-allowed}
${R} .t4-btitle{font-size:17px;font-weight:800;line-height:1.3;text-wrap:pretty}
${R} .t4-bprice{font-size:15px;font-weight:800;line-height:1.45;white-space:nowrap;font-variant-numeric:tabular-nums}
${R} .t4-bbody{display:flex;gap:14px;align-items:flex-start;padding:14px 16px 16px}
${R} .t4-bbody img{flex:none;width:72px;height:72px;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--t4-sh) l c h / 0.3)) drop-shadow(0 8px 10px oklch(from var(--t4-sh) l c h / 0.22))}
${R} .t4-bbody p{font-size:15px;line-height:1.45;font-weight:500;text-wrap:pretty}
${R} .t4-bbody .t4-bterms{margin-top:6px;font-weight:800}
${R} .t4-next{display:grid;gap:12px;margin-top:24px}
${R} .t4-close{display:grid;gap:16px;margin-top:24px}
${R} .t4-close .t4-alert{margin:0}
${R} .t4-price{display:inline-flex;align-items:flex-start;font-family:var(--font-display,inherit);font-weight:800;font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;letter-spacing:-0.03em;font-variant-numeric:tabular-nums;color:var(--t4-ink);transform-origin:left bottom}
${R} .t4-cur,${R} .t4-cents{font-size:0.44em;line-height:1;margin-top:0.12em;letter-spacing:0}
${R} .t4-cur{margin-right:0.06em}
${R} .t4-cents{margin-left:0.04em}
${R} .t4-cad{margin-top:12px;font-size:15px;font-weight:600;line-height:1.4;color:var(--t4-muted);text-wrap:pretty}
${R} .t4-cad.is-add{margin-top:4px;color:var(--t4-ink)}
${R} .t4-terms{font-size:15px;font-weight:500;line-height:1.45;color:var(--t4-muted);text-wrap:pretty}
${R} .t4-note,${R} .t4-secure{font-size:15px;font-weight:500;line-height:1.4;color:var(--t4-muted);text-align:center;text-wrap:pretty}
${R} .t4-secure{font-weight:600}
${R} .t4-ps{margin-top:8px;font-size:17px;line-height:1.5;color:var(--t4-ink);text-wrap:pretty}
${R} .t4-ps strong{font-weight:800}
${R} .t4-cta{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));font-family:var(--button-font,var(--font-display,inherit));font-weight:var(--button-weight,800);text-transform:var(--button-case,none);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-align:center;text-wrap:balance;color:var(--button-ink,var(--cta-ink,#fff));text-shadow:var(--button-text-shadow,none);background:linear-gradient(oklch(from var(--t4-bg) calc(l + 0.04) c h),oklch(from var(--t4-bg2) calc(l - 0.02) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--t4-bg) calc(l + 0.14) c h / 0.7),inset 0 -3px 0 oklch(from var(--t4-bg) calc(l - 0.16) c h),0 1px 2px oklch(from var(--t4-sh) l c h / 0.3),0 8px 16px -6px oklch(from var(--t4-sh) l c h / 0.45));cursor:pointer;transition:background 0.16s ease,box-shadow 0.16s ease,transform 0.16s ease}
${R} .t4-cta > span{min-width:0}
${R} .t4-cta:hover:not(:disabled),${R} .t4-cta.is-hover:not(:disabled){background:linear-gradient(oklch(from var(--t4-bg) calc(l - 0.01) c h),oklch(from var(--t4-bg2) calc(l - 0.07) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--t4-bg) calc(l + 0.12) c h / 0.6),inset 0 -3px 0 oklch(from var(--t4-bg) calc(l - 0.2) c h),0 1px 2px oklch(from var(--t4-sh) l c h / 0.34),0 10px 20px -6px oklch(from var(--t4-sh) l c h / 0.55))}
${R} .t4-cta:active:not(:disabled){transform:translateY(1px);box-shadow:inset 0 2px 4px oklch(from var(--t4-bg) calc(l - 0.22) c h / 0.45),inset 0 -2px 0 oklch(from var(--t4-bg) calc(l - 0.16) c h),0 1px 2px oklch(from var(--t4-sh) l c h / 0.3)}
${R} .t4-cta:focus-visible{outline:3px solid var(--field-focus,var(--t4-accent));outline-offset:3px}
${R} .t4-cta:disabled:not([aria-busy='true']){cursor:not-allowed;background:var(--button-2-bg,var(--t4-secondary));color:var(--button-2-ink,var(--t4-secondary-ink));box-shadow:var(--button-2-shadow,var(--shadow-sm,0 1px 2px oklch(from var(--t4-sh) l c h / 0.2)));text-shadow:none}
${R} .t4-cta[aria-busy='true']{cursor:progress}
@keyframes t4-rise{from{opacity:0.82;transform:translateY(8px)}}
@keyframes t4-pop{from{transform:scale(0.9)}}
@keyframes t4-spin{to{transform:rotate(360deg)}}
${R} .t4-in{animation:t4-rise 0.45s cubic-bezier(0.2,0.7,0.2,1) both}
${R} .t4-in:nth-child(2){animation-delay:0.07s}
${R} .t4-in:nth-child(3){animation-delay:0.14s}
${R} .t4-in:nth-child(4){animation-delay:0.21s}
${R} .t4-pop{animation:t4-pop 0.3s cubic-bezier(0.2,0.7,0.2,1) both}
${R} .t4-spin{animation:t4-spin 0.8s linear infinite}
@media (max-width:900px){
${R} .t4-wrap{grid-template-columns:minmax(0,1fr);gap:32px}
${R} .t4-order{position:relative;top:auto}
${R} .t4-stage{--t4-tuck:140px;align-self:start;display:grid;grid-template-columns:minmax(0,1fr) 220px;column-gap:24px;align-items:start;margin-right:-100vw;padding-right:100vw;margin-bottom:calc(-1 * var(--t4-tuck));padding-bottom:var(--t4-tuck)}
${R} .t4-stage > *{grid-column:1}
${R} .t4-stage > .t4-shot{grid-column:2;grid-row:1 / span 3;margin-top:0}
}
@media (max-width:600px){
${R} .t4-stage{display:block}
${R} .t4-stage > .t4-shot{display:none}
${R} .t4-pack{margin-top:24px}
${R} .t4-route{padding:20px var(--t4-rp) 18px}
${R} .t4-track{top:34px;left:calc(var(--t4-rp) + 16px);right:calc(var(--t4-rp) + 16px)}
${R} .t4-dot{width:32px;height:32px}
${R} .t4-label{font-size:14px;line-height:1.2}
${R} .t4-sub{display:none}
${R} .t4-node{gap:6px}
${R} .t4-f.is-half{grid-column:span 12}
${R} .t4-f.is-quarter{grid-column:span 6}
}
@media (max-width:420px){
${R} .t4-strip{grid-template-columns:auto minmax(0,1fr)}
${R} .t4-bprice{grid-column:2}
${R} .t4-bbody img{width:56px;height:56px}
}
@media (prefers-reduced-motion:reduce){
${R} *,${R} *::before,${R} *::after{animation:none !important;transition:none !important}
}
`
pieces/checkout/two-step-order-4/specimen.tsx 74 lines
import __studioImage038331af from "../assets/947795f85ec8ddca.webp";
import __studioImage0f072225 from "../assets/e8822fc9f7e9d7d2.webp";
// Specimen: the fictional Fernway monthly plant box on its route to the first box.
import * as React from 'react'
import { TwoStepOrder4, type TwoStepOrder4State } from '../two-step-order-4'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'error', 'disabled']
const ADDRESS: Record<string, string> = {
name: 'Jane Smith',
email: 'jane@example.com',
address: '12 Elm Street',
city: 'Austin',
state: 'TX',
zip: '78701',
}
const VALUES: Partial<Record<TwoStepOrder4State, Record<string, string>>> = {
active: { ...ADDRESS, card: '4242 4242 4242 4242' },
error: { name: 'Jane Smith', email: 'jane@example', address: '12 Elm Street' },
disabled: ADDRESS,
}
export default function TwoStepOrder4Specimen({ state }: { state?: TwoStepOrder4State }) {
const sample = defaults.sample
return (
<TwoStepOrder4
key={state ?? 'default'}
state={state}
defaultValues={state ? VALUES[state] : undefined}
headline='Your first Fernway box is two quick steps away'
lead='Two easy-care houseplants and everything they need, delivered every month.'
productName='The Fernway Monthly Plant Box'
productNote='New plants every month · Skip or cancel anytime'
productImage={slot(
'product',
__studioImage038331af
)}
productImageAlt='An open Fernway box with two potted houseplants, a care card and potting mix'
pacingLine='When your first box lands, you’ll lift the lid on:'
contents={[
{ name: 'Two easy-care houseplants', detail: 'Potted and ready for a shelf, sill or desk.' },
{ name: 'A care card for each plant', detail: 'Light, water and repotting, in plain words.' },
{ name: 'A bag of fresh potting mix', detail: 'Ready for the day your plant outgrows its pot.' },
]}
price={sample.price}
cadenceNote='Due today, then {price} every month'
billing={'You’re billed ' + sample.price + ' today, then ' + sample.price + ' every month until you cancel. Skip a month or cancel anytime.'}
stops={['Your details', 'Payment', 'Your first box']}
destinationNote='Straight to your door'
step1Heading='Where should we deliver your first box?'
step1Lead='Tell us where your plants should land.'
step2Heading='Lock in your first Fernway box'
nextLabel='Continue to Payment'
nextNote='You’ll see your total before you pay.'
orderLabel='Add To Cart · {total}'
orderNote='Secure checkout · Cancel anytime from your account'
bump={{
title: 'glazed ceramic planter',
price: '$19',
body: 'A hand-glazed 5-inch pot with a matching saucer, sized for your first plant.',
image: slot(
'item-1',
__studioImage0f072225
),
imageAlt: 'Green glazed ceramic planter with saucer',
}}
ps={'Your first box is covered by our ' + sample.guarantee + '. If it isn’t right for you, you get your money back.'}
onSubmit={() => undefined}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalTwoStepOrder4 |
string |
Default 'Your first box is two quick steps away'
|
lead OptionalTwoStepOrder4 |
string |
Default 'Tell us where it goes, add your payment, and your first box is booked.'
|
productName OptionalTwoStepOrder4 |
string |
Default 'Your monthly box'
|
productNote OptionalTwoStepOrder4 |
string |
|
productImage OptionalTwoStepOrder4 |
string |
|
productImageAlt OptionalTwoStepOrder4 |
string |
Default 'An open subscription box'
|
contents OptionalTwoStepOrder4 |
FirstBoxItem[] |
Default []
|
pacingLine OptionalTwoStepOrder4 |
string |
Default 'When your first box lands, you’ll unpack:'
|
price OptionalTwoStepOrder4 |
string |
Default '$47'
|
cadenceNote OptionalTwoStepOrder4 |
string |
Default 'Due today, then {price} every month'
|
billing OptionalTwoStepOrder4 |
string | null |
Default null
|
stops OptionalTwoStepOrder4 |
[string, string, string] |
Default ['Your details', 'Payment', 'Your first box']
|
destinationNote OptionalTwoStepOrder4 |
string |
Default 'Straight to your door'
|
fields OptionalTwoStepOrder4 |
FirstBoxField[] |
Default SHIP_FIELDS
|
paymentFields OptionalTwoStepOrder4 |
FirstBoxField[] |
Default PAY_FIELDS
|
step1Heading OptionalTwoStepOrder4 |
string |
Default 'Where should we deliver your first box?'
|
step1Lead OptionalTwoStepOrder4 |
string |
|
step2Heading OptionalTwoStepOrder4 |
string |
Default 'Lock in your first box'
|
step2Lead OptionalTwoStepOrder4 |
string |
|
nextLabel OptionalTwoStepOrder4 |
string |
Default 'Continue to Payment'
|
nextNote OptionalTwoStepOrder4 |
string |
Default 'You’ll see your total before you pay.'
|
orderLabel OptionalTwoStepOrder4 |
string |
Default 'Add To Cart · {total}'
|
orderNote OptionalTwoStepOrder4 |
string |
Default 'Secure checkout'
|
backLabel OptionalTwoStepOrder4 |
string |
Default 'Back'
|
bump OptionalTwoStepOrder4 |
FirstBoxBump | null |
Default null
|
ps OptionalTwoStepOrder4 |
string | null |
Default null
|
acceptedCards OptionalTwoStepOrder4 |
CardMark[] |
Default ALL_CARDS
|
currency OptionalTwoStepOrder4 |
string |
Default 'USD'
|
copy OptionalTwoStepOrder4 |
Partial<TwoStepOrder4Copy> |
|
state OptionalTwoStepOrder4 |
TwoStepOrder4State |
|
initialStep OptionalTwoStepOrder4 |
1 | 2 |
Default 1
|
defaultValues OptionalTwoStepOrder4 |
Record<string, string> |
|
disabled OptionalTwoStepOrder4 |
boolean |
Default false
|
onContinue OptionalTwoStepOrder4 |
(values: Readonly<Record<string, string>>) => void |
|
onSubmit OptionalTwoStepOrder4 |
(values: Readonly<Record<string, string>>, bumpSelected: boolean) => void | Promise<void> |
|
className OptionalTwoStepOrder4 |
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).
-
947795f85ec8ddca.webp
image/webp · 106 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
e8822fc9f7e9d7d2.webp
image/webp · 72.6 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB