Two Step Order 13
Takes the order as a short two-step interview: quick contact questions first, then the reasons, payment, the optional add-on and an order button that carries today’s total.
Use it in a prompt
Use checkout/two-step-order-13 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-13.tsx. - Import it and pass your copy and images (Props tab):
import { TwoStepOrder13 } from "@/components/funneldna/checkout/two-step-order-13"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/checkout/two-step-order-13/component.tsx 826 lines
// layout: interview-qa
// Takes the order as a short two-step interview: quick contact questions first, then the reasons, payment, the optional add-on and an order button that carries today’s total.
// Theme notes: official payment-network SVG marks (Visa, Mastercard, American Express, Discover) keep their brand colours under the theme-contract mark exception. The completed-step tick and the add-on tick are solid --success fills with a white glyph, overridable through --status-glyph.
'use client'
import * as React from 'react'
import { AlertCircle, CalendarDays, Check, CreditCard, Loader2, Lock, Mail, MapPin, ShieldCheck, User, type LucideIcon } from 'lucide-react'
import { AmericanExpress, Discover, Mastercard, Visa } from 'react-svg-credit-card-payment-icons/icons/flat-rounded'
export type OrderField = {
/** Key in the submitted values; also picks the field icon and the default placeholder. */
name: string
/** Small label inside grouped questions; also used in the required-field message. */
label: string
type?: string
autoComplete?: string
/** Example answer. A sensible default is shown when omitted. */
placeholder?: string
inputMode?: 'text' | 'email' | 'numeric' | 'tel'
/** Shares a row with the neighbouring half field. */
half?: boolean
}
/** One interview question. A single field uses the question itself as its label. */
export type OrderQuestion = { question: string; fields: OrderField[] }
export type OrderItem = { name: string; image?: string; imageAlt?: string }
export type OrderBump = {
title: string
/** Supplied add-on price, added to the total only when ticked. */
price: string
body?: string
}
export type CardMark = 'visa' | 'mastercard' | 'amex' | 'discover'
export type TwoStepOrder13State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
const COPY = {
stepsLabel: 'Checkout steps',
steps: ['Your details', 'Payment'] as [string, string],
stepOf: 'Step {n}: ',
completed: 'completed',
qLabel: 'Q{n}',
step1Heading: 'Let’s get {product} to you',
step2Heading: 'Last step: finish your order',
nextLabel: 'Continue to Payment',
nextNote: 'You’ll see your total before you pay.',
detailsLabel: 'Sending to',
back: 'Back',
reasonsQuestion: 'What do I get for {price}?',
reasonsLead: '{count} reasons this is {price} today:',
numberWords: ['One', 'Two', 'Three', 'Four', 'Five', 'Six'],
payQuestion: 'How would you like to pay?',
weAccept: 'We accept',
bumpQuestion: 'Want the {title} too?',
bumpLabel: 'Yes, add the {title} for {price}',
bumpAdded: 'Added to your order. Your new total is {total}.',
finalQuestion: 'Ready to plan your first funnel?',
orderLabel: 'Start Planning My Funnel',
orderSub: '{total} today · One payment',
loading: 'Processing your order…',
secureNote: 'Secure checkout · Instant download',
alert: 'Please fix {count} {fields} to continue.',
fieldWord: 'answer',
fieldsWord: 'answers',
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 TwoStepOrder13Copy = typeof COPY
export type TwoStepOrder13Props = {
productName?: string
/** Short line beside the product name on step 1. */
productNote?: string
/** Today’s supplied price: shown on the order button and in the reasons. */
price?: string
/** Kit contents; up to three thumbnails sit beside the product name (slots: item-1 … item-3). */
items?: OrderItem[]
/** Numbered inline reasons answering copy.reasonsQuestion. Pass [] to hide the question. */
reasons?: string[]
/** Step 1 contact questions. */
contactQuestions?: OrderQuestion[]
/** Appends shippingQuestions to step 1 for physical products. */
collectShipping?: boolean
shippingQuestions?: OrderQuestion[]
/** Step 2 card fields. */
paymentFields?: OrderField[]
/** Optional add-on, unchecked unless initialBump is set. Supply only with a real price. */
bump?: OrderBump | null
/** Guarantee line under the order button. Pass null to hide it. */
guarantee?: string | null
acceptedCards?: CardMark[]
/** ISO currency code used when the add-on changes the total. */
currency?: string
/** Interface copy. Templates replace {n}, {product}, {price}, {count}, {title}, {total}, {fields} and {label} as text. */
copy?: Partial<TwoStepOrder13Copy>
/** active opens step 2 (payment); hover previews the button hover; error shows step 1 with inline errors. */
state?: TwoStepOrder13State
initialStep?: 1 | 2
initialBump?: boolean
/** Prefilled answers keyed by field name. */
defaultValues?: Record<string, string>
/** Locks every control, same as state disabled. */
disabled?: boolean
/** Called with the validated step 1 answers when the buyer moves to payment. */
onContinue?: (values: Readonly<Record<string, string>>) => void
/** Receives validated values and the add-on choice. The piece never sends data or charges money. 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 TwoStepOrder13({
productName = 'The Funnel Starter Kit',
productNote = 'One payment · Lifetime access',
price = '$47',
items = [],
reasons = DEFAULT_REASONS,
contactQuestions = CONTACT_QUESTIONS,
collectShipping = false,
shippingQuestions = SHIPPING_QUESTIONS,
paymentFields = PAYMENT_FIELDS,
bump = null,
guarantee = '30-day money-back guarantee',
acceptedCards = ALL_CARDS,
currency = 'USD',
copy: copyOverrides,
state,
initialStep = 1,
initialBump = false,
defaultValues,
disabled: disabledProp = false,
onContinue,
onSubmit,
className = '',
}: TwoStepOrder13Props) {
const copy = { ...COPY, ...defined<TwoStepOrder13Copy>(copyOverrides) } as TwoStepOrder13Copy
const uid = 't13' + React.useId().replace(/[^a-zA-Z0-9]/g, '')
const step1Questions = React.useMemo(
() => [...contactQuestions, ...(collectShipping ? shippingQuestions : [])],
[contactQuestions, collectShipping, shippingQuestions]
)
const step1Fields = React.useMemo(() => step1Questions.flatMap((q) => q.fields), [step1Questions])
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' ? check(step1Fields, defaultValues ?? {}, copy) : {}
)
const [alertOn, setAlertOn] = React.useState(state === 'error')
const [bumpOn, setBumpOn] = React.useState(initialBump)
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)
const disabled = state === 'disabled' || disabledProp
const loading = status === 'loading'
const locked = disabled || loading
const hover = state === 'hover' ? ' is-hover' : ''
React.useEffect(
() => () => {
run.current++
if (frame.current !== undefined) cancelAnimationFrame(frame.current)
},
[]
)
React.useEffect(() => {
if (seenState.current === state) return
seenState.current = state
run.current++
setStep(state === 'active' ? 2 : state === 'error' ? 1 : initialStep)
setStatus('idle')
setErrors(state === 'error' ? check(step1Fields, values, copy) : {})
setAlertOn(state === 'error')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
React.useEffect(() => {
if (moved.current) headRef.current?.focus()
}, [step])
const base = toNum(price)
const bumpChosen = Boolean(bump && bumpOn)
const totalText = bump && bumpOn ? money(base + toNum(bump.price), currency) : price
const errorCount = Object.keys(errors).length
const thumbs = items.filter((it) => it.image).slice(0, 3)
const fid = (name: string) => `${uid}-${name}`
const recap = [values.name, values.email].map((v) => (v ?? '').trim()).filter(Boolean).join(' · ')
const focusFirst = (errs: Record<string, string>) => {
const key = Object.keys(errs)[0]
if (!key) return
frame.current = requestAnimationFrame(() => {
formRef.current?.querySelector<HTMLInputElement>(`[name='${key}']`)?.focus()
})
}
const update = (name: string, raw: string) => {
setValues((prev) => ({ ...prev, [name]: shape(name, raw) }))
if (errors[name]) {
setErrors((prev) => {
const next = { ...prev }
delete next[name]
return next
})
}
if (status === 'failed') setStatus('idle')
}
const goNext = () => {
if (locked) return
const errs = check(step1Fields, values, copy)
setErrors(errs)
if (Object.keys(errs).length) {
setAlertOn(true)
focusFirst(errs)
return
}
setAlertOn(false)
onContinue?.(pick(values, step1Fields))
moved.current = true
setStep(2)
}
const goBack = () => {
if (locked) return
moved.current = true
setErrors({})
setAlertOn(false)
setStatus('idle')
setStep(1)
}
const submit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
if (locked) return
if (step === 1) return goNext()
const errs = check(paymentFields, values, copy)
setErrors(errs)
if (Object.keys(errs).length) {
setAlertOn(true)
focusFirst(errs)
return
}
setAlertOn(false)
const result: unknown = onSubmit?.(pick(values, [...step1Fields, ...paymentFields]), bumpChosen)
if (result && typeof (result as PromiseLike<void>).then === 'function') {
const id = ++run.current
setStatus('loading')
try {
await result
if (id === run.current) setStatus('idle')
} catch {
if (id === run.current) setStatus('failed')
}
}
}
const renderField = (f: OrderField, showLabel: boolean) => {
const id = fid(f.name)
const err = errors[f.name]
const Icon = ICONS[f.name] ?? (f.type === 'email' ? Mail : undefined)
return (
<div className={`t13-field${f.half ? ' is-half' : ''}`} key={f.name}>
{showLabel && (
<label className='t13-label' htmlFor={id}>
{f.label}
</label>
)}
<div className='t13-control'>
{Icon && <Icon className='t13-ficon' aria-hidden='true' strokeWidth={2.5} />}
<input
id={id}
name={f.name}
className={`t13-input${Icon ? ' has-icon' : ''}`}
type={f.type ?? 'text'}
inputMode={f.inputMode}
autoComplete={f.autoComplete}
placeholder={placeholderFor(f)}
value={values[f.name] ?? ''}
onChange={(e) => update(f.name, e.target.value)}
disabled={locked}
required
aria-invalid={err ? true : undefined}
aria-describedby={err ? `${id}-err` : undefined}
/>
</div>
{err && (
<p className='t13-err' id={`${id}-err`}>
<AlertCircle className='t13-ii' aria-hidden='true' strokeWidth={2.5} />
{err}
</p>
)}
</div>
)
}
const renderGroup = (q: OrderQuestion, n: number) => {
const first = q.fields[0]
return (
<div className='t13-qa t13-in' style={rise(n)} key={`${n}-${q.question}`}>
<span className='t13-qn' aria-hidden='true'>
{fill(copy.qLabel, { n })}
</span>
{q.fields.length === 1 && first ? (
<div className='t13-qbody'>
<label className='t13-q' htmlFor={fid(first.name)}>
{q.question}
</label>
{renderField(first, false)}
</div>
) : (
<fieldset className='t13-qbody t13-set'>
<legend className='t13-q'>{q.question}</legend>
<div className='t13-row'>{q.fields.map((f) => renderField(f, true))}</div>
</fieldset>
)}
</div>
)
}
let qn = step1Questions.length
const reasonsN = reasons.length ? ++qn : 0
const payN = ++qn
const bumpN = bump ? ++qn : 0
const finalN = ++qn
return (
<div className={`cf-two-step-order-13 ${className}`.trim()}>
<style>{CSS}</style>
<form ref={formRef} className='t13-card' noValidate onSubmit={submit} aria-labelledby={`${uid}-h`}>
<ol className='t13-tabs' aria-label={copy.stepsLabel}>
{copy.steps.map((label, i) => {
const sn = (i + 1) as 1 | 2
const active = step === sn
const done = sn === 1 && step === 2
return (
<li key={sn}>
<button
type='button'
className={`t13-tab${active ? ' is-active' : ''}${done ? ' is-done' : ''}`}
aria-current={active ? 'step' : undefined}
disabled={locked || active}
onClick={sn === 1 ? goBack : goNext}
>
<span className='t13-tab-n' aria-hidden='true'>
{done ? <Check strokeWidth={3} /> : sn}
</span>
<span className='t13-tab-l'>
<span className='t13-sr'>{fill(copy.stepOf, { n: sn })}</span>
{label}
{done && <span className='t13-sr'>{` (${copy.completed})`}</span>}
</span>
</button>
</li>
)
})}
</ol>
<div className='t13-panel' key={step}>
<h2 id={`${uid}-h`} ref={headRef} tabIndex={-1} className='t13-h'>
{fill(step === 1 ? copy.step1Heading : copy.step2Heading, { product: productName })}
</h2>
{alertOn && errorCount > 0 && (
<p className='t13-alert' role='alert'>
<AlertCircle className='t13-ii' aria-hidden='true' strokeWidth={2.5} />
{fill(copy.alert, { count: errorCount, fields: errorCount === 1 ? copy.fieldWord : copy.fieldsWord })}
</p>
)}
{status === 'failed' && (
<p className='t13-alert' role='alert'>
<AlertCircle className='t13-ii' aria-hidden='true' strokeWidth={2.5} />
{copy.submitError}
</p>
)}
{step === 1 ? (
<>
{productName && (
<div className='t13-kit t13-in' style={rise(0)}>
{thumbs.length > 0 && (
<div className='t13-thumbs'>
{thumbs.map((it, i) => (
<img key={`${it.name}-${i}`} src={it.image} alt={it.imageAlt ?? it.name} width={56} height={56} decoding='async' />
))}
</div>
)}
<p className='t13-kit-t'>
<strong>{productName}</strong>
{productNote && <span>{productNote}</span>}
</p>
</div>
)}
<div className='t13-qas'>
{step1Questions.map((q, i) => renderGroup(q, i + 1))}
<div className='t13-act t13-in' style={rise(step1Questions.length + 1)}>
<button type='submit' className={`t13-btn t13-btn--next${hover}`} disabled={locked}>
<span className='t13-btn-main'>{copy.nextLabel}</span>
</button>
{copy.nextNote && <p className='t13-note'>{copy.nextNote}</p>}
</div>
</div>
</>
) : (
<>
<div className='t13-recap t13-in' style={rise(0)}>
<p className='t13-recap-t'>
{recap ? (
<>
<span>{copy.detailsLabel}</span> <strong>{recap}</strong>
</>
) : (
<strong>{copy.steps[0]}</strong>
)}
</p>
<button type='button' className='t13-btn2' onClick={goBack} disabled={locked}>
{copy.back}
</button>
</div>
<div className='t13-qas'>
{reasonsN > 0 && (
<div className='t13-qa t13-in' style={rise(1)}>
<span className='t13-qn' aria-hidden='true'>
{fill(copy.qLabel, { n: reasonsN })}
</span>
<div className='t13-qbody'>
<h3 className='t13-q'>{fill(copy.reasonsQuestion, { price })}</h3>
<p className='t13-a'>
<strong>
{fill(copy.reasonsLead, { count: copy.numberWords[reasons.length - 1] ?? String(reasons.length), price })}
</strong>
{reasons.map((r, i) => (
<React.Fragment key={i}>
{' '}
<span className='t13-r'>
<b className='t13-rn'>{i + 1}.</b>
{r}
</span>
</React.Fragment>
))}
</p>
</div>
</div>
)}
<div className='t13-qa t13-in' style={rise(2)}>
<span className='t13-qn' aria-hidden='true'>
{fill(copy.qLabel, { n: payN })}
</span>
<fieldset className='t13-qbody t13-set'>
<legend className='t13-q'>{copy.payQuestion}</legend>
{acceptedCards.length > 0 && (
<p className='t13-marks'>
<span>{copy.weAccept}</span>
{acceptedCards.map((c) => (
<span key={c} className='t13-mark' role='img' aria-label={CARD_LABELS[c]}>
{CARD_MARKS[c]()}
</span>
))}
</p>
)}
<div className='t13-row'>{paymentFields.map((f) => renderField(f, true))}</div>
</fieldset>
</div>
{bump && (
<div className='t13-qa t13-in' style={rise(3)}>
<span className='t13-qn' aria-hidden='true'>
{fill(copy.qLabel, { n: bumpN })}
</span>
<div className='t13-qbody'>
<h3 className='t13-q'>{fill(copy.bumpQuestion, { title: bump.title, price: bump.price })}</h3>
<div className={`t13-bump${bumpOn ? ' is-on' : ''}`}>
<label className='t13-bump-strip' htmlFor={fid('order-bump')}>
<input
id={fid('order-bump')}
type='checkbox'
className='t13-bump-in'
checked={bumpOn}
onChange={(e) => setBumpOn(e.target.checked)}
disabled={locked}
/>
<span className='t13-box' aria-hidden='true'>
<Check strokeWidth={3} />
</span>
<span>{fill(copy.bumpLabel, { title: bump.title, price: bump.price })}</span>
</label>
{bump.body && <p className='t13-bump-b'>{bump.body}</p>}
<p className='t13-bump-added' aria-live='polite'>
{bumpOn ? fill(copy.bumpAdded, { total: totalText, price: bump.price }) : ''}
</p>
</div>
</div>
</div>
)}
<div className='t13-qa t13-in' style={rise(4)}>
<span className='t13-qn' aria-hidden='true'>
{fill(copy.qLabel, { n: finalN })}
</span>
<div className='t13-qbody'>
<h3 className='t13-q'>{copy.finalQuestion}</h3>
</div>
<div className='t13-wide'>
<button
type='submit'
className={`t13-btn t13-btn--order${hover}`}
disabled={locked}
aria-busy={loading || undefined}
>
{loading ? (
<span className='t13-btn-main'>
<Loader2 className='t13-spin' aria-hidden='true' strokeWidth={2.5} />
{copy.loading}
</span>
) : (
<>
<span className='t13-btn-main'>{copy.orderLabel}</span>
<span className='t13-btn-sub'>{fill(copy.orderSub, { total: totalText })}</span>
</>
)}
</button>
<p className='t13-assure'>
<Lock className='t13-ii' aria-hidden='true' strokeWidth={2.5} />
{copy.secureNote}
{guarantee ? (
<>
<span className='t13-sep' aria-hidden='true'>
·
</span>
<ShieldCheck className='t13-ii' aria-hidden='true' strokeWidth={2.5} />
{guarantee}
</>
) : null}
</p>
</div>
</div>
</div>
</>
)}
</div>
</form>
</div>
)
}
export default TwoStepOrder13
const DEFAULT_REASONS = [
'You get the guide, workbook, and checklist in one download.',
'You pay once and it’s yours to keep.',
'You’re covered by the 30-day money-back guarantee.',
]
const CONTACT_QUESTIONS: OrderQuestion[] = [
{ question: 'What’s your name?', fields: [{ name: 'name', label: 'Full name', autoComplete: 'name', placeholder: 'Jane Smith' }] },
{
question: 'Where should we email your kit?',
fields: [{ name: 'email', label: 'Email address', type: 'email', inputMode: 'email', autoComplete: 'email', placeholder: 'you@example.com' }],
},
]
const SHIPPING_QUESTIONS: OrderQuestion[] = [
{
question: 'Where should we ship it?',
fields: [
{ name: 'address', label: 'Street address', autoComplete: 'shipping street-address', placeholder: '123 Main Street' },
{ name: 'city', label: 'City', autoComplete: 'shipping address-level2', placeholder: 'Austin', half: true },
{ name: 'zip', label: 'ZIP / Postal code', autoComplete: 'shipping postal-code', placeholder: '78701', half: true },
],
},
]
const PAYMENT_FIELDS: OrderField[] = [
{ name: 'cardNumber', label: 'Card number', inputMode: 'numeric', autoComplete: 'cc-number', placeholder: '1234 5678 9012 3456' },
{ name: 'cardExpiry', label: 'Expiry', inputMode: 'numeric', autoComplete: 'cc-exp', placeholder: 'MM / YY', half: true },
{ name: 'cardCvc', label: 'Security code', inputMode: 'numeric', autoComplete: 'cc-csc', placeholder: '123', half: true },
]
const ALL_CARDS: CardMark[] = ['visa', 'mastercard', 'amex', 'discover']
const CARD_LABELS: Record<CardMark, string> = { visa: 'Visa', mastercard: 'Mastercard', amex: 'American Express', discover: 'Discover' }
// Official payment-network SVGs keep their brand colours (theme-contract mark exception).
const CARD_MARKS: Record<CardMark, () => React.ReactNode> = {
visa: () => <Visa aria-hidden='true' />,
mastercard: () => <Mastercard aria-hidden='true' />,
amex: () => <AmericanExpress aria-hidden='true' />,
discover: () => <Discover aria-hidden='true' />,
}
const ICONS: Partial<Record<string, LucideIcon>> = {
name: User,
email: Mail,
address: MapPin,
cardNumber: CreditCard,
cardExpiry: CalendarDays,
cardCvc: Lock,
}
const PLACEHOLDERS: Record<string, string> = {
name: 'Jane Smith',
email: 'you@example.com',
phone: '(555) 123-4567',
address: '123 Main Street',
city: 'Austin',
zip: '78701',
cardNumber: '1234 5678 9012 3456',
cardExpiry: 'MM / YY',
cardCvc: '123',
}
function placeholderFor(f: OrderField) {
if (f.placeholder) return f.placeholder
if (PLACEHOLDERS[f.name]) return PLACEHOLDERS[f.name]
if (f.type === 'email') return 'you@example.com'
if (f.type === 'tel') return '(555) 123-4567'
return `Your ${f.label.toLowerCase()}`
}
function rise(i: number) {
return { '--i': i } as React.CSSProperties
}
function defined<T extends object>(o?: Partial<T>): Partial<T> {
return Object.fromEntries(Object.entries(o ?? {}).filter(([, v]) => v !== undefined)) as Partial<T>
}
function fill(template: string, vars: Record<string, string | number>) {
return template.replace(/{([a-zA-Z]+)}/g, (m, k: string) => (k in vars ? String(vars[k]) : m))
}
const digits = (s: string) => s.replace(/[^0-9]/g, '')
function toNum(s?: string) {
if (!s) return 0
const n = parseFloat(s.replace(/[^0-9.]/g, ''))
return Number.isFinite(n) ? n : 0
}
function money(n: number, currency: string) {
const whole = Math.abs(n - Math.round(n)) < 0.005
try {
return new Intl.NumberFormat('en-US', { style: 'currency', currency, minimumFractionDigits: whole ? 0 : 2, maximumFractionDigits: whole ? 0 : 2 }).format(n)
} catch {
return `$${n.toFixed(whole ? 0 : 2)}`
}
}
function shape(name: string, raw: string) {
if (name === 'cardNumber') return digits(raw).slice(0, 19).replace(/(.{4})/g, '$1 ').trim()
if (name === 'cardExpiry') {
const d = digits(raw).slice(0, 4)
return d.length > 2 ? `${d.slice(0, 2)} / ${d.slice(2)}` : d
}
if (name === 'cardCvc') return digits(raw).slice(0, 4)
return raw
}
function pick(values: Record<string, string>, fields: OrderField[]) {
const out: Record<string, string> = {}
for (const f of fields) out[f.name] = (values[f.name] ?? '').trim()
return out
}
function check(fields: OrderField[], values: Record<string, string>, copy: TwoStepOrder13Copy) {
const out: Record<string, string> = {}
for (const f of fields) {
const v = (values[f.name] ?? '').trim()
const d = digits(v)
if (!v) {
out[f.name] = fill(copy.required, { label: f.label.toLowerCase() })
continue
}
if (f.type === 'email' && !/^[^ @]+@[^ @]+[.][^ @]+$/.test(v)) out[f.name] = copy.email
else if (f.name === 'cardNumber' && (d.length < 13 || d.length > 19)) out[f.name] = copy.card
else if (f.name === 'cardExpiry') {
const month = Number(d.slice(0, 2))
if (d.length !== 4 || month < 1 || month > 12) out[f.name] = copy.expiry
} else if (f.name === 'cardCvc' && (d.length < 3 || d.length > 4)) out[f.name] = copy.cvc
}
return out
}
const S = '.cf-two-step-order-13'
const CSS = `
${S}{--t13-well:color-mix(in oklch, var(--ink) 4%, var(--card));--t13-shadow:var(--shadow, oklch(0.22 0.03 260));container:t13 / inline-size;width:100%;max-width:46rem;margin-inline:auto;color:var(--ink);font-family:var(--font-body);font-size:clamp(1.0625rem, 1.25vw, 1.125rem);line-height:1.5;-webkit-font-smoothing:antialiased}
${S}, ${S} *, ${S} *::before, ${S} *::after{box-sizing:border-box}
${S} :where(h2, h3, p, ol, fieldset, legend){margin:0;padding:0}
${S} .t13-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
${S} .t13-card{background:var(--card);border:1px solid var(--card-border, oklch(from var(--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(0.22 0.03 260 / 0.22), 0 12px 24px -8px oklch(0.22 0.03 260 / 0.32)));padding:clamp(20px, 3vw, 32px)}
${S} .t13-tabs{list-style:none;display:grid;grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);gap:6px;padding:6px;margin:0 0 clamp(24px, 3vw, 32px);border-radius:calc(var(--radius, 12px) + 4px);background:color-mix(in oklch, var(--ink) 6%, var(--card))}
${S} .t13-tabs li{display:flex;min-width:0}
${S} .t13-tab{position:relative;display:flex;align-items:center;gap:10px;width:100%;min-width:0;min-height:56px;padding:8px 16px;border:0;border-radius:var(--radius, 12px);background:transparent;color:var(--muted);font-family:var(--font-display);font-size:1.0625rem;font-weight:700;line-height:1.2;text-align:left;cursor:pointer;transition:background .16s ease, box-shadow .16s ease, color .16s ease}
${S} .t13-tab:hover:not(:disabled){background:color-mix(in oklch, var(--ink) 10%, var(--card));color:var(--ink)}
${S} .t13-tab:disabled{cursor:default}
${S} .t13-tab.is-active{background:var(--card);color:var(--ink);box-shadow:var(--shadow-sm, 0 1px 2px oklch(0.22 0.03 260 / 0.2))}
${S} .t13-tab.is-active::after{content:'';position:absolute;left:16px;right:16px;bottom:0;height:3px;border-radius:3px 3px 0 0;background:var(--accent-fill, var(--accent));pointer-events:none}
${S} .t13-tab:focus-visible{outline:3px solid var(--field-focus, var(--accent));outline-offset:2px}
${S} .t13-tab-n{flex:none;min-width:1ch;font-family:var(--font-display);font-size:1.375rem;font-weight:800;line-height:1;font-variant-numeric:lining-nums tabular-nums;color:var(--muted)}
${S} .t13-tab.is-active .t13-tab-n{color:var(--accent)}
${S} .t13-tab.is-done .t13-tab-n{display:inline-grid;place-items:center;width:24px;height:24px;border-radius:999px;background:var(--success);color:var(--status-glyph, #fff)}
${S} .t13-tab.is-done .t13-tab-n svg{width:15px;height:15px}
${S} .t13-tab-l{min-width:0;overflow-wrap:anywhere}
${S} .t13-h{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;color:var(--ink);text-wrap:balance;outline:none}
${S} .t13-alert{margin-top:16px;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}
${S} .t13-ii{display:inline-block;width:1em;height:1em;vertical-align:-.15em;margin-inline-end:.4em}
${S} .t13-kit{display:flex;flex-wrap:wrap;align-items:center;gap:12px 16px;margin-top:16px;padding:12px;border-radius:10px;background:var(--t13-well)}
${S} .t13-thumbs{flex:none;display:flex;gap:6px}
${S} .t13-thumbs img{display:block;width:56px;height:56px;border-radius:8px;object-fit:cover;object-position:center}
${S} .t13-kit-t{flex:1 1 13rem;display:grid;gap:2px;min-width:0}
${S} .t13-kit-t strong{font-family:var(--font-display);font-size:1.0625rem;font-weight:800;line-height:1.2;color:var(--ink);text-wrap:balance}
${S} .t13-kit-t span{color:var(--muted);font-size:.9375rem;font-weight:500;line-height:1.4;text-wrap:pretty}
${S} .t13-recap{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:16px;padding:12px 12px 12px 16px;border-radius:10px;background:var(--t13-well)}
${S} .t13-recap-t{min-width:0;font-size:1rem;line-height:1.4;overflow-wrap:anywhere}
${S} .t13-recap-t span{color:var(--muted);font-weight:500}
${S} .t13-recap-t strong{font-weight:700;color:var(--ink)}
${S} .t13-qas{display:grid;gap:28px;margin-top:28px}
${S} .t13-qa{display:grid;grid-template-columns:2.75rem minmax(0, 1fr);column-gap:8px;row-gap:16px;align-items:start}
${S} .t13-qn{font-family:var(--font-display);font-size:clamp(1.125rem, 1.5vw, 1.375rem);font-weight:800;line-height:1.3;letter-spacing:-.01em;font-variant-numeric:lining-nums tabular-nums;color:var(--accent)}
${S} .t13-qbody{display:grid;gap:12px;min-width:0;margin:0;padding:0;border:0}
${S} .t13-set{display:block;min-inline-size:0}
${S} .t13-set > legend{margin-bottom:12px}
${S} .t13-set > * + *{margin-top:12px}
${S} .t13-q{display:block;width:100%;padding:0;font-family:var(--font-display);font-size:clamp(1.125rem, 1.5vw, 1.375rem);font-weight:800;line-height:1.3;color:var(--ink);text-wrap:balance}
${S} .t13-a{color:var(--ink);text-wrap:pretty}
${S} .t13-a strong{font-weight:700}
${S} .t13-rn{margin-inline-end:.3em;font-family:var(--font-display);font-weight:800;font-variant-numeric:lining-nums tabular-nums;color:var(--accent)}
${S} .t13-wide{grid-column:1 / -1;display:grid;gap:12px}
${S} .t13-act{display:grid;gap:12px;margin-top:4px}
${S} .t13-row{display:flex;flex-wrap:wrap;gap:12px}
${S} .t13-field{flex:1 1 100%;min-width:0;display:grid;gap:6px}
${S} .t13-field.is-half{flex:1 1 calc(50% - 6px);min-width:8rem}
${S} .t13-label{font-size:1rem;font-weight:700;line-height:1.3;color:var(--label-ink, var(--ink))}
${S} .t13-control{position:relative}
${S} .t13-ficon{position:absolute;left:16px;top:50%;width:18px;height:18px;transform:translateY(-50%);color:color-mix(in oklch, var(--field-ink) 60%, var(--field));pointer-events:none}
${S} .t13-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;font-weight:500;box-shadow:inset 0 1px 2px oklch(from var(--t13-shadow) l c h / 0.08);transition:border-color .16s ease, box-shadow .16s ease}
${S} .t13-input.has-icon{padding-left:46px}
${S} .t13-input::placeholder{color:color-mix(in oklch, var(--field-ink) 65%, var(--field));opacity:1;font-weight:400}
${S} .t13-input:hover:not(:disabled){border-color:color-mix(in oklch, var(--ink) 40%, transparent)}
${S} .t13-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)}
${S} .t13-input[aria-invalid='true']{border-color:var(--danger)}
${S} .t13-input[aria-invalid='true']:focus{box-shadow:0 0 0 3px oklch(from var(--danger) l c h / 0.3)}
${S} .t13-input:disabled{cursor:not-allowed;background:color-mix(in oklch, var(--field-ink) 5%, var(--field));color:color-mix(in oklch, var(--field-ink) 70%, var(--field))}
${S} .t13-err{color:var(--danger);font-size:.9375rem;font-weight:600;line-height:1.4;text-wrap:pretty}
${S} .t13-marks{display:flex;flex-wrap:wrap;align-items:center;gap:8px;color:var(--muted);font-size:.9375rem;font-weight:600}
${S} .t13-marks > span:first-child{margin-inline-end:4px}
${S} .t13-mark{display:inline-flex}
${S} .t13-mark svg{display:block;width:40px;height:auto}
${S} .t13-bump{overflow:hidden;border:1px solid oklch(from var(--bump-ink) l c h / 0.16);border-radius:var(--radius, 12px);background:var(--bump);color:var(--bump-ink);transition:border-color .16s ease}
${S} .t13-bump.is-on{border-color:oklch(from var(--bump-ink) l c h / 0.32)}
${S} .t13-bump-strip{position:relative;display:flex;align-items:center;gap:12px;padding:14px 16px;background:var(--bump-strip);color:var(--bump-ink);font-family:var(--font-display);font-size:1.0625rem;font-weight:800;line-height:1.3;cursor:pointer;transition:background .16s ease}
${S} .t13-bump-strip:hover{background:oklch(from var(--bump-strip) calc(l - 0.03) c h)}
${S} .t13-bump-strip:has(:disabled){cursor:not-allowed}
${S} .t13-bump-in{position:absolute;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
${S} .t13-box{flex:none;display:grid;place-items:center;width:26px;height:26px;border:2px solid var(--bump-ink);border-radius:7px;background:var(--field);color:transparent;transition:background .16s ease, border-color .16s ease}
${S} .t13-box svg{width:16px;height:16px}
${S} .t13-bump-in:checked + .t13-box{background:var(--success);border-color:var(--success);color:var(--status-glyph, #fff)}
${S} .t13-bump-in:focus-visible + .t13-box{outline:3px solid var(--field-focus, var(--accent));outline-offset:2px}
${S} .t13-bump-in:disabled ~ *{opacity:.6}
${S} .t13-bump-b{padding:12px 16px 14px;font-size:1rem;line-height:1.5;text-wrap:pretty}
${S} .t13-bump-added{padding:0 16px 14px;font-size:.9375rem;font-weight:700;line-height:1.4}
${S} .t13-bump-added:empty{padding:0}
${S} .t13-btn{--t13-b:var(--button-bg, var(--cta));--t13-b2:var(--button-bg-2, var(--cta-2));display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;width:100%;min-height:72px;padding:12px 28px;border:0;border-radius:var(--button-radius, var(--radius, 12px));background:linear-gradient(oklch(from var(--t13-b) calc(l + 0.04) c h), oklch(from var(--t13-b2) calc(l - 0.02) c h));color:var(--button-ink, var(--cta-ink));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight, 800);text-transform:var(--button-case, none);text-shadow:var(--button-text-shadow, none);text-align:center;cursor:pointer;box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--t13-b) calc(l + 0.14) c h / 0.7), inset 0 -3px 0 oklch(from var(--t13-b) calc(l - 0.16) c h), 0 1px 2px oklch(from var(--t13-shadow) l c h / 0.3), 0 8px 16px -6px oklch(from var(--t13-shadow) l c h / 0.45));transition:background .16s ease, box-shadow .16s ease, transform .16s ease}
${S} .t13-btn--next{min-height:64px}
${S} .t13-btn:hover:not(:disabled), ${S} .t13-btn.is-hover:not(:disabled){background:linear-gradient(oklch(from var(--t13-b) calc(l - 0.01) c h), oklch(from var(--t13-b2) calc(l - 0.07) c h));box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--t13-b) calc(l + 0.1) c h / 0.6), inset 0 -3px 0 oklch(from var(--t13-b) calc(l - 0.2) c h), 0 1px 2px oklch(from var(--t13-shadow) l c h / 0.32), 0 10px 18px -6px oklch(from var(--t13-shadow) l c h / 0.52))}
${S} .t13-btn:active:not(:disabled){transform:translateY(1px);box-shadow:inset 0 2px 4px oklch(from var(--t13-b) calc(l - 0.22) c h / 0.55), inset 0 -2px 0 oklch(from var(--t13-b) calc(l - 0.16) c h), 0 1px 1px oklch(from var(--t13-shadow) l c h / 0.3)}
${S} .t13-btn:focus-visible{outline:3px solid var(--field-focus, var(--accent));outline-offset:3px}
${S} .t13-btn:disabled:not([aria-busy='true']){cursor:not-allowed;background:var(--button-2-bg, var(--secondary));color:color-mix(in oklch, var(--button-2-ink, var(--secondary-ink)) 65%, var(--button-2-bg, var(--secondary)));text-shadow:none;box-shadow:none}
${S} .t13-btn[aria-busy='true']{cursor:progress}
${S} .t13-btn-main{display:inline-flex;align-items:center;justify-content:center;gap:10px;font-size:clamp(1.125rem, 1.55vw, 1.375rem);line-height:1.15;text-wrap:balance}
${S} .t13-btn-sub{font-family:var(--font-body);font-size:.9375rem;font-weight:600;line-height:1.3;font-variant-numeric:lining-nums tabular-nums;text-wrap:pretty}
${S} .t13-spin{width:20px;height:20px;flex:none;animation:t13-spin .8s linear infinite}
${S} .t13-btn2{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: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-size:.9375rem;font-weight:var(--button-weight, 800);text-transform:var(--button-case, none);box-shadow:var(--button-2-shadow, var(--shadow-sm, 0 1px 2px oklch(0.22 0.03 260 / 0.2)));cursor:pointer;transition:background .16s ease, transform .16s ease}
${S} .t13-btn2:hover:not(:disabled){background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.04) c h)}
${S} .t13-btn2:active:not(:disabled){transform:translateY(1px);background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.07) c h)}
${S} .t13-btn2:focus-visible{outline:3px solid var(--field-focus, var(--accent));outline-offset:2px}
${S} .t13-btn2:disabled{cursor:not-allowed;opacity:.6}
${S} .t13-note, ${S} .t13-assure{color:var(--muted);font-size:.9375rem;font-weight:500;line-height:1.4;text-align:center;text-wrap:pretty}
${S} .t13-sep{margin-inline:.5em}
@keyframes t13-rise{from{opacity:.82;transform:translateY(8px)}}
@keyframes t13-spin{to{transform:rotate(360deg)}}
${S} .t13-in{animation:t13-rise .45s cubic-bezier(.2,.7,.2,1) both;animation-delay:min(calc(var(--i, 0) * .07s), .28s)}
@container t13 (max-width: 520px){
${S} .t13-qa{grid-template-columns:2.25rem minmax(0, 1fr);column-gap:6px}
${S} .t13-tab{gap:8px;padding:8px 12px}
${S} .t13-btn{padding:12px 20px}
${S} .t13-thumbs img{width:48px;height:48px}
${S} .t13-kit{gap:12px}
${S} .t13-recap{flex-wrap:wrap}
}
@media (prefers-reduced-motion: reduce){
${S} *, ${S} *::before, ${S} *::after{animation:none !important;transition:none !important}
${S} .t13-btn:active:not(:disabled), ${S} .t13-btn2:active:not(:disabled){transform:none}
}
`
pieces/checkout/two-step-order-13/specimen.tsx 39 lines
// Specimen: the interview-style two-step order for the sample kit. Default shows step 1 (contact); active shows step 2 (payment, add-on and order button).
import * as React from 'react'
import { TwoStepOrder13, type TwoStepOrder13State } from '../two-step-order-13'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function TwoStepOrder13Specimen({ state = 'default' }: { state?: TwoStepOrder13State }) {
const sample = defaults.sample
const items = sample.items.map((item, i) => ({
name: item.name,
image: slot(`item-${i + 1}`, item.image),
imageAlt: item.imageAlt,
}))
return (
<TwoStepOrder13
key={state}
state={state}
productName={sample.name}
productNote={sample.note}
price={sample.price}
items={items}
reasons={[
'You get the guide, workbook, and checklist in one download.',
'You pay once and it’s yours to keep.',
'You’re covered by the 30-day money-back guarantee.',
]}
guarantee={sample.guarantee}
bump={{
title: 'Funnel Swipe File',
price: '$17',
body: 'Example headlines, offers and calls to action you can adapt for your own pages, added to today’s order with one tick.',
}}
copy={{ secureNote: sample.sublabel }}
defaultValues={state === 'active' ? { name: 'Jane Smith', email: 'jane@example.com' } : undefined}
/>
)
}
| Name | Type | Details |
|---|---|---|
productName OptionalTwoStepOrder13 |
string |
Default 'The Funnel Starter Kit'
|
productNote OptionalTwoStepOrder13 |
string |
Default 'One payment · Lifetime access'
|
price OptionalTwoStepOrder13 |
string |
Default '$47'
|
items OptionalTwoStepOrder13 |
OrderItem[] |
Default []
|
reasons OptionalTwoStepOrder13 |
string[] |
Default DEFAULT_REASONS
|
contactQuestions OptionalTwoStepOrder13 |
OrderQuestion[] |
Default CONTACT_QUESTIONS
|
collectShipping OptionalTwoStepOrder13 |
boolean |
Default false
|
shippingQuestions OptionalTwoStepOrder13 |
OrderQuestion[] |
Default SHIPPING_QUESTIONS
|
paymentFields OptionalTwoStepOrder13 |
OrderField[] |
Default PAYMENT_FIELDS
|
bump OptionalTwoStepOrder13 |
OrderBump | null |
Default null
|
guarantee OptionalTwoStepOrder13 |
string | null |
Default '30-day money-back guarantee'
|
acceptedCards OptionalTwoStepOrder13 |
CardMark[] |
Default ALL_CARDS
|
currency OptionalTwoStepOrder13 |
string |
Default 'USD'
|
copy OptionalTwoStepOrder13 |
Partial<TwoStepOrder13Copy> |
|
state OptionalTwoStepOrder13 |
TwoStepOrder13State |
|
initialStep OptionalTwoStepOrder13 |
1 | 2 |
Default 1
|
initialBump OptionalTwoStepOrder13 |
boolean |
Default false
|
defaultValues OptionalTwoStepOrder13 |
Record<string, string> |
|
disabled OptionalTwoStepOrder13 |
boolean |
Default false
|
onContinue OptionalTwoStepOrder13 |
(values: Readonly<Record<string, string>>) => void |
|
onSubmit OptionalTwoStepOrder13 |
(values: Readonly<Record<string, string>>, bumpSelected: boolean) => void | Promise<void> |
|
className OptionalTwoStepOrder13 |
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-*- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB