Free Book Hero 1
Pairs a free book offer with the first step of its shipping form.
Use it in a prompt
Use hero/free-book-hero 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/hero/free-book-hero.tsx. - Import it and pass your copy and images (Props tab):
import { FreeBookHero } from "@/components/funneldna/hero/free-book-hero"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/hero/free-book-hero/component.tsx 515 lines
// Pairs a free book offer with the first step of its shipping form.
'use client'
import * as React from 'react'
import { AlertCircle, Loader2, Lock, Truck } from 'lucide-react'
export type FreeBookHeroProps = {
/** Supporting labels and plain-text templates; named placeholders are documented below. */
copy?: Partial<FreeBookHeroCopy>
headline?: string
highlight?: string
lead?: string
/** productImage is the canonical slot image; bookImage is retained for compatibility. */
productImage?: string
bookImage?: string
bookImageAlt?: string
bookName?: string
cardTitle?: string
/** Struck regular price; only a real, supplied price. Omitted, no anchor is shown. */
retailPrice?: string
freeLabel?: string
shipping?: string
shippingNote?: string
shipPromise?: string
steps?: [string, string]
fields?: FreeBookField[]
ctaLabel?: string
ctaNote?: string
loadingLabel?: string
/** @deprecated No longer rendered: the builder wires what happens after a valid submit. */
successTitle?: string
/** @deprecated No longer rendered. */
successText?: string
callouts?: FreeBookCallout[]
calloutsTitle?: string
/** "success" is accepted for older callers and renders as default. */
state?: FreeBookHeroState
/** Receives validated values. A returned promise shows the loading label until it settles. */
onSubmit?: (values: Record<string, string>) => void | Promise<void>
className?: string
style?: React.CSSProperties
}
export function FreeBookHero({
headline = 'Build your first funnel with a clear plan',
highlight = 'a clear plan',
lead = 'Plan your funnel, write your page copy, and check every step before you launch.',
bookImage: legacyBookImage,
productImage: bookImage = legacyBookImage,
bookImageAlt = 'Hardcover book on a lit display pedestal',
bookName = 'your book',
cardTitle = 'Get Your FREE Book',
retailPrice,
freeLabel = 'FREE',
shipping,
shippingNote,
shipPromise = 'Your book, shipped to your door.',
steps = DEFAULT_STEPS,
fields = DEFAULT_FIELDS,
ctaLabel = 'Send Me My FREE Book',
ctaNote = 'Next: enter your shipping address.',
loadingLabel = 'Saving your details…',
callouts: suppliedCallouts = NO_CALLOUTS,
calloutsTitle = 'Inside your book',
state = 'default',
onSubmit,
className,
style,
copy,
}: FreeBookHeroProps) {
const text = { ...DEFAULT_COPY, ...copy }
const callouts = suppliedCallouts.map(item => ({ ...item, image: item.itemImage === undefined ? item.image : item.itemImage }))
const uid = React.useId()
const formRef = React.useRef<HTMLFormElement>(null)
const mounted = React.useRef(true)
const [phase, setPhase] = React.useState<'form' | 'loading'>('form')
const [errors, setErrors] = React.useState<Record<string, string>>(() => (state === 'error' ? requiredErrors(fields, text) : {}))
const [values, setValues] = React.useState<Record<string, string>>({})
React.useEffect(() => {
setPhase('form')
setErrors(state === 'error' ? requiredErrors(fields, text) : {})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
React.useEffect(() => {
mounted.current = true
return () => {
mounted.current = false
}
}, [])
const disabled = state === 'disabled'
const loading = phase === 'loading'
const errorCount = Object.values(errors).filter(Boolean).length
const noteText = shipping ? shippingNote : shippingNote ?? text.shippingNote
function change(name: string, value: string) {
setValues((prev) => ({ ...prev, [name]: value }))
if (errors[name]) {
setErrors((prev) => {
const next = { ...prev }
delete next[name]
return next
})
}
}
async function submit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
if (disabled || loading) return
const next: Record<string, string> = {}
for (const field of fields) {
const message = validate(field, values[field.name] ?? '', text)
if (message) next[field.name] = message
}
setErrors(next)
const firstBad = fields.find((field) => next[field.name])
if (firstBad) {
formRef.current?.querySelector<HTMLInputElement>(`[name='${firstBad.name}']`)?.focus()
return
}
const result = onSubmit?.(values)
if (!result) return
setPhase('loading')
try {
await result
} finally {
if (mounted.current) setPhase('form')
}
}
const btnClass = [
'fbh__btn',
state === 'hover' ? 'is-hover' : '',
state === 'active' ? 'is-active' : '',
loading ? 'is-loading' : '',
].filter(Boolean).join(' ')
return (
<section className={['cf-free-book-hero', className].filter(Boolean).join(' ')} style={style} aria-labelledby={`${uid}-h`}>
<style>{CSS}</style>
<div className='fbh__wrap'>
<header className='fbh__head'>
<h1 id={`${uid}-h`} className='fbh__h1'>{renderHeadline(headline, highlight)}</h1>
{lead ? <p className='fbh__lead'>{lead}</p> : null}
</header>
<div className='fbh__grid'>
<div className='fbh__show'>
<div className='fbh__stage'>
<span className='fbh__beam' aria-hidden='true'><span /></span>
<span className='fbh__floor' aria-hidden='true' />
{bookImage ? (
<img className='fbh__book' src={bookImage} alt={bookImageAlt} width={720} height={1080} decoding='async' />
) : null}
</div>
{callouts.length ? (
<div className='fbh__calls'>
<p className='fbh__calls-title' id={`${uid}-calls`}>{calloutsTitle}</p>
<ul aria-labelledby={`${uid}-calls`}>
{callouts.map((item, i) => (
<li className='fbh__call' key={item.name} style={{ '--i': i } as React.CSSProperties}>
<div>
<p className='fbh__call-name'>{item.name}</p>
{item.detail ? <p className='fbh__call-detail'>{item.detail}</p> : null}
</div>
{item.image ? (
<img className='fbh__call-thumb' src={item.image} alt={item.imageAlt ?? item.name} width={64} height={64} loading='lazy' />
) : null}
</li>
))}
</ul>
</div>
) : null}
</div>
<div className='fbh__card'>
<h2 className='fbh__title'>{cardTitle}</h2>
{retailPrice ? <p className='fbh__sr'>{copyText(text.priceAria, { retailPrice, freeLabel: freeLabel.toLowerCase(), shipping: shipping ? `${shipping} ` : '' })}</p> : null}
<div className='fbh__price' aria-hidden={retailPrice ? 'true' : undefined}>
{retailPrice ? (
<span className='fbh__was'>
<span className='fbh__was-label'>{text.retail}</span>
<s>{retailPrice}</s>
</span>
) : null}
<span className='fbh__free'>{freeLabel}</span>
</div>
<p className='fbh__ship' aria-hidden={retailPrice ? 'true' : undefined}>
{copyNodes(text.shipping, { amount: shipping ? <> <span className='fbh__ship-amt'>{shipping}</span></> : null })}
</p>
{noteText ? <p className='fbh__ship-note'>{noteText}</p> : null}
<p className='fbh__promise'>
<span className='fbh__promise-ic'><Truck aria-hidden='true' /></span>
<span>{shipPromise}</span>
</p>
<ol className='fbh__tabs' aria-label={text.stepsAria}>
<li className='fbh__tab is-on' aria-current='step'>
<span className='fbh__tab-n'>1</span>
<span>{steps[0]}</span>
</li>
<li className='fbh__tab'>
<span className='fbh__tab-n'>2</span>
<span>{steps[1]}</span>
</li>
</ol>
<form ref={formRef} className='fbh__form' noValidate onSubmit={submit} aria-busy={loading || undefined}>
{fields.map((field) => {
const id = `${uid}-${field.name}`
const err = errors[field.name]
return (
<div className='fbh__field' key={field.name}>
<label className='fbh__label' htmlFor={id}>{field.label}</label>
<input
id={id}
className='fbh__input'
name={field.name}
type={field.type || 'text'}
autoComplete={field.autoComplete}
inputMode={field.type === 'email' ? 'email' : undefined}
placeholder={placeholderFor(field, text)}
required
readOnly={loading}
value={values[field.name] ?? ''}
onChange={(e) => change(field.name, e.target.value)}
aria-invalid={err ? true : undefined}
aria-describedby={err ? `${id}-err` : undefined}
/>
{err ? (
<p id={`${id}-err`} className='fbh__err'><AlertCircle aria-hidden='true' />{err}</p>
) : null}
</div>
)
})}
{errorCount ? (
<p className='fbh__alert' role='alert'>
<AlertCircle aria-hidden='true' />
<span>{errorCount === 1 ? text.errorOne : text.errorMany}</span>
</p>
) : null}
<button type='submit' className={btnClass} disabled={disabled}>
{loading ? (
<>
<Loader2 className='fbh__spin' aria-hidden='true' />
<span>{loadingLabel}</span>
</>
) : (
<span className='fbh__btn-label'>{ctaLabel}</span>
)}
</button>
<p className='fbh__note'><Lock aria-hidden='true' />{ctaNote}</p>
</form>
</div>
</div>
</div>
</section>
)
}
export default FreeBookHero
export type FreeBookField = {
name: string
label: string
type?: string
autoComplete?: string
placeholder?: string
}
export type FreeBookCallout = {
name: string
detail?: string
/** Canonical item-N image; image is retained as an alias. */
itemImage?: string
image?: string
imageAlt?: string
}
export type FreeBookHeroState = 'default' | 'hover' | 'active' | 'disabled' | 'error' | 'success'
const DEFAULT_FIELDS: FreeBookField[] = [
{ name: 'name', label: 'Full name', autoComplete: 'name' },
{ name: 'email', label: 'Email address', type: 'email', autoComplete: 'email' },
]
const DEFAULT_STEPS: [string, string] = ['Your details', 'Shipping info']
const NO_CALLOUTS: FreeBookCallout[] = []
function placeholderFor(field: FreeBookField, text: FreeBookHeroCopy) {
return field.placeholder ?? copyText(text.placeholder, { label: field.label.toLowerCase() })
}
function isEmail(value: string) {
const at = value.indexOf('@')
if (at < 1 || value.includes(' ')) return false
const domain = value.slice(at + 1)
const dot = domain.lastIndexOf('.')
return dot > 0 && dot < domain.length - 2
}
function validate(field: FreeBookField, raw: string, text: FreeBookHeroCopy) {
const value = raw.trim()
const email = field.type === 'email'
if (!value) return email ? text.emailRequired : copyText(text.required, { label: field.label.toLowerCase() })
if (email && !isEmail(value)) return text.emailInvalid
return ''
}
function requiredErrors(fields: FreeBookField[], text: FreeBookHeroCopy) {
const out: Record<string, string> = {}
for (const field of fields) out[field.name] = validate(field, '', text)
return out
}
function renderHeadline(headline: string, highlight?: string) {
const open = <span className='fbh__q' aria-hidden='true'>“</span>
const close = <span className='fbh__q' aria-hidden='true'>”</span>
const at = highlight ? headline.toLowerCase().indexOf(highlight.toLowerCase()) : -1
if (!highlight || at < 0) return <>{open}{headline}{close}</>
const before = headline.slice(0, at)
const phrase = headline.slice(at, at + highlight.length)
const after = headline.slice(at + highlight.length)
if (!after.trim()) {
return <>{open}{before}<span className='fbh__nobr'><mark className='fbh__mark'>{phrase}</mark>{close}</span></>
}
return <>{open}{before}<mark className='fbh__mark'>{phrase}</mark>{after}{close}</>
}
// Photographic product art is replaceable via slots; pure black/white alpha shadows provide close depth.
const CSS = `
.cf-free-book-hero{--fbh-marker:var(--marker,#fae37c);position:relative;isolation:isolate;overflow:hidden;background:var(--band,#0f2747);color:var(--band-ink,#ffffff);font-family:var(--font-body,Arial,sans-serif);padding-block:clamp(44px,6vw,96px);box-shadow:inset 0 -2px 3px oklch(from var(--surface) calc(l - 0.12) c h / .42)}
.cf-free-book-hero *,.cf-free-book-hero *::before,.cf-free-book-hero *::after{box-sizing:border-box}
.cf-free-book-hero img{display:block;max-width:100%}
:where(.cf-free-book-hero) .fbh__sr,:where(.cf-free-book-hero) .fbh__calls-title.is-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
:where(.cf-free-book-hero) .fbh__wrap{width:min(1240px,100%);margin-inline:auto;padding-inline:clamp(16px,4vw,40px)}
:where(.cf-free-book-hero) .fbh__head{max-width:1000px;margin:0 auto clamp(30px,4.4vw,56px);text-align:center}
:where(.cf-free-book-hero) .fbh__h1{margin:0 auto;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,900);font-size:clamp(2.35rem,5.4vw,5.1rem);line-height:1.03;letter-spacing:var(--display-tracking,-.028em);color:var(--band-ink,#ffffff);text-wrap:balance;text-transform:var(--display-case,none)}
:where(.cf-free-book-hero) .fbh__q{color:var(--band-ink)}
:where(.cf-free-book-hero) .fbh__nobr{white-space:nowrap}
:where(.cf-free-book-hero) .fbh__mark{color:var(--ink,#101828);background:var(--marker,#fae37c);padding:.02em .16em .06em;margin-inline:-.02em;border-radius:.16em .5em .22em .44em/.42em .3em .5em .36em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
:where(.cf-free-book-hero) .fbh__lead{max-width:44ch;margin:22px auto 0;font-size:clamp(1.1rem,1.55vw,1.375rem);font-weight:500;line-height:1.45;color:var(--band-ink,#ffffff);text-wrap:pretty}
:where(.cf-free-book-hero) .fbh__grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(360px,440px);grid-template-areas:'show card';column-gap:clamp(24px,3.2vw,48px);align-items:start}
:where(.cf-free-book-hero) .fbh__show{grid-area:show;display:grid;grid-template-columns:minmax(0,.78fr) minmax(0,1fr);grid-template-areas:'calls stage';align-items:center}
:where(.cf-free-book-hero) .fbh__stage{grid-area:stage;position:relative;z-index:0;display:grid;place-items:end center;min-height:220px;padding-top:8px}
:where(.cf-free-book-hero) .fbh__beam{position:absolute;left:50%;top:-24px;bottom:30px;width:min(140%,600px);transform:translateX(-50%);filter:blur(16px);pointer-events:none}
:where(.cf-free-book-hero) .fbh__beam span{position:absolute;inset:0;background:linear-gradient(180deg,oklch(from var(--band-ink) l c h / 0.15),oklch(from var(--band-ink) l c h / 0.07) 62%,transparent);clip-path:polygon(40% 0,60% 0,96% 100%,4% 100%)}
:where(.cf-free-book-hero) .fbh__floor{position:absolute;left:50%;bottom:-8px;width:min(115%,480px);height:96px;transform:translateX(-50%);border-radius:50%;background:oklch(from var(--band) l c h / 0.7);pointer-events:none}
:where(.cf-free-book-hero) .fbh__book{position:relative;z-index:1;width:min(100%,360px);height:auto;filter:drop-shadow(0 3px 4px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.3))}
:where(.cf-free-book-hero) .fbh__calls{grid-area:calls;position:relative;z-index:2;padding-bottom:12%}
:where(.cf-free-book-hero) .fbh__calls-title{margin:0 0 14px;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,800);font-size:1.125rem;line-height:1.2;color:var(--band-ink,#ffffff);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,normal)}
:where(.cf-free-book-hero) .fbh__calls ul{list-style:none;margin:0;padding:0;display:grid;gap:clamp(22px,3vw,38px)}
:where(.cf-free-book-hero) .fbh__call{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:14px;align-items:start;text-align:right}
:where(.cf-free-book-hero) .fbh__call-name{margin:0;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,800);font-size:1.0625rem;line-height:1.2;color:var(--band-ink,#ffffff);text-wrap:balance;text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,normal)}
:where(.cf-free-book-hero) .fbh__call-detail{margin:6px 0 0;font-size:.9375rem;line-height:1.45;color:var(--band-ink,#ffffff);text-wrap:pretty}
:where(.cf-free-book-hero) .fbh__call-thumb{width:64px;height:64px;border-radius:12px;object-fit:cover;background:transparent;box-shadow:none;filter:drop-shadow(0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21))}
:where(.cf-free-book-hero) .fbh__call::after{content:'';position:absolute;left:calc(100% + 8px);top:31px;width:var(--fbh-reach,104px);height:2px;border-radius:2px;background:linear-gradient(90deg,oklch(from var(--band-ink,#ffffff) l c h / 0.35),var(--fbh-marker));transform-origin:left center;pointer-events:none}
:where(.cf-free-book-hero) .fbh__call::before{content:'';position:absolute;left:calc(100% + 2px + var(--fbh-reach,104px));top:26px;width:12px;height:12px;border-radius:50%;background:var(--fbh-marker);box-shadow:0 0 0 4px oklch(from var(--fbh-marker) l c h / 0.3),0 2px 6px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.27);z-index:1;pointer-events:none}
:where(.cf-free-book-hero) .fbh__card{grid-area:card;position:relative;z-index:2;background:var(--card,#ffffff);color:var(--ink,#101828);border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,calc(var(--radius,14px) + 6px));padding:clamp(24px,2.6vw,34px) clamp(20px,2.4vw,32px) clamp(22px,2.4vw,30px);box-shadow:inset 0 0 0 5px color-mix(in oklch,var(--ink) 4%,var(--card)),inset 0 0 0 6px var(--card-border,oklch(from var(--ink) l c h / 0.12)),var(--card-shadow,0 3px 4px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21))}
:where(.cf-free-book-hero) .fbh__title{margin:0;text-align:center;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,900);font-size:clamp(1.55rem,2.3vw,2.05rem);line-height:1.08;letter-spacing:var(--display-tracking,-.02em);color:var(--ink,#101828);text-wrap:balance;text-transform:var(--display-case,none)}
:where(.cf-free-book-hero) .fbh__price{display:flex;align-items:flex-end;justify-content:center;gap:clamp(12px,2vw,20px);margin-top:14px}
:where(.cf-free-book-hero) .fbh__was{display:flex;flex-direction:column;align-items:center;gap:6px;padding-bottom:.35em}
:where(.cf-free-book-hero) .fbh__was-label{font-size:.875rem;font-weight:700;line-height:1;letter-spacing:.04em;text-transform:uppercase;color:var(--muted,#4a5565)}
:where(.cf-free-book-hero) .fbh__was s{position:relative;text-decoration:none;padding:0 .06em;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,900);font-size:clamp(2.1rem,3.2vw,2.75rem);line-height:1;color:var(--danger);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,normal)}
:where(.cf-free-book-hero) .fbh__was s::after{content:'';position:absolute;left:-.08em;right:-.08em;top:50%;height:.12em;border-radius:99px;background:var(--danger);transform:rotate(-14deg);box-shadow:0 1px 0 oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-free-book-hero) .fbh__free{font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,900);font-size:clamp(3.8rem,6.2vw,5.75rem);line-height:.82;letter-spacing:var(--display-tracking,-.035em);color:var(--success);text-shadow:none;text-transform:var(--display-case,none)}
:where(.cf-free-book-hero) .fbh__ship{margin:18px 0 0;text-align:center;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,800);font-size:clamp(1.3rem,1.8vw,1.55rem);line-height:1.15;color:var(--ink,#101828);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,normal)}
:where(.cf-free-book-hero) .fbh__ship-amt{color:var(--ink)}
:where(.cf-free-book-hero) .fbh__ship-note{margin:6px 0 0;text-align:center;font-size:1rem;line-height:1.4;color:var(--muted,#4a5565);text-wrap:pretty}
:where(.cf-free-book-hero) .fbh__promise{display:flex;align-items:center;justify-content:center;gap:10px;margin:16px 0 0;padding:10px 14px;border-radius:var(--card-radius,var(--radius,12px));background:color-mix(in oklch,var(--marker,#fae37c) 42%,var(--card));border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));color:var(--ink,#101828);font-weight:700;font-size:1.0625rem;line-height:1.3;text-wrap:pretty}
:where(.cf-free-book-hero) .fbh__promise-ic{display:inline-grid;place-items:center;width:34px;height:34px;flex:none;border-radius:50%;background:transparent;color:var(--accent,#0f5fc2);box-shadow:none}
:where(.cf-free-book-hero) .fbh__promise-ic svg{width:19px;height:19px}
:where(.cf-free-book-hero) .fbh__tabs{list-style:none;margin:22px 0 20px;padding:5px;display:grid;grid-template-columns:1fr 1fr;gap:4px;background:color-mix(in oklch,var(--ink) 5%,var(--card));border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius,13px))}
:where(.cf-free-book-hero) .fbh__tab{display:flex;align-items:center;justify-content:center;gap:8px;min-height:46px;padding:8px 12px;border-radius:9px;color:var(--muted,#4a5565);font-weight:700;font-size:1rem;line-height:1.15;white-space:nowrap}
:where(.cf-free-book-hero) .fbh__tab-n{display:inline-grid;place-items:center;width:26px;height:26px;flex:none;border-radius:50%;background:var(--card);color:var(--muted,#4a5565);font-weight:800;font-size:.9rem;box-shadow:inset 0 0 0 1.5px var(--card-border,oklch(from var(--ink) l c h / 0.12))}
:where(.cf-free-book-hero) .fbh__tab.is-on{background:var(--band);color:var(--band-ink);box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / .22)}
:where(.cf-free-book-hero) .fbh__tab.is-on:not(.is-last){clip-path:polygon(0 0,calc(100% - 12px) 0,100% 50%,calc(100% - 12px) 100%,0 100%);border-radius:9px 0 0 9px;padding-right:22px}
:where(.cf-free-book-hero) .fbh__tab.is-on .fbh__tab-n{background:var(--card);color:var(--ink);box-shadow:none}
:where(.cf-free-book-hero) .fbh__field + .fbh__field{margin-top:16px}
:where(.cf-free-book-hero) .fbh__label{display:block;margin:0 0 8px;font-weight:800;font-size:1.0625rem;line-height:1.2;color:var(--label-ink,var(--ink))}
:where(.cf-free-book-hero) .fbh__input{width:100%;min-height:56px;padding:12px 16px;border:1.5px solid var(--field-border,oklch(from var(--ink) l c h / 0.22));border-radius:var(--field-radius,var(--radius,10px));background:var(--field,#ffffff);color:var(--field-ink,#101828);font:500 1.0625rem/1.3 var(--font-body,Arial,sans-serif);box-shadow:inset 0 2px 3px oklch(from var(--surface) calc(l - 0.12) c h / .06);transition:border-color .15s ease,box-shadow .15s ease}
:where(.cf-free-book-hero) .fbh__input::placeholder{color:color-mix(in oklch, var(--field-ink) 65%, var(--field));opacity:1}
:where(.cf-free-book-hero) .fbh__input:hover{border-color:var(--field-border,oklch(from var(--ink) l c h / 0.42))}
:where(.cf-free-book-hero) .fbh__input:focus{outline:none;border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 4px oklch(from var(--field-focus,var(--accent)) l c h / 0.22),inset 0 2px 3px oklch(from var(--surface) calc(l - 0.12) c h / .06)}
:where(.cf-free-book-hero) .fbh__input[aria-invalid='true']{border-color:var(--danger);box-shadow:0 0 0 4px oklch(from var(--danger) l c h / 0.22),inset 0 2px 3px oklch(from var(--surface) calc(l - 0.12) c h / .06)}
:where(.cf-free-book-hero) .fbh__err{display:flex;align-items:flex-start;gap:6px;margin:8px 0 0;font-size:.9375rem;font-weight:600;line-height:1.35;color:var(--danger)}
:where(.cf-free-book-hero) .fbh__err svg{width:17px;height:17px;flex:none;margin-top:1px}
:where(.cf-free-book-hero) .fbh__alert{display:flex;align-items:center;gap:10px;margin:18px 0 0;padding:12px 14px;border-radius:var(--card-radius,var(--radius,10px));background:var(--danger-soft);border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));color:var(--danger);font-size:.9375rem;font-weight:600;line-height:1.35}
:where(.cf-free-book-hero) .fbh__alert svg{width:19px;height:19px;flex:none}
:where(.cf-free-book-hero) .fbh__btn{position:relative;display:flex;width:100%;min-height:66px;align-items:center;justify-content:center;gap:10px;margin-top:22px;padding:12px 16px;border:1px solid var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h));border-radius:var(--button-radius,calc(var(--radius,14px) - 2px));background:linear-gradient(180deg,var(--button-bg,var(--cta)),var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h)));color:var(--button-ink,var(--cta-ink));font:var(--button-weight,900) clamp(1.15rem,1.9vw,1.5rem)/1 var(--button-font,var(--font-display));letter-spacing:-.01em;text-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75));cursor:pointer;box-shadow:var(--button-shadow,0 3px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21));transition:transform .16s ease,box-shadow .16s ease,filter .16s ease;text-transform:var(--button-case,none)}
:where(.cf-free-book-hero) .fbh__btn-label{white-space:nowrap}
:where(.cf-free-book-hero) .fbh__btn .fbh__spin{width:22px;height:22px}
:where(.cf-free-book-hero) .fbh__btn:not(:disabled):hover,:where(.cf-free-book-hero) .fbh__btn.is-hover:not(:disabled){transform:translateY(-2px);background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.06) c h);box-shadow:var(--button-shadow,0 3px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21))}
:where(.cf-free-book-hero) .fbh__btn:not(:disabled):active,:where(.cf-free-book-hero) .fbh__btn.is-active:not(:disabled){transform:translateY(2px);background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.06) c h);box-shadow:var(--button-shadow,0 3px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21))}
:where(.cf-free-book-hero) .fbh__btn:focus-visible{outline:3px solid var(--accent,#0f5fc2);outline-offset:3px}
:where(.cf-free-book-hero) .fbh__btn.is-loading{cursor:progress}
:where(.cf-free-book-hero) .fbh__btn:disabled{background:var(--field);border-color:var(--field-border,oklch(from var(--ink) l c h / 0.22));color:var(--field-ink);text-shadow:none;box-shadow:var(--button-shadow,0 3px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.21));cursor:not-allowed}
:where(.cf-free-book-hero) .fbh__note{display:flex;align-items:center;justify-content:center;gap:7px;margin:14px 0 0;font-size:.9375rem;font-weight:600;line-height:1.35;color:var(--muted,#4a5565);text-align:center}
:where(.cf-free-book-hero) .fbh__note svg{width:16px;height:16px;flex:none}
@media (min-width:1081px){
:where(.cf-free-book-hero) .fbh__calls-title{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
}
@media (max-width:1080px){
:where(.cf-free-book-hero) .fbh__grid{grid-template-columns:minmax(0,1fr) minmax(330px,420px)}
:where(.cf-free-book-hero) .fbh__show{grid-template-columns:minmax(0,1fr);grid-template-areas:'stage' 'calls';row-gap:28px;align-items:start}
:where(.cf-free-book-hero) .fbh__calls{padding:18px;border-radius:var(--card-radius,var(--radius,18px));background:var(--band);box-shadow:inset 0 0 0 1px var(--card-border,oklch(from var(--ink) l c h / 0.12))}
:where(.cf-free-book-hero) .fbh__calls ul{gap:16px}
:where(.cf-free-book-hero) .fbh__call{grid-template-columns:auto minmax(0,1fr);text-align:left}
:where(.cf-free-book-hero) .fbh__call-thumb{order:-1;width:56px;height:56px}
:where(.cf-free-book-hero) .fbh__call::before,:where(.cf-free-book-hero) .fbh__call::after{display:none}
:where(.cf-free-book-hero) .fbh__book{width:min(100%,320px)}
}
@media (max-width:820px){
:where(.cf-free-book-hero) .fbh__grid{grid-template-columns:minmax(0,1fr);grid-template-areas:'stage' 'card' 'calls';row-gap:28px}
:where(.cf-free-book-hero) .fbh__show{display:contents}
:where(.cf-free-book-hero) .fbh__card,:where(.cf-free-book-hero) .fbh__calls{width:100%;max-width:520px;justify-self:center}
:where(.cf-free-book-hero) .fbh__book{width:min(62vw,250px)}
}
@media (max-width:640px){
:where(.cf-free-book-hero) .fbh__tab-n{display:none}
}
@media (max-width:480px){
:where(.cf-free-book-hero) .fbh__card{padding:22px 18px 20px}
:where(.cf-free-book-hero) .fbh__tab{font-size:.9375rem;padding:8px 6px;gap:6px}
:where(.cf-free-book-hero) .fbh__tab.is-on:not(.is-last){padding-right:16px}
:where(.cf-free-book-hero) .fbh__btn{font-size:1.125rem;min-height:62px}
:where(.cf-free-book-hero) .fbh__promise{font-size:1rem}
}
@keyframes fbh-in{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes fbh-rise{from{opacity:.82;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes fbh-draw{from{transform:scaleX(0)}to{transform:scaleX(1)}}
@keyframes fbh-pop{from{transform:scale(0)}to{transform:scale(1)}}
@keyframes fbh-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:no-preference){
:where(.cf-free-book-hero) .fbh__book{animation:fbh-rise .55s cubic-bezier(.2,.7,.2,1) both}
:where(.cf-free-book-hero) .fbh__card{animation:fbh-in .45s ease-out .06s both}
:where(.cf-free-book-hero) .fbh__call{animation:fbh-in .45s ease-out both;animation-delay:calc(var(--i,0) * 90ms + 120ms)}
:where(.cf-free-book-hero) .fbh__call::after{animation:fbh-draw .5s ease-out both;animation-delay:calc(var(--i,0) * 90ms + 300ms)}
:where(.cf-free-book-hero) .fbh__call::before{animation:fbh-pop .3s ease-out both;animation-delay:calc(var(--i,0) * 90ms + 720ms)}
:where(.cf-free-book-hero) .fbh__spin{animation:fbh-spin .9s linear infinite}
}
@media (prefers-reduced-motion:reduce){
.cf-free-book-hero *,.cf-free-book-hero *::before,.cf-free-book-hero *::after{animation:none!important;transition:none!important}
:where(.cf-free-book-hero) .fbh__btn:hover,:where(.cf-free-book-hero) .fbh__btn.is-hover,:where(.cf-free-book-hero) .fbh__btn:active,:where(.cf-free-book-hero) .fbh__btn.is-active{transform:none!important}
}
`
type FreeBookHeroCopy = {
/** Uses {label} in lower case. */
placeholder: string
emailRequired: string
/** Uses {label} in lower case. */
required: string
emailInvalid: string
shippingNote: string
/** Uses {retailPrice}, lowercase {freeLabel}, and {shipping} including its trailing space. */
priceAria: string
retail: string
/** {amount} renders the supplied shipping price with its leading space and original emphasis. */
shipping: string
stepsAria: string
/** Uses {name}. */
successNamed: string
success: string
/** Uses {bookName}. */
successBody: string
edit: string
errorOne: string
errorMany: string
}
const DEFAULT_COPY: FreeBookHeroCopy = {
"placeholder": "Enter your {label}",
"emailRequired": "Please enter your email address.",
"required": "Please enter your {label}.",
"emailInvalid": "Please enter a valid email, like you@example.com.",
"shippingNote": "Shipping calculated at the next step.",
"priceAria": "Regular price {retailPrice}. Yours {freeLabel} today, just cover {shipping}shipping.",
"retail": "Retail",
"shipping": "Just cover{amount} shipping",
"stepsAria": "Order steps",
"successNamed": "Got it, {name}! Step 1 is done.",
"success": "Got it! Step 1 is done.",
"successBody": "Next, add your shipping address and we’ll send {bookName} straight to your door.",
"edit": "Edit my details",
"errorOne": "Almost there. Please fix the field above.",
"errorMany": "Almost there. Please fix the fields above."
}
function copyText(template: string, values: Record<string, string | number>) {
return template.replace(/\{(\w+)\}/g, (match, key: string) => Object.hasOwn(values, key) ? String(values[key]) : match)
}
function copyNodes(template: string, values: Record<string, React.ReactNode>) {
return template.split(/(\{\w+\})/g).map((part, index) => {
const key = part.slice(1, -1)
return part.startsWith("{") && Object.hasOwn(values, key) ? <React.Fragment key={index}>{values[key]}</React.Fragment> : part
})
}
pieces/hero/free-book-hero/specimen.tsx 33 lines
import __studioImage81ee0aac from "../assets/b4be169e2fabdc7c.webp";
import * as React from 'react'
import { FreeBookHero, type FreeBookField, type FreeBookHeroState } from '../free-book-hero'
import { slot } from '../../slots'
import defaults from '../../studio-defaults.json'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function FreeBookHeroSpecimen({ state = 'default' }: { state?: string }) {
const s = defaults.sample
return (
<div>
<FreeBookHero
headline={s.headline}
highlight='a clear plan'
lead={s.lead}
bookName={s.name}
productImage={slot('product', __studioImage81ee0aac)}
bookImageAlt={`${s.name} hardcover book on a lit display pedestal`}
retailPrice={s.regularPrice}
shipPromise={`${s.name}, shipped to your door.`}
fields={s.fields as FreeBookField[]}
callouts={s.items.map((item, i) => ({
name: item.name,
detail: item.detail,
itemImage: slot(`item-${i + 1}`, item.image),
imageAlt: item.imageAlt,
}))}
state={state as FreeBookHeroState}
/>
</div>
)
}
| Name | Type | Details |
|---|---|---|
copy OptionalFreeBookHero |
Partial<FreeBookHeroCopy> |
|
headline OptionalFreeBookHero |
string |
Default 'Build your first funnel with a clear plan'
|
highlight OptionalFreeBookHero |
string |
Default 'a clear plan'
|
lead OptionalFreeBookHero |
string |
Default 'Plan your funnel, write your page copy, and check every step before you launch.'
|
productImage OptionalFreeBookHero |
string |
Default legacyBookImage
|
bookImage OptionalFreeBookHero |
string |
|
bookImageAlt OptionalFreeBookHero |
string |
Default 'Hardcover book on a lit display pedestal'
|
bookName OptionalFreeBookHero |
string |
Default 'your book'
|
cardTitle OptionalFreeBookHero |
string |
Default 'Get Your FREE Book'
|
retailPrice OptionalFreeBookHero |
string |
|
freeLabel OptionalFreeBookHero |
string |
Default 'FREE'
|
shipping OptionalFreeBookHero |
string |
|
shippingNote OptionalFreeBookHero |
string |
|
shipPromise OptionalFreeBookHero |
string |
Default 'Your book, shipped to your door.'
|
steps OptionalFreeBookHero |
[string, string] |
Default DEFAULT_STEPS
|
fields OptionalFreeBookHero |
FreeBookField[] |
Default DEFAULT_FIELDS
|
ctaLabel OptionalFreeBookHero |
string |
Default 'Send Me My FREE Book'
|
ctaNote OptionalFreeBookHero |
string |
Default 'Next: enter your shipping address.'
|
loadingLabel OptionalFreeBookHero |
string |
Default 'Saving your details…'
|
successTitle OptionalFreeBookHero |
string |
|
successText OptionalFreeBookHero |
string |
|
callouts OptionalFreeBookHero |
FreeBookCallout[] |
Default NO_CALLOUTS
|
calloutsTitle OptionalFreeBookHero |
string |
Default 'Inside your book'
|
state OptionalFreeBookHero |
FreeBookHeroState |
Default 'default'
|
onSubmit OptionalFreeBookHero |
(values: Record<string, string>) => void | Promise<void> |
|
className OptionalFreeBookHero |
string |
|
style OptionalFreeBookHero |
React.CSSProperties |
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.
--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.
--marker- The highlighter colour behind key phrases.
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.
product- The main product shot or cover (ebook, kit, bottle).
-
b4be169e2fabdc7c.webp
image/webp · 258 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB