Roi Calculator 1
Lets the visitor enter their own numbers and see an estimated yearly return set against the price.
Use it in a prompt
Use content/roi-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/roi-calculator.tsx. - Import it and pass your copy and images (Props tab):
import { RoiCalculator } from "@/components/funneldna/content/roi-calculator"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/roi-calculator/component.tsx 748 lines
// Lets the visitor enter their own numbers and see an estimated yearly return set against the price.
// layout: before-after-split
// ROI calculator: the visitor's own numbers on the 'today' side, their assumed lift and the yearly estimate set
// against the price on the 'after' side, so the offer feels small next to its value. Always labelled an estimate.
import * as React from 'react'
import { AlertCircle, Calculator, Lock } from 'lucide-react'
export type RoiCalculatorValues = {
customers: number | null
averageSale: number | null
/** Assumed improvement in percent, as the visitor entered it */
improvement: number | null
/** Estimated extra sales per year from those numbers */
yearlyValue: number | null
}
export type RoiCalculatorCopy = {
beforeTitle: string
afterTitle: string
customersLabel: string
customersPlaceholder: string
averageSaleLabel: string
averageSalePlaceholder: string
improvementLabel: string
improvementPlaceholder: string
improvementHint: string
todayLabel: string
resultLabel: string
perYear: string
breakEvenLabel: string
/** Placeholder: {price} */
breakEvenNote: string
/** Placeholders: {percent}, {price} */
breakEvenLine: string
/** Placeholders: {multiple}, {price} */
multipleLine: string
invalidLabel: string
invalidNote: string
priceBarLabel: string
valueBarLabel: string
/** Accessible label for the comparison bars. Placeholders: {price}, {value} */
barsLabel: string
formula: string
customersError: string
averageSaleError: string
improvementError: string
}
export type RoiCalculatorProps = {
/** Big headline; emphasise one phrase with <span className='rc-em'> */
headline?: React.ReactNode
subhead?: React.ReactNode
productName?: string
/** Slot: product. Small product shot beside the price */
productImage?: string
productImageAlt?: string
/** Price as shown, e.g. '$47'; its number drives the comparison */
price?: string
priceNote?: string
buttonLabel?: string
/** One short line under the button */
reassurance?: string
disclaimer?: string
/** Starting customers per month */
customers?: number
/** Starting average sale */
averageSale?: number
/** The supplied improvement assumption in percent; leave unset to let the visitor choose their own */
improvement?: number
/** ISO currency used to format money */
currency?: string
/** Symbol shown inside the average-sale field */
currencySymbol?: string
locale?: string
copy?: Partial<RoiCalculatorCopy>
href?: string
onAction?: (values: RoiCalculatorValues) => void
disabled?: boolean
state?: 'default' | 'hover' | 'active' | 'disabled' | 'error'
className?: string
}
type FieldKey = 'customers' | 'averageSale' | 'improvement'
type FieldValues = Record<FieldKey, string>
const LIMITS = {
customers: [1, 100000],
averageSale: [1, 100000],
improvement: [0.1, 100],
} as const
const DEFAULT_COPY: RoiCalculatorCopy = {
beforeTitle: 'Your business today',
afterTitle: 'With your assumed lift',
customersLabel: 'Customers per month',
customersPlaceholder: '100',
averageSaleLabel: 'Average sale',
averageSalePlaceholder: '50',
improvementLabel: 'Assumed improvement',
improvementPlaceholder: '5',
improvementHint: 'Your own assumption. Start small.',
todayLabel: 'Yearly sales today',
resultLabel: 'Estimated extra sales per year',
perYear: '/yr',
breakEvenLabel: 'Lift needed to cover the kit',
breakEvenNote: 'That’s all it takes for {price} to pay for itself within a year. Enter your own lift to see your estimate.',
breakEvenLine: 'Break-even: a {percent} lift covers {price}.',
multipleLine: 'About {multiple}× the {price} price, by your numbers.',
invalidLabel: 'Your estimate',
invalidNote: 'Check your numbers to see your estimate.',
priceBarLabel: 'Kit price',
valueBarLabel: 'Your estimate',
barsLabel: 'Kit price {price} compared with your estimated {value} a year',
formula: 'Customers × average sale × your lift × 12',
customersError: 'Enter customers per month from 1 to 100,000.',
averageSaleError: 'Enter an average sale from 1 to 100,000.',
improvementError: 'Enter a lift from 0.1% to 100%.',
}
const DEFAULT_HEADLINE = (
<>
What this is <span className='rc-em'>worth to you</span>
</>
)
export function RoiCalculator(props: RoiCalculatorProps) {
const {
headline = DEFAULT_HEADLINE,
subhead = 'Plug in your own numbers. See what a small lift could add over a year.',
productName = 'The Funnel Starter Kit',
productImage,
productImageAlt = '',
price = '$47',
priceNote = 'One payment · Lifetime access',
buttonLabel = 'Get The Funnel Starter Kit',
reassurance = '',
disclaimer = 'Estimate only. Actual results vary. Revenue estimate excludes expenses.',
customers = 100,
averageSale = 50,
improvement,
currency = 'USD',
currencySymbol = '$',
locale = 'en-US',
copy: copyOverrides,
href,
onAction,
disabled = false,
state = 'default',
className,
} = props
const copy: RoiCalculatorCopy = { ...DEFAULT_COPY, ...copyOverrides }
const uid = React.useId()
const titleId = `${uid}-title`
const startValues = (s: RoiCalculatorProps['state']): FieldValues =>
s === 'error'
? { customers: '', averageSale: String(averageSale), improvement: '150' }
: {
customers: String(customers),
averageSale: String(averageSale),
improvement: improvement == null ? '' : String(improvement),
}
const startTouched = (s: RoiCalculatorProps['state']): Record<FieldKey, boolean> => {
const t = s === 'error'
return { customers: t, averageSale: t, improvement: t }
}
const [values, setValues] = React.useState<FieldValues>(() => startValues(state))
const [touched, setTouched] = React.useState<Record<FieldKey, boolean>>(() => startTouched(state))
React.useEffect(() => {
setValues(startValues(state))
setTouched(startTouched(state))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
const num = {
customers: parseNumber(values.customers),
averageSale: parseNumber(values.averageSale),
improvement: parseNumber(values.improvement),
}
const isValid = (k: FieldKey) => {
const n = num[k]
return n != null && n >= LIMITS[k][0] && n <= LIMITS[k][1]
}
const improvementEmpty = values.improvement.trim() === ''
const invalid: Record<FieldKey, boolean> = {
customers: !isValid('customers'),
averageSale: !isValid('averageSale'),
improvement: !improvementEmpty && !isValid('improvement'),
}
const errorFor = (k: FieldKey, message: string) => (touched[k] && invalid[k] ? message : undefined)
const revenue =
!invalid.customers && !invalid.averageSale ? num.customers! * num.averageSale! * 12 : null
const priceNumber = parseNumber(price)
const yearlyValue =
revenue != null && !improvementEmpty && !invalid.improvement ? revenue * (num.improvement! / 100) : null
const breakEven =
revenue != null && revenue > 0 && priceNumber != null && priceNumber > 0 ? (priceNumber / revenue) * 100 : null
const money = (n: number) => formatMoney(n, locale, currency)
let mode: 'value' | 'breakeven' | 'invalid' = 'invalid'
if (yearlyValue != null) mode = 'value'
else if (improvementEmpty && breakEven != null) mode = 'breakeven'
let label: string = copy.invalidLabel
let figure = '—'
let note: string = copy.invalidNote
if (mode === 'value' && yearlyValue != null) {
label = copy.resultLabel
figure = money(yearlyValue)
const multiple = priceNumber != null && priceNumber > 0 ? yearlyValue / priceNumber : null
if (multiple != null && multiple >= 1) {
note = fill(copy.multipleLine, { multiple: formatMultiple(multiple, locale), price })
} else if (breakEven != null) {
note = fill(copy.breakEvenLine, { percent: formatPercent(breakEven, locale), price })
} else {
note = ''
}
} else if (mode === 'breakeven' && breakEven != null) {
label = copy.breakEvenLabel
figure = formatPercent(breakEven, locale)
note = fill(copy.breakEvenNote, { price })
}
const barMax =
mode === 'value' && yearlyValue != null && priceNumber != null && priceNumber > 0
? Math.max(priceNumber, yearlyValue)
: null
const setField = (k: FieldKey) => (v: string) => setValues((prev) => ({ ...prev, [k]: v }))
const touch = (k: FieldKey) => () => setTouched((prev) => (prev[k] ? prev : { ...prev, [k]: true }))
const isDisabled = disabled || state === 'disabled'
const handleAction = (event: React.MouseEvent<HTMLElement>) => {
if (isDisabled) {
event.preventDefault()
return
}
onAction?.({
customers: invalid.customers ? null : num.customers,
averageSale: invalid.averageSale ? null : num.averageSale,
improvement: improvementEmpty || invalid.improvement ? null : num.improvement,
yearlyValue,
})
}
const ctaClass = 'rc-cta' + (state === 'hover' ? ' is-hover' : '') + (state === 'active' ? ' is-active' : '')
return (
<section className={['cf-roi-calculator', className].filter(Boolean).join(' ')} aria-labelledby={titleId}>
<style>{CSS}</style>
<header className='rc-head'>
<h2 id={titleId} className='rc-title'>
{headline}
</h2>
{subhead ? <p className='rc-sub'>{subhead}</p> : null}
</header>
<div className='rc-split'>
<div className='rc-panel rc-panel--before'>
<h3 className='rc-panel-title'>{copy.beforeTitle}</h3>
<Field
id={`${uid}-customers`}
label={copy.customersLabel}
value={values.customers}
placeholder={copy.customersPlaceholder}
inputMode='numeric'
error={errorFor('customers', copy.customersError)}
onChange={setField('customers')}
onBlur={touch('customers')}
/>
<Field
id={`${uid}-sale`}
label={copy.averageSaleLabel}
value={values.averageSale}
placeholder={copy.averageSalePlaceholder}
inputMode='decimal'
prefix={currencySymbol}
error={errorFor('averageSale', copy.averageSaleError)}
onChange={setField('averageSale')}
onBlur={touch('averageSale')}
/>
<div className='rc-today'>
<span className='rc-today-label'>{copy.todayLabel}</span>
<span className='rc-today-value'>{revenue == null ? '—' : money(revenue)}</span>
</div>
</div>
<div className='rc-divider' aria-hidden='true' />
<div className='rc-panel rc-panel--after'>
<h3 className='rc-panel-title'>{copy.afterTitle}</h3>
<Field
id={`${uid}-lift`}
label={copy.improvementLabel}
value={values.improvement}
placeholder={copy.improvementPlaceholder}
inputMode='decimal'
suffix='%'
hint={copy.improvementHint}
error={errorFor('improvement', copy.improvementError)}
onChange={setField('improvement')}
onBlur={touch('improvement')}
/>
<div className='rc-result' aria-live='polite' aria-atomic='true'>
<p className='rc-result-label'>{label}</p>
<p key={mode + figure} className={`rc-figure rc-figure--${mode}`}>
<span>{figure}</span>
{mode === 'value' ? <span className='rc-per'>{copy.perYear}</span> : null}
</p>
{note ? <p className='rc-note'>{note}</p> : null}
</div>
{barMax != null && yearlyValue != null && priceNumber != null ? (
<div
className='rc-bars'
role='img'
aria-label={fill(copy.barsLabel, { price, value: money(yearlyValue) })}
>
<div className='rc-bar'>
<span className='rc-bar-name'>{copy.priceBarLabel}</span>
<span className='rc-track'>
<span className='rc-fill rc-fill--price' style={{ width: `${(priceNumber / barMax) * 100}%` }} />
</span>
<span className='rc-bar-amount'>{price}</span>
</div>
<div className='rc-bar'>
<span className='rc-bar-name'>{copy.valueBarLabel}</span>
<span className='rc-track'>
<span className='rc-fill rc-fill--value' style={{ width: `${(yearlyValue / barMax) * 100}%` }} />
</span>
<span className='rc-bar-amount'>{money(yearlyValue)}</span>
</div>
</div>
) : null}
<div className='rc-offer'>
{productImage ? (
<img
className='rc-thumb'
src={productImage}
alt={productImageAlt}
width={64}
height={64}
loading='lazy'
decoding='async'
/>
) : null}
<div className='rc-offer-text'>
<p className='rc-offer-name'>{productName}</p>
{priceNote ? <p className='rc-offer-note'>{priceNote}</p> : null}
</div>
<p className='rc-price'>{price}</p>
</div>
<div className='rc-action'>
{href && !isDisabled ? (
<a className={ctaClass} href={href} onClick={handleAction}>
{buttonLabel}
</a>
) : (
<button type='button' className={ctaClass} onClick={handleAction} disabled={isDisabled}>
{buttonLabel}
</button>
)}
{reassurance ? (
<p className='rc-reassure'>
<Lock aria-hidden='true' />
<span>{reassurance}</span>
</p>
) : null}
</div>
</div>
</div>
<div className='rc-fine'>
<p className='rc-formula'>
<Calculator aria-hidden='true' />
<span>{copy.formula}</span>
</p>
{disclaimer ? <p className='rc-disclaimer'>{disclaimer}</p> : null}
</div>
</section>
)
}
export default RoiCalculator
function Field(props: {
id: string
label: string
value: string
placeholder: string
inputMode: 'numeric' | 'decimal'
prefix?: string
suffix?: string
hint?: string
error?: string
onChange: (value: string) => void
onBlur: () => void
}) {
const { id, label, value, placeholder, inputMode, prefix, suffix, hint, error, onChange, onBlur } = props
const noteId = `${id}-note`
const hasNote = Boolean(error || hint)
return (
<div className='rc-field'>
<label className='rc-label' htmlFor={id}>
{label}
</label>
<div className={error ? 'rc-control is-invalid' : 'rc-control'}>
{prefix ? (
<span className='rc-adorn rc-adorn--pre' aria-hidden='true'>
{prefix}
</span>
) : null}
<input
id={id}
className='rc-input'
type='text'
inputMode={inputMode}
autoComplete='off'
spellCheck={false}
value={value}
placeholder={placeholder}
aria-invalid={error ? true : undefined}
aria-describedby={hasNote ? noteId : undefined}
onChange={(e) => onChange(e.target.value)}
onBlur={onBlur}
/>
{suffix ? (
<span className='rc-adorn rc-adorn--post' aria-hidden='true'>
{suffix}
</span>
) : null}
</div>
{error ? (
<p id={noteId} className='rc-error'>
<AlertCircle aria-hidden='true' />
<span>{error}</span>
</p>
) : hint ? (
<p id={noteId} className='rc-hint'>
{hint}
</p>
) : null}
</div>
)
}
function parseNumber(raw: string): number | null {
const cleaned = raw.replace(/[^0-9.-]/g, '')
if (cleaned === '' || cleaned === '-' || cleaned === '.') return null
const n = Number(cleaned)
return Number.isFinite(n) ? n : null
}
function fill(template: string, vars: Record<string, string>): string {
return Object.keys(vars).reduce((out, key) => out.split('{' + key + '}').join(vars[key]), template)
}
function formatMoney(n: number, locale: string, currency: string): string {
const big = Math.abs(n) >= 10000000
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
notation: big ? 'compact' : 'standard',
minimumFractionDigits: 0,
maximumFractionDigits: big ? 1 : 0,
}).format(n)
}
function formatPercent(n: number, locale: string): string {
if (n < 0.01) return '<' + new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }).format(0.01) + '%'
const digits = n < 1 ? 2 : n < 10 ? 1 : 0
return new Intl.NumberFormat(locale, { maximumFractionDigits: digits }).format(n) + '%'
}
function formatMultiple(n: number, locale: string): string {
return new Intl.NumberFormat(locale, { maximumFractionDigits: n < 10 ? 1 : 0 }).format(n)
}
const CSS = `
.cf-roi-calculator {
--rc-radius: var(--card-radius, var(--radius, 12px));
--rc-well: color-mix(in oklch, var(--ink) 4%, var(--card));
--rc-hair: oklch(from var(--ink) l c h / 0.14);
--rc-btn: var(--button-bg, var(--cta));
--rc-shade: var(--shadow, oklch(0.22 0.03 260));
box-sizing: border-box;
width: 100%;
max-width: 1040px;
margin-inline: auto;
padding: clamp(1.25rem, 0.9rem + 1.8vw, 2.75rem);
background: var(--card);
color: var(--ink);
border: 1px solid var(--card-border, color-mix(in oklch, var(--ink) 12%, transparent));
border-radius: calc(var(--rc-radius) + 8px);
box-shadow: var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 260 / 0.22), 0 12px 24px -8px oklch(0.22 0.03 260 / 0.32)));
font-family: var(--font-body);
font-size: 1rem;
line-height: 1.5;
}
.cf-roi-calculator *, .cf-roi-calculator *::before, .cf-roi-calculator *::after { box-sizing: border-box; }
.cf-roi-calculator .rc-head { margin-bottom: clamp(1.5rem, 1rem + 2vw, 2.5rem); text-align: center; }
.cf-roi-calculator .rc-title {
margin: 0 0 1rem;
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, 1.4rem + 3vw, 3.5rem);
line-height: 1.04;
color: var(--ink);
text-wrap: balance;
}
.cf-roi-calculator .rc-em { color: var(--accent); }
.cf-roi-calculator .rc-sub {
margin: 0 auto;
max-width: 52ch;
font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
font-weight: 500;
line-height: 1.45;
color: var(--muted);
text-wrap: pretty;
}
.cf-roi-calculator .rc-split { display: grid; grid-template-columns: minmax(0, 1fr) 3.75rem minmax(0, 1.2fr); align-items: start; }
.cf-roi-calculator .rc-panel { min-width: 0; }
.cf-roi-calculator .rc-panel--before { padding: clamp(1.25rem, 1rem + 1vw, 2rem); background: var(--rc-well); border-radius: var(--rc-radius); }
.cf-roi-calculator .rc-panel--after { padding: clamp(1.25rem, 1rem + 1vw, 2rem) 0 0; }
.cf-roi-calculator .rc-panel-title {
margin: 0 0 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.015em);
font-size: clamp(1.3125rem, 1.15rem + 0.6vw, 1.625rem);
line-height: 1.15;
color: var(--ink);
text-wrap: balance;
}
.cf-roi-calculator .rc-divider { position: relative; align-self: stretch; }
.cf-roi-calculator .rc-divider::before { content: ''; position: absolute; top: 0.75rem; bottom: 0.75rem; left: 50%; width: 1px; background: var(--rc-hair); }
.cf-roi-calculator .rc-field + .rc-field { margin-top: 1.25rem; }
.cf-roi-calculator .rc-label { display: block; margin-bottom: 0.5rem; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; color: var(--label-ink, var(--ink)); }
.cf-roi-calculator .rc-control {
display: flex;
align-items: center;
min-height: 3.625rem;
padding-inline: 1rem;
background: var(--field);
color: var(--field-ink);
border: 1.5px solid var(--field-border, color-mix(in oklch, var(--ink) 22%, transparent));
border-radius: var(--field-radius, var(--radius));
box-shadow: inset 0 1px 2px oklch(from var(--rc-shade) l c h / 0.1);
transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cf-roi-calculator .rc-control:hover { border-color: color-mix(in oklch, var(--field-ink) 45%, var(--field)); }
.cf-roi-calculator .rc-control:focus-within { border-color: var(--field-focus, var(--accent)); box-shadow: 0 0 0 3px color-mix(in oklch, var(--field-focus, var(--accent)) 30%, transparent); }
.cf-roi-calculator .rc-control.is-invalid { border-color: var(--danger); }
.cf-roi-calculator .rc-control.is-invalid:focus-within { box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 28%, transparent); }
.cf-roi-calculator .rc-input {
flex: 1;
min-width: 0;
width: 100%;
height: 3.375rem;
margin: 0;
padding: 0;
border: 0;
outline: 0;
background: var(--field);
color: var(--field-ink);
font-family: var(--font-body);
font-size: 1.375rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.cf-roi-calculator .rc-input::placeholder { color: color-mix(in oklch, var(--field-ink) 65%, var(--field)); opacity: 1; font-weight: 500; }
.cf-roi-calculator .rc-adorn { flex: none; font-size: 1.25rem; font-weight: 800; color: var(--field-ink); }
.cf-roi-calculator .rc-adorn--pre { margin-right: 0.375rem; }
.cf-roi-calculator .rc-adorn--post { margin-left: 0.5rem; }
.cf-roi-calculator .rc-hint { margin: 0.5rem 0 0; font-size: 0.9375rem; line-height: 1.4; color: var(--muted); text-wrap: pretty; }
.cf-roi-calculator .rc-error { display: flex; align-items: flex-start; gap: 0.375rem; margin: 0.5rem 0 0; font-size: 0.9375rem; font-weight: 600; line-height: 1.35; color: var(--danger); text-wrap: pretty; }
.cf-roi-calculator .rc-error svg { flex: none; width: 1.05em; height: 1.05em; margin-top: 0.12em; }
.cf-roi-calculator .rc-today { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; margin-top: 1.75rem; }
.cf-roi-calculator .rc-today-label { font-size: 1rem; font-weight: 600; }
.cf-roi-calculator .rc-today-value { font-family: var(--font-display); font-weight: var(--display-weight, 800); font-size: 1.75rem; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cf-roi-calculator .rc-result { margin-top: 1.75rem; }
.cf-roi-calculator .rc-result-label { margin: 0 0 0.75rem; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.cf-roi-calculator .rc-figure {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0.25rem 0.5rem;
margin: 0;
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
font-size: clamp(2.875rem, 2rem + 3.6vw, 4.5rem);
line-height: 1;
letter-spacing: -0.03em;
font-variant-numeric: tabular-nums;
overflow-wrap: anywhere;
}
.cf-roi-calculator .rc-figure--value { color: var(--success); }
.cf-roi-calculator .rc-figure--breakeven { color: var(--accent); }
.cf-roi-calculator .rc-figure--invalid { color: var(--muted); }
.cf-roi-calculator .rc-per { font-size: 0.36em; font-weight: 800; letter-spacing: 0; color: var(--ink); }
.cf-roi-calculator .rc-note { margin: 0.875rem 0 0; font-size: 1.0625rem; font-weight: 500; line-height: 1.45; text-wrap: pretty; }
.cf-roi-calculator .rc-bars { display: grid; gap: 0.625rem; margin-top: 1.25rem; }
.cf-roi-calculator .rc-bar { display: grid; grid-template-columns: 7rem minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; font-size: 0.9375rem; }
.cf-roi-calculator .rc-bar-name { font-weight: 600; line-height: 1.25; color: var(--muted); }
.cf-roi-calculator .rc-track { display: block; height: 0.75rem; border-radius: 999px; background: color-mix(in oklch, var(--ink) 8%, var(--card)); overflow: hidden; }
.cf-roi-calculator .rc-fill { display: block; height: 100%; min-width: 0.375rem; border-radius: inherit; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cf-roi-calculator .rc-fill--price { background: color-mix(in oklch, var(--ink) 45%, var(--card)); }
.cf-roi-calculator .rc-fill--value { background: linear-gradient(90deg, oklch(from var(--success) calc(l + 0.1) c h), var(--success)); }
.cf-roi-calculator .rc-bar-amount { font-weight: 800; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.cf-roi-calculator .rc-offer { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; padding: 1rem 1.25rem; background: var(--rc-well); border-radius: var(--rc-radius); }
.cf-roi-calculator .rc-thumb {
flex: none;
display: block;
width: 4rem;
height: 4rem;
object-fit: cover;
object-position: center;
border-radius: calc(var(--rc-radius) * 0.6);
filter: drop-shadow(0 2px 3px oklch(from var(--rc-shade) l c h / 0.3));
}
.cf-roi-calculator .rc-offer-text { flex: 1; min-width: 0; }
.cf-roi-calculator .rc-offer-name { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.125rem; line-height: 1.2; color: var(--ink); text-wrap: balance; }
.cf-roi-calculator .rc-offer-note { margin: 0.25rem 0 0; font-size: 0.9375rem; font-weight: 500; line-height: 1.35; color: var(--ink); text-wrap: pretty; }
.cf-roi-calculator .rc-price {
flex: none;
margin: 0;
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
font-size: clamp(2rem, 1.6rem + 1.4vw, 2.625rem);
line-height: 1;
letter-spacing: -0.02em;
color: var(--ink);
font-variant-numeric: tabular-nums;
}
.cf-roi-calculator .rc-action { margin-top: 1.25rem; }
.cf-roi-calculator .rc-cta {
appearance: none;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 4rem;
margin: 0;
padding: 0.875rem 1.25rem;
border: 1px solid oklch(from var(--rc-btn) calc(l - 0.14) c h);
border-radius: var(--button-radius, var(--radius));
background: linear-gradient(oklch(from var(--rc-btn) calc(l + 0.04) 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);
text-transform: var(--button-case, none);
font-size: clamp(1.1875rem, 1.05rem + 0.5vw, 1.4375rem);
line-height: 1.15;
text-align: center;
text-wrap: balance;
text-decoration: none;
text-shadow: var(--button-text-shadow, none);
cursor: pointer;
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--rc-btn) calc(l + 0.14) c h / 0.55), inset 0 -3px 0 oklch(from var(--rc-btn) calc(l - 0.16) c h), var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));
transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.cf-roi-calculator .rc-cta:hover:not(:disabled), .cf-roi-calculator .rc-cta.is-hover {
transform: translateY(-1px);
background: linear-gradient(oklch(from var(--rc-btn) 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(--rc-btn) calc(l + 0.12) c h / 0.55), inset 0 -3px 0 oklch(from var(--rc-btn) calc(l - 0.2) c h), var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 260 / 0.22), 0 12px 24px -8px oklch(0.22 0.03 260 / 0.32)));
}
.cf-roi-calculator .rc-cta:active:not(:disabled), .cf-roi-calculator .rc-cta.is-active {
transform: translateY(1px);
background: linear-gradient(oklch(from var(--rc-btn) calc(l - 0.08) c h), oklch(from var(--button-bg-2, var(--cta-2)) calc(l - 0.08) c h));
box-shadow: inset 0 2px 3px oklch(from var(--rc-btn) calc(l - 0.24) c h / 0.5), inset 0 -1px 0 oklch(from var(--rc-btn) calc(l - 0.16) c h), var(--shadow-sm, 0 1px 1px oklch(0.22 0.03 260 / 0.18), 0 1px 3px oklch(0.22 0.03 260 / 0.14));
}
.cf-roi-calculator .rc-cta:focus-visible { outline: 3px solid var(--field-focus, var(--accent)); outline-offset: 3px; }
.cf-roi-calculator .rc-cta:disabled {
cursor: not-allowed;
transform: none;
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-roi-calculator .rc-reassure { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin: 0.75rem 0 0; font-size: 0.9375rem; font-weight: 600; line-height: 1.35; color: var(--muted); text-align: center; text-wrap: pretty; }
.cf-roi-calculator .rc-reassure svg { flex: none; width: 1em; height: 1em; }
.cf-roi-calculator .rc-fine { margin-top: clamp(1.5rem, 1rem + 1.5vw, 2.25rem); text-align: center; }
.cf-roi-calculator .rc-formula {
display: inline-flex;
align-items: center;
gap: 0.5rem;
max-width: 100%;
margin: 0;
padding: 0.5rem 0.875rem;
border-radius: 0.75rem;
background: var(--rc-well);
color: var(--ink);
font-size: 0.9375rem;
font-weight: 700;
line-height: 1.35;
text-align: left;
}
.cf-roi-calculator .rc-formula svg { flex: none; width: 1.1em; height: 1.1em; color: var(--accent); }
.cf-roi-calculator .rc-disclaimer { margin: 0.75rem auto 0; max-width: 62ch; font-size: 0.875rem; line-height: 1.5; color: var(--muted); text-wrap: pretty; }
@keyframes cf-roi-calculator-pop {
from { opacity: 0.55; transform: translateY(4px); }
to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
.cf-roi-calculator .rc-figure { animation: cf-roi-calculator-pop 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
}
@media (max-width: 760px) {
.cf-roi-calculator .rc-split { grid-template-columns: minmax(0, 1fr); }
.cf-roi-calculator .rc-divider { height: 2.5rem; }
.cf-roi-calculator .rc-divider::before { top: 50%; bottom: auto; left: 0; right: 0; width: auto; height: 1px; }
.cf-roi-calculator .rc-panel--after { padding-top: 0; }
.cf-roi-calculator .rc-bar { grid-template-columns: 5.75rem minmax(0, 1fr) auto; gap: 0.5rem; }
.cf-roi-calculator .rc-bar-name { font-size: 0.875rem; }
}
@media (max-width: 420px) {
.cf-roi-calculator .rc-panel--before { padding: 1.125rem; }
.cf-roi-calculator .rc-offer { gap: 0.75rem; padding: 0.875rem; }
.cf-roi-calculator .rc-thumb { width: 3.25rem; height: 3.25rem; }
}
@media (prefers-reduced-motion: reduce) {
.cf-roi-calculator *, .cf-roi-calculator *::before, .cf-roi-calculator *::after { transition: none !important; animation: none !important; }
.cf-roi-calculator .rc-cta:hover:not(:disabled), .cf-roi-calculator .rc-cta.is-hover, .cf-roi-calculator .rc-cta:active:not(:disabled), .cf-roi-calculator .rc-cta.is-active { transform: none; }
}
`
pieces/content/roi-calculator/specimen.tsx 25 lines
import * as React from 'react'
import { RoiCalculator } from '../roi-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 RoiCalculatorSpecimen({ state = 'default' }: { state?: SpecimenState }) {
const sample = defaults.sample
const product = sample.items[0]
return (
<RoiCalculator
productName={sample.name}
productImage={slot('product', product.image)}
productImageAlt={product.imageAlt}
price={sample.price}
priceNote={sample.note}
buttonLabel={'Get ' + sample.name}
reassurance={sample.sublabel}
state={state}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalRoiCalculator |
React.ReactNode |
|
subhead OptionalRoiCalculator |
React.ReactNode |
|
productName OptionalRoiCalculator |
string |
|
productImage OptionalRoiCalculator |
string |
|
productImageAlt OptionalRoiCalculator |
string |
|
price OptionalRoiCalculator |
string |
|
priceNote OptionalRoiCalculator |
string |
|
buttonLabel OptionalRoiCalculator |
string |
|
reassurance OptionalRoiCalculator |
string |
|
disclaimer OptionalRoiCalculator |
string |
|
customers OptionalRoiCalculator |
number |
|
averageSale OptionalRoiCalculator |
number |
|
improvement OptionalRoiCalculator |
number |
|
currency OptionalRoiCalculator |
string |
|
currencySymbol OptionalRoiCalculator |
string |
|
locale OptionalRoiCalculator |
string |
|
copy OptionalRoiCalculator |
Partial<RoiCalculatorCopy> |
|
href OptionalRoiCalculator |
string |
|
onAction OptionalRoiCalculator |
(values: RoiCalculatorValues) => void |
|
disabled OptionalRoiCalculator |
boolean |
|
state OptionalRoiCalculator |
'default' | 'hover' | 'active' | 'disabled' | 'error' |
|
className OptionalRoiCalculator |
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--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.
product- The main product shot or cover (ebook, kit, bottle).
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB