Cart Closing 1
Counts down to the real cart close and puts the offer and the buy button in front of the visitor before it shuts.
Use it in a prompt
Use urgency/cart-closing 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/urgency/cart-closing.tsx. - Import it and pass your copy and images (Props tab):
import { CartClosing } from "@/components/funneldna/urgency/cart-closing"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/urgency/cart-closing/component.tsx 381 lines
// Counts down to the real cart close and puts the offer and the buy button in front of the visitor before it shuts.
// layout: fact-scoreboard
// Cart-close scoreboard: a live split-flap countdown to the real close, the kit and launch price that close with the cart, and the buy button as the final tile.
import * as React from 'react'
import { Lock, LockKeyhole, ShieldCheck } from 'lucide-react'
export type CartClosingItem = {
name: string
/** Product image src (slot item-n). */
image?: string
imageAlt?: string
/** Supplied value, e.g. '$49'. */
value?: string
}
export type CartClosingUnits = { days: string; hours: string; minutes: string; seconds: string }
export type CartClosingProps = {
/** The real moment the cart closes (ISO string, epoch ms or Date). Without a deadline no countdown renders. */
deadline?: string | number | Date
/** Force the closed (terminal) view. It also shows automatically once the deadline passes. */
closed?: boolean
headline?: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
/** Lead line; {price} is replaced with the price. */
lead?: string
timerLabel?: string
closedTimerLabel?: string
units?: CartClosingUnits
/** Unit labels used on narrow widths. */
shortUnits?: CartClosingUnits
/** Screen-reader countdown; {days} {hours} {minutes} {seconds} are replaced. */
timerAriaLabel?: string
lossHeading?: string
items?: CartClosingItem[]
/** {value} is replaced with the item value. */
valueLabel?: string
itemTag?: string
closedItemTag?: string
todayLabel?: string
price?: string
regularPrice?: string
/** Screen-reader prefix for the struck price. */
regularPriceLabel?: string
/** Screen-reader prefix for the price today. */
priceLabel?: string
/** {amount} is replaced with the computed saving. */
savingsLabel?: string
priceNote?: string
label?: string
reassurance?: string[]
closedHeadline?: string
closedLead?: string
closedLabel?: string
href?: string
onAction?: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void
state?: 'default' | 'hover' | 'active' | 'disabled'
className?: string
}
const UNIT_KEYS = ['days', 'hours', 'minutes', 'seconds'] as const
const DEFAULT_ITEMS: CartClosingItem[] = [
{ name: 'Funnel Planning Guide', value: '$49' },
{ name: 'Page Copy Workbook', value: '$29' },
{ name: 'Launch Checklist', value: '$19' },
]
export function CartClosing(props: CartClosingProps) {
const {
deadline,
closed = false,
headline = 'Doors close Friday at midnight',
highlight = 'Friday at midnight',
lead = 'Lock in the complete kit at {price} before the cart closes.',
timerLabel = 'Offer closes in',
closedTimerLabel = 'The offer has closed',
units = { days: 'Days', hours: 'Hours', minutes: 'Minutes', seconds: 'Seconds' },
shortUnits = { days: 'Days', hours: 'Hrs', minutes: 'Min', seconds: 'Sec' },
timerAriaLabel = '{days} days, {hours} hours, {minutes} minutes and {seconds} seconds left',
lossHeading = 'Miss Friday and you lose all of this',
items = DEFAULT_ITEMS,
valueLabel = '{value} value',
itemTag = 'Closes Friday',
closedItemTag = 'Closed',
todayLabel = 'Get the complete kit for',
price = '$47',
regularPrice = '$97',
regularPriceLabel = 'Regular price',
priceLabel = 'Price today',
savingsLabel = 'Save {amount}',
priceNote = 'One payment',
label = 'Yes! Give Me Instant Access',
reassurance = ['30-day money-back guarantee'],
closedHeadline = 'The doors are closed',
closedLead = 'This offer is no longer available.',
closedLabel = 'Doors are closed',
href,
onAction,
state = 'default',
className,
} = props
const titleId = React.useId()
const target = toMs(deadline)
const now = useNow(target)
const remaining = target == null ? null : Math.max(0, target - now)
const isClosed = closed || remaining === 0
const total = isClosed || remaining == null ? 0 : Math.floor(remaining / 1000)
const parts = {
days: Math.floor(total / 86400),
hours: Math.floor((total % 86400) / 3600),
minutes: Math.floor((total % 3600) / 60),
seconds: total % 60,
}
const timerAria = fill(timerAriaLabel, {
days: String(parts.days),
hours: String(parts.hours),
minutes: String(parts.minutes),
seconds: String(parts.seconds),
})
const saving = savings(regularPrice, price, savingsLabel)
const disabled = isClosed || state === 'disabled'
const btnClass = ['cf-cc-btn', state === 'hover' ? 'is-hover' : '', state === 'active' ? 'is-active' : ''].filter(Boolean).join(' ')
const cols = Math.min(Math.max(items.length, 1), 3)
const rootClass = ['cf-cart-closing', isClosed ? 'cf-cc-closed' : '', className ?? ''].filter(Boolean).join(' ')
const buttonText = <span>{isClosed ? closedLabel : label}</span>
return (
<div className={rootClass} aria-labelledby={titleId}>
<style>{STYLES}</style>
<div className='cf-cc-head'>
<h2 className='cf-cc-title' id={titleId}>
{isClosed ? closedHeadline : withMarker(headline, highlight)}
</h2>
<p className='cf-cc-lead'>{isClosed ? closedLead : fill(lead, { price })}</p>
</div>
{target != null ? (
<div className='cf-cc-timer-wrap'>
<p className='cf-cc-timer-label'>
<span className='cf-cc-dot' aria-hidden='true' />
{isClosed ? closedTimerLabel : timerLabel}
</p>
<div className='cf-cc-timer' role='timer' aria-live='off' aria-label={timerAria}>
{UNIT_KEYS.map((key, index) => {
const value = parts[key]
const flips = key !== 'seconds'
return (
<div className='cf-cc-unit cf-cc-tile' key={key} style={{ '--i': index } as React.CSSProperties} aria-hidden='true'>
<div className='cf-cc-flap'>
<span key={flips ? key + '-' + value : key} className={flips ? 'cf-cc-digit is-flip' : 'cf-cc-digit'}>
{pad(value)}
</span>
</div>
<span className='cf-cc-unit-label'>
<span className='cf-cc-long'>{units[key]}</span>
<span className='cf-cc-short'>{shortUnits[key]}</span>
</span>
</div>
)
})}
</div>
</div>
) : null}
{items.length ? (
<>
<h3 className='cf-cc-loss'>{lossHeading}</h3>
<ul className='cf-cc-items' style={{ '--cf-cc-cols': cols } as React.CSSProperties}>
{items.map((item, index) => (
<li
key={item.name + index}
className={item.image ? 'cf-cc-item cf-cc-tile has-img' : 'cf-cc-item cf-cc-tile'}
style={{ '--i': index + 4 } as React.CSSProperties}
>
{item.image ? (
<img className='cf-cc-img' src={item.image} alt={item.imageAlt ?? item.name} loading='lazy' decoding='async' />
) : null}
<div className='cf-cc-item-body'>
<p className='cf-cc-item-name'>{item.name}</p>
<div className='cf-cc-meta'>
{item.value ? <span className='cf-cc-value'>{fill(valueLabel, { value: item.value })}</span> : null}
<span className={isClosed ? 'cf-cc-chip is-shut' : 'cf-cc-chip'}>
<LockKeyhole aria-hidden='true' size={14} strokeWidth={2.4} />
{isClosed ? closedItemTag : itemTag}
</span>
</div>
</div>
</li>
))}
</ul>
</>
) : null}
<div className='cf-cc-close cf-cc-tile' style={{ '--i': 7 } as React.CSSProperties}>
<div className='cf-cc-price'>
<p className='cf-cc-today'>{todayLabel}</p>
<p className='cf-cc-pricerow'>
{regularPrice ? (
<s className='cf-cc-was'>
<span className='cf-cc-sr'>{regularPriceLabel} </span>
{regularPrice}
</s>
) : null}
<span className='cf-cc-now'>
<span className='cf-cc-sr'>{priceLabel} </span>
{price}
</span>
</p>
{saving || priceNote ? (
<p className='cf-cc-save'>
{saving ? <span className='cf-cc-save-chip'>{saving}</span> : null}
{priceNote ? <span className='cf-cc-note'>{priceNote}</span> : null}
</p>
) : null}
</div>
<div className='cf-cc-action'>
{href && !disabled ? (
<a className={btnClass} href={href} onClick={onAction}>
{buttonText}
</a>
) : (
<button type='button' className={btnClass} disabled={disabled} onClick={onAction}>
{buttonText}
</button>
)}
{reassurance.length ? (
<ul className='cf-cc-assure'>
{reassurance.map((line, index) => (
<li key={line}>
{index === 0 ? (
<Lock aria-hidden='true' size={15} strokeWidth={2.4} />
) : (
<ShieldCheck aria-hidden='true' size={16} strokeWidth={2.4} />
)}
{line}
</li>
))}
</ul>
) : null}
</div>
</div>
</div>
)
}
export default CartClosing
function useNow(target: number | null) {
const [now, setNow] = React.useState(() => Date.now())
React.useEffect(() => {
if (target == null) return
setNow(Date.now())
if (Date.now() >= target) return
const id = window.setInterval(() => {
const t = Date.now()
setNow(t)
if (t >= target) window.clearInterval(id)
}, 1000)
return () => window.clearInterval(id)
}, [target])
return now
}
function toMs(value: string | number | Date | undefined): number | null {
if (value == null) return null
const ms = value instanceof Date ? value.getTime() : typeof value === 'number' ? value : Date.parse(value)
return Number.isFinite(ms) ? ms : null
}
function pad(value: number) {
return String(value).padStart(2, '0')
}
function fill(text: string, values: Record<string, string>) {
return Object.keys(values).reduce((out, key) => out.split('{' + key + '}').join(values[key]), text)
}
function withMarker(text: string, phrase?: string): React.ReactNode {
const at = phrase ? text.indexOf(phrase) : -1
if (!phrase || at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='cf-cc-mark'>{phrase}</span>
{text.slice(at + phrase.length)}
</>
)
}
function savings(regular: string | undefined, price: string | undefined, template: string) {
if (!regular || !price) return null
const num = (s: string) => parseFloat(s.replace(/[^0-9.]/g, ''))
const r = num(regular)
const p = num(price)
if (!Number.isFinite(r) || !Number.isFinite(p) || r <= p) return null
const prefix = (price.match(/^[^0-9]*/)?.[0] ?? '').trim()
const diff = r - p
const amount = Number.isInteger(diff) ? diff.toLocaleString('en-US') : diff.toFixed(2)
return fill(template, { amount: prefix + amount })
}
const STYLES = `
.cf-cart-closing{--cf-cc-radius:var(--card-radius,var(--radius,.75rem));--cf-cc-marker:var(--marker,#fae37c);--cf-cc-shadow:var(--shadow,oklch(0.22 0.03 260));container-type:inline-size;box-sizing:border-box;width:100%;max-width:72rem;margin-inline:auto;color:var(--ink);font-family:var(--font-body)}
.cf-cart-closing *,.cf-cart-closing *::before,.cf-cart-closing *::after{box-sizing:border-box}
.cf-cc-head{text-align:center}
.cf-cc-title{margin:0 0 clamp(.75rem,1.6cqi,1.25rem);font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,-0.025em);font-size:clamp(2.125rem,6.2cqi,4.25rem);line-height:1.04;text-wrap:balance;color:var(--ink)}
.cf-cc-mark{background-image:linear-gradient(176deg,transparent 0 52%,color-mix(in oklch,var(--cf-cc-marker) 82%,transparent) 52% 91%,transparent 91%);-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:0 .08em;border-radius:.18em .5em .3em .22em}
.cf-cc-lead{margin:0 auto;max-width:56ch;font-size:clamp(1.0625rem,1.8cqi,1.3125rem);font-weight:500;line-height:1.5;color:var(--muted);text-wrap:pretty}
.cf-cc-timer-wrap{margin-top:clamp(1.5rem,3.5cqi,2.5rem)}
.cf-cc-timer-label{display:flex;align-items:center;justify-content:center;gap:.625rem;margin:0 0 .875rem;font-family:var(--font-display);font-weight:800;font-size:clamp(1.0625rem,1.8cqi,1.25rem);line-height:1.3;color:var(--ink)}
.cf-cc-dot{position:relative;flex:none;width:.625rem;height:.625rem;border-radius:50%;background:var(--warning)}
.cf-cc-dot::after{content:'';position:absolute;inset:-4px;border-radius:50%;border:2px solid var(--warning);opacity:0}
.cf-cc-closed .cf-cc-dot,.cf-cc-closed .cf-cc-dot::after{background:var(--danger);border-color:var(--danger)}
.cf-cc-timer{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:clamp(.5rem,1.6cqi,1rem);max-width:52rem;margin:0 auto}
.cf-cc-unit{display:flex;flex-direction:column;align-items:center;min-width:0}
.cf-cc-flap{position:relative;display:grid;place-items:center;width:100%;padding:clamp(.875rem,2.4cqi,1.5rem) .25rem;border-radius:var(--cf-cc-radius);background:linear-gradient(180deg,oklch(from var(--band) calc(l + 0.06) c h) 0 50%,var(--band) 50% 100%);color:var(--band-ink);box-shadow:inset 0 1px 0 oklch(from var(--band) calc(l + 0.16) c h / .65),inset 0 -2px 0 oklch(from var(--band) calc(l - 0.08) c h),var(--shadow-md,0 1px 2px oklch(from var(--cf-cc-shadow) l c h / .22),0 4px 10px -2px oklch(from var(--cf-cc-shadow) l c h / .2));perspective:420px;overflow:hidden}
.cf-cc-flap::after{content:'';position:absolute;left:0;right:0;top:50%;height:2px;margin-top:-1px;background:oklch(from var(--band) calc(l - 0.1) c h);z-index:2}
.cf-cc-flap::before{content:'';position:absolute;inset:0;z-index:3;pointer-events:none;background:radial-gradient(circle at 7px 50%,oklch(from var(--band) calc(l + 0.2) c h) 0 2.5px,transparent 3px),radial-gradient(circle at calc(100% - 7px) 50%,oklch(from var(--band) calc(l + 0.2) c h) 0 2.5px,transparent 3px)}
.cf-cc-digit{position:relative;z-index:1;display:block;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(2.25rem,7cqi,5rem);line-height:1;letter-spacing:-0.02em;font-variant-numeric:tabular-nums;transform-origin:50% 50%}
.cf-cc-unit-label{margin-top:.625rem;font-size:.875rem;font-weight:800;line-height:1.2;letter-spacing:.08em;text-transform:uppercase;color:var(--ink)}
.cf-cc-short{display:none}
.cf-cc-loss{margin:clamp(2rem,4.5cqi,3.25rem) 0 clamp(.875rem,1.8cqi,1.25rem);text-align:center;font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);font-size:clamp(1.375rem,2.6cqi,1.875rem);line-height:1.15;text-wrap:balance;color:var(--ink)}
.cf-cc-items{display:grid;grid-template-columns:repeat(var(--cf-cc-cols,3),minmax(0,1fr));gap:clamp(.625rem,1.6cqi,1rem);margin:0;padding:0;list-style:none}
.cf-cc-item{display:flex;flex-direction:column;gap:.875rem;min-width:0;padding:.75rem .75rem 1rem;background:var(--card);border:1px solid var(--card-border,color-mix(in oklch,var(--ink) 12%,transparent));border-radius:var(--cf-cc-radius);box-shadow:var(--card-shadow,var(--shadow-sm,0 1px 1px oklch(from var(--cf-cc-shadow) l c h / .18),0 1px 3px oklch(from var(--cf-cc-shadow) l c h / .14)))}
.cf-cc-img{display:block;width:100%;aspect-ratio:16/10;object-fit:cover;object-position:center;border-radius:calc(var(--cf-cc-radius) * .65);transition:filter .3s ease}
.cf-cc-closed .cf-cc-img{filter:grayscale(1)}
.cf-cc-item-body{min-width:0;padding:0 .25rem}
.cf-cc-item-name{margin:0;font-family:var(--font-display);font-weight:800;font-size:1.125rem;line-height:1.25;text-wrap:balance;color:var(--ink)}
.cf-cc-meta{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;margin-top:.5rem}
.cf-cc-value{font-size:.9375rem;font-weight:600;line-height:1.35;color:var(--muted)}
.cf-cc-chip{display:inline-flex;align-items:center;gap:.375rem;padding:.25rem .75rem;border-radius:999px;background:color-mix(in oklch,var(--ink) 6%,var(--card));color:var(--ink);font-size:.875rem;font-weight:700;line-height:1.3;white-space:nowrap}
.cf-cc-chip svg{flex:none}
.cf-cc-chip.is-shut{background:var(--danger-soft);color:var(--danger)}
.cf-cc-close{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.15fr);align-items:center;gap:clamp(1.25rem,3.5cqi,3rem);margin-top:clamp(.625rem,1.6cqi,1rem);padding:clamp(1.25rem,3.2cqi,2.25rem) clamp(1.25rem,3.6cqi,2.75rem);background:color-mix(in oklch,var(--ink) 4%,var(--card));border:1px solid oklch(from var(--ink) l c h / .08);border-radius:var(--cf-cc-radius)}
.cf-cc-price{min-width:0}
.cf-cc-today{margin:0 0 .5rem;font-family:var(--font-display);font-weight:700;font-size:clamp(1.125rem,1.8cqi,1.375rem);line-height:1.25;text-wrap:balance;color:var(--ink)}
.cf-cc-pricerow{display:flex;flex-wrap:wrap;align-items:baseline;gap:.25rem .875rem;margin:0}
.cf-cc-was{font-family:var(--font-display);font-weight:800;font-size:clamp(1.5rem,2.8cqi,2.25rem);line-height:1.2;color:var(--muted);text-decoration-line:line-through;text-decoration-color:var(--danger);text-decoration-thickness:.09em}
.cf-cc-now{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(3.25rem,7.2cqi,5.25rem);line-height:1;letter-spacing:-0.03em;font-variant-numeric:tabular-nums;color:var(--ink)}
.cf-cc-save{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;margin:.875rem 0 0}
.cf-cc-save-chip{display:inline-flex;align-items:center;padding:.25rem .75rem;border-radius:999px;background:var(--success-soft);color:var(--success);font-size:.9375rem;font-weight:800;line-height:1.35}
.cf-cc-note{font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);text-wrap:pretty}
.cf-cc-action{min-width:0}
.cf-cc-btn{display:flex;align-items:center;justify-content:center;width:100%;min-height:4.25rem;margin:0;padding:1rem 1.5rem;border:1px solid oklch(from var(--button-bg-2,var(--cta-2)) calc(l - 0.06) c h);border-radius:var(--button-radius,var(--radius,.75rem));background:linear-gradient(180deg,oklch(from var(--button-bg,var(--cta)) calc(l + 0.03) c h),var(--button-bg-2,var(--cta-2)));color:var(--button-ink,var(--cta-ink));font-family:var(--button-font,var(--font-display));font-weight:var(--button-weight,800);font-size:clamp(1.1875rem,2.1cqi,1.4375rem);line-height:1.15;text-align:center;text-transform:var(--button-case,none);text-decoration:none;text-wrap:balance;text-shadow:var(--button-text-shadow,none);box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--button-bg,var(--cta)) calc(l + 0.14) c h / .7),inset 0 -3px 0 oklch(from var(--button-bg,var(--cta)) calc(l - 0.16) c h),0 1px 2px oklch(from var(--cf-cc-shadow) l c h / .3),0 6px 14px -4px oklch(from var(--cf-cc-shadow) l c h / .45));cursor:pointer;transition:transform .14s ease,background .14s ease,box-shadow .14s ease;-webkit-tap-highlight-color:transparent}
.cf-cc-btn:hover:not(:disabled),.cf-cc-btn.is-hover:not(:disabled){transform:translateY(-1px);background:linear-gradient(180deg,oklch(from var(--button-bg,var(--cta)) calc(l - 0.02) c h),oklch(from var(--button-bg-2,var(--cta-2)) calc(l - 0.06) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--button-bg,var(--cta)) calc(l + 0.1) c h / .6),inset 0 -3px 0 oklch(from var(--button-bg,var(--cta)) calc(l - 0.2) c h),0 2px 3px oklch(from var(--cf-cc-shadow) l c h / .32),0 9px 18px -6px oklch(from var(--cf-cc-shadow) l c h / .5))}
.cf-cc-btn:active:not(:disabled),.cf-cc-btn.is-active:not(:disabled){transform:translateY(2px);background:linear-gradient(180deg,oklch(from var(--button-bg-2,var(--cta-2)) calc(l - 0.05) c h),oklch(from var(--button-bg-2,var(--cta-2)) calc(l - 0.09) c h));box-shadow:inset 0 2px 4px oklch(from var(--cf-cc-shadow) l c h / .35),0 1px 1px oklch(from var(--cf-cc-shadow) l c h / .2)}
.cf-cc-btn:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-cc-btn:disabled{cursor:not-allowed;border-color:transparent;background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));text-shadow:none;box-shadow:var(--button-2-shadow, var(--shadow-sm))}
.cf-cc-assure{display:flex;flex-wrap:wrap;justify-content:center;gap:.375rem 1.125rem;margin:.875rem 0 0;padding:0;list-style:none}
.cf-cc-assure li{display:inline-flex;align-items:center;gap:.375rem;font-size:.875rem;font-weight:600;line-height:1.4;color:var(--muted);text-wrap:pretty}
.cf-cc-assure svg{flex:none;color:var(--success)}
.cf-cc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
@container (max-width: 40rem){
.cf-cc-long{display:none}
.cf-cc-short{display:inline}
.cf-cc-unit-label{letter-spacing:.06em}
.cf-cc-items{grid-template-columns:minmax(0,1fr)}
.cf-cc-item{padding:.625rem}
.cf-cc-item.has-img{display:grid;grid-template-columns:5.5rem minmax(0,1fr);align-items:start;gap:.875rem}
.cf-cc-item.has-img .cf-cc-img{aspect-ratio:1/1}
.cf-cc-item-body{padding:.25rem 0 0}
.cf-cc-close{grid-template-columns:minmax(0,1fr);padding:1.25rem 1rem;text-align:center}
.cf-cc-pricerow,.cf-cc-save{justify-content:center}
.cf-cc-btn{min-height:4rem;padding:.875rem}
}
@media (prefers-reduced-motion: no-preference){
.cf-cc-tile{animation:cf-cc-in .45s cubic-bezier(.2,.8,.2,1) both;animation-delay:min(calc(var(--i,0) * .07s),.28s)}
.cf-cc-digit.is-flip{animation:cf-cc-flip .42s cubic-bezier(.2,.9,.25,1) both}
.cf-cc-dot::after{animation:cf-cc-ping 1.6s ease-out 3}
}
@media (prefers-reduced-motion: reduce){
.cf-cc-btn,.cf-cc-img{transition:none}
.cf-cc-btn:hover:not(:disabled),.cf-cc-btn.is-hover:not(:disabled),.cf-cc-btn:active:not(:disabled),.cf-cc-btn.is-active:not(:disabled){transform:none}
}
@keyframes cf-cc-in{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cf-cc-flip{from{opacity:.82;transform:rotateX(-75deg)}to{opacity:1;transform:none}}
@keyframes cf-cc-ping{0%{opacity:.7;transform:scale(.6)}100%{opacity:0;transform:scale(1.9)}}
`
pieces/urgency/cart-closing/specimen.tsx 40 lines
import * as React from 'react'
import { CartClosing } from '../cart-closing'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled']
type SpecimenState = 'default' | 'hover' | 'active' | 'disabled'
// Friday at midnight, as the brief states: the start of the coming Saturday, local time.
function nextFridayMidnight(): number {
const close = new Date()
close.setHours(0, 0, 0, 0)
const daysAhead = (6 - close.getDay() + 7) % 7 || 7
close.setDate(close.getDate() + daysAhead)
return close.getTime()
}
export default function CartClosingSpecimen({ state = 'default' }: { state?: SpecimenState }) {
const sample = defaults.sample
const deadline = React.useMemo(nextFridayMidnight, [])
return (
<CartClosing
deadline={deadline}
state={state}
price={sample.price}
regularPrice={sample.regularPrice}
todayLabel={sample.todayLabel}
priceNote={sample.note}
label={sample.label}
reassurance={[sample.sublabel, sample.guarantee]}
items={sample.items.map((item, index) => ({
name: item.name,
value: item.value,
image: slot(`item-${index + 1}`, item.image),
imageAlt: item.imageAlt,
}))}
/>
)
}
| Name | Type | Details |
|---|---|---|
deadline OptionalCartClosing |
string | number | Date |
|
closed OptionalCartClosing |
boolean |
|
headline OptionalCartClosing |
string |
|
highlight OptionalCartClosing |
string |
|
lead OptionalCartClosing |
string |
|
timerLabel OptionalCartClosing |
string |
|
closedTimerLabel OptionalCartClosing |
string |
|
units OptionalCartClosing |
CartClosingUnits |
|
shortUnits OptionalCartClosing |
CartClosingUnits |
|
timerAriaLabel OptionalCartClosing |
string |
|
lossHeading OptionalCartClosing |
string |
|
items OptionalCartClosing |
CartClosingItem[] |
|
valueLabel OptionalCartClosing |
string |
|
itemTag OptionalCartClosing |
string |
|
closedItemTag OptionalCartClosing |
string |
|
todayLabel OptionalCartClosing |
string |
|
price OptionalCartClosing |
string |
|
regularPrice OptionalCartClosing |
string |
|
regularPriceLabel OptionalCartClosing |
string |
|
priceLabel OptionalCartClosing |
string |
|
savingsLabel OptionalCartClosing |
string |
|
priceNote OptionalCartClosing |
string |
|
label OptionalCartClosing |
string |
|
reassurance OptionalCartClosing |
string[] |
|
closedHeadline OptionalCartClosing |
string |
|
closedLead OptionalCartClosing |
string |
|
closedLabel OptionalCartClosing |
string |
|
href OptionalCartClosing |
string |
|
onAction OptionalCartClosing |
(event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void |
|
state OptionalCartClosing |
'default' | 'hover' | 'active' | 'disabled' |
|
className OptionalCartClosing |
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-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.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB