Size Finder Calculator 1
Size finder: the visitor enters their household, sees which supplied size lasts the whole period on a supply bar, and adds that one size with a single action.
Use it in a prompt
Use content/size-finder-calculator 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/content/size-finder-calculator.tsx. - Import it and pass your copy and images (Props tab):
import { SizeFinderCalculator } from "@/components/funneldna/content/size-finder-calculator"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/size-finder-calculator/component.tsx 521 lines
// layout: diagonal-split
// Size finder: the visitor enters their household, sees which supplied size lasts the whole period on a supply bar, and adds that one size with a single action.
import React from "react";
import { Minus, Plus, ShieldCheck, Calculator, AlertCircle } from "lucide-react";
import { Texture, Divider, FX_HOST } from "../fx/fx";
import linen from "../fx/textures/linen";
export type SizeFinderInput = {
id: string;
label: string;
hint?: string;
// plural word used in the formula line ("people", "days a week")
unit?: string;
// singular word used when the value is 1 ("person")
unitOne?: string;
min?: number;
max?: number;
// starting value
value?: number;
placeholder?: string;
};
export type SizeFinderOption = {
id: string;
name: string;
// servings (or uses) in this size; the math divides this by servings per day
servings: number;
price?: string;
image?: string;
imageAlt?: string;
};
export type SizeFinderCopy = typeof DEFAULT_COPY;
export type SizeFinderCalculatorProps = {
headline?: React.ReactNode;
// dear-friend note under the headline; set to null to hide
letter?: { salutation?: string; paragraphs?: React.ReactNode[]; signoff?: string; signer?: string } | null;
// 2 or 3 inputs; their values multiply into servings per week
inputs?: SizeFinderInput[];
// the supplied sizes; the smallest one that lasts periodDays is recommended
options?: SizeFinderOption[];
periodDays?: number;
// what the visitor would otherwise pay, shown beside the per-serving price ("a $7 café green juice")
alternative?: string;
reassurance?: string;
// templates: {name} {days} {spare} {day} {terms} {perWeek} {perDay} {price} {alternative} {label} {min} {max}
copy?: Partial<SizeFinderCopy>;
// called with the recommended option id
onAction?: (optionId: string) => void;
href?: string;
state?: "default" | "hover" | "active" | "disabled" | "error";
className?: string;
};
const DEFAULT_COPY = {
fitTitle: "The {name} covers your month",
shortTitle: "The {name} gets you closest",
daysUnit: "days of supply",
spare: "{spare} days to spare before you reorder",
spareNone: "Lasts right to the end of your month",
shortBy: "Runs out after day {days}, so reorder early",
dayLabel: "Day {day}",
rowLasts: "Lasts {days} days",
rowShort: "Empty after day {days}",
bestFit: "Best fit",
formula: "{terms} = {perWeek} servings a week, about {perDay} a day.",
perServing: "{price} a serving",
vs: "vs. {alternative}",
action: "Send me the {name}",
legend: "Your household",
decrease: "Fewer: {label}",
increase: "More: {label}",
rangeError: "Enter a whole number from {min} to {max}.",
empty: "Add your sizes to see which one lasts your month.",
chartLabel: "How long each size lasts you",
};
const DEFAULT_INPUTS: SizeFinderInput[] = [
{ id: "people", label: "People in your home", hint: "Count everyone who uses it", unit: "people", unitOne: "person", min: 1, max: 8, value: 2 },
{ id: "uses", label: "Uses per week, each", hint: "A typical week is fine", unit: "uses a week", unitOne: "use a week", min: 1, max: 14, value: 5 },
];
const DEFAULT_OPTIONS: SizeFinderOption[] = [
{ id: "small", name: "30-serving size", servings: 30 },
{ id: "medium", name: "60-serving size", servings: 60 },
{ id: "large", name: "90-serving size", servings: 90 },
];
const DEFAULT_LETTER = {
salutation: "Hi friend,",
paragraphs: [
"Buy too small and you run out before your next order. Buy too big and it sits in the cupboard.",
"Tell me who uses it and how often. I'll show you the size that carries you to the end of the month.",
],
signoff: "Talk soon,",
signer: "",
};
export function SizeFinderCalculator(props: SizeFinderCalculatorProps) {
const {
headline = "Find the size that lasts your whole month",
letter = DEFAULT_LETTER,
inputs = DEFAULT_INPUTS,
options = DEFAULT_OPTIONS,
periodDays = 30,
alternative = "",
reassurance = "",
copy: copyProp,
onAction,
href,
state = "default",
className = "",
} = props;
const copy = { ...DEFAULT_COPY, ...copyProp };
const uid = React.useId();
const [values, setValues] = React.useState<Record<string, number>>(() => initValues(inputs));
const [drafts, setDrafts] = React.useState<Record<string, string>>({});
React.useEffect(() => {
if (state === "error" && inputs[0]) setDrafts({ [inputs[0].id]: "" });
else setDrafts({});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);
const live = inputs.map((i) => {
const min = i.min ?? 1;
const max = i.max ?? 10;
return { ...i, min, max, v: clamp(values[i.id] ?? i.value ?? min, min, max) };
});
const perWeek = live.reduce((p, i) => p * i.v, 1);
const perDay = perWeek / 7;
const period = Math.max(1, periodDays);
const rows = options
.filter((o) => o.servings > 0)
.sort((a, b) => a.servings - b.servings)
.map((o) => ({ ...o, days: Math.floor(o.servings / perDay) }));
const pick = rows.find((r) => r.days >= period) ?? rows[rows.length - 1];
const fits = !!pick && pick.days >= period;
const spare = pick ? pick.days - period : 0;
const terms = live
.map((i) => `${i.v} ${i.v === 1 ? i.unitOne ?? i.unit ?? "" : i.unit ?? ""}`.trim())
.join(" × ");
const perDayText = String(Math.round(perDay * 10) / 10);
const disabled = state === "disabled" || !pick;
const commit = (id: string, n: number) => setValues((prev) => ({ ...prev, [id]: n }));
const clearDraft = (id: string) =>
setDrafts((prev) => {
const next = { ...prev };
delete next[id];
return next;
});
const bump = (inp: (typeof live)[number], delta: number) => {
commit(inp.id, clamp(inp.v + delta, inp.min, inp.max));
clearDraft(inp.id);
};
const handleAction = () => {
if (disabled || !pick) return;
onAction?.(pick.id);
};
const ctaClass = `sfc-cta${state === "hover" ? " is-hover" : ""}${state === "active" ? " is-active" : ""}`;
const ctaLabel = pick ? fillName(copy.action, pick.name) : null;
const mid = Math.round(period / 2);
return (
<section className={`cf-size-finder-calculator ${className}`.trim()} style={FX_HOST} aria-labelledby={`${uid}-h`}>
<style>{CSS}</style>
<Texture src={linen} tone="band-ink" />
<div className="sfc-field" aria-hidden="true" />
<Divider shape="angle" tone="surface" height={56} />
<div className="sfc-wrap">
<div className="sfc-head sfc-reveal">
<h2 id={`${uid}-h`} className="sfc-h2">{headline}</h2>
{letter && (
<div className="sfc-letter">
{letter.salutation && <p className="sfc-salute">{letter.salutation}</p>}
{(letter.paragraphs ?? []).map((p, i) => (
<p key={i}>{p}</p>
))}
{(letter.signoff || letter.signer) && (
<p className="sfc-sign">
{letter.signoff && <span>{letter.signoff}</span>}
{letter.signer && <strong>{letter.signer}</strong>}
</p>
)}
</div>
)}
</div>
<div className="sfc-result sfc-reveal">
<div className="sfc-card">
{pick ? (
<>
<div className={`sfc-pick${pick.image ? "" : " no-img"}`}>
{pick.image && (
<img className="sfc-pick-img" src={pick.image} alt={pick.imageAlt ?? pick.name} width={240} height={240} />
)}
<div>
<h3 className="sfc-h3" aria-live="polite">
{fillName(fits ? copy.fitTitle : copy.shortTitle, pick.name)}
</h3>
<p className="sfc-days">
<span className="sfc-num">{pick.days}</span>
<span className="sfc-unit">{copy.daysUnit}</span>
</p>
<p className={`sfc-status ${fits ? "is-ok" : "is-short"}`}>
{fits
? spare > 0
? fill(copy.spare, { spare })
: copy.spareNone
: fill(copy.shortBy, { days: pick.days })}
</p>
</div>
</div>
<div className="sfc-well" role="group" aria-label={copy.chartLabel}>
<div className="sfc-axis" aria-hidden="true">
<span>{fill(copy.dayLabel, { day: 1 })}</span>
<span>{fill(copy.dayLabel, { day: mid })}</span>
<span>{fill(copy.dayLabel, { day: period })}</span>
</div>
{rows.map((r) => {
const isPick = r.id === pick.id;
const lasts = r.days >= period;
const pct = Math.max(2, Math.min(1, r.days / period) * 100);
return (
<div className={`sfc-bar${isPick ? " is-pick" : ""}`} key={r.id}>
<div className="sfc-bar-head">
{r.image && <img className="sfc-thumb" src={r.image} alt="" width={72} height={72} />}
<span className="sfc-bar-name">{r.name}</span>
{r.price && <span className="sfc-bar-price">{r.price}</span>}
{isPick && <span className="sfc-chip">{copy.bestFit}</span>}
<span className={`sfc-bar-out ${lasts ? "is-ok" : "is-short"}`}>
{fill(lasts ? copy.rowLasts : copy.rowShort, { days: r.days })}
</span>
</div>
<div className="sfc-track" aria-hidden="true">
<span className={`sfc-fill${lasts ? "" : " is-short"}`} style={{ width: `${pct}%` }} />
</div>
</div>
);
})}
</div>
{pick.price && (
<div className="sfc-price">
<span className="sfc-amount">{pick.price}</span>
<span className="sfc-price-side">
{perServing(pick.price, pick.servings) && (
<span className="sfc-per">{fill(copy.perServing, { price: perServing(pick.price, pick.servings) })}</span>
)}
{alternative && <span className="sfc-vs">{fill(copy.vs, { alternative })}</span>}
</span>
</div>
)}
{href && !disabled ? (
<a className={ctaClass} href={href} onClick={handleAction}>
{ctaLabel}
</a>
) : (
<button type="button" className={ctaClass} onClick={handleAction} disabled={disabled}>
{ctaLabel}
</button>
)}
{reassurance && (
<p className="sfc-reassure">
<ShieldCheck size={16} strokeWidth={2.5} aria-hidden="true" />
{reassurance}
</p>
)}
</>
) : (
<p className="sfc-empty">{copy.empty}</p>
)}
</div>
</div>
{live.length > 0 && (
<fieldset className="sfc-inputs sfc-reveal">
<legend className="sfc-legend">{copy.legend}</legend>
<div className="sfc-rows">
{live.map((inp, idx) => {
const id = `${uid}-in-${idx}`;
const errId = `${id}-err`;
const hintId = `${id}-hint`;
const draft = drafts[inp.id];
const invalid = draft !== undefined && !isValid(draft, inp.min, inp.max);
const described = [inp.hint ? hintId : "", invalid ? errId : ""].filter(Boolean).join(" ") || undefined;
return (
<div className="sfc-row" key={inp.id}>
<div>
<label htmlFor={id} className="sfc-label">{inp.label}</label>
{inp.hint && <span id={hintId} className="sfc-hint">{inp.hint}</span>}
</div>
<div className={`sfc-step${invalid ? " is-invalid" : ""}`}>
<button
type="button"
className="sfc-step-btn"
aria-label={fill(copy.decrease, { label: inp.label })}
onClick={() => bump(inp, -1)}
disabled={inp.v <= inp.min && !invalid}
>
<Minus size={20} strokeWidth={2.5} aria-hidden="true" />
</button>
<input
id={id}
className="sfc-step-input"
type="number"
inputMode="numeric"
min={inp.min}
max={inp.max}
step={1}
value={draft ?? String(inp.v)}
placeholder={inp.placeholder ?? String(inp.value ?? inp.min)}
aria-invalid={invalid || undefined}
aria-describedby={described}
onChange={(e) => {
const raw = e.target.value;
setDrafts((prev) => ({ ...prev, [inp.id]: raw }));
if (isValid(raw, inp.min, inp.max)) commit(inp.id, parseInt(raw, 10));
}}
onBlur={(e) => {
if (isValid(e.target.value, inp.min, inp.max)) clearDraft(inp.id);
}}
/>
<button
type="button"
className="sfc-step-btn"
aria-label={fill(copy.increase, { label: inp.label })}
onClick={() => bump(inp, 1)}
disabled={inp.v >= inp.max && !invalid}
>
<Plus size={20} strokeWidth={2.5} aria-hidden="true" />
</button>
</div>
{invalid && (
<p className="sfc-error" id={errId} role="alert">
<AlertCircle size={16} strokeWidth={2.5} aria-hidden="true" />
{fill(copy.rangeError, { min: inp.min, max: inp.max })}
</p>
)}
</div>
);
})}
</div>
<p className="sfc-formula">
<Calculator size={16} strokeWidth={2.5} aria-hidden="true" />
{fill(copy.formula, { terms, perWeek, perDay: perDayText })}
</p>
</fieldset>
)}
</div>
</section>
);
}
export default SizeFinderCalculator;
function clamp(n: number, min: number, max: number) {
return Math.min(max, Math.max(min, Math.round(n)));
}
function initValues(inputs: SizeFinderInput[]) {
const out: Record<string, number> = {};
inputs.forEach((i) => {
const min = i.min ?? 1;
out[i.id] = clamp(i.value ?? min, min, i.max ?? 10);
});
return out;
}
function isValid(raw: string, min: number, max: number) {
const t = raw.trim();
if (!/^[0-9]+$/.test(t)) return false;
const n = parseInt(t, 10);
return n >= min && n <= max;
}
// replaces {name} with the size name kept on one line, so "60-serving" never breaks at its hyphen
function fillName(template: string, name: string): React.ReactNode {
const parts = template.split("{name}");
if (parts.length === 1) return template;
return parts.map((p, i) => (
<React.Fragment key={i}>
{p}
{i < parts.length - 1 && <span className="sfc-nowrap">{name}</span>}
</React.Fragment>
));
}
function fill(template: string, vars: Record<string, string | number>) {
return template.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? String(vars[k]) : m));
}
function perServing(price: string | undefined, servings: number) {
if (!price || servings <= 0) return "";
const m = price.trim().match(/^([^0-9]*)([0-9][0-9,.]*)(.*)$/);
if (!m) return "";
const n = parseFloat(m[2].replace(/,/g, ""));
if (!isFinite(n)) return "";
return `${m[1]}${(n / servings).toFixed(2)}${m[3]}`;
}
const S = ".cf-size-finder-calculator";
const SH = "oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h";
const BG = "var(--button-bg, var(--cta))";
const BG2 = "var(--button-bg-2, var(--cta-2))";
const CSS = `
${S}{position:relative;background:var(--band);color:var(--band-ink);font-family:var(--font-body);padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) calc(clamp(64px,8.5vw,120px) + 56px);}
${S} *{box-sizing:border-box;}
${S} .sfc-field{display:none;}
${S} .sfc-wrap{position:relative;z-index:1;display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:"head" "inputs" "result";gap:32px;max-width:40rem;margin:0 auto;}
${S} .sfc-nowrap{white-space:nowrap;}
${S} .sfc-head{grid-area:head;min-width:0;}
${S} .sfc-result{grid-area:result;min-width:0;}
${S} .sfc-inputs{grid-area:inputs;border:0;margin:0;padding:0;min-width:0;}
${S} .sfc-h2{margin:0 0 24px;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance;color:var(--band-ink);}
${S} .sfc-letter p{margin:0;max-width:64ch;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;text-wrap:pretty;color:color-mix(in oklch,var(--band-ink) 86%,var(--band));}
${S} .sfc-letter p + p{margin-top:12px;}
${S} .sfc-letter .sfc-salute{font-weight:700;color:var(--band-ink);}
${S} .sfc-letter .sfc-sign{margin-top:16px;display:flex;flex-direction:column;gap:2px;color:var(--band-ink);}
${S} .sfc-sign strong{font-weight:700;}
${S} .sfc-legend{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;padding:0;}
${S} .sfc-rows{display:grid;gap:12px;}
${S} .sfc-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:16px;row-gap:12px;padding:12px 12px 12px 16px;border-radius:var(--radius,12px);background:oklch(from var(--band-ink) l c h / .08);border:1px solid oklch(from var(--band-ink) l c h / .16);}
${S} .sfc-label{display:block;font-size:1.0625rem;font-weight:700;line-height:1.3;color:var(--band-ink);cursor:pointer;text-wrap:pretty;}
${S} .sfc-hint{display:block;margin-top:4px;font-size:.9375rem;font-weight:500;line-height:1.4;color:color-mix(in oklch,var(--band-ink) 82%,var(--band));text-wrap:pretty;}
${S} .sfc-step{display:inline-flex;align-items:center;gap:4px;height:56px;padding:4px;background:var(--field);border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));box-shadow:var(--shadow-sm,0 1px 2px ${SH} / .22));}
${S} .sfc-step:focus-within{border-color:var(--field-focus,var(--accent));}
${S} .sfc-step.is-invalid{border-color:var(--danger);box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .35);}
${S} .sfc-step-btn{display:inline-flex;align-items:center;justify-content:center;width:46px;height:46px;padding:0;border:1px solid var(--button-2-border,transparent);border-radius:calc(var(--field-radius,var(--radius,12px)) - 4px);background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));cursor:pointer;transition:background .16s ease,transform .16s ease;}
${S} .sfc-step-btn:hover:not(:disabled){background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - .05) c h);}
${S} .sfc-step-btn:active:not(:disabled){background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - .09) c h);transform:translateY(1px);}
${S} .sfc-step-btn:focus-visible{outline:3px solid oklch(from var(--field-focus,var(--accent)) l c h / .6);outline-offset:1px;}
${S} .sfc-step-btn:disabled{opacity:.4;cursor:not-allowed;}
${S} .sfc-step-input{width:56px;height:46px;padding:0;border:0;border-radius:8px;background:var(--field);color:var(--field-ink);font-family:var(--font-display);font-weight:800;font-size:clamp(1.125rem,1.5vw,1.375rem);text-align:center;font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield;}
${S} .sfc-step-input::-webkit-inner-spin-button,${S} .sfc-step-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}
${S} .sfc-step-input::placeholder{color:color-mix(in oklch,var(--field-ink) 65%,var(--field));opacity:1;}
${S} .sfc-step-input:focus-visible{outline:3px solid oklch(from var(--field-focus,var(--accent)) l c h / .45);outline-offset:0;}
${S} .sfc-error{grid-column:1 / -1;margin:0;padding:8px 12px;border-radius:10px;background:var(--danger-soft);color:var(--danger);font-size:.9375rem;font-weight:600;line-height:1.4;text-wrap:pretty;}
${S} .sfc-error svg,${S} .sfc-formula svg,${S} .sfc-reassure svg{display:inline-block;vertical-align:-.15em;margin-inline-end:.4em;}
${S} .sfc-formula{margin:16px 0 0;font-size:.9375rem;font-weight:500;line-height:1.45;color:color-mix(in oklch,var(--band-ink) 86%,var(--band));text-wrap:pretty;}
${S} .sfc-card{background:var(--card);color:var(--ink);border-radius:var(--card-radius,var(--radius,14px));border:1px solid color-mix(in oklch,var(--accent) 26%,var(--card));box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px ${SH} / .22),0 12px 24px -8px ${SH} / .32)));padding:clamp(20px,3vw,32px);}
${S} .sfc-pick{display:grid;grid-template-columns:120px minmax(0,1fr);gap:20px;align-items:start;}
${S} .sfc-pick.no-img{grid-template-columns:minmax(0,1fr);}
${S} .sfc-pick-img{display:block;width:120px;height:120px;object-fit:contain;filter:drop-shadow(0 2px 3px ${SH} / .28)) drop-shadow(0 12px 16px ${SH} / .18));}
${S} .sfc-h3{margin:0 0 14px;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;text-wrap:balance;color:var(--ink);}
${S} .sfc-days{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;margin:0;}
${S} .sfc-num{display:block;padding-block:.18em;font-family:var(--font-display);font-weight:800;letter-spacing:-0.03em;font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;font-variant-numeric:tabular-nums;color:var(--ink);}
${S} .sfc-unit{font-size:1.0625rem;font-weight:600;color:var(--muted);}
${S} .sfc-status{margin:clamp(14px,1.4vw,18px) 0 0;font-size:.9375rem;font-weight:600;line-height:1.4;text-wrap:pretty;}
${S} .is-ok{color:var(--success);}
${S} .is-short{color:var(--danger);}
${S} .sfc-well{margin-top:24px;padding:16px 16px 18px;border-radius:10px;background:color-mix(in oklch,var(--ink) 4%,var(--card));}
${S} .sfc-axis{display:flex;justify-content:space-between;gap:8px;font-size:.875rem;font-weight:800;line-height:1.2;color:var(--muted);font-variant-numeric:tabular-nums;}
${S} .sfc-bar{margin-top:16px;}
${S} .sfc-bar-head{display:flex;align-items:center;flex-wrap:wrap;column-gap:10px;row-gap:4px;}
${S} .sfc-thumb{width:36px;height:36px;object-fit:contain;filter:drop-shadow(0 1px 2px ${SH} / .25));}
${S} .sfc-bar-name{font-size:.9375rem;font-weight:600;line-height:1.3;color:var(--ink);}
${S} .sfc-bar.is-pick .sfc-bar-name{font-weight:800;}
${S} .sfc-bar-price{font-size:.9375rem;font-weight:500;color:var(--muted);font-variant-numeric:tabular-nums;}
${S} .sfc-chip{display:inline-flex;align-items:center;min-height:26px;padding:4px 12px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-size:.875rem;font-weight:800;line-height:1.2;white-space:nowrap;animation:sfc-pop .3s ease both;}
${S} .sfc-bar-out{margin-left:auto;font-size:.9375rem;font-weight:700;line-height:1.3;font-variant-numeric:tabular-nums;}
${S} .sfc-track{position:relative;margin-top:8px;height:12px;border-radius:999px;overflow:hidden;background-color:color-mix(in oklch,var(--ink) 10%,var(--card));background-image:linear-gradient(to right,oklch(from var(--ink) l c h / .2) 1px,transparent 1px);background-size:25% 100%;background-position:-1px 0;}
${S} .sfc-bar.is-pick .sfc-track{height:18px;}
${S} .sfc-fill{display:block;height:100%;border-radius:999px;background:color-mix(in oklch,var(--ink) 34%,var(--card));transition:width .45s cubic-bezier(.2,.7,.2,1);}
${S} .sfc-bar.is-pick .sfc-fill{background:linear-gradient(to right,oklch(from var(--accent-fill,var(--accent)) calc(l + .06) c h),var(--accent-fill,var(--accent)));}
${S} .sfc-fill.is-short{box-shadow:inset -4px 0 0 var(--danger);}
${S} .sfc-price{display:flex;align-items:center;flex-wrap:wrap;gap:12px 16px;margin-top:24px;}
${S} .sfc-amount{padding-block:.1em;font-family:var(--font-display);font-weight:800;letter-spacing:-0.03em;font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;font-variant-numeric:tabular-nums;color:var(--ink);}
${S} .sfc-price-side{display:flex;flex-direction:column;gap:2px;min-width:0;}
${S} .sfc-per{font-size:1.0625rem;font-weight:700;line-height:1.3;color:var(--ink);}
${S} .sfc-vs{font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted);text-wrap:pretty;}
${S} .sfc-cta{display:flex;align-items:center;justify-content:center;width:100%;min-height:64px;margin-top:20px;padding:10px 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));font-family:var(--button-font,var(--font-display));font-weight:var(--button-weight,800);text-transform:var(--button-case,none);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-align:center;text-wrap:balance;text-decoration:none;color:var(--button-ink,var(--cta-ink));text-shadow:var(--button-text-shadow,none);cursor:pointer;background:linear-gradient(oklch(from ${BG} calc(l + .04) c h),oklch(from ${BG2} calc(l - .02) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from ${BG} calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from ${BG} calc(l - .16) c h),0 1px 2px ${SH} / .3),0 8px 16px -6px ${SH} / .4));transition:transform .16s ease,box-shadow .16s ease,background .16s ease;}
${S} .sfc-cta:hover:not(:disabled),${S} .sfc-cta.is-hover{transform:translateY(-1px);background:linear-gradient(oklch(from ${BG} calc(l - .01) c h),oklch(from ${BG2} calc(l - .07) c h));box-shadow:inset 0 1px 0 oklch(from ${BG} calc(l + .12) c h / .7),inset 0 -3px 0 oklch(from ${BG} calc(l - .2) c h),0 1px 2px ${SH} / .34),0 10px 18px -6px ${SH} / .5);}
${S} .sfc-cta:active:not(:disabled),${S} .sfc-cta.is-active{transform:translateY(1px);background:linear-gradient(oklch(from ${BG} calc(l - .04) c h),oklch(from ${BG2} calc(l - .08) c h));box-shadow:inset 0 2px 4px ${SH} / .35),inset 0 -2px 0 oklch(from ${BG} calc(l - .2) c h),0 1px 2px ${SH} / .3);}
${S} .sfc-cta:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px;}
${S} .sfc-cta:disabled{cursor:not-allowed;transform:none;background:var(--secondary);color:var(--secondary-ink);text-shadow:none;box-shadow:var(--shadow-sm,0 1px 2px ${SH} / .2));}
${S} .sfc-reassure{margin:12px 0 0;text-align:center;font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted);text-wrap:pretty;}
${S} .sfc-reassure svg{color:var(--success);}
${S} .sfc-empty{margin:0;font-size:1.0625rem;line-height:1.5;color:var(--muted);text-align:center;padding:24px 0;}
${S} .sfc-reveal{animation:sfc-rise .45s cubic-bezier(.2,.7,.2,1) both;}
${S} .sfc-result.sfc-reveal{animation-delay:.07s;}
${S} .sfc-inputs.sfc-reveal{animation-delay:.14s;}
@keyframes sfc-rise{from{opacity:.82;transform:translateY(8px);}to{opacity:1;transform:none;}}
@keyframes sfc-pop{from{transform:scale(.9);}to{transform:scale(1);}}
@media (min-width:900px){
${S} .sfc-field{display:block;position:absolute;z-index:0;top:0;bottom:0;right:0;width:52%;background:var(--surface);clip-path:polygon(14% 0,100% 0,100% 100%,0 100%);}
${S} .sfc-wrap{max-width:1120px;grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);grid-template-rows:auto 1fr;grid-template-areas:"head result" "inputs result";column-gap:clamp(32px,5vw,72px);row-gap:32px;align-items:start;}
}
@media (max-width:520px){
${S} .sfc-pick{grid-template-columns:84px minmax(0,1fr);gap:16px;}
${S} .sfc-pick-img{width:84px;height:84px;}
${S} .sfc-cta{font-size:1.0625rem;padding:10px 16px;}
${S} .sfc-row{grid-template-columns:minmax(0,1fr);padding:14px;row-gap:12px;}
${S} .sfc-step{display:flex;width:100%;}
${S} .sfc-step-btn{width:52px;}
${S} .sfc-step-input{flex:1 1 auto;width:auto;min-width:0;}
${S} .sfc-well{padding:14px 14px 16px;}
}
@media (prefers-reduced-motion:reduce){
${S} .sfc-reveal,${S} .sfc-chip{animation:none;}
${S} .sfc-fill,${S} .sfc-cta,${S} .sfc-step-btn{transition:none;}
${S} .sfc-cta:hover:not(:disabled),${S} .sfc-cta.is-hover,${S} .sfc-cta:active:not(:disabled),${S} .sfc-cta.is-active{transform:none;}
}
`;
pieces/content/size-finder-calculator/specimen.tsx 63 lines
import __studioImage3ff59105 from "../assets/5d25774f71191595.webp";
import __studioImagecb9e3aaf from "../assets/0f0db4b2e3dbd253.webp";
import __studioImagea6e0e665 from "../assets/a9600b9357cb4457.webp";
import { SizeFinderCalculator } from "../size-finder-calculator";
import defaults from "../../studio-defaults.json";
import { slot } from "../../slots";
export const states = ["default", "hover", "active", "disabled", "error"];
type SpecimenState = "default" | "hover" | "active" | "disabled" | "error";
export default function SizeFinderCalculatorSpecimen({ state = "default" }: { state?: SpecimenState }) {
return (
<SizeFinderCalculator
state={state}
headline="Pick the tub that lasts your whole month"
letter={{
salutation: "Hi friend,",
paragraphs: [
"Most people grab the small tub, run dry in week three and lose the habit right when it starts working.",
"Tell me who's drinking Morrow Greens and how often. I'll show you the tub that carries you to your next order.",
],
signoff: "Talk soon,",
signer: "Ana Morrow, founder of Morrow Greens",
}}
inputs={[
{ id: "people", label: "People drinking it", hint: "Count everyone at home who'll have a glass", unit: "people", unitOne: "person", min: 1, max: 6, value: 2, placeholder: "2" },
{ id: "days", label: "Days a week", hint: "Weekends count too", unit: "days a week", unitOne: "day a week", min: 1, max: 7, value: 5, placeholder: "5" },
{ id: "scoops", label: "Scoops each time", hint: "One level scoop is one serving", unit: "scoops", unitOne: "scoop", min: 1, max: 3, value: 1, placeholder: "1" },
]}
options={[
{
id: "tub-30",
name: "30-serving tub",
servings: 30,
price: "$39",
image: slot("item-1", __studioImage3ff59105),
imageAlt: "Morrow Greens 30-serving tub",
},
{
id: "tub-60",
name: "60-serving tub",
servings: 60,
price: "$69",
image: slot("item-2", __studioImagecb9e3aaf),
imageAlt: "Morrow Greens 60-serving tub",
},
{
id: "tub-90",
name: "90-serving tub",
servings: 90,
price: "$95",
image: slot("item-3", __studioImagea6e0e665),
imageAlt: "Morrow Greens 90-serving tub",
},
]}
periodDays={30}
alternative="a $7 café green juice"
reassurance={defaults.sample.guarantee}
onAction={() => {}}
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalSizeFinderCalculator |
React.ReactNode |
|
letter OptionalSizeFinderCalculator |
{ salutation?: string; paragraphs?: React.ReactNode[]; signoff?: string; signer?: string } | null |
|
inputs OptionalSizeFinderCalculator |
SizeFinderInput[] |
|
options OptionalSizeFinderCalculator |
SizeFinderOption[] |
|
periodDays OptionalSizeFinderCalculator |
number |
|
alternative OptionalSizeFinderCalculator |
string |
|
reassurance OptionalSizeFinderCalculator |
string |
|
copy OptionalSizeFinderCalculator |
Partial<SizeFinderCopy> |
|
onAction OptionalSizeFinderCalculator |
(optionId: string) => void |
|
href OptionalSizeFinderCalculator |
string |
|
state OptionalSizeFinderCalculator |
"default" | "hover" | "active" | "disabled" | "error" |
|
className OptionalSizeFinderCalculator |
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- Secondary button.
--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
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.
-
0f0db4b2e3dbd253.webp
image/webp · 21.5 KB
-
2c539f422023a290.webp
image/webp · 115 KB
-
5d25774f71191595.webp
image/webp · 15.5 KB
-
a9600b9357cb4457.webp
image/webp · 17.6 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB