Bundle Picker 3
Build-your-box bundle picker: the buyer chooses a box size and taps flavours into its slots in order, so they own the
Use it in a prompt
Use offer/bundle-picker-3 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/offer/bundle-picker-3.tsx. - Import it and pass your copy and images (Props tab):
import { BundlePicker3 } from "@/components/funneldna/offer/bundle-picker-3"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/bundle-picker-3/component.tsx 723 lines
// layout: split-contrast
// Build-your-box bundle picker: the buyer chooses a box size and taps flavours into its slots in order, so they own the
// bundle they built (the IKEA effect). Add To Cart unlocks only when every slot is filled.
'use client'
import * as React from 'react'
import { AlertCircle, Check, Info, Loader2, Minus, Plus, ShieldCheck, ShoppingCart } from 'lucide-react'
export type BoxFlavour = {
/** Stable id passed back with the selection. */
id: string
name: string
/** One short line on what is in it. */
detail?: string
/** Single-bag price. When every flavour has one, the ledger adds the box up bag by bag. */
price?: number
/** Product photo (item-n slot). */
image?: string
/** When image is a contact sheet of several products, the cell this flavour shows (0-based col and row). */
sheetCell?: { cols: number; rows: number; col: number; row: number }
}
export type BoxSize = {
/** Slots (bags) in the box, e.g. 3, 6, 12. */
slots: number
/** Price of the full box. */
price: number
/** Value passed back for this size; defaults to the slot count. */
id?: string
}
export type BoxSelection = {
size: BoxSize
sizeIndex: number
/** Flavours in slot order. */
picks: BoxFlavour[]
/** Bags per flavour id. */
counts: Record<string, number>
full: boolean
}
export type BundlePicker3State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
/**
* Copy templates. Named placeholders are replaced as text: {slots}, {slotWord}, {unit}, {Unit}, {unitOther}, {price},
* {perUnit}, {filled}, {remaining}, {remainingWord}, {guarantee}, {name}, {count}, {n}, {savings}, {countWord}.
*/
export type BundlePicker3Copy = typeof DEFAULT_COPY
export type BundlePicker3Props = {
headline?: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
lead?: string
/** Box sizes, shown as a segmented choice. */
sizes?: BoxSize[]
/** Size index chosen on load; defaults to the second size. */
defaultSize?: number
flavours?: BoxFlavour[]
/** Flavour ids already in the box on load, in slot order. */
defaultPicks?: string[]
/** Flat-lay photo of the open, empty box (scene slot). */
sceneImage?: string
sceneImageAlt?: string
/** Unit words in lower case, e.g. bag / bags. */
unit?: { one: string; other: string }
/** ISO currency code for every price. */
currency?: string
locale?: string
/** Supplied guarantee; empty hides it. */
guarantee?: string
/** Replaces the computed numbered reasons; entries may use the copy placeholders. */
reasons?: string[]
/** Forces a preview state. hover, active and error show on a full box. */
state?: BundlePicker3State
/** Called after every size change, add and removal. */
onChange?: (selection: BoxSelection) => void
/** Add To Cart with the full box. A rejected promise shows the inline error. */
onAction?: (selection: BoxSelection) => void | Promise<void>
copy?: Partial<BundlePicker3Copy>
className?: string
style?: React.CSSProperties
}
type Vars = Record<string, string | number>
export function BundlePicker3(props: BundlePicker3Props) {
const {
headline = 'Build your own box and pick every bag',
highlight = 'pick every bag',
lead = 'Choose your box size, then tap the flavours you want. Each bag drops into the next open slot.',
sizes = DEFAULT_SIZES,
defaultSize,
flavours = DEFAULT_FLAVOURS,
defaultPicks,
sceneImage,
sceneImageAlt = 'Open gift box with empty compartments, ready to fill',
unit = { one: 'bag', other: 'bags' },
currency = 'USD',
locale = 'en-US',
guarantee = '',
reasons,
state,
onChange,
onAction,
copy,
className,
style,
} = props
const text: BundlePicker3Copy = { ...DEFAULT_COPY, ...copy }
const uid = React.useId()
const ids = { title: `${uid}-title`, note: `${uid}-note`, err: `${uid}-err`, size: `${uid}-size` }
const money = (n: number) => formatMoney(n, locale, currency)
const word = (n: number) => (n === 1 ? unit.one : unit.other)
const Unit = unit.one.charAt(0).toUpperCase() + unit.one.slice(1)
const perSize = sizes.map((s) => s.price / slotCount(s))
const smallest = sizes.reduce((m, s, i) => (s.slots < sizes[m].slots ? i : m), 0)
const best = bestIndex(perSize)
const startSize =
typeof defaultSize === 'number' && defaultSize >= 0 && defaultSize < sizes.length
? Math.floor(defaultSize)
: Math.min(1, Math.max(0, sizes.length - 1))
const [sizeIndex, setSizeIndex] = React.useState(startSize)
const [picks, setPicks] = React.useState<string[]>(() => {
const known = new Set(flavours.map((f) => f.id))
return (defaultPicks ?? []).filter((id) => known.has(id)).slice(0, slotCount(sizes[startSize]))
})
const [status, setStatus] = React.useState<'idle' | 'loading' | 'error'>(state === 'error' ? 'error' : 'idle')
const [live, setLive] = React.useState('')
React.useEffect(() => {
setStatus(state === 'error' ? 'error' : 'idle')
}, [state])
const alive = React.useRef(true)
React.useEffect(() => {
alive.current = true
return () => {
alive.current = false
}
}, [])
if (!sizes.length || !flavours.length) return null
const si = Math.min(Math.max(sizeIndex, 0), sizes.length - 1)
const size = sizes[si]
const slots = slotCount(size)
const byId = new Map(flavours.map((f) => [f.id, f] as const))
const resolve = (list: string[]) => list.map((id) => byId.get(id)).filter((f): f is BoxFlavour => Boolean(f))
const list = resolve(picks).slice(0, slots)
const filled = list.length
const full = filled >= slots
const remaining = Math.max(0, slots - filled)
const counts = countBy(list)
const disabled = state === 'disabled'
const loading = status === 'loading'
const vars: Vars = {
slots,
slotWord: word(slots),
unit: unit.one,
Unit,
unitOther: unit.other,
price: money(size.price),
perUnit: money(perSize[si]),
filled,
remaining,
remainingWord: word(remaining),
guarantee,
}
const selection = (index: number, next: string[]): BoxSelection => {
const cap = slotCount(sizes[index])
const chosen = resolve(next).slice(0, cap)
return { size: sizes[index], sizeIndex: index, picks: chosen, counts: countBy(chosen), full: chosen.length >= cap }
}
const commit = (index: number, next: string[], message: string) => {
setSizeIndex(index)
setPicks(next)
setLive(message)
if (status === 'error') setStatus('idle')
onChange?.(selection(index, next))
}
const add = (f: BoxFlavour) => {
if (disabled || loading || full) return
const next = [...list.map((x) => x.id), f.id]
const message = fill(text.liveAdd, { ...vars, name: f.name, filled: next.length })
commit(si, next, next.length >= slots ? `${message} ${text.liveFull}` : message)
}
const remove = (f: BoxFlavour) => {
if (disabled || loading) return
const current = list.map((x) => x.id)
const at = current.lastIndexOf(f.id)
if (at < 0) return
const next = current.filter((_, i) => i !== at)
commit(si, next, fill(text.liveRemove, { ...vars, name: f.name, filled: next.length }))
}
const chooseSize = (i: number) => {
if (disabled || loading || i === si) return
const n = slotCount(sizes[i])
const next = list.map((x) => x.id).slice(0, n)
commit(i, next, fill(text.liveSize, { ...vars, slots: n, filled: next.length }))
}
const submit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
if (!full || disabled || loading || !onAction) return
setStatus('loading')
try {
await onAction(selection(si, list.map((x) => x.id)))
if (alive.current) setStatus('idle')
} catch {
if (alive.current) setStatus('error')
}
}
const hasValues = flavours.every((f) => typeof f.price === 'number' && f.price >= 0)
const order = Array.from(new Set(list.map((f) => f.id))).map((id) => byId.get(id) as BoxFlavour)
const bagTotal = hasValues ? list.reduce((sum, f) => sum + (f.price ?? 0), 0) : 0
const savings = full && hasValues ? bagTotal - size.price : 0
const cheaper = si !== smallest && perSize[si] < perSize[smallest] - 0.005
const reasonList = (
reasons ?? [text.reasonPick, ...(cheaper ? [text.reasonPer] : []), ...(guarantee ? [text.reasonGuarantee] : [])]
).map((r) => fill(r, vars))
const reasonsTitle =
reasonList.length === 1
? fill(text.reasonsTitleOne, vars)
: fill(text.reasonsTitle, { ...vars, countWord: text.countWords[reasonList.length - 1] ?? String(reasonList.length) })
const panelTitle = fill(filled === 0 ? text.panelEmpty : full ? text.panelFull : text.panelGoing, vars)
const force = full && !disabled && (state === 'hover' || state === 'active') ? state : undefined
const describedBy = status === 'error' ? ids.err : !full ? ids.note : undefined
const renderSlots = (variant: 'mini' | 'board') => (
<ol
className={`slots ${variant}`}
aria-label={fill(text.slotsLabel, vars)}
style={{ '--cols': Math.min(slots, 6), '--count': slots } as React.CSSProperties}
>
{Array.from({ length: slots }, (_, i) => {
const f = list[i]
return (
<li key={i} className={`slot${f ? ' on' : ''}${!f && i === filled ? ' next' : ''}`}>
{f ? (
<Thumb key={`${f.id}-${i}`} flavour={f} className='slot-img' />
) : (
<span className='slot-n' aria-hidden='true'>
{i + 1}
</span>
)}
<span className='sr'>{fill(f ? text.slotFilled : text.slotEmpty, { ...vars, n: i + 1, name: f ? f.name : '' })}</span>
</li>
)
})}
</ol>
)
return (
<section
className={`cf-bp3${className ? ` ${className}` : ''}`}
style={style}
aria-labelledby={ids.title}
data-disabled={disabled || undefined}
>
<style>{CSS}</style>
<form className='split' onSubmit={submit} noValidate>
<div className='light'>
<div className='light-in'>
<h2 id={ids.title}>
<Marked text={headline} mark={highlight} />
</h2>
{lead ? <p className='lead'>{lead}</p> : null}
<fieldset className='sizes' disabled={disabled}>
<legend className='sr'>{text.sizeLegend}</legend>
<div className='track' style={{ '--n': sizes.length } as React.CSSProperties}>
{sizes.map((s, i) => {
const on = i === si
return (
<label key={s.id ?? i} className='seg' data-on={on || undefined}>
<input
className='sr'
type='radio'
name={ids.size}
value={s.id ?? String(slotCount(s))}
checked={on}
disabled={disabled || loading}
onChange={() => chooseSize(i)}
/>
{i === best ? <span className='flag'>{text.bestValue}</span> : null}
<span className='seg-t'>
{fill(text.sizeName, { ...vars, slots: slotCount(s), slotWord: word(slotCount(s)) })}
</span>
<span className='seg-p'>{money(s.price)}</span>
<span className='seg-u'>{fill(text.perUnit, { ...vars, perUnit: money(perSize[i]) })}</span>
</label>
)
})}
</div>
</fieldset>
<div className='meter' data-full={full || undefined}>
<span className='meter-t'>
{full ? (
<>
<span className='ok' aria-hidden='true'>
<Check size={14} strokeWidth={3} />
</span>
{text.full}
</>
) : (
fill(text.meter, vars)
)}
</span>
{renderSlots('mini')}
</div>
<p className='hint'>{text.hint}</p>
<ul className='grid'>
{flavours.map((f, i) => {
const count = counts[f.id] ?? 0
return (
<li
key={f.id}
className='card reveal'
data-picked={count > 0 || undefined}
data-full={full || undefined}
style={{ '--d': `${Math.min(i * 0.07, 0.28)}s` } as React.CSSProperties}
>
<button
type='button'
className='pick'
onClick={() => add(f)}
disabled={disabled || full}
aria-label={fill(text.add, { ...vars, name: f.name })}
>
<Thumb flavour={f} className='thumb'>
{count > 0 ? (
<span key={count} className='count' aria-hidden='true'>
×{count}
</span>
) : null}
</Thumb>
<span className='name'>{f.name}</span>
{f.detail ? <span className='detail'>{f.detail}</span> : null}
{typeof f.price === 'number' ? (
<span className='each'>{fill(text.each, { ...vars, price: money(f.price) })}</span>
) : null}
</button>
<div className='stepper' role='group' aria-label={f.name}>
<button
type='button'
className='step'
onClick={() => remove(f)}
disabled={disabled || count === 0}
aria-label={fill(text.remove, { ...vars, name: f.name })}
>
<Minus size={20} strokeWidth={2.5} aria-hidden='true' />
</button>
<output className='qty' aria-label={fill(text.qty, { ...vars, name: f.name, count })}>
{count}
</output>
<button
type='button'
className='step'
onClick={() => add(f)}
disabled={disabled || full}
aria-label={fill(text.add, { ...vars, name: f.name })}
>
<Plus size={20} strokeWidth={2.5} aria-hidden='true' />
</button>
</div>
</li>
)
})}
</ul>
{reasonList.length ? (
<div className='reasons'>
<h3>{reasonsTitle}</h3>
<p>
{reasonList.map((r, i) => (
<React.Fragment key={i}>
{i > 0 ? ' ' : null}
<span className='n'>{i + 1}.</span>
{r}
</React.Fragment>
))}
</p>
</div>
) : null}
</div>
</div>
<div className='dark'>
<div className='dark-in'>
<h3 className='panel-t'>{panelTitle}</h3>
{sceneImage ? (
<img className='scene' src={sceneImage} alt={sceneImageAlt} width={1200} height={600} decoding='async' />
) : null}
{renderSlots('board')}
<ul className='ledger'>
{order.map((f) => (
<li key={f.id}>
<span className='lbl'>{fill(text.ledgerLine, { ...vars, name: f.name, count: counts[f.id] })}</span>
{hasValues ? (
<>
<span className='dots' aria-hidden='true' />
<span className='val'>{money((f.price ?? 0) * counts[f.id])}</span>
</>
) : null}
</li>
))}
{remaining > 0 ? (
<li className='soft'>
<span className='lbl'>{fill(text.ledgerOpen, vars)}</span>
</li>
) : null}
</ul>
<div className='today'>
<span className='today-l'>{fill(text.today, vars)}</span>
<span className='today-v'>
{savings > 0.005 ? (
<s className='was'>
<span className='sr'>{fill(text.ledgerTotal, vars)}: </span>
{money(bagTotal)}
</s>
) : null}
<span className='today-p'>{money(size.price)}</span>
</span>
</div>
{savings > 0.005 ? <p className='save'>{fill(text.savings, { ...vars, savings: money(savings) })}</p> : null}
<div className='act'>
<button
type='submit'
className='cta'
disabled={!full || disabled}
data-force={force}
aria-busy={loading || undefined}
aria-describedby={describedBy}
>
{loading ? (
<Loader2 className='spin' size={20} strokeWidth={2.5} aria-hidden='true' />
) : (
<ShoppingCart size={20} strokeWidth={2.5} aria-hidden='true' />
)}
<span>{loading ? text.loading : fill(text.button, vars)}</span>
</button>
{status === 'error' ? (
<p id={ids.err} className='err' role='alert'>
<AlertCircle size={18} strokeWidth={2.5} aria-hidden='true' />
{text.error}
</p>
) : null}
{!full ? (
<p id={ids.note} className='note'>
<Info size={18} strokeWidth={2.5} aria-hidden='true' />
{fill(text.notFull, vars)}
</p>
) : null}
{guarantee ? (
<p className='guar'>
<ShieldCheck size={18} strokeWidth={2.5} aria-hidden='true' />
{guarantee}
</p>
) : null}
</div>
</div>
</div>
<p className='sr' aria-live='polite'>
{live}
</p>
</form>
</section>
)
}
export default BundlePicker3
function Thumb({ flavour, className, children }: { flavour: BoxFlavour; className: string; children?: React.ReactNode }) {
const c = flavour.sheetCell
const crop =
c && c.cols > 0 && c.rows > 0
? { width: `${c.cols * 100}%`, height: `${c.rows * 100}%`, left: `${-c.col * 100}%`, top: `${-c.row * 100}%` }
: undefined
return (
<span className={className}>
{flavour.image ? (
<img className={crop ? 'sheet' : 'full'} src={flavour.image} alt='' style={crop} loading='lazy' decoding='async' />
) : (
<span className='initial' aria-hidden='true'>
{flavour.name.trim().charAt(0)}
</span>
)}
{children}
</span>
)
}
function Marked({ text, mark }: { text: string; mark?: string }) {
const at = mark ? text.indexOf(mark) : -1
if (!mark || at < 0) return <>{text}</>
return (
<>
{text.slice(0, at)}
<span className='mk'>{mark}</span>
{text.slice(at + mark.length)}
</>
)
}
function slotCount(s?: BoxSize) {
return s ? Math.max(1, Math.round(s.slots)) : 1
}
function countBy(list: BoxFlavour[]) {
const out: Record<string, number> = {}
for (const f of list) out[f.id] = (out[f.id] ?? 0) + 1
return out
}
function bestIndex(per: number[]) {
if (per.length < 2) return -1
const min = Math.min(...per)
const max = Math.max(...per)
const hits = per.filter((p) => Math.abs(p - min) < 0.005)
if (hits.length !== 1 || min > max - 0.005) return -1
return per.findIndex((p) => Math.abs(p - min) < 0.005)
}
function fill(template: string, vars: Vars) {
return Object.keys(vars).reduce((s, k) => s.split('{' + k + '}').join(String(vars[k])), template)
}
function formatMoney(n: number, locale: string, currency: string) {
const whole = Math.abs(n - Math.round(n)) < 0.005
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
minimumFractionDigits: whole ? 0 : 2,
maximumFractionDigits: whole ? 0 : 2,
}).format(whole ? Math.round(n) : n)
}
const DEFAULT_COPY = {
sizeLegend: 'Choose your box size',
sizeName: '{slots} {slotWord}',
perUnit: '{perUnit} a {unit}',
bestValue: 'Best value',
hint: 'Tap a flavour to drop it into your box.',
add: 'Add one {name}',
remove: 'Remove one {name}',
qty: '{name}: {count} in your box',
each: '{price} a {unit}',
meter: '{filled} of {slots}',
full: 'Box full',
slotsLabel: 'Your box: {filled} of {slots} filled',
slotFilled: 'Slot {n}: {name}',
slotEmpty: 'Slot {n}: empty',
panelEmpty: 'Fill your {slots}-{unit} box',
panelGoing: '{remaining} more {remainingWord} to fill your box',
panelFull: 'Your box is full and ready',
ledgerLine: '{name} × {count}',
ledgerOpen: '{remaining} {remainingWord} still to pick',
ledgerSoFar: '{Unit} by {unit} so far',
ledgerTotal: 'Bought {unit} by {unit}',
today: 'Your {slots}-{unit} box today',
savings: 'That’s {savings} less than buying each {unit} on its own.',
button: 'Add To Cart · {price}',
loading: 'Adding to your cart…',
notFull: 'Pick {remaining} more {remainingWord} to fill your box and add it to your cart.',
error: 'We couldn’t add your box to the cart. Please try again.',
reasonsTitle: '{countWord} reasons this box is {price} today',
reasonsTitleOne: 'Why this box is {price} today',
countWords: ['One', 'Two', 'Three', 'Four', 'Five', 'Six'],
reasonPick: 'You pick every {unit}, so your box holds only the flavours you want.',
reasonPer: 'Bigger boxes cost less per {unit}: {perUnit} a {unit} in this one.',
reasonGuarantee: 'Every box comes with a {guarantee}.',
liveAdd: '{name} added. {filled} of {slots} filled.',
liveRemove: '{name} removed. {filled} of {slots} filled.',
liveFull: 'Your box is full.',
liveSize: '{slots}-{unit} box selected. {filled} of {slots} filled.',
}
const DEFAULT_SIZES: BoxSize[] = [
{ slots: 3, price: 18 },
{ slots: 6, price: 34 },
{ slots: 12, price: 62 },
]
const DEFAULT_FLAVOURS: BoxFlavour[] = [
{ id: 'honey-almond', name: 'Honey Almond Crunch', detail: 'Toasted almonds, honey oat clusters, sea salt', price: 6.99 },
{ id: 'cherry-cocoa', name: 'Dark Cherry Cocoa', detail: 'Dark chocolate, tart cherries, cashews', price: 7.49 },
{ id: 'maple-pecan', name: 'Smoky Maple Pecan', detail: 'Maple pecans, pumpkin seeds, smoked salt', price: 7.49 },
{ id: 'tropical', name: 'Tropical Sunrise', detail: 'Mango, coconut chips, macadamias', price: 6.99 },
{ id: 'espresso', name: 'Espresso Trek', detail: 'Espresso beans, hazelnuts, cacao nibs', price: 7.49 },
{ id: 'peanut-raisin', name: 'Classic Peanut Raisin', detail: 'Roasted peanuts, golden raisins, chocolate drops', price: 5.99 },
]
const CSS = `
.cf-bp3{--g:clamp(16px,5vw,48px);--sh:var(--shadow,oklch(0.22 0.03 260));--mk:var(--marker,#fae37c);--e:cubic-bezier(.2,.7,.2,1);--soft-ink:color-mix(in oklch,var(--band-ink) 82%,var(--band));position:relative;background:var(--surface);color:var(--ink);font-family:var(--font-body);overflow-x:clip}
.cf-bp3 *,.cf-bp3 *::before,.cf-bp3 *::after{box-sizing:border-box}
.cf-bp3 .sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.cf-bp3 h2,.cf-bp3 h3,.cf-bp3 p{margin:0}
.cf-bp3 .split{display:flex;flex-direction:column;margin:0}
.cf-bp3 .light{background:var(--surface);color:var(--ink);padding:clamp(56px,8vw,112px) var(--g) clamp(48px,7vw,96px)}
.cf-bp3 .dark{background:var(--band);color:var(--band-ink);padding:clamp(48px,7vw,96px) var(--g) clamp(64px,8.5vw,120px)}
.cf-bp3 .light-in,.cf-bp3 .dark-in{max-width:46rem;margin-inline:auto}
@media (min-width:960px){
.cf-bp3 .split{flex-direction:row;align-items:stretch}
.cf-bp3 .light{flex:1 1 56%;min-width:0;padding-right:clamp(32px,4vw,64px);padding-bottom:clamp(64px,8.5vw,120px)}
.cf-bp3 .dark{flex:1 1 44%;min-width:0;padding-top:clamp(56px,8vw,112px);padding-left:clamp(32px,4vw,64px)}
.cf-bp3 .light-in{max-width:620px;margin:0 0 0 auto}
.cf-bp3 .dark-in{max-width:500px;margin:0 auto 0 0}
}
@media (min-width:960px) and (min-height:840px){.cf-bp3 .dark-in{position:sticky;top:24px}}
.cf-bp3 h2{font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance}
.cf-bp3 .mk{background:linear-gradient(transparent 54%,color-mix(in oklch,var(--mk) 78%,transparent) 54% 93%,transparent 93%);-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:0 .08em;margin:0 -.04em;border-radius:.12em}
.cf-bp3 .lead{margin-top:16px;max-width:60ch;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
.cf-bp3 .sizes{margin:40px 0 0;padding:0;border:0;min-inline-size:0}
.cf-bp3 .track{display:grid;grid-template-columns:repeat(var(--n),minmax(0,1fr));gap:6px;padding:6px;border-radius:calc(var(--radius,12px) + 6px);background:color-mix(in oklch,var(--ink) 5%,var(--surface))}
.cf-bp3 .seg{position:relative;display:grid;justify-items:center;align-content:start;gap:4px;padding:18px 8px 14px;border:2px solid transparent;border-radius:var(--radius,12px);text-align:center;cursor:pointer;transition:background .16s ease,box-shadow .16s ease,border-color .16s ease}
.cf-bp3 .seg:hover{background:color-mix(in oklch,var(--ink) 3%,var(--card))}
.cf-bp3 .seg[data-on]{background:var(--card);border-color:var(--accent);box-shadow:var(--shadow-md,0 1px 2px oklch(from var(--sh) l c h / .22),0 4px 10px -2px oklch(from var(--sh) l c h / .2))}
.cf-bp3 .seg:has(input:focus-visible){outline:3px solid oklch(from var(--field-focus,var(--accent)) l c h / .55);outline-offset:2px}
.cf-bp3[data-disabled] .seg{cursor:not-allowed}
.cf-bp3[data-disabled] .seg:hover{background:transparent}
.cf-bp3 .seg-t{font-weight:800;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.2}
.cf-bp3 .seg-p{font-family:var(--font-display);font-weight:800;font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;font-variant-numeric:tabular-nums}
.cf-bp3 .seg-u{font-size:.875rem;line-height:1.2;font-weight:600;color:var(--muted);font-variant-numeric:tabular-nums;text-wrap:balance}
@media (max-width:599px){.cf-bp3 .track{gap:4px;padding:4px;border-radius:calc(var(--radius,12px) + 4px)}.cf-bp3 .seg{padding:18px 4px 12px}}
.cf-bp3 .flag{position:absolute;top:0;left:50%;translate:-50% -60%;max-width:calc(100% + 4px);padding:4px 12px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-size:.875rem;font-weight:800;line-height:1.2;white-space:nowrap;box-shadow:var(--shadow-sm,0 1px 2px oklch(from var(--sh) l c h / .2))}
.cf-bp3 .meter{position:sticky;top:8px;z-index:2;margin-top:24px;display:flex;align-items:center;gap:12px;padding:10px 14px;background:var(--card);border:1px solid var(--card-border,oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--shadow-md,0 1px 2px oklch(from var(--sh) l c h / .22),0 4px 10px -2px oklch(from var(--sh) l c h / .2))}
@media (min-width:960px){.cf-bp3 .meter{display:none}}
.cf-bp3 .meter-t{flex:0 0 auto;display:inline-flex;align-items:center;gap:6px;font-weight:800;font-size:.9375rem;line-height:1.2;white-space:nowrap;font-variant-numeric:tabular-nums}
.cf-bp3 .ok{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:999px;background:var(--success);color:var(--success-ink,#fff)}
.cf-bp3 .slots{list-style:none;margin:0;padding:0;display:grid}
.cf-bp3 .slot{position:relative;aspect-ratio:1;border-radius:999px;display:grid;place-items:center;overflow:hidden}
.cf-bp3 .slot-img{position:absolute;inset:0;border-radius:inherit;overflow:hidden;background:var(--card);animation:cfbp3-pop .3s var(--e) both}
.cf-bp3 .mini{flex:1 1 auto;min-width:0;grid-template-columns:repeat(var(--count),minmax(0,20px));gap:4px;justify-content:end}
.cf-bp3 .mini .slot{background:color-mix(in oklch,var(--ink) 8%,var(--card));box-shadow:inset 0 1px 2px oklch(from var(--sh) l c h / .25)}
.cf-bp3 .mini .slot.next{box-shadow:inset 0 0 0 2px var(--accent)}
.cf-bp3 .mini .slot-n{display:none}
.cf-bp3 .board{margin-top:20px;grid-template-columns:repeat(var(--cols),minmax(0,64px));gap:12px}
.cf-bp3 .board .slot{background:oklch(from var(--band-ink) l c h / .08);box-shadow:inset 0 2px 4px oklch(from var(--sh) calc(l - .05) c h / .55),inset 0 0 0 1px oklch(from var(--band-ink) l c h / .18)}
.cf-bp3 .board .slot.next{box-shadow:inset 0 2px 4px oklch(from var(--sh) calc(l - .05) c h / .55),inset 0 0 0 2px oklch(from var(--band-ink) l c h / .72)}
.cf-bp3 .board .slot.on{box-shadow:0 1px 2px oklch(from var(--sh) calc(l - .08) c h / .5)}
.cf-bp3 .board .slot-n{font-size:.875rem;font-weight:800;line-height:1;color:var(--soft-ink);font-variant-numeric:tabular-nums}
@media (max-width:959px){.cf-bp3 .board{display:none}}
.cf-bp3 .hint{margin:32px 0 16px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--muted)}
.cf-bp3 .grid{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
@media (min-width:600px){.cf-bp3 .grid{grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:16px}}
.cf-bp3 .card{position:relative;display:flex;flex-direction:column;min-width:0;padding:10px 10px 12px;background:var(--card);color:var(--ink);border:1px solid var(--card-border,oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-md,0 1px 2px oklch(from var(--sh) l c h / .22),0 4px 10px -2px oklch(from var(--sh) l c h / .2)));transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease,background .16s ease}
.cf-bp3 .card:hover:has(.pick:not(:disabled)){transform:translateY(-2px);box-shadow:var(--shadow-lg,0 2px 4px oklch(from var(--sh) l c h / .22),0 12px 24px -8px oklch(from var(--sh) l c h / .32))}
.cf-bp3 .card[data-picked]{border-color:oklch(from var(--accent) l c h / .6);background:color-mix(in oklch,var(--accent) 6%,var(--card))}
.cf-bp3 .pick{display:flex;flex-direction:column;width:100%;margin:0;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer;border-radius:10px}
.cf-bp3 .pick:disabled{cursor:not-allowed}
.cf-bp3 .pick:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-bp3 .thumb{position:relative;display:block;aspect-ratio:1;overflow:hidden;border-radius:10px;background:color-mix(in oklch,var(--ink) 4%,var(--card))}
.cf-bp3 .thumb img,.cf-bp3 .slot-img img{position:absolute;display:block;max-width:none;object-fit:cover;transition:opacity .16s ease}
.cf-bp3 .thumb img.full,.cf-bp3 .slot-img img.full{inset:0;width:100%;height:100%}
.cf-bp3 .card[data-full]:not([data-picked]) .thumb img{opacity:.6}
.cf-bp3 .initial{position:absolute;inset:0;display:grid;place-items:center;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-family:var(--font-display);font-weight:800;font-size:clamp(1.3125rem,1.8vw,1.625rem)}
.cf-bp3 .count{position:absolute;top:8px;right:8px;display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:28px;padding:0 12px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-size:.875rem;font-weight:800;line-height:1;font-variant-numeric:tabular-nums;box-shadow:var(--shadow-sm,0 1px 2px oklch(from var(--sh) l c h / .2));animation:cfbp3-pop .3s var(--e) both}
.cf-bp3 .name{margin-top:12px;font-weight:800;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.2;text-wrap:balance}
.cf-bp3 .detail{margin-top:4px;font-size:.9375rem;line-height:1.4;color:var(--muted);text-wrap:pretty}
.cf-bp3 .each{margin-top:8px;font-size:.9375rem;line-height:1.4;font-weight:700;font-variant-numeric:tabular-nums}
.cf-bp3 .stepper{margin-top:auto;padding-top:12px;display:flex;align-items:center;justify-content:space-between;gap:8px}
.cf-bp3 .step{display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;padding:0;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));box-shadow:var(--button-2-shadow,var(--shadow-sm));cursor:pointer;transition:background .16s ease,transform .16s ease,box-shadow .16s ease}
.cf-bp3 .step:hover:not(:disabled){background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - .05) c h)}
.cf-bp3 .step:active:not(:disabled){transform:translateY(1px);box-shadow:none;background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - .09) c h)}
.cf-bp3 .step:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:2px}
.cf-bp3 .step:disabled{opacity:.45;box-shadow:none;cursor:not-allowed}
.cf-bp3 .qty{min-width:2ch;text-align:center;font-family:var(--font-display);font-weight:800;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-variant-numeric:tabular-nums}
.cf-bp3 .reasons{margin-top:48px}
.cf-bp3 .reasons h3,.cf-bp3 .panel-t{font-family:var(--font-display);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}
.cf-bp3 .reasons p{margin-top:12px;max-width:64ch;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;text-wrap:pretty}
.cf-bp3 .reasons .n{font-family:var(--font-display);font-weight:800;color:var(--accent);margin-inline-end:.3em}
.cf-bp3 .scene{display:block;width:100%;height:auto;aspect-ratio:2/1;margin-top:16px;object-fit:cover;object-position:center;border-radius:12px}
.cf-bp3 .ledger{list-style:none;margin:24px 0 0;padding:0;display:grid;gap:8px}
.cf-bp3 .ledger li{display:flex;align-items:baseline;gap:8px;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.4}
.cf-bp3 .ledger .lbl{min-width:0;overflow-wrap:anywhere}
.cf-bp3 .ledger .dots{flex:1 1 24px;min-width:16px;align-self:center;height:1px;background:currentColor;opacity:.22}
.cf-bp3 .ledger .val{flex:0 0 auto;font-weight:700;white-space:nowrap;font-variant-numeric:tabular-nums}
.cf-bp3 .ledger .soft{color:var(--soft-ink)}
.cf-bp3 .today{margin-top:24px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 16px;padding:20px 24px;border-radius:12px;background:oklch(from var(--band-ink) l c h / .08)}
.cf-bp3 .today-v{display:inline-flex;align-items:baseline;gap:12px}
.cf-bp3 .was{font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1;font-weight:700;color:var(--soft-ink);text-decoration-thickness:2px;font-variant-numeric:tabular-nums}
.cf-bp3 .today-l{font-weight:800;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.3}
.cf-bp3 .today-p{font-family:var(--font-display);font-weight:800;font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;letter-spacing:-0.03em;font-variant-numeric:tabular-nums}
.cf-bp3 .save{margin-top:12px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--soft-ink);text-wrap:pretty}
.cf-bp3 .act{margin-top:24px}
.cf-bp3 .cta{--b:var(--button-bg,var(--cta));--b2:var(--button-bg-2,var(--cta-2));position:relative;display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:72px;padding:0 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from var(--b) calc(l + .04) c h),oklch(from var(--b2) calc(l - .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);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-wrap:balance;text-shadow:var(--button-text-shadow,none);cursor:pointer;box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--b) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--b) calc(l - .16) c h),0 1px 2px oklch(from var(--sh) l c h / .35),0 8px 16px -6px oklch(from var(--sh) l c h / .5));transition:background .16s ease,box-shadow .16s ease,transform .16s ease}
.cf-bp3 .cta svg{flex:0 0 auto}
.cf-bp3 .cta:not(:disabled):hover,.cf-bp3 .cta[data-force=hover]{background:linear-gradient(oklch(from var(--b) calc(l - .01) c h),oklch(from var(--b2) calc(l - .07) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--b) calc(l + .1) c h / .6),inset 0 -3px 0 oklch(from var(--b) calc(l - .2) c h),0 1px 2px oklch(from var(--sh) l c h / .4),0 10px 18px -6px oklch(from var(--sh) l c h / .6))}
.cf-bp3 .cta:not(:disabled):active,.cf-bp3 .cta[data-force=active]{transform:translateY(1px);background:linear-gradient(oklch(from var(--b) calc(l - .04) c h),oklch(from var(--b2) calc(l - .08) c h));box-shadow:inset 0 2px 4px oklch(from var(--b) calc(l - .22) c h / .55),inset 0 -2px 0 oklch(from var(--b) calc(l - .16) c h),0 1px 2px oklch(from var(--sh) l c h / .35)}
.cf-bp3 .cta:focus-visible{outline:3px solid var(--band-ink);outline-offset:3px}
.cf-bp3 .cta:disabled{background:color-mix(in oklch,var(--band-ink) 14%,var(--band));color:color-mix(in oklch,var(--band-ink) 88%,var(--band));text-shadow:none;box-shadow:inset 0 0 0 1px oklch(from var(--band-ink) l c h / .3);cursor:not-allowed}
.cf-bp3 .cta[aria-busy=true]{cursor:progress}
.cf-bp3 .note,.cf-bp3 .guar{margin-top:12px;font-size:.9375rem;line-height:1.4;font-weight:600;text-align:center;text-wrap:pretty}
.cf-bp3 .note svg,.cf-bp3 .guar svg,.cf-bp3 .err svg{display:inline-block;vertical-align:-.15em;margin-inline-end:.4em}
.cf-bp3 .err{margin-top:12px;padding:12px 16px;border-radius:10px;background:var(--danger-soft);color:var(--danger);font-size:.9375rem;line-height:1.4;font-weight:700;text-wrap:pretty}
@keyframes cfbp3-pop{from{transform:scale(.9)}to{transform:scale(1)}}
@keyframes cfbp3-in{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cfbp3-spin{to{transform:rotate(360deg)}}
.cf-bp3 .reveal{animation:cfbp3-in .45s var(--e) backwards;animation-delay:var(--d,0s)}
.cf-bp3 .spin{animation:cfbp3-spin .8s linear infinite}
@media (prefers-reduced-motion:reduce){.cf-bp3 *,.cf-bp3 *::before,.cf-bp3 *::after{animation:none!important;transition:none!important}}
`
pieces/offer/bundle-picker-3/specimen.tsx 54 lines
import __studioImage7f05aa98 from "../assets/f581d98d1878e8be.webp";
import __studioImage0a0aefd0 from "../assets/083642d0c836ef67.webp";
import * as React from 'react'
import { BundlePicker3, type BoxFlavour, type BundlePicker3State } from '../bundle-picker-3'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
const FLAVOUR_SHEET = __studioImage7f05aa98
const BOX_FLATLAY = __studioImage0a0aefd0
const FLAVOURS: (Omit<BoxFlavour, 'image' | 'sheetCell'> & { col: number; row: number })[] = [
{ id: 'honey-almond', name: 'Honey Almond Crunch', detail: 'Toasted almonds, honey oat clusters, sea salt', price: 6.99, col: 0, row: 0 },
{ id: 'cherry-cocoa', name: 'Dark Cherry Cocoa', detail: 'Dark chocolate, tart cherries, cashews', price: 7.49, col: 1, row: 0 },
{ id: 'maple-pecan', name: 'Smoky Maple Pecan', detail: 'Maple pecans, pumpkin seeds, smoked salt', price: 7.49, col: 2, row: 0 },
{ id: 'tropical', name: 'Tropical Sunrise', detail: 'Mango, coconut chips, macadamias', price: 6.99, col: 0, row: 1 },
{ id: 'espresso', name: 'Espresso Trek', detail: 'Espresso beans, hazelnuts, cacao nibs', price: 7.49, col: 1, row: 1 },
{ id: 'peanut-raisin', name: 'Classic Peanut Raisin', detail: 'Roasted peanuts, golden raisins, chocolate drops', price: 5.99, col: 2, row: 1 },
]
const PARTIAL = ['honey-almond', 'cherry-cocoa', 'honey-almond', 'maple-pecan']
const FULL = ['honey-almond', 'cherry-cocoa', 'honey-almond', 'maple-pecan', 'tropical', 'espresso']
export default function BundlePicker3Specimen({ state = 'default' }: { state?: BundlePicker3State }) {
const full = state === 'hover' || state === 'active' || state === 'error'
const flavours: BoxFlavour[] = FLAVOURS.map(({ col, row, ...f }, i) => {
const image = slot(`item-${i + 1}`, FLAVOUR_SHEET)
return { ...f, image, sheetCell: image === FLAVOUR_SHEET ? { cols: 3, rows: 2, col, row } : undefined }
})
return (
<BundlePicker3
key={state}
state={state}
headline='Build your own trail mix box, one bag at a time'
highlight='one bag at a time'
lead='Pick a 3, 6 or 12-bag Trail Mix Co. variety box, then tap the flavours you love. Each bag drops into the next open slot.'
sizes={[
{ slots: 3, price: 18 },
{ slots: 6, price: 34 },
{ slots: 12, price: 62 },
]}
defaultSize={1}
flavours={flavours}
defaultPicks={full ? FULL : PARTIAL}
sceneImage={slot('scene', BOX_FLATLAY)}
sceneImageAlt='Open white Trail Mix Co. gift box with empty compartments, ready to fill'
guarantee={defaults.sample.guarantee}
onAction={() => undefined}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalBundlePicker3 |
string |
|
highlight OptionalBundlePicker3 |
string |
|
lead OptionalBundlePicker3 |
string |
|
sizes OptionalBundlePicker3 |
BoxSize[] |
|
defaultSize OptionalBundlePicker3 |
number |
|
flavours OptionalBundlePicker3 |
BoxFlavour[] |
|
defaultPicks OptionalBundlePicker3 |
string[] |
|
sceneImage OptionalBundlePicker3 |
string |
|
sceneImageAlt OptionalBundlePicker3 |
string |
|
unit OptionalBundlePicker3 |
{ one: string; other: string } |
|
currency OptionalBundlePicker3 |
string |
|
locale OptionalBundlePicker3 |
string |
|
guarantee OptionalBundlePicker3 |
string |
|
reasons OptionalBundlePicker3 |
string[] |
|
state OptionalBundlePicker3 |
BundlePicker3State |
|
onChange OptionalBundlePicker3 |
(selection: BoxSelection) => void |
|
onAction OptionalBundlePicker3 |
(selection: BoxSelection) => void | Promise<void> |
|
copy OptionalBundlePicker3 |
Partial<BundlePicker3Copy> |
|
className OptionalBundlePicker3 |
string |
|
style OptionalBundlePicker3 |
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.
--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-focus- 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.
scene- A wide atmosphere photo behind or beside the copy.
-
083642d0c836ef67.webp
image/webp · 69.9 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB
-
f581d98d1878e8be.webp
image/webp · 126 KB