Daily Deal 1
Daily deal: today’s price against the regular price, a live countdown to the supplied end time in the offer’s time zone,
Use it in a prompt
Use offer/daily-deal 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/daily-deal.tsx. - Import it and pass your copy and images (Props tab):
import { DailyDeal } from "@/components/funneldna/offer/daily-deal"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/daily-deal/component.tsx 431 lines
// layout: card-fan
// Daily deal: today’s price against the regular price, a live countdown to the supplied end time in the offer’s time zone,
// the real stock left and a fanned hand of everything in the kit, all steering the eye to one two-line buy button.
import * as React from 'react';
import { ShieldCheck } from 'lucide-react';
import { Glow, FX_HOST } from '../fx/fx';
export type DailyDealItem = {
name: string;
/** One line shown under the fan while this card is on top. */
detail?: string;
/** Supplied value, shown as “{value} value”. */
value?: string;
/** Item photo (item-1 … item-n slot). */
image?: string;
imageAlt?: string;
};
export type DailyDealCopy = {
/** Line above the clock; {time} is the formatted end time in the offer’s time zone. */
endsAt: string;
ended: string;
days: string;
hours: string;
minutes: string;
seconds: string;
/** Accessible timer label with {days} {hours} {minutes} {seconds}. */
timerLabel: string;
regular: string;
/** Chip text with {value}. */
valueSuffix: string;
/** Stock line with {left} and {total}. */
stock: string;
/** Stock line with {left} when no total is supplied. */
stockOnly: string;
stockLabel: string;
/** Accessible card label with {name}. */
showItem: string;
itemsLabel: string;
endedLabel: string;
endedSub: string;
soldOutLabel: string;
soldOutSub: string;
};
export type DailyDealProps = {
headline?: string;
/** Phrase inside the headline swiped with the marker highlight. */
highlight?: string;
lead?: string;
productName?: string;
/** Kit items fanned out as a hand of cards (up to 5); the top card is active. */
items?: DailyDealItem[];
price?: string;
regularPrice?: string;
/** Supplied per-day breakdown under the price. */
priceBreakdown?: string;
/** Supplied end time, ISO 8601. Omit it and no countdown shows. */
endsAt?: string;
/** IANA time zone the end time is shown in, e.g. America/New_York. */
timeZone?: string;
locale?: string;
/** Supplied stock remaining at the deal price. Omit it and no stock line shows. */
stockLeft?: number;
stockTotal?: number;
label?: string;
sublabel?: string;
/** Reassurance phrases joined on one line under the button. */
assurance?: string[];
href?: string;
onAction?: (event: React.MouseEvent<HTMLElement>) => void;
state?: 'default' | 'hover' | 'active' | 'disabled';
className?: string;
copy?: Partial<DailyDealCopy>;
};
const DEFAULT_COPY: DailyDealCopy = {
endsAt: 'Today’s price ends at {time}',
ended: 'This deal has ended',
days: 'days',
hours: 'hrs',
minutes: 'min',
seconds: 'sec',
timerLabel: '{days} days, {hours} hours, {minutes} minutes and {seconds} seconds left at today’s price',
regular: 'regular price',
valueSuffix: '{value} value',
stock: '{left} of {total} left at this price',
stockOnly: '{left} left at this price',
stockLabel: 'Stock left at the deal price',
showItem: 'Show {name}',
itemsLabel: 'Everything in today’s deal',
endedLabel: 'This deal has ended',
endedSub: 'Today’s price is no longer available',
soldOutLabel: 'Sold out at this price',
soldOutSub: 'Every deal-price copy has been claimed',
};
export function DailyDeal(props: DailyDealProps) {
const {
headline = 'Get the whole kit at today’s deal price',
highlight = 'today’s deal price',
lead,
productName,
items = [],
price,
regularPrice,
priceBreakdown,
endsAt,
timeZone,
locale = 'en-US',
stockLeft,
stockTotal,
label = 'Get my kit at today’s price',
sublabel = 'Instant download · one payment',
assurance = [],
href,
onAction,
state = 'default',
className,
} = props;
const copy = { ...DEFAULT_COPY, ...props.copy };
const titleId = React.useId();
const list = items.slice(0, 5);
const count = list.length;
const [picked, setPicked] = React.useState(() => Math.floor(Math.max(count - 1, 0) / 2));
const activeIndex = Math.min(picked, Math.max(count - 1, 0));
const current = list[activeIndex];
const cardRefs = React.useRef<Array<HTMLButtonElement | null>>([]);
const end = endsAt ? Date.parse(endsAt) : Number.NaN;
const hasClock = Number.isFinite(end);
const [now, setNow] = React.useState(() => Date.now());
const running = hasClock && state !== 'disabled' && now < end;
React.useEffect(() => {
if (!running) return undefined;
const id = window.setInterval(() => setNow(Date.now()), 1000);
return () => window.clearInterval(id);
}, [running]);
const ended = state === 'disabled' || (hasClock && now >= end);
const soldOut = typeof stockLeft === 'number' && stockLeft <= 0;
const closed = ended || soldOut;
const parts = splitTime(running ? end - now : 0);
const units = [
...(parts.days > 0 ? [{ key: 'd', value: parts.days, label: copy.days }] : []),
{ key: 'h', value: parts.hours, label: copy.hours },
{ key: 'm', value: parts.minutes, label: copy.minutes },
{ key: 's', value: parts.seconds, label: copy.seconds },
];
const hasStock = typeof stockLeft === 'number' && stockLeft >= 0;
const hasTotal = hasStock && typeof stockTotal === 'number' && stockTotal > 0;
const pct = hasTotal ? Math.max(0, Math.min(1, (stockLeft ?? 0) / (stockTotal ?? 1))) : 0;
const onFanKey = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (count < 2 || (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft')) return;
event.preventDefault();
const next = (activeIndex + (event.key === 'ArrowRight' ? 1 : -1) + count) % count;
setPicked(next);
cardRefs.current[next]?.focus();
};
const buttonClass = ['cf-dd-btn', state === 'hover' ? 'is-hover' : '', state === 'active' ? 'is-active' : '']
.filter(Boolean)
.join(' ');
const mainLabel = ended ? copy.endedLabel : soldOut ? copy.soldOutLabel : label;
const subLabel = ended ? copy.endedSub : soldOut ? copy.soldOutSub : sublabel;
const inner = (
<>
<span className='cf-dd-btn-main'>{mainLabel}</span>
{subLabel ? <span className='cf-dd-btn-sub'>{subLabel}</span> : null}
</>
);
const button =
href && !closed ? (
<a className={buttonClass} href={href} onClick={onAction}>
{inner}
</a>
) : (
<button type='button' className={buttonClass} disabled={closed} onClick={closed ? undefined : onAction}>
{inner}
</button>
);
return (
<section className={['cf-daily-deal', className].filter(Boolean).join(' ')} style={FX_HOST} aria-labelledby={titleId}>
<style>{CSS}</style>
<Glow />
<div className='cf-dd-inner'>
<header className='cf-dd-head'>
{hasClock ? (
<div className='cf-dd-clock cf-dd-rise'>
<p className='cf-dd-ends'>{ended ? copy.ended : fill(copy.endsAt, { time: formatEnd(end, timeZone, locale) })}</p>
<div
className='cf-dd-tiles'
role='timer'
aria-label={fill(copy.timerLabel, { days: parts.days, hours: parts.hours, minutes: parts.minutes, seconds: parts.seconds })}
>
{units.map((unit, i) => (
<React.Fragment key={unit.key}>
{i > 0 ? (
<span className='cf-dd-colon' aria-hidden='true'>
:
</span>
) : null}
<span className='cf-dd-unit' aria-hidden='true'>
<span className='cf-dd-tile'>
<span key={unit.value} className='cf-dd-digit'>
{pad(unit.value)}
</span>
</span>
<span className='cf-dd-label'>{unit.label}</span>
</span>
</React.Fragment>
))}
</div>
</div>
) : null}
<h2 id={titleId} className='cf-dd-title cf-dd-rise' style={{ animationDelay: '.07s' }}>
{renderHeadline(headline, highlight)}
</h2>
{lead ? (
<p className='cf-dd-lead cf-dd-rise' style={{ animationDelay: '.14s' }}>
{lead}
</p>
) : null}
</header>
<div className={count ? 'cf-dd-stage' : 'cf-dd-stage is-solo'}>
{count ? (
<div className='cf-dd-show cf-dd-rise' style={{ animationDelay: '.21s' }}>
<div
className='cf-dd-fan'
role='group'
aria-label={copy.itemsLabel}
onKeyDown={onFanKey}
style={{ '--n': count } as React.CSSProperties}
>
{list.map((item, i) => {
const offset = i - (count - 1) / 2;
const isActive = i === activeIndex;
// Stack falls away from the active card, so each card is only ever covered on the side facing it;
// its words sit on the open side and are never hidden.
const dist = Math.abs(i - activeIndex);
const side = i < activeIndex ? 'start' : i > activeIndex ? 'end' : 'mid';
return (
<button
key={item.name + i}
ref={(el) => {
cardRefs.current[i] = el;
}}
type='button'
className='cf-dd-fcard'
aria-pressed={isActive}
aria-label={fill(copy.showItem, { name: item.name })}
data-side={side}
onClick={() => setPicked(i)}
style={{ '--o': offset, '--ao': Math.abs(offset), '--z': count - dist } as React.CSSProperties}
>
{item.image ? <img src={item.image} alt='' width={360} height={360} loading='lazy' draggable={false} /> : null}
<span className='cf-dd-ftitle'>{item.name}</span>
{item.value ? <span className='cf-dd-fchip'>{fill(copy.valueSuffix, { value: item.value })}</span> : null}
</button>
);
})}
</div>
{current ? (
<div key={activeIndex} className='cf-dd-caption cf-dd-rise' aria-live='polite'>
<p className='cf-dd-cap-name'>{current.name}</p>
{current.detail ? <p className='cf-dd-cap-detail'>{current.detail}</p> : null}
</div>
) : null}
</div>
) : null}
<div className='cf-dd-deal cf-dd-rise' style={{ animationDelay: '.28s' }}>
{productName ? <h3 className='cf-dd-name'>{productName}</h3> : null}
{price ? (
<div>
<p className='cf-dd-price'>
<span className='cf-dd-now'>{price}</span>
{regularPrice ? (
<span className='cf-dd-was'>
<s>{regularPrice}</s>
<span>{copy.regular}</span>
</span>
) : null}
</p>
{priceBreakdown ? <p className='cf-dd-perday'>{priceBreakdown}</p> : null}
</div>
) : null}
{hasStock ? (
<div className='cf-dd-stock'>
<p className='cf-dd-stock-text'>
{hasTotal
? fill(copy.stock, { left: stockLeft ?? 0, total: stockTotal ?? 0 })
: fill(copy.stockOnly, { left: stockLeft ?? 0 })}
</p>
{hasTotal ? (
<div
className='cf-dd-bar'
role='meter'
aria-label={copy.stockLabel}
aria-valuemin={0}
aria-valuemax={stockTotal}
aria-valuenow={stockLeft}
>
<span style={{ width: `${pct > 0 ? Math.max(pct * 100, 3) : 0}%` }} />
</div>
) : null}
</div>
) : null}
<div>
{button}
{assurance.length ? (
<p className='cf-dd-assure'>
<ShieldCheck size={16} strokeWidth={2.5} aria-hidden='true' />
{assurance.join(' · ')}
</p>
) : null}
</div>
</div>
</div>
</div>
</section>
);
}
export default DailyDeal;
function renderHeadline(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text;
const at = text.indexOf(phrase);
if (at < 0) return text;
return (
<>
{text.slice(0, at)}
<span className='cf-dd-mark'>{phrase}</span>
{text.slice(at + phrase.length)}
</>
);
}
function fill(template: string, values: Record<string, string | number>) {
return Object.keys(values).reduce((out, key) => out.split(`{${key}}`).join(String(values[key])), template);
}
function splitTime(ms: number) {
const total = Math.max(0, Math.floor(ms / 1000));
return {
days: Math.floor(total / 86400),
hours: Math.floor((total % 86400) / 3600),
minutes: Math.floor((total % 3600) / 60),
seconds: total % 60,
};
}
function pad(value: number) {
return String(value).padStart(2, '0');
}
function formatEnd(ms: number, timeZone: string | undefined, locale: string) {
const options: Intl.DateTimeFormatOptions = { hour: 'numeric', minute: '2-digit', timeZoneName: 'short' };
try {
return new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(ms);
} catch {
return new Intl.DateTimeFormat(locale, options).format(ms);
}
}
const CSS = `
.cf-daily-deal{--dd-ease:cubic-bezier(.2,.7,.2,1);--dd-shadow:var(--shadow,oklch(0.22 0.03 256));position:relative;isolation:isolate;overflow:clip;background:var(--band,oklch(0.27 0.07 256));color:var(--band-ink,oklch(1 0 0));font-family:var(--font-body);padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) clamp(64px,8.5vw,120px)}
.cf-daily-deal *,.cf-daily-deal *::before,.cf-daily-deal *::after{box-sizing:border-box}
.cf-daily-deal .cf-dd-inner{position:relative;z-index:1;max-width:1120px;margin:0 auto}
.cf-daily-deal .cf-dd-head{max-width:52rem;margin:0 auto;text-align:center}
.cf-daily-deal .cf-dd-clock{display:flex;flex-direction:column;align-items:center;gap:12px;margin:0 0 32px}
.cf-daily-deal .cf-dd-ends{margin:0;font-size:.9375rem;line-height:1.4;font-weight:700;color:var(--band-ink);text-wrap:pretty}
.cf-daily-deal .cf-dd-tiles{display:flex;align-items:flex-start;justify-content:center;gap:8px}
.cf-daily-deal .cf-dd-unit{display:flex;flex-direction:column;align-items:center;gap:8px}
.cf-daily-deal .cf-dd-tile{position:relative;display:block;min-width:clamp(62px,7vw,88px);padding:10px 8px;overflow:hidden;border-radius:var(--radius,12px);background:var(--card);color:var(--ink);font-family:var(--font-display);font-size:clamp(2.5rem,4.2vw,3.75rem);font-weight:var(--display-weight,800);line-height:1;letter-spacing:-.03em;font-variant-numeric:tabular-nums;text-align:center;box-shadow:var(--shadow-md,0 1px 2px oklch(from var(--dd-shadow) l c h / .22),0 4px 10px -2px oklch(from var(--dd-shadow) l c h / .2)),inset 0 -3px 0 color-mix(in oklch,var(--ink) 8%,var(--card))}
.cf-daily-deal .cf-dd-tile::after{content:'';position:absolute;left:0;right:0;top:50%;height:1px;background:oklch(from var(--ink) l c h / .1)}
.cf-daily-deal .cf-dd-digit{display:block;animation:cf-dd-flip .32s var(--dd-ease) both}
.cf-daily-deal .cf-dd-colon{padding-top:10px;font-family:var(--font-display);font-size:clamp(2.5rem,4.2vw,3.75rem);font-weight:var(--display-weight,800);line-height:1;color:var(--band-ink)}
.cf-daily-deal .cf-dd-label{font-size:.875rem;font-weight:800;line-height:1.2;letter-spacing:.08em;text-transform:uppercase;color:var(--band-ink)}
.cf-daily-deal .cf-dd-title{position:relative;z-index:0;margin:0 0 16px;font-family:var(--font-display);font-size:clamp(2rem,3.6vw,3.25rem);font-weight:var(--display-weight,800);line-height:1.06;letter-spacing:var(--display-tracking,-.025em);text-transform:var(--display-case,none);color:var(--band-ink);text-wrap:balance}
.cf-daily-deal .cf-dd-mark{position:relative;z-index:-1;padding:0 .14em;margin:0 -.04em;border-radius:.12em .26em .2em .3em;background:linear-gradient(transparent .14em,oklch(from var(--marker,#fae37c) 0.9 c h / 1) .14em);color:oklch(from var(--marker,#fae37c) 0.24 0.04 h / 1);-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-daily-deal .cf-dd-lead{margin:0 auto;max-width:40rem;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--band-ink);text-wrap:pretty}
.cf-daily-deal .cf-dd-stage{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:clamp(32px,5vw,72px);align-items:start;margin-top:clamp(40px,5vw,56px)}
.cf-daily-deal .cf-dd-stage.is-solo{grid-template-columns:minmax(0,30rem);justify-content:center}
.cf-daily-deal .cf-dd-show{container-type:inline-size;width:100%;display:flex;flex-direction:column;align-items:center;gap:16px;min-width:0}
.cf-daily-deal .cf-dd-fan{--cw:clamp(124px,38cqi,210px);--spread:min(calc(var(--cw) * .78),calc((100cqi - var(--cw) - 56px) / max(var(--n,3) - 1,1)));--tilt:8deg;--drop:16px;display:grid;justify-items:center;align-items:stretch;width:100%;padding:28px 0 40px}
.cf-daily-deal .cf-dd-fcard{--lift:0px;--rot:1;--sc:1;grid-area:1/1;appearance:none;margin:0;width:var(--cw);display:flex;flex-direction:column;gap:12px;padding:12px;text-align:left;font:inherit;color:var(--ink);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(--dd-shadow) l c h / .22),0 4px 10px -2px oklch(from var(--dd-shadow) l c h / .2));cursor:pointer;z-index:var(--z,1);transform-origin:50% 100%;transform:translateX(calc(var(--o,0) * var(--spread))) translateY(calc(var(--ao,0) * var(--drop) + var(--lift))) rotate(calc(var(--o,0) * var(--tilt) * var(--rot))) scale(var(--sc));transition:transform .35s var(--dd-ease),box-shadow .16s ease}
.cf-daily-deal .cf-dd-fcard[aria-pressed='true']{--lift:-18px;--rot:.35;--sc:1.05;z-index:20;cursor:default;box-shadow:var(--shadow-lg,0 2px 4px oklch(from var(--dd-shadow) l c h / .22),0 12px 24px -8px oklch(from var(--dd-shadow) l c h / .32))}
@media (hover:hover){.cf-daily-deal .cf-dd-fcard:not([aria-pressed='true']):hover{--lift:-10px}}
.cf-daily-deal .cf-dd-fcard:focus-visible{outline:3px solid var(--band-ink);outline-offset:4px}
.cf-daily-deal .cf-dd-fcard img{display:block;width:100%;height:auto;aspect-ratio:1/1;object-fit:cover;object-position:center;border-radius:8px;background:color-mix(in oklch,var(--ink) 4%,var(--card))}
.cf-daily-deal .cf-dd-ftitle{display:block;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:800;line-height:1.2;text-wrap:balance}
.cf-daily-deal .cf-dd-fchip{align-self:flex-start;margin-top:auto;display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;background:color-mix(in oklch,var(--ink) 6%,var(--card));color:var(--ink);font-size:.875rem;font-weight:800;line-height:1.2;white-space:nowrap}
.cf-daily-deal .cf-dd-fcard[data-side='end']{text-align:right}
.cf-daily-deal .cf-dd-fcard[data-side='end'] .cf-dd-fchip{align-self:flex-end}
.cf-daily-deal .cf-dd-caption{max-width:28rem;text-align:center}
.cf-daily-deal .cf-dd-cap-name{margin:0;font-family:var(--font-display);font-size:clamp(1.3125rem,1.8vw,1.625rem);font-weight:var(--display-weight,800);line-height:1.15;letter-spacing:-.01em;color:var(--band-ink);text-wrap:balance}
.cf-daily-deal .cf-dd-cap-detail{margin:8px 0 0;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--band-ink);text-wrap:pretty}
.cf-daily-deal .cf-dd-deal{display:flex;flex-direction:column;gap:24px;min-width:0;padding:clamp(20px,3vw,32px);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-lg,0 2px 4px oklch(from var(--dd-shadow) l c h / .22),0 12px 24px -8px oklch(from var(--dd-shadow) l c h / .32)))}
.cf-daily-deal .cf-dd-name{margin:0;font-family:var(--font-display);font-size:clamp(1.3125rem,1.8vw,1.625rem);font-weight:var(--display-weight,800);line-height:1.15;letter-spacing:-.01em;color:var(--ink);text-wrap:balance}
.cf-daily-deal .cf-dd-price{margin:0;display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px 16px}
.cf-daily-deal .cf-dd-now{font-family:var(--font-display);font-size:clamp(2.5rem,4.2vw,3.75rem);font-weight:var(--display-weight,800);line-height:1;letter-spacing:-.03em;font-variant-numeric:tabular-nums;color:var(--ink)}
.cf-daily-deal .cf-dd-was{display:flex;flex-direction:column;gap:4px;padding-bottom:4px;font-size:.9375rem;font-weight:600;line-height:1.2;color:var(--muted)}
.cf-daily-deal .cf-dd-was s{font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:800;color:var(--muted);text-decoration-color:var(--danger);text-decoration-thickness:2px}
.cf-daily-deal .cf-dd-perday{margin:12px 0 0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:600;line-height:1.5;color:var(--ink);text-wrap:pretty}
.cf-daily-deal .cf-dd-stock{display:grid;gap:8px}
.cf-daily-deal .cf-dd-stock-text{margin:0;font-size:.9375rem;font-weight:700;line-height:1.4;color:var(--ink)}
.cf-daily-deal .cf-dd-bar{height:10px;border-radius:999px;overflow:hidden;background:color-mix(in oklch,var(--ink) 10%,var(--card))}
.cf-daily-deal .cf-dd-bar>span{display:block;height:100%;border-radius:inherit;background:var(--accent-fill,var(--accent))}
.cf-daily-deal .cf-dd-btn{--b:var(--button-bg,var(--cta));--b2:var(--button-bg-2,var(--cta-2,var(--button-bg,var(--cta))));appearance:none;border:0;margin:0;width:100%;min-height:72px;padding:12px 28px;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;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));text-transform:var(--button-case,none);text-shadow:var(--button-text-shadow,none);text-decoration:none;text-align:center;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(--dd-shadow) l c h / .3),0 8px 16px -6px oklch(from var(--dd-shadow) l c h / .45));transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
.cf-daily-deal .cf-dd-btn:not(:disabled):hover,.cf-daily-deal .cf-dd-btn.is-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 + .12) c h / .7),inset 0 -3px 0 oklch(from var(--b) calc(l - .2) c h),0 1px 2px oklch(from var(--dd-shadow) l c h / .34),0 12px 20px -6px oklch(from var(--dd-shadow) l c h / .5))}
.cf-daily-deal .cf-dd-btn:not(:disabled):active,.cf-daily-deal .cf-dd-btn.is-active{transform:translateY(1px);background:linear-gradient(oklch(from var(--b) calc(l - .04) c h),oklch(from var(--b2) calc(l - .09) 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 - .18) c h),0 1px 2px oklch(from var(--dd-shadow) l c h / .3)}
.cf-daily-deal .cf-dd-btn:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-daily-deal .cf-dd-btn:disabled{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));cursor:not-allowed;transform:none}
.cf-daily-deal .cf-dd-btn-main{font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;font-weight:var(--button-weight,800);text-wrap:balance}
.cf-daily-deal .cf-dd-btn-sub{font-family:var(--font-body);font-size:.9375rem;line-height:1.3;font-weight:600;text-wrap:pretty}
.cf-daily-deal .cf-dd-assure{margin:12px 0 0;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);text-align:center;text-wrap:pretty}
.cf-daily-deal .cf-dd-assure svg{display:inline-block;vertical-align:-.15em;margin-inline-end:.4em;color:var(--success)}
@keyframes cf-dd-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cf-dd-flip{from{opacity:.35;transform:translateY(-30%)}to{opacity:1;transform:none}}
.cf-daily-deal .cf-dd-rise{animation:cf-dd-rise .45s var(--dd-ease) both}
@media (max-width:900px){.cf-daily-deal .cf-dd-stage{grid-template-columns:minmax(0,1fr);max-width:34rem;margin-inline:auto}}
@media (max-width:640px){.cf-daily-deal .cf-dd-fan{--tilt:5deg;--drop:10px;padding:24px 0 28px}.cf-daily-deal .cf-dd-ftitle{display:none}.cf-daily-deal .cf-dd-tiles{gap:4px}.cf-daily-deal .cf-dd-tile{min-width:58px}.cf-daily-deal .cf-dd-clock{margin-bottom:24px}.cf-daily-deal .cf-dd-btn{padding:12px 16px}}
@media (prefers-reduced-motion:reduce){.cf-daily-deal .cf-dd-rise,.cf-daily-deal .cf-dd-digit{animation:none}.cf-daily-deal .cf-dd-fcard,.cf-daily-deal .cf-dd-btn{transition:none}}
`;
pieces/offer/daily-deal/specimen.tsx 65 lines
// Specimen: today’s deal on The Funnel Starter Kit, ending tonight at 11:59 PM New York time, with fictional stock numbers.
import * as React from 'react';
import DailyDeal, { type DailyDealProps } from '../daily-deal';
import defaults from '../../studio-defaults.json';
import { slot } from '../../slots';
export const states = ['default', 'hover', 'active', 'disabled'];
const TIME_ZONE = 'America/New_York';
export default function DailyDealSpecimen({ state }: { state?: DailyDealProps['state'] }) {
const sample = defaults.sample;
const [endsAt] = React.useState(() => tonightIn(TIME_ZONE, 23, 59));
return (
<DailyDeal
headline='Today only, the whole kit for less than half price'
highlight='less than half price'
lead={sample.reason}
productName={sample.name}
items={sample.items.map((item, i) => ({
name: item.name,
detail: item.detail,
value: item.value,
image: slot(`item-${i + 1}`, item.image),
imageAlt: item.imageAlt,
}))}
price={sample.price}
regularPrice={sample.regularPrice}
priceBreakdown='$47 once, about $1.57 a day for a month'
endsAt={endsAt}
timeZone={TIME_ZONE}
stockLeft={38}
stockTotal={200}
label='Get my kit at today’s price'
sublabel='Instant download · one payment'
assurance={[sample.guarantee, 'Instant digital access']}
state={state}
/>
);
}
// The instant of today’s given wall-clock time in the deal’s time zone (rolls to tomorrow if it has passed).
function tonightIn(timeZone: string, hour: number, minute: number) {
const read = (date: Date) => {
const found = new Intl.DateTimeFormat('en-US', {
timeZone,
hourCycle: 'h23',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).formatToParts(date);
const get = (type: string) => Number(found.find((part) => part.type === type)?.value ?? 0);
return { y: get('year'), mo: get('month'), d: get('day'), h: get('hour'), mi: get('minute'), s: get('second') };
};
const today = read(new Date());
const guess = Date.UTC(today.y, today.mo - 1, today.d, hour, minute);
const seen = read(new Date(guess));
const offset = Date.UTC(seen.y, seen.mo - 1, seen.d, seen.h, seen.mi, seen.s) - guess;
let end = guess - offset;
if (end <= Date.now()) end += 86400000;
return new Date(end).toISOString();
}
| Name | Type | Details |
|---|---|---|
headline OptionalDailyDeal |
string |
|
highlight OptionalDailyDeal |
string |
|
lead OptionalDailyDeal |
string |
|
productName OptionalDailyDeal |
string |
|
items OptionalDailyDeal |
DailyDealItem[] |
|
price OptionalDailyDeal |
string |
|
regularPrice OptionalDailyDeal |
string |
|
priceBreakdown OptionalDailyDeal |
string |
|
endsAt OptionalDailyDeal |
string |
|
timeZone OptionalDailyDeal |
string |
|
locale OptionalDailyDeal |
string |
|
stockLeft OptionalDailyDeal |
number |
|
stockTotal OptionalDailyDeal |
number |
|
label OptionalDailyDeal |
string |
|
sublabel OptionalDailyDeal |
string |
|
assurance OptionalDailyDeal |
string[] |
|
href OptionalDailyDeal |
string |
|
onAction OptionalDailyDeal |
(event: React.MouseEvent<HTMLElement>) => void |
|
state OptionalDailyDeal |
'default' | 'hover' | 'active' | 'disabled' |
|
className OptionalDailyDeal |
string |
|
copy OptionalDailyDeal |
Partial<DailyDealCopy> |
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