Cart Drawer 2
Cart drawer written as an itemised ledger: every line runs to its own total, one relevant add-on drops into the order in a single tap, and the bold total ends in the checkout button.
Use it in a prompt
Use checkout/cart-drawer-2 from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/checkout/cart-drawer-2.tsx. - Import it and pass your copy and images (Props tab):
import { CartDrawer2 } from "@/components/funneldna/checkout/cart-drawer-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/checkout/cart-drawer-2/component.tsx 851 lines
// layout: ledger-receipt
// Cart drawer written as an itemised ledger: every line runs to its own total, one relevant add-on drops into the order in a single tap, and the bold total ends in the checkout button.
'use client'
import * as React from 'react'
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from 'motion/react'
import { AlertCircle, Loader2, Lock, Minus, Plus, ShoppingBag, Trash2, Truck, X } from 'lucide-react'
import { Spot } from '../fx/fx'
import gift from '../fx/spots/gift'
export type CartDrawer2Item = {
id: string
name: string
/** Unit price as displayed, e.g. '$47'. The total is summed from these. */
price: string
/** Regular unit price, shown slashed beside the price when higher. Supplied values only. */
regularPrice?: string
/** Short line under the name; may carry emphasis. */
detail?: React.ReactNode
/** Product photo (theme slot item-n). */
image?: string
/** Alt text for the photo; defaults to the name. */
imageAlt?: string
/** Starting quantity, default 1. */
quantity?: number
/** Stepper ceiling, default 10. */
maxQuantity?: number
}
export type CartDrawer2AddOn = {
id: string
name: string
price: string
/** Pitch under the one-tap strip; may carry emphasis. */
detail?: React.ReactNode
/** Line shown under the name once it is in the cart. */
lineDetail?: React.ReactNode
/** Product photo (theme slot item-n). It flies into the ledger when added. */
image?: string
imageAlt?: string
maxQuantity?: number
}
/** One checkout line passed to onAction. */
export type CartDrawer2Line = { id: string; name: string; price: string; quantity: number }
/** Interface strings. Templates use {count}, {items}, {name}, {price}, {max}, {quantity}, {remaining}, {savings} and {total}. */
export type CartDrawer2Copy = {
count: string
item: string
items: string
openCart: string
closeCart: string
quantity: string
decrease: string
increase: string
each: string
limit: string
remove: string
removeLabel: string
removed: string
undo: string
undoLabel: string
regular: string
addOnHeadline: string
addOnAdded: string
quantityChanged: string
subtotal: string
shipping: string
shippingFree: string
shippingLater: string
shippingProgress: string
shippingUnlocked: string
total: string
savings: string
}
export type CartDrawer2State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
export type CartDrawer2Props = {
items?: CartDrawer2Item[]
/** One relevant add-on offered as a one-tap add. null hides it. */
addOn?: CartDrawer2AddOn | null
/** Drawer heading; wrap the promise in <mark> for the marker stroke. */
title?: React.ReactNode
/** Text on the cart trigger button. */
triggerLabel?: string
/** Checkout button. {total} and {count} are replaced. */
actionLabel?: string
/** Button text while onAction's promise is pending. */
loadingLabel?: string
/** Line under the checkout button, beside the lock. */
reassurance?: string
/** Shown when onAction rejects or state is 'error'. */
errorMessage?: string
emptyTitle?: string
emptyBody?: string
emptyActionLabel?: string
/** Destination of the empty-cart button; without it the button calls onContinue (and closes the overlay). */
emptyActionHref?: string
onContinue?: () => void
/** Free-shipping progress, shown only when supplied, e.g. { threshold: '$100' }. */
freeShipping?: { threshold: string } | null
/** Checkout destination when no onAction is given. */
href?: string
/** Checkout with the current lines. A returned promise shows loadingLabel; a rejection shows errorMessage. */
onAction?: (lines: CartDrawer2Line[]) => void | Promise<void>
/** 'overlay' slides in over the page (a bottom sheet on phones); 'inline' opens in place under the trigger. */
mode?: 'overlay' | 'inline'
defaultOpen?: boolean
copy?: Partial<CartDrawer2Copy>
/** Preview state: hover/active force the checkout button look, disabled blocks checkout, error shows errorMessage. */
state?: CartDrawer2State
className?: string
}
export function CartDrawer2(props: CartDrawer2Props) {
const {
items = [],
addOn = null,
title = 'Your cart',
triggerLabel = 'Cart',
actionLabel = 'Send me my order · {total}',
loadingLabel = 'Opening secure checkout…',
reassurance = 'Secure checkout',
errorMessage = 'We couldn’t open checkout. Please try again.',
emptyTitle = 'Your cart is empty',
emptyBody = 'Add something you love and it lands right here, totalled and ready to send.',
emptyActionLabel = 'Keep shopping',
emptyActionHref,
onContinue,
freeShipping = null,
href,
onAction,
mode = 'overlay',
defaultOpen = false,
copy: copyOverrides,
state = 'default',
className = '',
} = props
const copy = mergeCopy(copyOverrides)
const reduce = useReducedMotion() === true
const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, '')
const overlay = mode === 'overlay'
const panelId = 'cd2-panel-' + uid
const titleId = 'cd2-title-' + uid
const triggerRef = React.useRef<HTMLButtonElement>(null)
const panelRef = React.useRef<HTMLDivElement>(null)
const closeRef = React.useRef<HTMLButtonElement>(null)
const userOpened = React.useRef(false)
const alive = React.useRef(true)
const [mounted, setMounted] = React.useState(false)
const [sheet, setSheet] = React.useState(false)
const [open, setOpen] = React.useState(defaultOpen)
const [lines, setLines] = React.useState<Line[]>(() => items.map(toLine))
const [removed, setRemoved] = React.useState<{ line: Line; index: number } | null>(null)
const [limitId, setLimitId] = React.useState<string | null>(null)
const [checkout, setCheckout] = React.useState<'idle' | 'loading' | 'error'>(state === 'error' ? 'error' : 'idle')
const [announce, setAnnounce] = React.useState('')
React.useEffect(() => {
alive.current = true
setMounted(true)
return () => {
alive.current = false
}
}, [])
React.useEffect(() => {
setCheckout(state === 'error' ? 'error' : 'idle')
}, [state])
React.useEffect(() => {
if (!overlay || typeof window.matchMedia !== 'function') return
const query = window.matchMedia('(max-width: 520px)')
const sync = () => setSheet(query.matches)
sync()
query.addEventListener('change', sync)
return () => query.removeEventListener('change', sync)
}, [overlay])
React.useEffect(() => {
if (!overlay || !open) return
const root = document.documentElement
const previous = root.style.overflow
root.style.overflow = 'hidden'
const onKey = (event: KeyboardEvent) => {
if (event.key !== 'Escape') return
setOpen(false)
triggerRef.current?.focus()
}
document.addEventListener('keydown', onKey)
const frame = userOpened.current ? window.requestAnimationFrame(() => closeRef.current?.focus()) : 0
return () => {
root.style.overflow = previous
document.removeEventListener('keydown', onKey)
window.cancelAnimationFrame(frame)
}
}, [overlay, open])
const isEmpty = lines.length === 0
const symbol = currencyOf(items[0]?.price ?? addOn?.price ?? '$')
const count = lines.reduce((n, l) => n + l.quantity, 0)
const subtotal = sumOf(lines)
const savings = round(
lines.reduce((n, l) => n + (l.regularPrice ? Math.max(0, parseMoney(l.regularPrice) - parseMoney(l.price)) * l.quantity : 0), 0),
)
const subtotalText = money(subtotal, symbol)
const countValues = { count: String(count), items: count === 1 ? copy.item : copy.items }
const countText = fill(copy.count, countValues)
const addOnInCart = !!addOn && lines.some((l) => l.id === addOn.id)
const showOffer = !!addOn && !addOnInCart && !isEmpty
const threshold = freeShipping ? parseMoney(freeShipping.threshold) : 0
const remaining = round(Math.max(0, threshold - subtotal))
const unlocked = !!freeShipping && remaining <= 0
const progress = threshold > 0 ? Math.min(1, subtotal / threshold) : 0
const loading = checkout === 'loading'
const blocked = state === 'disabled' || isEmpty || loading
const force = state === 'hover' || state === 'active' ? state : undefined
const animate = mounted && !reduce
const flyId = (id: string) => (animate && addOn && id === addOn.id ? 'cd2-fly-' + id : undefined)
const openNow = () => {
userOpened.current = true
setOpen(true)
}
const close = () => {
setOpen(false)
triggerRef.current?.focus()
}
const step = (id: string, delta: number) => {
const line = lines.find((l) => l.id === id)
if (!line) return
const quantity = line.quantity + delta
if (quantity > (line.maxQuantity ?? 10)) {
setLimitId(id)
return
}
if (quantity < 1) return
setLimitId(null)
const next = lines.map((l) => (l.id === id ? { ...l, quantity } : l))
setLines(next)
setAnnounce(fill(copy.quantityChanged, { name: line.name, quantity: String(quantity), total: money(sumOf(next), symbol) }))
}
const remove = (id: string) => {
const index = lines.findIndex((l) => l.id === id)
if (index < 0) return
const line = lines[index]
setRemoved({ line, index })
setLimitId(null)
setLines(lines.filter((l) => l.id !== id))
setAnnounce(fill(copy.removed, { name: line.name }))
}
const undo = () => {
if (!removed) return
const next = lines.filter((l) => l.id !== removed.line.id)
next.splice(Math.min(removed.index, next.length), 0, removed.line)
setLines(next)
setRemoved(null)
setAnnounce(fill(copy.quantityChanged, { name: removed.line.name, quantity: String(removed.line.quantity), total: money(sumOf(next), symbol) }))
}
const addAddOn = () => {
if (!addOn || addOnInCart) return
const next: Line[] = [
...lines,
{ id: addOn.id, name: addOn.name, price: addOn.price, detail: addOn.lineDetail, image: addOn.image, imageAlt: addOn.imageAlt, maxQuantity: addOn.maxQuantity, quantity: 1 },
]
setLines(next)
setRemoved(null)
setAnnounce(fill(copy.addOnAdded, { name: addOn.name, total: money(sumOf(next), symbol) }))
}
const continueShopping = () => {
onContinue?.()
if (overlay) close()
}
const runCheckout = (event: React.MouseEvent<HTMLElement>) => {
if (blocked) {
event.preventDefault()
return
}
if (!onAction) return
event.preventDefault()
const payload = lines.map(({ id, name, price, quantity }) => ({ id, name, price, quantity }))
setCheckout('idle')
try {
const result: unknown = onAction(payload)
if (isThenable(result)) {
setCheckout('loading')
result.then(
() => {
if (alive.current) setCheckout('idle')
},
() => {
if (alive.current) setCheckout('error')
},
)
}
} catch {
setCheckout('error')
}
}
const onPanelKey = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === 'Escape') {
event.stopPropagation()
close()
return
}
if (!overlay || event.key !== 'Tab' || !panelRef.current) return
const nodes = Array.from(panelRef.current.querySelectorAll<HTMLElement>('a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'))
if (!nodes.length) return
const first = nodes[0]
const last = nodes[nodes.length - 1]
if (event.shiftKey && document.activeElement === first) {
event.preventDefault()
last.focus()
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault()
first.focus()
}
}
const undoRow = removed ? (
<div className='cd2-undo' role='status'>
<span>{fill(copy.removed, { name: removed.line.name })}</span>
<button type='button' className='cd2-undo-btn' aria-label={fill(copy.undoLabel, { name: removed.line.name })} onClick={undo}>
{copy.undo}
</button>
</div>
) : null
const label = fill(actionLabel, { total: subtotalText, count: String(count) })
const ctaContent = loading ? (
<>
<Loader2 className='cd2-spin' aria-hidden='true' />
<span>{loadingLabel}</span>
</>
) : (
<span>{label}</span>
)
const hidden = reduce ? { opacity: 0 } : overlay ? (sheet ? { y: '100%' } : { x: '100%' }) : { opacity: 0.82, y: 8 }
const gone = reduce ? { opacity: 0 } : overlay ? hidden : { opacity: 0, y: 8 }
const panel = (
<motion.div
key='panel'
ref={panelRef}
id={panelId}
className='cd2-panel'
data-overlay={overlay ? '' : undefined}
role={overlay ? 'dialog' : 'region'}
aria-modal={overlay ? true : undefined}
aria-labelledby={titleId}
onKeyDown={onPanelKey}
initial={hidden}
animate={{ opacity: 1, x: 0, y: 0 }}
exit={gone}
transition={{ duration: reduce ? 0.01 : 0.34, ease: EASE }}
>
<span className='cd2-grip' aria-hidden='true' />
<div className='cd2-head'>
<h2 className='cd2-title' id={titleId}>
{title}
</h2>
{!isEmpty ? <span className='cd2-count'>{countText}</span> : null}
<button ref={closeRef} type='button' className='cd2-close' aria-label={copy.closeCart} onClick={close}>
<X aria-hidden='true' />
</button>
</div>
<LayoutGroup id={'cd2-' + uid}>
<div className='cd2-body'>
{isEmpty ? (
<>
{undoRow}
<div className='cd2-empty'>
<Spot src={gift} size={96} />
<p className='cd2-empty-title'>{emptyTitle}</p>
<p className='cd2-empty-body'>{emptyBody}</p>
{emptyActionHref ? (
<a className='cd2-cta cd2-cta--fit' href={emptyActionHref}>
{emptyActionLabel}
</a>
) : (
<button type='button' className='cd2-cta cd2-cta--fit' onClick={continueShopping}>
{emptyActionLabel}
</button>
)}
</div>
</>
) : (
<>
<ul className='cd2-ledger'>
<AnimatePresence initial={false}>
{lines.map((line) => (
<LedgerRow
key={line.id}
line={line}
copy={copy}
symbol={symbol}
reduce={!animate}
flyId={flyId(line.id)}
limited={limitId === line.id}
onStep={(delta) => step(line.id, delta)}
onRemove={() => remove(line.id)}
/>
))}
</AnimatePresence>
</ul>
{undoRow}
</>
)}
<AnimatePresence initial={false}>
{showOffer && addOn ? (
<motion.section
key='offer'
className='cd2-bump'
aria-label={addOn.name}
initial={animate ? { opacity: 0.82, y: 8 } : false}
animate={{ opacity: 1, y: 0 }}
exit={animate ? { opacity: 0, y: 8, transition: { duration: 0.2 } } : { opacity: 0, transition: { duration: 0.01 } }}
transition={{ duration: 0.45, ease: EASE }}
>
<button type='button' className='cd2-bump-strip' onClick={addAddOn}>
<span className='cd2-box' aria-hidden='true'>
<Plus />
</span>
<span>{fill(copy.addOnHeadline, { name: addOn.name, price: addOn.price })}</span>
</button>
{addOn.image || addOn.detail ? (
<div className='cd2-bump-body' data-noimg={addOn.image ? undefined : ''}>
{addOn.image ? (
<motion.img layoutId={flyId(addOn.id)} className='cd2-bump-img' src={addOn.image} alt={addOn.imageAlt ?? addOn.name} width={72} height={72} loading='lazy' />
) : null}
{addOn.detail ? <p className='cd2-bump-copy'>{addOn.detail}</p> : null}
</div>
) : null}
</motion.section>
) : null}
</AnimatePresence>
</div>
</LayoutGroup>
{!isEmpty ? (
<div className='cd2-foot'>
{freeShipping ? (
<div className='cd2-ship'>
<p className='cd2-ship-note' data-done={unlocked ? '' : undefined}>
<Truck className='cd2-ico' aria-hidden='true' />
{unlocked ? copy.shippingUnlocked : fill(copy.shippingProgress, { remaining: money(remaining, symbol) })}
</p>
<div className='cd2-meter' aria-hidden='true'>
<motion.span className='cd2-meter-fill' initial={false} animate={{ scaleX: progress }} transition={{ duration: reduce ? 0 : 0.45, ease: EASE }} />
</div>
</div>
) : null}
{freeShipping ? (
<dl className='cd2-sums'>
<div className='cd2-sum'>
<dt>{copy.subtotal}</dt>
<dd>{subtotalText}</dd>
</div>
<div className='cd2-sum'>
<dt>{copy.shipping}</dt>
<dd data-free={unlocked ? '' : undefined}>{unlocked ? copy.shippingFree : copy.shippingLater}</dd>
</div>
</dl>
) : null}
<div className='cd2-total'>
<span className='cd2-total-label'>{copy.total}</span>
<span className='cd2-leader' aria-hidden='true' />
<span className='cd2-total-fig'>
<AnimatePresence initial={false} mode='popLayout'>
<motion.span
key={subtotalText}
className='cd2-fig'
initial={animate ? { y: '-55%', opacity: 0.4 } : false}
animate={{ y: 0, opacity: 1 }}
exit={animate ? { y: '55%', opacity: 0 } : { opacity: 0, transition: { duration: 0 } }}
transition={{ duration: 0.3, ease: EASE }}
>
{subtotalText}
</motion.span>
</AnimatePresence>
</span>
</div>
{savings > 0 ? <p className='cd2-savings'>{fill(copy.savings, { savings: money(savings, symbol) })}</p> : null}
{href && !onAction && !blocked ? (
<a className='cd2-cta' href={href} onClick={runCheckout}>
{ctaContent}
</a>
) : (
<button
type='button'
className='cd2-cta'
disabled={state === 'disabled'}
aria-busy={loading || undefined}
aria-disabled={loading || undefined}
onClick={runCheckout}
>
{ctaContent}
</button>
)}
{reassurance ? (
<p className='cd2-assure'>
{reassurance.split(' · ').map((part, i) => (
<React.Fragment key={i}>
{i > 0 ? ' · ' : null}
<span className='cd2-nobr'>
{i === 0 ? <Lock className='cd2-ico' aria-hidden='true' /> : null}
{part}
</span>
</React.Fragment>
))}
</p>
) : null}
{checkout === 'error' ? (
<p className='cd2-error' role='alert'>
<AlertCircle className='cd2-ico' aria-hidden='true' />
{errorMessage}
</p>
) : null}
</div>
) : null}
</motion.div>
)
return (
<div className={('cf-cart-drawer-2 ' + className).trim()} data-mode={mode} data-force={force}>
<style>{CSS}</style>
<button
ref={triggerRef}
type='button'
className='cd2-trigger'
aria-expanded={open}
aria-controls={panelId}
aria-label={fill(copy.openCart, countValues)}
onClick={() => (open ? close() : openNow())}
>
<ShoppingBag aria-hidden='true' />
<span>{triggerLabel}</span>
{count > 0 ? (
<motion.span key={count} className='cd2-badge' aria-hidden='true' initial={animate ? { scale: 0.9 } : false} animate={{ scale: 1 }} transition={{ duration: 0.3, ease: EASE }}>
{count}
</motion.span>
) : null}
</button>
<AnimatePresence initial={false}>
{open && overlay ? (
<motion.div key='scrim' className='cd2-scrim' aria-hidden='true' onClick={close} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: reduce ? 0.01 : 0.25 }} />
) : null}
{open ? panel : null}
</AnimatePresence>
<p className='cd2-sr' aria-live='polite'>
{announce}
</p>
</div>
)
}
export default CartDrawer2
type Line = CartDrawer2Item & { quantity: number }
type LedgerRowProps = {
line: Line
copy: CartDrawer2Copy
symbol: string
reduce: boolean
flyId?: string
limited: boolean
onStep: (delta: number) => void
onRemove: () => void
}
function LedgerRow({ line, copy, symbol, reduce, flyId, limited, onStep, onRemove }: LedgerRowProps) {
const unit = parseMoney(line.price)
const regular = line.regularPrice ? parseMoney(line.regularPrice) : 0
const max = line.maxQuantity ?? 10
const values = { name: line.name, price: line.price, max: String(max) }
return (
<motion.li
layout={reduce ? false : 'position'}
className='cd2-row'
data-noimg={line.image ? undefined : ''}
initial={reduce ? false : { opacity: 0.82, y: 8 }}
animate={{ opacity: 1, y: 0 }}
exit={reduce ? { opacity: 0, transition: { duration: 0.01 } } : { opacity: 0, x: 24, transition: { duration: 0.2, ease: EASE } }}
transition={{ duration: 0.45, ease: EASE }}
>
{line.image ? <motion.img layoutId={flyId} className='cd2-thumb' src={line.image} alt={line.imageAlt ?? line.name} width={64} height={64} loading='lazy' /> : null}
<div className='cd2-main'>
<div className='cd2-line'>
<p className='cd2-name'>{line.name}</p>
<span className='cd2-leader' aria-hidden='true' />
<span className='cd2-amount'>
{regular > unit ? (
<span className='cd2-was'>
<span className='cd2-sr'>{copy.regular} </span>
{money(round(regular * line.quantity), symbol)}
</span>
) : null}
<span className='cd2-now'>{money(round(unit * line.quantity), symbol)}</span>
</span>
</div>
{line.detail ? <p className='cd2-detail'>{line.detail}</p> : null}
<div className='cd2-controls'>
<div className='cd2-step' role='group' aria-label={fill(copy.quantity, values)}>
<button type='button' className='cd2-step-btn' aria-label={fill(copy.decrease, values)} disabled={line.quantity <= 1} onClick={() => onStep(-1)}>
<Minus aria-hidden='true' />
</button>
<span className='cd2-qty'>{line.quantity}</span>
<button type='button' className='cd2-step-btn' aria-label={fill(copy.increase, values)} data-max={line.quantity >= max ? '' : undefined} onClick={() => onStep(1)}>
<Plus aria-hidden='true' />
</button>
</div>
{line.quantity > 1 ? <span className='cd2-each'>{fill(copy.each, values)}</span> : null}
<button type='button' className='cd2-remove' aria-label={fill(copy.removeLabel, values)} onClick={onRemove}>
<Trash2 aria-hidden='true' />
{copy.remove}
</button>
</div>
{limited ? (
<p className='cd2-limit' role='status'>
{fill(copy.limit, values)}
</p>
) : null}
</div>
</motion.li>
)
}
const EASE: [number, number, number, number] = [0.2, 0.7, 0.2, 1]
const COPY: CartDrawer2Copy = {
count: '{count} {items}',
item: 'item',
items: 'items',
openCart: 'Open cart, {count} {items}',
closeCart: 'Close cart',
quantity: 'Quantity of {name}',
decrease: 'Remove one {name}',
increase: 'Add one {name}',
each: '{price} each',
limit: 'Limit {max} per order',
remove: 'Remove',
removeLabel: 'Remove {name} from your cart',
removed: '{name} removed.',
undo: 'Undo',
undoLabel: 'Put {name} back in your cart',
regular: 'Regular price',
addOnHeadline: 'Yes, add {name} for {price}',
addOnAdded: '{name} added. Total today {total}.',
quantityChanged: '{name}: quantity {quantity}. Total today {total}.',
subtotal: 'Subtotal',
shipping: 'Shipping',
shippingFree: 'Free',
shippingLater: 'At checkout',
shippingProgress: 'You’re {remaining} away from free shipping',
shippingUnlocked: 'Free shipping unlocked',
total: 'Total today',
savings: 'Includes {savings} in savings',
}
function mergeCopy(overrides?: Partial<CartDrawer2Copy>): CartDrawer2Copy {
const copy: CartDrawer2Copy = { ...COPY }
if (!overrides) return copy
for (const key of Object.keys(overrides) as (keyof CartDrawer2Copy)[]) {
const value = overrides[key]
if (value !== undefined) copy[key] = value
}
return copy
}
function fill(template: string, values: Record<string, string>) {
return template.replace(/\{([a-zA-Z]+)\}/g, (match, key: string) => values[key] ?? match)
}
function parseMoney(value: string) {
return Number(String(value).replace(/[^0-9.]/g, '')) || 0
}
function currencyOf(value: string) {
const match = value.trim().match(/^[^0-9.,-]+/)
return match ? match[0].trim() : '$'
}
function round(amount: number) {
return Math.round(amount * 100) / 100
}
function money(amount: number, symbol: string) {
const cents = !Number.isInteger(amount)
return symbol + amount.toLocaleString('en-US', { minimumFractionDigits: cents ? 2 : 0, maximumFractionDigits: 2 })
}
function sumOf(lines: Line[]) {
return round(lines.reduce((n, l) => n + parseMoney(l.price) * l.quantity, 0))
}
function toLine(item: CartDrawer2Item): Line {
return { ...item, quantity: Math.max(1, Math.round(item.quantity ?? 1)) }
}
function isThenable(value: unknown): value is PromiseLike<unknown> {
return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function'
}
const S = '.cf-cart-drawer-2'
const CSS = `
${S}{--cd2-ink:var(--ink, #1b2333);--cd2-line:oklch(from var(--ink, #1b2333) l c h / .14);--cd2-well:color-mix(in oklch, var(--ink, #1b2333) 4%, var(--card, #ffffff));--cd2-focus:oklch(from var(--field-focus, var(--accent, #2f5fd0)) l c h / .6);--cd2-bg:var(--button-bg, var(--cta, #d0342c));--cd2-bg-2:var(--button-bg-2, var(--cta-2, #b02a23));--cd2-l1:.04;--cd2-l2:-.02;--cd2-shadow:var(--shadow, oklch(.22 .03 260));position:relative;display:flex;flex-direction:column;align-items:flex-end;gap:12px;color:var(--cd2-ink);font-family:var(--font-body, system-ui, sans-serif);font-size:1.0625rem;line-height:1.5}
${S}[data-mode='overlay']{display:inline-flex}
${S}[data-mode='inline']{width:100%;max-width:440px;margin-inline:auto;align-items:center}
${S}[data-mode='inline'] .cd2-panel{align-self:stretch}
${S},${S} *,${S} *::before,${S} *::after{box-sizing:border-box}
${S} :where(p,h2,ul,dl,dd){margin:0}
${S} ul{list-style:none;padding:0}
${S} button{font:inherit;-webkit-tap-highlight-color:transparent}
${S} svg{stroke-width:2.5;flex:none}
${S} :where(a,button):focus-visible{outline:3px solid var(--cd2-focus);outline-offset:2px}
${S} .cd2-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
${S} .cd2-ico{display:inline-block;width:16px;height:16px;vertical-align:-.15em;margin-inline-end:.4em}
${S} .cd2-trigger{display:inline-flex;align-items:center;gap:8px;min-height:48px;padding:0 14px 0 16px;border:1px solid var(--button-2-border, transparent);border-radius:var(--button-radius, var(--radius, 12px));background:var(--button-2-bg, var(--secondary, #e9ecf3));color:var(--button-2-ink, var(--secondary-ink, #1b2333));box-shadow:var(--button-2-shadow, var(--shadow-sm, 0 1px 2px oklch(.22 .03 260 / .2)));font-family:var(--button-font, var(--font-display, inherit));font-weight:var(--button-weight, 800);text-transform:var(--button-case, none);font-size:1.0625rem;line-height:1;cursor:pointer;transition:background .16s ease,transform .16s ease}
${S} .cd2-trigger:hover{background:oklch(from var(--button-2-bg, var(--secondary, #e9ecf3)) calc(l - .04) c h)}
${S} .cd2-trigger:active{transform:translateY(1px)}
${S} .cd2-trigger svg{width:20px;height:20px}
${S} .cd2-badge{display:inline-flex;align-items:center;justify-content:center;min-width:28px;height:28px;padding:0 8px;border-radius:999px;background:var(--accent-fill, var(--accent, #2f5fd0));color:var(--accent-fill-ink, var(--card, #ffffff));font-family:var(--font-body, inherit);font-size:.875rem;font-weight:800;font-variant-numeric:tabular-nums}
${S} .cd2-scrim{position:fixed;inset:0;z-index:1000;background:oklch(from var(--band, #1d2b4a) l c h / .6)}
${S} .cd2-panel{position:relative;display:flex;flex-direction:column;width:100%;overflow:hidden;background:var(--card, #ffffff);color:var(--cd2-ink);border:1px solid var(--card-border, oklch(from var(--ink, #1b2333) l c h / .12));border-radius:var(--card-radius, var(--radius, 14px));box-shadow:var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(.22 .03 260 / .22), 0 12px 24px -8px oklch(.22 .03 260 / .32)))}
${S} .cd2-panel[data-overlay]{position:fixed;z-index:1001;top:0;right:0;bottom:0;width:min(440px, 100vw);max-height:100dvh;border-right:0;border-radius:var(--card-radius, var(--radius, 14px)) 0 0 var(--card-radius, var(--radius, 14px));box-shadow:var(--shadow-lg, 0 2px 4px oklch(.22 .03 260 / .22), 0 12px 24px -8px oklch(.22 .03 260 / .32))}
${S} .cd2-grip{display:none}
${S} .cd2-head{display:flex;align-items:center;gap:12px;padding:20px 16px 12px 24px}
${S} .cd2-title{flex:1 1 auto;min-width:0;font-family:var(--font-display, inherit);font-size:clamp(1.3125rem, 1.8vw, 1.625rem);font-weight:var(--display-weight, 800);text-transform:var(--display-case, none);letter-spacing:var(--display-tracking, -.01em);line-height:1.15;text-wrap:balance;color:var(--cd2-ink)}
${S} .cd2-title mark{color:inherit;background:linear-gradient(to bottom, transparent 54%, oklch(from var(--marker, #fae37c) l c h / .8) 54%, oklch(from var(--marker, #fae37c) l c h / .8) 94%, transparent 94%);padding:0 .14em;margin:0 -.04em;border-radius:.12em .3em .18em .3em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
${S} .cd2-count{flex:none;display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;background:color-mix(in oklch, var(--ink, #1b2333) 6%, var(--card, #ffffff));color:var(--cd2-ink);font-size:.875rem;font-weight:800;line-height:1.2;white-space:nowrap;font-variant-numeric:tabular-nums}
${S} .cd2-close{flex:none;display:inline-grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--cd2-ink);cursor:pointer;transition:background .16s ease}
${S} .cd2-close:hover{background:color-mix(in oklch, var(--ink, #1b2333) 7%, var(--card, #ffffff))}
${S} .cd2-close svg{width:20px;height:20px}
${S} .cd2-body{flex:1 1 auto;min-height:0;padding:0 24px 24px}
${S} .cd2-panel[data-overlay] .cd2-body{overflow-y:auto;overscroll-behavior:contain}
${S} .cd2-ledger{display:grid}
${S} .cd2-row{display:grid;grid-template-columns:64px minmax(0,1fr);gap:16px;align-items:start;padding:16px 0;background:var(--card, #ffffff)}
${S} .cd2-row + .cd2-row{border-top:1px solid var(--cd2-line)}
${S} .cd2-row[data-noimg]{grid-template-columns:minmax(0,1fr)}
${S} .cd2-main{min-width:0}
${S} .cd2-thumb{display:block;width:64px;height:64px;border-radius:8px;object-fit:cover;object-position:center}
${S} .cd2-line{display:flex;align-items:baseline;align-items:last baseline;gap:8px}
${S} .cd2-name{flex:0 1 auto;min-width:0;font-weight:800;font-size:1.0625rem;line-height:1.3;color:var(--cd2-ink);text-wrap:pretty;overflow-wrap:anywhere}
${S} .cd2-leader{flex:1 1 16px;min-width:16px;height:1px;background:var(--cd2-line);transform:translateY(-.25em)}
${S} .cd2-amount{flex:none;display:inline-flex;align-items:baseline;gap:8px;white-space:nowrap;font-variant-numeric:tabular-nums}
${S} .cd2-now{display:inline-block;padding:3px 12px;border-radius:8px;background:color-mix(in oklch, var(--ink, #1b2333) 6%, var(--card, #ffffff));font-family:var(--font-display, inherit);font-weight:800;font-size:1.125rem;line-height:1.3;letter-spacing:-.01em;color:var(--cd2-ink)}
${S} .cd2-was{position:relative;padding-inline:2px;font-size:.9375rem;font-weight:600;color:var(--muted, #4a5468)}
${S} .cd2-was::after{content:'';position:absolute;left:0;right:0;top:50%;height:2px;border-radius:2px;background:var(--danger, #c0392b);transform:translateY(-50%) rotate(-8deg);pointer-events:none}
${S} .cd2-detail{margin-top:4px;font-size:.9375rem;line-height:1.4;color:var(--muted, #4a5468);text-wrap:pretty}
${S} .cd2-controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin-top:12px}
${S} .cd2-step{display:inline-flex;align-items:center;height:44px;border-radius:999px;background:var(--cd2-well);border:1px solid var(--cd2-line)}
${S} .cd2-step-btn{display:inline-grid;place-items:center;width:42px;height:42px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--cd2-ink);cursor:pointer;transition:background .16s ease}
${S} .cd2-step-btn:hover:not(:disabled){background:color-mix(in oklch, var(--ink, #1b2333) 9%, var(--card, #ffffff))}
${S} .cd2-step-btn:active:not(:disabled){background:color-mix(in oklch, var(--ink, #1b2333) 14%, var(--card, #ffffff))}
${S} .cd2-step-btn:disabled,${S} .cd2-step-btn[data-max]{color:oklch(from var(--ink, #1b2333) l c h / .38);cursor:not-allowed}
${S} .cd2-step-btn svg{width:18px;height:18px}
${S} .cd2-qty{min-width:28px;text-align:center;font-weight:800;font-size:1.0625rem;font-variant-numeric:tabular-nums}
${S} .cd2-each{font-size:.9375rem;color:var(--muted, #4a5468)}
${S} .cd2-remove{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin-inline-start:auto;padding:0 4px;border:0;background:none;color:var(--muted, #4a5468);font-size:.9375rem;font-weight:600;text-decoration:underline;text-decoration-color:oklch(from var(--muted, #4a5468) l c h / .45);text-underline-offset:.18em;cursor:pointer;transition:color .16s ease}
${S} .cd2-remove:hover{color:var(--danger, #c0392b);text-decoration-color:currentColor}
${S} .cd2-remove svg{width:16px;height:16px}
${S} .cd2-limit{margin-top:4px;font-size:.9375rem;font-weight:700;color:var(--warning, #8a6400)}
${S} .cd2-undo{display:flex;flex-wrap:wrap;align-items:center;gap:0 12px;margin-top:8px;padding:4px 8px 4px 16px;border-radius:10px;background:var(--cd2-well);font-size:.9375rem;color:var(--cd2-ink)}
${S} .cd2-undo-btn{min-height:44px;padding:0 8px;border:0;background:none;color:var(--link, var(--accent, #2f5fd0));font-weight:800;text-decoration:underline;text-decoration-color:oklch(from var(--link, var(--accent, #2f5fd0)) l c h / .45);text-underline-offset:.18em;cursor:pointer}
${S} .cd2-undo-btn:hover{color:oklch(from var(--link, var(--accent, #2f5fd0)) calc(l - .08) c h);text-decoration-color:currentColor}
${S} .cd2-bump{margin-top:16px;overflow:hidden;border-radius:12px;background:var(--bump, oklch(.975 .04 95));color:var(--bump-ink, #1b2333);border:1px solid oklch(from var(--bump-ink, #1b2333) l c h / .16)}
${S} .cd2-bump-strip{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:12px 16px;border:0;background:var(--bump-strip, oklch(.93 .11 95));color:var(--bump-ink, #1b2333);font-size:1.0625rem;font-weight:var(--button-weight, 800);line-height:1.3;text-align:left;text-wrap:pretty;cursor:pointer;transition:background .16s ease}
${S} .cd2-bump-strip:hover{background:oklch(from var(--bump-strip, oklch(.93 .11 95)) calc(l - .04) c h)}
${S} .cd2-bump-strip:active{background:oklch(from var(--bump-strip, oklch(.93 .11 95)) calc(l - .08) c h)}
${S} .cd2-bump-strip:focus-visible{outline-offset:-3px}
${S} .cd2-box{display:inline-grid;place-items:center;flex:none;width:28px;height:28px;border-radius:8px;border:2px solid var(--bump-ink, #1b2333);background:var(--bump, oklch(.975 .04 95));color:var(--bump-ink, #1b2333);transition:transform .16s ease}
${S} .cd2-bump-strip:hover .cd2-box{transform:scale(1.06)}
${S} .cd2-box svg{width:16px;height:16px;stroke-width:3}
${S} .cd2-bump-body{display:grid;grid-template-columns:72px minmax(0,1fr);gap:16px;align-items:start;padding:16px}
${S} .cd2-bump-body[data-noimg]{grid-template-columns:minmax(0,1fr)}
${S} .cd2-bump-img{display:block;width:72px;height:72px;border-radius:8px;object-fit:cover}
${S} .cd2-bump-copy{font-size:1rem;line-height:1.45;text-wrap:pretty}
${S} .cd2-bump-copy strong{font-weight:800}
${S} .cd2-foot{padding:20px 24px 24px;background:var(--cd2-well)}
${S} .cd2-panel[data-overlay] .cd2-foot{padding-bottom:calc(24px + env(safe-area-inset-bottom, 0px))}
${S} .cd2-ship{margin-bottom:16px}
${S} .cd2-ship-note{font-size:.9375rem;font-weight:700;line-height:1.4;color:var(--cd2-ink);text-wrap:pretty}
${S} .cd2-ship-note[data-done]{color:var(--success, #1e7a3c)}
${S} .cd2-meter{height:8px;margin-top:8px;border-radius:999px;background:color-mix(in oklch, var(--ink, #1b2333) 10%, var(--card, #ffffff));overflow:hidden}
${S} .cd2-meter-fill{display:block;height:100%;border-radius:inherit;background:var(--accent-fill, var(--accent, #2f5fd0));transform-origin:left center}
${S} .cd2-sums{display:grid;gap:8px;margin-bottom:16px}
${S} .cd2-sum{display:flex;align-items:baseline;gap:8px;font-size:1rem}
${S} .cd2-sum dt{flex:1 1 auto;display:flex;align-items:baseline;gap:8px;color:var(--muted, #4a5468);font-weight:600}
${S} .cd2-sum dt::after{content:'';flex:1 1 16px;min-width:16px;height:1px;background:var(--cd2-line);transform:translateY(-.25em)}
${S} .cd2-sum dd{font-weight:800;font-variant-numeric:tabular-nums;color:var(--cd2-ink)}
${S} .cd2-sum dd[data-free]{color:var(--success, #1e7a3c)}
${S} .cd2-total{display:flex;align-items:baseline;gap:12px}
${S} .cd2-total-label{flex:none;font-weight:800;font-size:1.0625rem;color:var(--cd2-ink)}
${S} .cd2-total .cd2-leader{transform:translateY(-.3em)}
${S} .cd2-total-fig{position:relative;flex:none;display:inline-block;padding:.08em 0;clip-path:inset(0);font-family:var(--font-display, inherit);font-size:clamp(2.5rem, 4.2vw, 3rem);font-weight:var(--display-weight, 800);line-height:1;letter-spacing:-.03em;font-variant-numeric:tabular-nums;color:var(--cd2-ink)}
${S} .cd2-fig{display:inline-block}
${S} .cd2-savings{margin-top:8px;text-align:right;font-size:.9375rem;font-weight:700;color:var(--success, #1e7a3c)}
${S} .cd2-cta{display:flex;width:100%;align-items:center;justify-content:center;gap:10px;min-height:64px;margin-top:24px;padding:12px 24px;border:0;border-radius:var(--button-radius, var(--radius, 12px));background:linear-gradient(oklch(from var(--cd2-bg) calc(l + var(--cd2-l1)) c h), oklch(from var(--cd2-bg-2) calc(l + var(--cd2-l2)) c h));color:var(--button-ink, var(--cta-ink, #ffffff));font-family:var(--button-font, var(--font-display, inherit));font-weight:var(--button-weight, 800);font-size:clamp(1.125rem, 1.55vw, 1.25rem);line-height:1.15;letter-spacing:-.005em;text-transform:var(--button-case, none);text-align:center;text-decoration:none;text-wrap:balance;text-shadow:var(--button-text-shadow, none);cursor:pointer;box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--cd2-bg) calc(l + .14) c h / .7), inset 0 -3px 0 oklch(from var(--cd2-bg) calc(l - .16) c h), 0 1px 2px oklch(from var(--cd2-shadow) l c h / .3), 0 8px 16px -6px oklch(from var(--cd2-shadow) l c h / .45));transition:background .16s ease,box-shadow .16s ease,transform .16s ease}
${S} .cd2-cta:hover:not(:disabled),${S}[data-force='hover'] .cd2-cta:not(:disabled){--cd2-l1:-.01;--cd2-l2:-.07;transform:translateY(-1px);box-shadow:inset 0 1px 0 oklch(from var(--cd2-bg) calc(l + .12) c h / .6), inset 0 -3px 0 oklch(from var(--cd2-bg) calc(l - .2) c h), 0 1px 2px oklch(from var(--cd2-shadow) l c h / .34), 0 10px 18px -6px oklch(from var(--cd2-shadow) l c h / .55)}
${S} .cd2-cta:active:not(:disabled),${S}[data-force='active'] .cd2-cta:not(:disabled){--cd2-l1:-.04;--cd2-l2:-.1;transform:translateY(1px);box-shadow:inset 0 2px 4px oklch(from var(--cd2-bg) calc(l - .22) c h / .55), inset 0 -2px 0 oklch(from var(--cd2-bg) calc(l - .16) c h), 0 1px 1px oklch(from var(--cd2-shadow) l c h / .3)}
${S} .cd2-cta:disabled{background:var(--button-2-bg, var(--secondary, #e9ecf3));color:var(--button-2-ink, var(--secondary-ink, #1b2333));text-shadow:none;box-shadow:var(--button-2-shadow, var(--shadow-sm, 0 1px 2px oklch(.22 .03 260 / .2)));cursor:not-allowed;transform:none}
${S} .cd2-cta[aria-busy='true']{cursor:progress}
${S} .cd2-cta svg{width:20px;height:20px}
${S} .cd2-cta--fit{width:auto;min-height:56px;margin-top:24px;padding:12px 28px}
${S} .cd2-spin{animation:cd2-spin .8s linear infinite}
@keyframes cd2-spin{to{transform:rotate(360deg)}}
${S} .cd2-assure{margin-top:12px;text-align:center;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted, #4a5468);text-wrap:pretty}
${S} .cd2-nobr{white-space:nowrap}
${S} .cd2-error{margin-top:12px;padding:12px 16px;border-radius:10px;background:var(--danger-soft, oklch(.93 .024 27));color:var(--danger, #c0392b);font-size:.9375rem;font-weight:700;line-height:1.4;text-wrap:pretty}
${S} .cd2-empty{display:flex;flex-direction:column;align-items:center;text-align:center;padding:16px 8px 8px}
${S} .cd2-empty-title{margin-top:16px;font-family:var(--font-display, inherit);font-size:clamp(1.3125rem, 1.8vw, 1.625rem);font-weight:var(--display-weight, 800);text-transform:var(--display-case, none);line-height:1.15;letter-spacing:var(--display-tracking, -.01em);text-wrap:balance;color:var(--cd2-ink)}
${S} .cd2-empty-body{margin-top:8px;max-width:34ch;font-size:1.0625rem;line-height:1.5;color:var(--muted, #4a5468);text-wrap:pretty}
@media (max-width:520px){
${S} .cd2-head{padding:16px 12px 8px 20px}
${S} .cd2-body{padding:0 20px 20px}
${S} .cd2-foot{padding:16px 20px 20px}
${S} .cd2-row{grid-template-columns:56px minmax(0,1fr);gap:12px}
${S} .cd2-line .cd2-leader{min-width:8px;flex-basis:8px}
${S} .cd2-now{padding:2px 10px}
${S} .cd2-thumb{width:56px;height:56px}
${S} .cd2-bump-body{grid-template-columns:60px minmax(0,1fr);gap:12px;padding:12px 16px 16px}
${S} .cd2-bump-img{width:60px;height:60px}
${S} .cd2-panel[data-overlay]{top:auto;left:0;width:100%;max-height:92dvh;border-right:1px solid var(--card-border, oklch(from var(--ink, #1b2333) l c h / .12));border-bottom:0;border-radius:var(--card-radius, var(--radius, 14px)) var(--card-radius, var(--radius, 14px)) 0 0}
${S} .cd2-panel[data-overlay] .cd2-grip{display:block;width:40px;height:4px;margin:8px auto 0;border-radius:999px;background:oklch(from var(--ink, #1b2333) l c h / .22)}
}
@media (prefers-reduced-motion:reduce){
${S} *,${S} *::before,${S} *::after{transition-duration:.01ms !important}
${S} .cd2-cta:hover:not(:disabled),${S} .cd2-cta:active:not(:disabled),${S} .cd2-trigger:active,${S} .cd2-bump-strip:hover .cd2-box{transform:none}
${S} .cd2-spin{animation-duration:2.4s}
}
`
pieces/checkout/cart-drawer-2/specimen.tsx 72 lines
import __studioImage0e02d62b from "../assets/af1f904e8b0281a1.webp";
// Specimen: the ledger cart drawer opened in place under its cart trigger, with the Funnel Starter Kit, a second workbook and a one-tap checklist add-on.
import * as React from 'react'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
import { CartDrawer2, type CartDrawer2State } from '../cart-drawer-2'
export const states = ['default', 'empty', 'hover', 'active', 'disabled', 'error']
export default function CartDrawer2Specimen({ state = 'default' }: { state?: CartDrawer2State | 'empty' }) {
const sample = defaults.sample
const workbook = sample.items[1]
const checklist = sample.items[2]
const items =
state === 'empty'
? []
: [
{
id: 'funnel-starter-kit',
name: sample.name,
price: sample.price,
regularPrice: sample.regularPrice,
detail: 'Guide, workbook and checklist together',
image: slot('item-1', __studioImage0e02d62b),
imageAlt: 'The Funnel Starter Kit: planning guide, copy workbook and launch checklist',
},
{
id: 'page-copy-workbook',
name: workbook.name,
price: workbook.value,
detail: 'A second copy for your next funnel',
image: slot('item-2', workbook.image),
imageAlt: workbook.imageAlt,
},
]
return (
<CartDrawer2
key={state}
mode='inline'
defaultOpen
items={items}
addOn={{
id: 'launch-checklist',
name: checklist.name,
price: checklist.value,
detail: (
<>
<strong>Launching more than once?</strong> Keep a spare checklist and run every launch through the same review.
</>
),
lineDetail: 'Spare copy for launch day',
image: slot('item-3', checklist.image),
imageAlt: checklist.imageAlt,
}}
title={
<>
Your order, <mark>ready to send</mark>
</>
}
actionLabel='Send Me My Kit · {total}'
reassurance={'Secure checkout · ' + sample.guarantee}
state={state === 'empty' ? 'default' : state}
onAction={() =>
new Promise<void>((resolve) => {
window.setTimeout(resolve, 1400)
})
}
/>
)
}
| Name | Type | Details |
|---|---|---|
items OptionalCartDrawer2 |
CartDrawer2Item[] |
|
addOn OptionalCartDrawer2 |
CartDrawer2AddOn | null |
|
title OptionalCartDrawer2 |
React.ReactNode |
|
triggerLabel OptionalCartDrawer2 |
string |
|
actionLabel OptionalCartDrawer2 |
string |
|
loadingLabel OptionalCartDrawer2 |
string |
|
reassurance OptionalCartDrawer2 |
string |
|
errorMessage OptionalCartDrawer2 |
string |
|
emptyTitle OptionalCartDrawer2 |
string |
|
emptyBody OptionalCartDrawer2 |
string |
|
emptyActionLabel OptionalCartDrawer2 |
string |
|
emptyActionHref OptionalCartDrawer2 |
string |
|
onContinue OptionalCartDrawer2 |
() => void |
|
freeShipping OptionalCartDrawer2 |
{ threshold: string } | null |
|
href OptionalCartDrawer2 |
string |
|
onAction OptionalCartDrawer2 |
(lines: CartDrawer2Line[]) => void | Promise<void> |
|
mode OptionalCartDrawer2 |
'overlay' | 'inline' |
|
defaultOpen OptionalCartDrawer2 |
boolean |
|
copy OptionalCartDrawer2 |
Partial<CartDrawer2Copy> |
|
state OptionalCartDrawer2 |
CartDrawer2State |
|
className OptionalCartDrawer2 |
string |
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-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-3- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
63571cb07acc4626.webp
image/webp · 17.3 KB
-
af1f904e8b0281a1.webp
image/webp · 67.3 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB