Before After Slam 1
Before/after slam: the transformation cut like a video ad (BEFORE slams, a hard wipe, AFTER slams, then the result line and a huge button land), ending as a drag-to-compare shot beside a numbered edit rail.
Use it in a prompt
Use content/before-after-slam 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/before-after-slam.tsx. - Import it and pass your copy and images (Props tab):
import { BeforeAfterSlam } from "@/components/funneldna/content/before-after-slam"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/before-after-slam/component.tsx 500 lines
// layout: number-rail
// Before/after slam: the transformation cut like a video ad (BEFORE slams, a hard wipe, AFTER slams, then the result line and a huge button land), ending as a drag-to-compare shot beside a numbered edit rail.
import React from 'react';
import { GripHorizontal, GripVertical, Pause, Play, RotateCcw } from 'lucide-react';
import { Backdrop, Divider, FX_HOST } from '../fx/fx';
import light from '../fx/backdrops/light';
const DEFAULT_COPY = {
compareLabel: 'Drag to compare before and after',
compareValue: '{before}% before, {after}% after', // {before} and {after} become the visible shares
compareHint: 'Drag to compare',
pause: 'Pause the edit',
play: 'Play the edit',
replay: 'Replay the edit',
};
export type BeforeAfterSlamCopy = typeof DEFAULT_COPY;
export type BeforeAfterSlamProps = {
/** Slot 'before': the starting shot, shown desaturated. */
beforeImage?: string;
beforeAlt?: string;
/** Slot 'after': the result from the same angle. With only one photo the edit plays that shot alone. */
afterImage?: string;
afterAlt?: string;
beforeLabel?: string; // giant word over the before shot
afterLabel?: string; // giant word over the after shot
beforeCaption?: React.ReactNode; // rail note beside 01
afterCaption?: React.ReactNode; // rail note beside 02
result?: React.ReactNode; // giant result line (h2): only what the page supplies; empty hides it
question?: React.ReactNode; // the question the button answers
actionLabel?: string;
actionNote?: React.ReactNode; // one short reassurance line under the button
href?: string;
onAction?: () => void;
disabled?: boolean;
desaturateBefore?: boolean;
backdropImage?: string; // fx backdrop asset behind the band
copy?: Partial<BeforeAfterSlamCopy>; // slider and control labels
state?: 'default' | 'hover' | 'active' | 'disabled';
className?: string;
};
type Mode = 'two' | 'one' | 'none';
export function BeforeAfterSlam(props: BeforeAfterSlamProps) {
const {
beforeImage = '',
beforeAlt = 'The before shot',
afterImage = '',
afterAlt = 'The after shot',
beforeLabel = 'Before',
afterLabel = 'After',
beforeCaption = 'Where things stand today',
afterCaption = 'Where this takes you',
result,
question = 'Ready for your own after?',
actionLabel = 'Yes, show me how',
actionNote,
href,
onAction,
desaturateBefore = true,
backdropImage = light,
state = 'default',
className,
} = props;
const copy = { ...DEFAULT_COPY, ...props.copy };
const hasBefore = Boolean(beforeImage);
const hasAfter = Boolean(afterImage);
const mode: Mode = hasBefore && hasAfter ? 'two' : hasBefore || hasAfter ? 'one' : 'none';
const forced = state !== 'default';
const disabled = Boolean(props.disabled) || state === 'disabled';
const headingId = React.useId();
const rootRef = React.useRef<HTMLElement>(null);
const stageRef = React.useRef<HTMLDivElement>(null);
const gripRef = React.useRef<HTMLDivElement>(null);
const dragging = React.useRef(false);
const armed = React.useRef(true);
const [phase, setPhase] = React.useState<'done' | 'play'>('done');
const [run, setRun] = React.useState(0);
const [paused, setPaused] = React.useState(false);
const [pos, setPos] = React.useState(50);
const [axis, setAxis] = React.useState<'x' | 'y'>('x');
const [reduced, setReduced] = React.useState(false);
const [touched, setTouched] = React.useState(false);
const closeHas = Boolean(result || question || actionLabel);
const canPlay = !forced && !reduced && (mode !== 'none' || closeHas);
const interactive = mode === 'two' && phase === 'done' && !reduced;
const lastKey = actionLabel ? 'action' : question ? 'question' : result ? 'result' : 'stage';
const start = React.useCallback(() => {
setPos(50);
setPaused(false);
setTouched(false);
setRun((r) => r + 1);
setPhase('play');
}, []);
React.useEffect(() => {
if (typeof window === 'undefined' || !window.matchMedia) return;
const mq = window.matchMedia('(prefers-reduced-motion: reduce)');
const sync = () => setReduced(mq.matches);
sync();
mq.addEventListener?.('change', sync);
return () => mq.removeEventListener?.('change', sync);
}, []);
React.useEffect(() => {
if (reduced) {
setPhase('done');
setPaused(false);
}
}, [reduced]);
React.useEffect(() => {
const el = rootRef.current;
if (!el || typeof ResizeObserver === 'undefined') return;
const ro = new ResizeObserver((entries) => {
for (const entry of entries) setAxis(entry.contentRect.width < 720 ? 'y' : 'x');
});
ro.observe(el);
return () => ro.disconnect();
}, []);
React.useEffect(() => {
const el = rootRef.current;
if (!el || !canPlay || typeof IntersectionObserver === 'undefined') return;
const io = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (!entry.isIntersecting) armed.current = true;
else if (armed.current && entry.intersectionRatio >= 0.25) {
armed.current = false;
start();
}
}
},
{ threshold: [0, 0.25] },
);
io.observe(el);
return () => io.disconnect();
}, [canPlay, start]);
const onAnimationEnd = (e: React.AnimationEvent<HTMLElement>) => {
if (phase !== 'play') return;
const t = e.target as HTMLElement;
if (t && t.dataset && t.dataset.last === 'true') setPhase('done');
};
const moveTo = (x: number, y: number) => {
const el = stageRef.current;
if (!el) return;
const r = el.getBoundingClientRect();
const ratio = axis === 'y' ? (y - r.top) / r.height : (x - r.left) / r.width;
setPos(clamp(Math.round(ratio * 1000) / 10));
setTouched(true);
};
const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
if (!interactive || e.button > 0) return;
const target = e.target as HTMLElement;
if (target.closest('.bas-ctl')) return;
const onGrip = Boolean(gripRef.current && gripRef.current.contains(target));
if (axis === 'y' && e.pointerType !== 'mouse' && !onGrip) return;
dragging.current = true;
e.currentTarget.setPointerCapture(e.pointerId);
moveTo(e.clientX, e.clientY);
};
const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
if (dragging.current) moveTo(e.clientX, e.clientY);
};
const endDrag = () => {
dragging.current = false;
};
const onGripKey = (e: React.KeyboardEvent<HTMLDivElement>) => {
if (!interactive) return;
const step = e.shiftKey ? 10 : 2;
let next: number;
switch (e.key) {
case 'ArrowLeft':
case 'ArrowUp':
next = pos - step;
break;
case 'ArrowRight':
case 'ArrowDown':
next = pos + step;
break;
case 'PageUp':
next = pos - 10;
break;
case 'PageDown':
next = pos + 10;
break;
case 'Home':
next = 0;
break;
case 'End':
next = 100;
break;
default:
return;
}
e.preventDefault();
setPos(clamp(next));
setTouched(true);
};
const valueText = copy.compareValue.replace('{before}', String(Math.round(pos))).replace('{after}', String(Math.round(100 - pos)));
const ctlLabel = phase === 'play' ? (paused ? copy.play : copy.pause) : copy.replay;
const CtlIcon = phase === 'play' ? (paused ? Play : Pause) : RotateCcw;
const onCtl = () => {
if (phase === 'play') setPaused((p) => !p);
else start();
};
const control = canPlay ? (
<button type='button' className={'bas-ctl' + (mode === 'none' ? ' bas-ctl--inline' : '')} aria-label={ctlLabel} title={ctlLabel} onClick={onCtl}>
<CtlIcon size={18} strokeWidth={2.5} aria-hidden='true' />
</button>
) : null;
const layer = (kind: 'before' | 'after' | 'solo', src: string, alt: string, label: string, gray: boolean, last: boolean) => (
<figure className={'bas-layer bas-a bas-' + kind + (gray ? ' bas-gray' : '')}>
<img className='bas-a' src={src} alt={alt} width={1600} height={900} loading='lazy' decoding='async' draggable={false} data-last={last ? 'true' : undefined} />
{label ? <figcaption className='bas-word bas-a'>{label}</figcaption> : null}
</figure>
);
const handle = (
<div className='bas-handle bas-a' data-last={lastKey === 'stage' ? 'true' : undefined}>
<span className='bas-line bas-a' aria-hidden='true' />
<div
ref={gripRef}
className='bas-grip bas-a'
role='slider'
tabIndex={interactive ? 0 : -1}
aria-label={copy.compareLabel}
aria-orientation={axis === 'y' ? 'vertical' : 'horizontal'}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={Math.round(pos)}
aria-valuetext={valueText}
aria-disabled={interactive ? undefined : true}
onKeyDown={onGripKey}
>
{axis === 'y' ? <GripHorizontal size={20} strokeWidth={2.5} aria-hidden='true' /> : <GripVertical size={20} strokeWidth={2.5} aria-hidden='true' />}
</div>
{interactive && !touched ? <span className='bas-hint' aria-hidden='true'>{copy.compareHint}</span> : null}
</div>
);
const soloLast = lastKey === 'stage' && mode === 'one';
const stage = (
<div ref={stageRef} className='bas-stage bas-a' onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={endDrag} onPointerCancel={endDrag}>
{mode === 'two' ? (
<>
{layer('before', beforeImage, beforeAlt, beforeLabel, desaturateBefore, false)}
{layer('after', afterImage, afterAlt, afterLabel, false, false)}
</>
) : hasAfter ? (
layer('solo', afterImage, afterAlt, afterLabel, false, soloLast)
) : (
layer('solo', beforeImage, beforeAlt, beforeLabel, desaturateBefore, soloLast)
)}
{mode === 'two' ? handle : null}
{control}
</div>
);
const fills: [number, number][] = mode === 'two' ? [[0, 1.15], [1.15, 1.8], [2.95, 1.13]] : mode === 'one' ? [[0, 0.95], [0.95, 1.13]] : [];
const captions: React.ReactNode[] = mode === 'two' ? [beforeCaption, afterCaption, null] : mode === 'one' ? [hasAfter ? afterCaption : beforeCaption, null] : [];
const btnClass = 'bas-btn' + (state === 'hover' ? ' is-hover' : '') + (state === 'active' ? ' is-active' : '');
const button =
href && !disabled ? (
<a className={btnClass} href={href} onClick={() => onAction?.()}>
{actionLabel}
</a>
) : (
<button type='button' className={btnClass} disabled={disabled} onClick={() => onAction?.()}>
{actionLabel}
</button>
);
return (
<section
ref={rootRef}
className={'cf-before-after-slam' + (className ? ' ' + className : '')}
aria-labelledby={result ? headingId : undefined}
data-mode={mode}
data-axis={axis}
data-phase={phase}
data-paused={paused ? 'true' : 'false'}
data-interactive={interactive ? 'true' : 'false'}
style={{ ...FX_HOST, ['--pos']: pos } as React.CSSProperties}
onAnimationEnd={onAnimationEnd}
>
<style>{CSS}</style>
<Backdrop src={backdropImage} treatment='scrim-dark' />
<div className='bas-wrap' key={run}>
{mode !== 'none' ? stage : null}
{fills.map(([delay, dur], i) => (
<div key={i} className='bas-n' data-i={i} style={{ ['--fdel']: delay + 's', ['--fdur']: dur + 's' } as React.CSSProperties}>
<span className='bas-num bas-a' aria-hidden='true'>{String(i + 1).padStart(2, '0')}</span>
<span className='bas-bar' aria-hidden='true'>
<i className='bas-a' />
</span>
{captions[i] ? <p className='bas-cap'>{captions[i]}</p> : null}
</div>
))}
{closeHas || mode === 'none' ? (
<div className='bas-close'>
{result ? (
<h2 id={headingId} className='bas-result bas-a' data-last={lastKey === 'result' ? 'true' : undefined}>
{result}
</h2>
) : null}
{question || actionLabel ? (
<div className='bas-ask'>
{question ? (
<p className='bas-q bas-a' data-last={lastKey === 'question' ? 'true' : undefined}>
{question}
</p>
) : null}
{actionLabel ? (
<div className='bas-action bas-a' data-last='true'>
{button}
{actionNote ? <p className='bas-note'>{actionNote}</p> : null}
</div>
) : null}
</div>
) : null}
{mode === 'none' ? control : null}
</div>
) : null}
</div>
<Divider shape='angle' tone='surface' height={56} />
</section>
);
}
export default BeforeAfterSlam;
function clamp(n: number) {
return Math.min(100, Math.max(0, n));
}
const R = '.cf-before-after-slam';
const CSS = `
${R} { position: relative; isolation: isolate; overflow: clip; container: bas / inline-size; background: var(--band); color: var(--band-ink); font-family: var(--font-body); padding-block: clamp(56px, 8vw, 112px) calc(clamp(64px, 8.5vw, 120px) + 56px); }
${R} *, ${R} *::before, ${R} *::after { box-sizing: border-box; }
${R}[data-mode='two'] { --d-bw: .2s; --d-j1: .41s; --d-wipe: 1.15s; --d-aw: 1.45s; --d-j2: 1.66s; --d-grip: 2.9s; --d-res: 2.95s; --d-q: 3.4s; --d-act: 3.6s; }
${R}[data-mode='one'] { --d-sw: .2s; --d-j1: .41s; --d-j2: .41s; --d-res: .95s; --d-q: 1.4s; --d-act: 1.6s; }
${R}[data-mode='none'] { --d-res: .1s; --d-q: .55s; --d-act: .75s; }
${R} .bas-wrap { position: relative; z-index: 1; max-inline-size: 1240px; margin-inline: auto; padding-inline: clamp(16px, 5vw, 48px); display: grid; grid-template-columns: minmax(0, clamp(8.5rem, 14cqi, 12.5rem)) minmax(0, 1fr); column-gap: clamp(24px, 3.6cqi, 56px); row-gap: clamp(32px, 4.5cqi, 64px); }
${R} .bas-wrap > * { min-width: 0; }
${R}[data-mode='two'] .bas-stage { grid-column: 2; grid-row: 1 / span 2; }
${R}[data-mode='two'] .bas-n[data-i='0'] { grid-column: 1; grid-row: 1; align-self: start; }
${R}[data-mode='two'] .bas-n[data-i='1'] { grid-column: 1; grid-row: 2; align-self: end; }
${R}[data-mode='two'] .bas-n[data-i='2'] { grid-column: 1; grid-row: 3; align-self: start; }
${R}[data-mode='two'] .bas-close { grid-column: 2; grid-row: 3; }
${R}[data-mode='one'] .bas-stage { grid-column: 2; grid-row: 1; }
${R}[data-mode='one'] .bas-n[data-i='0'] { grid-column: 1; grid-row: 1; align-self: start; }
${R}[data-mode='one'] .bas-n[data-i='1'] { grid-column: 1; grid-row: 2; align-self: start; }
${R}[data-mode='one'] .bas-close { grid-column: 2; grid-row: 2; }
${R}[data-mode='none'] .bas-wrap { grid-template-columns: minmax(0, 1fr); max-inline-size: 1040px; }
${R}[data-mode='none'] .bas-close { grid-column: 1; }
${R} .bas-n { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
${R} .bas-num { font-family: var(--font-display); font-weight: var(--display-weight, 800); font-size: clamp(2.5rem, 4.2cqi, 3.75rem); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--band-ink); }
${R} .bas-bar { display: block; inline-size: 100%; block-size: 4px; border-radius: 2px; overflow: hidden; background: oklch(from var(--band-ink) l c h / .2); }
${R} .bas-bar i { display: block; block-size: 100%; background: var(--accent-fill, var(--accent)); transform-origin: left center; }
${R} .bas-cap { margin: 0; font-size: clamp(1.0625rem, 1.25vw, 1.125rem); font-weight: 500; line-height: 1.4; color: var(--band-ink); text-wrap: pretty; overflow-wrap: anywhere; }
${R} .bas-stage { position: relative; container: basstage / inline-size; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: color-mix(in oklch, var(--band-ink) 8%, var(--band)); user-select: none; -webkit-user-select: none; touch-action: pan-y; }
${R}[data-axis='y'] .bas-stage { aspect-ratio: 4 / 5; touch-action: auto; }
${R}[data-interactive='true'] .bas-stage { cursor: ew-resize; }
${R}[data-interactive='true'][data-axis='y'] .bas-stage { cursor: ns-resize; }
${R} .bas-layer { position: absolute; inset: 0; margin: 0; overflow: hidden; }
${R} .bas-layer img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; object-position: center; display: block; }
${R} .bas-gray img { filter: grayscale(1) contrast(1.08) brightness(.9); }
${R} .bas-layer::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(to top, oklch(from var(--band) l c h / .86) 0%, oklch(from var(--band) l c h / .42) 32%, oklch(from var(--band) l c h / 0) 62%); }
${R}[data-axis='y'] .bas-before::after { background: linear-gradient(to bottom, oklch(from var(--band) l c h / .86) 0%, oklch(from var(--band) l c h / .42) 26%, oklch(from var(--band) l c h / 0) 48%); }
${R} .bas-word { position: absolute; z-index: 2; margin: 0; inset-block-end: clamp(14px, 4cqi, 40px); max-inline-size: 44%; font-family: var(--font-display); font-weight: var(--display-weight, 800); text-transform: uppercase; letter-spacing: -0.02em; line-height: .92; font-size: clamp(2rem, 10cqi, 8.5rem); color: var(--band-ink); text-shadow: 0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .45); overflow-wrap: anywhere; hyphens: auto; text-wrap: balance; }
${R} .bas-before .bas-word, ${R} .bas-solo .bas-word { inset-inline-start: clamp(14px, 4cqi, 40px); transform-origin: left bottom; }
${R} .bas-after .bas-word { inset-inline-end: clamp(14px, 4cqi, 40px); text-align: end; transform-origin: right bottom; }
${R} .bas-solo .bas-word { max-inline-size: calc(100% - 2 * clamp(14px, 4cqi, 40px)); font-size: clamp(2.25rem, 14cqi, 10rem); }
${R}[data-axis='y'] .bas-word { font-size: clamp(2.25rem, 16cqi, 6.5rem); max-inline-size: calc(100% - 2 * clamp(14px, 4cqi, 40px)); }
${R}[data-axis='y'] .bas-before .bas-word { inset-block-end: auto; inset-block-start: clamp(14px, 4cqi, 40px); transform-origin: left top; }
${R}[data-phase='done'][data-axis='x'] .bas-after { clip-path: inset(0 0 0 calc(var(--pos) * 1%)); }
${R}[data-phase='done'][data-axis='y'] .bas-after { clip-path: inset(calc(var(--pos) * 1%) 0 0 0); }
${R} .bas-handle { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
${R}[data-phase='done'][data-axis='x'] .bas-handle { transform: translateX(calc(var(--pos) * 1%)); }
${R}[data-phase='done'][data-axis='y'] .bas-handle { transform: translateY(calc(var(--pos) * 1%)); }
${R} .bas-line { position: absolute; inset-block: 0; left: 0; inline-size: 3px; translate: -50% 0; background: var(--band-ink); box-shadow: 0 0 0 1px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .25); }
${R}[data-axis='y'] .bas-line { inset-block: auto; top: 0; left: 0; right: 0; inline-size: auto; block-size: 3px; translate: 0 -50%; }
${R} .bas-grip { position: absolute; left: 0; top: 50%; translate: -50% -50%; inline-size: 52px; block-size: 52px; border-radius: 999px; display: grid; place-items: center; background: var(--card); color: var(--ink); box-shadow: var(--shadow-md, 0 1px 2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .22), 0 4px 10px -2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .2)); pointer-events: auto; touch-action: none; cursor: ew-resize; transition: scale .16s ease; }
${R}[data-axis='y'] .bas-grip { top: 0; left: 50%; cursor: ns-resize; }
${R} .bas-grip:hover { scale: 1.06; }
${R} .bas-grip:active { scale: .96; }
${R} .bas-grip[aria-disabled='true'] { cursor: default; }
${R} .bas-grip:focus-visible { outline: 3px solid var(--band-ink); outline-offset: 3px; }
${R} .bas-hint { position: absolute; left: 0; top: calc(50% + 40px); translate: -50% 0; display: inline-flex; align-items: center; min-block-size: 28px; padding: 4px 12px; border-radius: 999px; background: var(--band); color: var(--band-ink); font-size: .875rem; font-weight: 800; line-height: 1.2; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-sm, 0 1px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .2)); }
${R}[data-axis='y'] .bas-hint { left: 50%; top: 36px; }
${R} .bas-ctl { position: absolute; z-index: 4; inset-block-start: 12px; inset-inline-end: 12px; inline-size: 44px; block-size: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 999px; border: 1px solid oklch(from var(--band-ink) l c h / .28); background: var(--band); color: var(--band-ink); cursor: pointer; box-shadow: var(--shadow-sm, 0 1px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .2)); transition: transform .16s ease, background .16s ease; }
${R} .bas-ctl:hover { background: oklch(from var(--band) calc(l + .06) c h); }
${R} .bas-ctl:active { transform: scale(.94); }
${R} .bas-ctl:focus-visible { outline: 3px solid var(--band-ink); outline-offset: 2px; }
${R} .bas-ctl--inline { position: static; margin-top: 24px; }
${R} .bas-close { min-width: 0; }
${R} .bas-result { margin: 0 0 clamp(20px, 2.4cqi, 32px); 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.5rem, 6.2cqi, 6.25rem); line-height: 1.02; color: var(--band-ink); text-wrap: balance; overflow-wrap: anywhere; hyphens: auto; }
${R} .bas-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 20px clamp(24px, 3cqi, 48px); }
${R} .bas-ask > * { min-width: 0; }
${R} .bas-q { flex: 1 1 16rem; margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.25rem, 2.1cqi, 1.875rem); line-height: 1.2; letter-spacing: -0.01em; color: var(--band-ink); text-wrap: balance; overflow-wrap: anywhere; }
${R} .bas-action { flex: 0 1 auto; max-inline-size: 100%; display: flex; flex-direction: column; align-items: stretch; }
${R} .bas-note { margin: 12px 0 0; font-size: .9375rem; font-weight: 600; line-height: 1.4; color: var(--band-ink); text-align: center; text-wrap: pretty; }
${R} .bas-btn { display: inline-flex; align-items: center; justify-content: center; min-block-size: 72px; max-inline-size: 100%; padding: 14px clamp(28px, 3.2cqi, 44px); border: 0; border-radius: var(--button-radius, var(--radius, 12px)); background: linear-gradient(oklch(from var(--button-bg, var(--cta)) calc(l + .04) c h), oklch(from var(--button-bg-2, var(--cta-2, var(--cta))) calc(l - .02) c h)); color: var(--button-ink, var(--cta-ink, oklch(1 0 0))); 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; letter-spacing: -0.01em; text-align: center; text-decoration: none; text-wrap: balance; overflow-wrap: anywhere; text-shadow: var(--button-text-shadow, none); cursor: pointer; box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + .14) c h / .7), inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .16) c h), 0 1px 2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .4), 0 8px 16px -6px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .55)); transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
${R} .bas-btn:hover:not(:disabled), ${R} .bas-btn.is-hover { background: linear-gradient(oklch(from var(--button-bg, var(--cta)) calc(l - .01) c h), oklch(from var(--button-bg-2, var(--cta-2, var(--cta))) calc(l - .07) c h)); transform: translateY(-1px); box-shadow: inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + .12) c h / .7), inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .2) c h), 0 1px 2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .45), 0 10px 18px -6px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .65); }
${R} .bas-btn:active:not(:disabled), ${R} .bas-btn.is-active { transform: translateY(1px); background: linear-gradient(oklch(from var(--button-bg, var(--cta)) calc(l - .06) c h), oklch(from var(--button-bg-2, var(--cta-2, var(--cta))) calc(l - .08) c h)); box-shadow: inset 0 2px 4px oklch(from var(--button-bg-2, var(--cta-2, var(--cta))) calc(l - .2) c h / .55), inset 0 -2px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .16) c h), 0 1px 2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .4); }
${R} .bas-btn:focus-visible { outline: 3px solid var(--band-ink); outline-offset: 4px; }
${R} .bas-btn:disabled { cursor: not-allowed; 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)); transform: none; }
${R}[data-phase='play'] .bas-stage { animation: bas-jolt .26s ease-out var(--d-j1) none, bas-jolt .26s ease-out var(--d-j2) none; }
${R}[data-phase='play'] .bas-before img, ${R}[data-phase='play'] .bas-solo img { animation: bas-zoom 1.1s cubic-bezier(.2,.7,.2,1) 0s both; }
${R}[data-phase='play'] .bas-after img { animation: bas-zoom 1.1s cubic-bezier(.2,.7,.2,1) var(--d-wipe) both; }
${R}[data-phase='play'] .bas-before .bas-word { animation: bas-slam .38s cubic-bezier(.2,.9,.25,1) var(--d-bw) both; }
${R}[data-phase='play'] .bas-solo .bas-word { animation: bas-slam .38s cubic-bezier(.2,.9,.25,1) var(--d-sw) both; }
${R}[data-phase='play'] .bas-after .bas-word { animation: bas-slide .4s cubic-bezier(.2,.9,.25,1) var(--d-aw) both; }
${R}[data-phase='play'][data-axis='x'] .bas-after { animation: bas-wipe-x 1.76s linear var(--d-wipe) both; }
${R}[data-phase='play'][data-axis='y'] .bas-after { animation: bas-wipe-y 1.76s linear var(--d-wipe) both; }
${R}[data-phase='play'][data-axis='x'] .bas-handle { animation: bas-handle-x 1.76s linear var(--d-wipe) both; }
${R}[data-phase='play'][data-axis='y'] .bas-handle { animation: bas-handle-y 1.76s linear var(--d-wipe) both; }
${R}[data-phase='play'] .bas-line { animation: bas-fade .12s linear var(--d-wipe) both; }
${R}[data-phase='play'] .bas-grip { animation: bas-pop .34s cubic-bezier(.3,1.5,.5,1) var(--d-grip) both; }
${R}[data-phase='play'] .bas-num { animation: bas-lit .2s linear var(--fdel) both; }
${R}[data-phase='play'] .bas-bar i { animation: bas-fill var(--fdur) linear var(--fdel) both; }
${R}[data-phase='play'] .bas-result { animation: bas-mask .52s cubic-bezier(.2,.8,.2,1) var(--d-res) both; }
${R}[data-phase='play'] .bas-q { animation: bas-rise .38s cubic-bezier(.2,.7,.2,1) var(--d-q) both; }
${R}[data-phase='play'] .bas-action { animation: bas-land .48s cubic-bezier(.2,.9,.3,1) var(--d-act) both; }
${R}[data-paused='true'][data-phase][data-axis][data-mode] .bas-a.bas-a { animation-play-state: paused; }
@keyframes bas-slam { 0% { opacity: 0; transform: scale(1.9); } 50% { opacity: 1; transform: scale(.94); } 76% { transform: scale(1.03); } 100% { opacity: 1; transform: none; } }
@keyframes bas-slide { 0% { opacity: 0; transform: translateX(40%) skewX(-10deg); } 55% { opacity: 1; transform: translateX(-3%) skewX(3deg); } 100% { opacity: 1; transform: none; } }
@keyframes bas-zoom { from { transform: scale(1.12); } to { transform: none; } }
@keyframes bas-jolt { 0% { transform: none; } 30% { transform: translate3d(0, 6px, 0) scale(.992); } 65% { transform: translate3d(0, -2px, 0); } 100% { transform: none; } }
@keyframes bas-wipe-x { 0% { clip-path: inset(0 0 0 100%); animation-timing-function: cubic-bezier(.86,0,.07,1); } 27% { clip-path: inset(0 0 0 0%); } 68% { clip-path: inset(0 0 0 0%); animation-timing-function: cubic-bezier(.2,.7,.2,1); } 100% { clip-path: inset(0 0 0 50%); } }
@keyframes bas-wipe-y { 0% { clip-path: inset(100% 0 0 0); animation-timing-function: cubic-bezier(.86,0,.07,1); } 27% { clip-path: inset(0% 0 0 0); } 68% { clip-path: inset(0% 0 0 0); animation-timing-function: cubic-bezier(.2,.7,.2,1); } 100% { clip-path: inset(50% 0 0 0); } }
@keyframes bas-handle-x { 0% { transform: translateX(100%); animation-timing-function: cubic-bezier(.86,0,.07,1); } 27% { transform: translateX(0%); } 68% { transform: translateX(0%); animation-timing-function: cubic-bezier(.2,.7,.2,1); } 100% { transform: translateX(50%); } }
@keyframes bas-handle-y { 0% { transform: translateY(100%); animation-timing-function: cubic-bezier(.86,0,.07,1); } 27% { transform: translateY(0%); } 68% { transform: translateY(0%); animation-timing-function: cubic-bezier(.2,.7,.2,1); } 100% { transform: translateY(50%); } }
@keyframes bas-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bas-pop { from { opacity: 0; scale: 0; } to { opacity: 1; scale: 1; } }
@keyframes bas-lit { from { opacity: .38; } to { opacity: 1; } }
@keyframes bas-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes bas-mask { from { clip-path: inset(0 0 100% 0); transform: translateY(.35em); } to { clip-path: inset(-30% -8% -30% -8%); transform: none; } }
@keyframes bas-rise { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes bas-land { 0% { opacity: 0; transform: translateY(24px) scale(.6); } 58% { opacity: 1; transform: scale(1.06); } 80% { transform: scale(.985); } 100% { opacity: 1; transform: none; } }
@container bas (max-width: 899.98px) {
${R} .bas-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; row-gap: clamp(20px, 4cqi, 32px); }
${R}[data-mode] .bas-stage { grid-column: 1 / -1; grid-row: 1; }
${R}[data-mode='two'] .bas-n[data-i='0'] { grid-column: 1; grid-row: 2; align-self: start; }
${R}[data-mode='two'] .bas-n[data-i='1'] { grid-column: 2; grid-row: 2; align-self: start; }
${R}[data-mode='two'] .bas-n[data-i='2'] { grid-column: 1 / -1; grid-row: 3; margin-top: 16px; }
${R}[data-mode='two'] .bas-close { grid-column: 1 / -1; grid-row: 4; }
${R}[data-mode='one'] .bas-n[data-i='0'] { grid-column: 1 / -1; grid-row: 2; }
${R}[data-mode='one'] .bas-n[data-i='1'] { grid-column: 1 / -1; grid-row: 3; margin-top: 16px; }
${R}[data-mode='one'] .bas-close { grid-column: 1 / -1; grid-row: 4; }
${R} .bas-n { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; row-gap: 8px; }
${R} .bas-num { font-size: 1.75rem; }
${R} .bas-cap { grid-column: 1 / -1; font-size: .9375rem; }
${R} .bas-action { flex: 1 1 100%; }
${R} .bas-btn { inline-size: 100%; }
}
@container bas (max-width: 479.98px) {
${R} .bas-btn { min-block-size: 64px; padding-inline: 16px; font-size: 1.125rem; letter-spacing: -0.015em; }
${R} .bas-q { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
${R}[data-phase][data-axis][data-mode] .bas-a.bas-a { animation: none; }
${R}[data-phase][data-axis][data-mode] .bas-stage { aspect-ratio: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 12px; overflow: visible; border-radius: 0; background: none; touch-action: auto; cursor: auto; }
${R}[data-phase][data-axis][data-mode] .bas-stage .bas-layer { position: relative; inset: auto; aspect-ratio: 4 / 3; clip-path: none; border-radius: 12px; }
${R}[data-phase][data-axis][data-mode='one'] .bas-stage .bas-layer { aspect-ratio: 16 / 9; }
${R}[data-phase][data-axis='y'][data-mode] .bas-stage .bas-layer { aspect-ratio: 4 / 3; }
${R}[data-phase][data-axis][data-mode] .bas-stage .bas-word { font-size: clamp(2rem, 7cqi, 6rem); max-inline-size: calc(100% - 28px); }
${R}[data-phase][data-axis='y'][data-mode] .bas-stage .bas-word { font-size: clamp(2rem, 13cqi, 5rem); }
${R} .bas-handle, ${R} .bas-ctl { display: none; }
${R} .bas-btn, ${R} .bas-grip, ${R} .bas-ctl { transition: none; }
}
`;
pieces/content/before-after-slam/specimen.tsx 31 lines
import __studioImaged7314763 from "../assets/5d5798d65eb76d7a.webp";
import __studioImaged5eafa18 from "../assets/3e70c62d252d4f93.webp";
// Specimen: Greenway Landscaping (fictional) backyard makeover, cut as a before/after slam.
import React from 'react';
import { BeforeAfterSlam } from '../before-after-slam';
import { slot } from '../../slots';
import nature from '../../fx/backdrops/nature';
export const states = ['default', 'hover', 'active', 'disabled'];
type SpecimenState = 'default' | 'hover' | 'active' | 'disabled';
export default function BeforeAfterSlamSpecimen({ state = 'default' }: { state?: SpecimenState }) {
return (
<BeforeAfterSlam
state={state}
beforeImage={slot('before', __studioImaged7314763)}
beforeAlt='The backyard before the makeover: patchy brown lawn, bare soil beds and a cracked concrete slab'
afterImage={slot('after', __studioImaged5eafa18)}
afterAlt='The same backyard after the Greenway Landscaping makeover: full green lawn, stone-edged planted beds and a paver patio with a dining table'
beforeCaption='Bare beds, a patchy lawn and a slab nobody sits on'
afterCaption='Full lawn, planted borders and a patio built for dinners outside'
result='Same yard. Now it’s the best room in the house.'
question='Ready to see your yard like this?'
actionLabel='Yes, plan my yard makeover'
actionNote='Free design visit · No obligation'
href='#plan-my-yard'
backdropImage={nature}
/>
);
}
| Name | Type | Details |
|---|---|---|
beforeImage OptionalBeforeAfterSlam |
string |
|
beforeAlt OptionalBeforeAfterSlam |
string |
|
afterImage OptionalBeforeAfterSlam |
string |
|
afterAlt OptionalBeforeAfterSlam |
string |
|
beforeLabel OptionalBeforeAfterSlam |
string |
|
afterLabel OptionalBeforeAfterSlam |
string |
|
beforeCaption OptionalBeforeAfterSlam |
React.ReactNode |
|
afterCaption OptionalBeforeAfterSlam |
React.ReactNode |
|
result OptionalBeforeAfterSlam |
React.ReactNode |
|
question OptionalBeforeAfterSlam |
React.ReactNode |
|
actionLabel OptionalBeforeAfterSlam |
string |
|
actionNote OptionalBeforeAfterSlam |
React.ReactNode |
|
href OptionalBeforeAfterSlam |
string |
|
onAction OptionalBeforeAfterSlam |
() => void |
|
disabled OptionalBeforeAfterSlam |
boolean |
|
desaturateBefore OptionalBeforeAfterSlam |
boolean |
|
backdropImage OptionalBeforeAfterSlam |
string |
|
copy OptionalBeforeAfterSlam |
Partial<BeforeAfterSlamCopy> |
|
state OptionalBeforeAfterSlam |
'default' | 'hover' | 'active' | 'disabled' |
|
className OptionalBeforeAfterSlam |
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.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
after- An image this piece places.
before- An image this piece places.
-
3e70c62d252d4f93.webp
image/webp · 288 KB
-
5d5798d65eb76d7a.webp
image/webp · 264 KB
-
8276864f4b8e6ac1.webp
image/webp · 47 KB
-
f6dd01ecec4a2c0e.webp
image/webp · 105 KB