Scrub Highlight Sentence 1
Scrub highlight sentence: one big argument paragraph whose key phrases get a highlighter swipe, left to right in sync with scroll, then add up in a short ledger so the reader keeps the argument's spine, not just the words.
Use it in a prompt
Use content/scrub-highlight-sentence 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/scrub-highlight-sentence.tsx. - Import it and pass your copy and images (Props tab):
import { ScrubHighlightSentence } from "@/components/funneldna/content/scrub-highlight-sentence"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/scrub-highlight-sentence/component.tsx 359 lines
// layout: ledger-receipt
// Scrub highlight sentence: one big argument paragraph whose key phrases get a highlighter swipe, left to right in sync with scroll, then add up in a short ledger so the reader keeps the argument's spine, not just the words.
import React, { Fragment, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Check } from "lucide-react";
import { BackdropVideo, FX_HOST } from "../fx/fx";
import steam from "../fx/loops/steam";
export type ScrubHighlightSentenceProps = {
/** Short band headline above the paragraph (h2). Empty shows the paragraph alone. */
headline?: React.ReactNode;
/** The argument, 3 to 5 sentences. Wrap each key phrase in double equals signs: "and ==this phrase lights up==." */
paragraph?: string;
/** Italic aside in the author's voice, under the paragraph. */
aside?: React.ReactNode;
/** Bold line that adds the lit phrases up (the ledger's total line). */
summary?: React.ReactNode;
/** Show the ledger of lit phrases under the paragraph. */
showLedger?: boolean;
/** Scrub the highlights with scroll; false shows every highlight at once. */
scrub?: boolean;
/** Looping fx backdrop behind the dark band (an imported fx loop); null for a plain band. */
backdrop?: typeof steam | null;
/** count: ledger tally, placeholders {lit} and {total}. regionLabel: accessible name when there is no headline. */
copy?: { count?: string; regionLabel?: string };
className?: string;
};
const DEFAULT_HEADLINE = "It was never about trying harder.";
const DEFAULT_PARAGRAPH =
"You don’t need more willpower. You need ==fewer decisions between you and the result==. When the plan is made ==before your busy week begins==, the hard choices are already behind you. So instead of starting from zero every day, you ==decide once and simply follow through==. ==The plan does the remembering==, and you get to do the living.";
const DEFAULT_ASIDE = "(I know. I didn’t believe it either.)";
const DEFAULT_SUMMARY = "Decide once. Then follow the plan.";
const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
export function ScrubHighlightSentence({
headline = DEFAULT_HEADLINE,
paragraph = DEFAULT_PARAGRAPH,
aside = DEFAULT_ASIDE,
summary = DEFAULT_SUMMARY,
showLedger = true,
scrub = true,
backdrop = steam,
copy,
className,
}: ScrubHighlightSentenceProps) {
const countTemplate = copy?.count ?? "{lit} of {total} lit";
const regionLabel = copy?.regionLabel ?? "The argument, highlighted";
const text = paragraph ?? "";
const parts = useMemo(() => parseParagraph(text), [text]);
const phrases = parts.filter((p): p is PhrasePart => p.kind === "phrase");
const total = phrases.length;
const headId = useId();
const rootRef = useRef<HTMLElement>(null);
const textRef = useRef<HTMLParagraphElement>(null);
const [motion, setMotion] = useState(false);
const [lit, setLit] = useState(total);
useIsoLayoutEffect(() => {
const root = rootRef.current;
const para = textRef.current;
if (!scrub || !root || !para || total === 0 || typeof window === "undefined") {
setMotion(false);
setLit(total);
return;
}
const phraseEls = Array.from(para.querySelectorAll<HTMLElement>(".cf-scrub__ph"));
const wordEls = phraseEls.map((el) => Array.from(el.querySelectorAll<HTMLElement>(".cf-scrub__w")));
const spans = wordEls.map((ws) => {
const lens = ws.map((w) => Math.max(1, (w.textContent || "").length));
const sum = lens.reduce((a, b) => a + b, 0);
let acc = 0;
return lens.map((l) => {
const a = acc / sum;
acc += l;
return [a, acc / sum] as [number, number];
});
});
const n = wordEls.length;
let raf = 0;
let last = -1;
let lastLit = -1;
let near = true;
let on = false;
const frame = () => {
raf = 0;
if (!on) return;
const vh = window.innerHeight || 1;
const r = para.getBoundingClientRect();
const se = document.scrollingElement || document.documentElement;
const y = window.scrollY || se.scrollTop || 0;
const maxY = Math.max(0, se.scrollHeight - vh);
let from = vh * 0.72;
let to = vh * 0.5 - r.height;
const topAtStart = r.top + y;
const topAtEnd = r.top - (maxY - y);
if (topAtStart < from) from = topAtStart;
if (topAtEnd > to) to = topAtEnd;
const range = from - to;
const raw = range < 2 ? 1 : (from - r.top) / range;
const prog = Math.round(clamp01(raw) * 500) / 500;
if (prog === last) return;
last = prog;
let done = 0;
for (let i = 0; i < n; i++) {
const pp = clamp01((prog * n - i) / 0.85);
if (pp >= 1) done++;
const ws = wordEls[i];
const sp = spans[i];
for (let j = 0; j < ws.length; j++) {
const [a, b] = sp[j];
ws[j].style.setProperty("--p", clamp01((pp - a) / (b - a)).toFixed(3));
}
}
if (done !== lastLit) {
lastLit = done;
setLit(done);
}
};
const schedule = () => {
if (!on || !near || raf) return;
raf = window.requestAnimationFrame(frame);
};
const onResize = () => {
last = -1;
schedule();
};
const reset = () => {
wordEls.forEach((ws) => ws.forEach((w) => w.style.removeProperty("--p")));
};
const start = () => {
on = true;
last = -1;
lastLit = -1;
setMotion(true);
frame();
};
const stop = () => {
on = false;
if (raf) window.cancelAnimationFrame(raf);
raf = 0;
reset();
setMotion(false);
setLit(total);
};
const mq = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
const apply = () => {
if (mq && mq.matches) stop();
else start();
};
const io =
"IntersectionObserver" in window
? new IntersectionObserver(
(entries) => {
near = entries.some((e) => e.isIntersecting);
if (near) {
last = -1;
schedule();
}
},
{ rootMargin: "25% 0px" },
)
: null;
apply();
window.addEventListener("scroll", schedule, { passive: true });
window.addEventListener("resize", onResize);
if (io) io.observe(root);
if (mq) {
if (typeof mq.addEventListener === "function") mq.addEventListener("change", apply);
else mq.addListener(apply);
}
return () => {
on = false;
if (raf) window.cancelAnimationFrame(raf);
window.removeEventListener("scroll", schedule);
window.removeEventListener("resize", onResize);
if (io) io.disconnect();
if (mq) {
if (typeof mq.removeEventListener === "function") mq.removeEventListener("change", apply);
else mq.removeListener(apply);
}
reset();
setMotion(false);
};
}, [scrub, total, text]);
const hasHead = headline !== undefined && headline !== null && headline !== "";
const hasText = text.trim() !== "";
if (!hasHead && !hasText) return null;
const showCount = showLedger && total > 0;
const hasSummary = summary !== undefined && summary !== null && summary !== "";
return (
<section
ref={rootRef}
className={["cf-scrub", hasText ? "" : "is-headonly", className].filter(Boolean).join(" ")}
data-scrub={motion ? "on" : undefined}
aria-labelledby={hasHead ? headId : undefined}
aria-label={hasHead ? undefined : regionLabel}
>
<style>{CSS}</style>
<div className="cf-scrub__band" style={FX_HOST}>
{backdrop ? <BackdropVideo video={backdrop} treatment="scrim-dark" control="top-right" /> : null}
{hasHead ? (
<div className="cf-scrub__head">
<h2 id={headId} className="cf-scrub__h">
{headline}
</h2>
</div>
) : null}
</div>
{hasText ? (
<div className="cf-scrub__stage">
<div className="cf-scrub__card">
<p ref={textRef} className="cf-scrub__text">
{parts.map((part, i) =>
part.kind === "text" ? (
<Fragment key={i}>{part.text}</Fragment>
) : (
<mark key={i} className="cf-scrub__ph">
{part.words.map((w, j) => (
<span
key={j}
className={
"cf-scrub__w" +
(j === 0 ? " is-start" : "") +
(j === part.words.length - 1 ? " is-end" : "")
}
>
{w}
{j < part.words.length - 1 ? " " : ""}
</span>
))}
</mark>
),
)}
</p>
{aside ? <p className="cf-scrub__aside">{aside}</p> : null}
{showLedger && total > 0 ? (
<ol className="cf-scrub__ledger" aria-hidden="true">
{phrases.map((p, i) => {
const isLit = !motion || i < lit;
return (
<li key={i} className={"cf-scrub__row" + (isLit ? " is-lit" : "")}>
<span className="cf-scrub__num">{String(i + 1).padStart(2, "0")}</span>
<span className="cf-scrub__item">{p.label}</span>
<span className="cf-scrub__leader" />
<span className="cf-scrub__badge">
<Check size={16} strokeWidth={3} />
</span>
</li>
);
})}
</ol>
) : null}
{hasSummary || showCount ? (
<div className="cf-scrub__total">
{hasSummary ? <p className="cf-scrub__sum">{summary}</p> : <span />}
{showCount ? (
<span className="cf-scrub__count" aria-hidden="true">
{fillCount(countTemplate, motion ? lit : total, total)}
</span>
) : null}
</div>
) : null}
</div>
</div>
) : null}
</section>
);
}
export default ScrubHighlightSentence;
type TextPart = { kind: "text"; text: string };
type PhrasePart = { kind: "phrase"; words: string[]; label: string };
type Part = TextPart | PhrasePart;
function parseParagraph(source: string): Part[] {
const parts: Part[] = [];
const re = /==([\s\S]+?)==/g;
let cursor = 0;
let m: RegExpExecArray | null;
while ((m = re.exec(source)) !== null) {
if (m.index > cursor) parts.push({ kind: "text", text: source.slice(cursor, m.index) });
const inner = m[1].trim();
let end = re.lastIndex;
const trail = /^[.,;:!?)”’]+/.exec(source.slice(end));
if (trail) {
end += trail[0].length;
re.lastIndex = end;
}
if (inner) {
const clean = inner.replace(/[.,;:]+$/, "");
parts.push({
kind: "phrase",
words: (inner + (trail ? trail[0] : "")).split(/\s+/),
label: clean.charAt(0).toUpperCase() + clean.slice(1),
});
} else if (trail) {
parts.push({ kind: "text", text: trail[0] });
}
cursor = end;
}
if (cursor < source.length) parts.push({ kind: "text", text: source.slice(cursor) });
return parts;
}
function fillCount(template: string, lit: number, total: number) {
return template.split(/({lit}|{total})/).map((s, i) =>
s === "{lit}" ? <b key={i}>{lit}</b> : s === "{total}" ? <b key={i}>{total}</b> : <Fragment key={i}>{s}</Fragment>,
);
}
function clamp01(v: number) {
return v < 0 ? 0 : v > 1 ? 1 : v;
}
const CSS = `
.cf-scrub{--scrub-marker:var(--scrub-marker-color,color-mix(in oklab,var(--marker,#fae37c) 50%,var(--card,oklch(1 0 0))));--scrub-lift:clamp(88px,11vw,160px);--scrub-gutter:clamp(16px,5vw,48px);--scrub-pad:clamp(20px,4vw,48px);position:relative;background:var(--surface,oklch(1 0 0));color:var(--ink,oklch(0.21 0.034 263));font-family:var(--font-body);padding-bottom:clamp(64px,8.5vw,120px);overflow-x:clip}
.cf-scrub *,.cf-scrub *::before,.cf-scrub *::after{box-sizing:border-box}
.cf-scrub__band{position:relative;background:var(--band,oklch(0.27 0.067 256));color:var(--band-ink,oklch(1 0 0));padding:clamp(56px,8vw,112px) var(--scrub-gutter) calc(var(--scrub-lift) + clamp(32px,4vw,56px))}
.cf-scrub.is-headonly .cf-scrub__band{padding-bottom:clamp(64px,8.5vw,120px)}
.cf-scrub.is-headonly{padding-bottom:0}
.cf-scrub__head{position:relative;z-index:1;max-width:56rem;margin:0 auto;padding-inline:calc(var(--scrub-pad) + 1px)}
.cf-scrub__h{margin:0;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;color:var(--band-ink,oklch(1 0 0));text-wrap:balance}
.cf-scrub__stage{position:relative;z-index:2;padding-inline:var(--scrub-gutter);margin-top:calc(-1 * var(--scrub-lift))}
.cf-scrub__card{max-width:56rem;margin:0 auto;background:var(--card,oklch(1 0 0));color:var(--ink,oklch(0.21 0.034 263));border:1px solid var(--card-border,oklch(from var(--ink,oklch(0.21 0.034 263)) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));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)));padding:clamp(24px,4.5vw,56px) var(--scrub-pad)}
.cf-scrub__text{margin:0;max-width:62ch;font-family:var(--font-display);font-weight:600;font-size:clamp(1.5rem,2.55vw,2.125rem);line-height:1.4;letter-spacing:-0.012em;color:var(--ink,oklch(0.21 0.034 263));text-wrap:pretty}
.cf-scrub__ph{background:none;color:inherit;padding:0}
.cf-scrub__w{--scrub-fill:1;background-image:linear-gradient(var(--scrub-marker),var(--scrub-marker));background-repeat:no-repeat;background-position:0 88%;background-size:calc(var(--scrub-fill) * 100%) 0.7em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-scrub__w.is-start{padding-left:0.14em;margin-left:-0.14em}
.cf-scrub__w.is-end{padding-right:0.1em;margin-right:-0.1em}
.cf-scrub[data-scrub="on"] .cf-scrub__w{--scrub-fill:var(--p,0)}
.cf-scrub__aside{margin:24px 0 0;font-family:var(--font-body);font-style:italic;font-weight:500;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));text-wrap:pretty}
.cf-scrub__ledger{list-style:none;margin:clamp(28px,3.5vw,40px) 0 0;padding:0;display:grid;gap:2px}
.cf-scrub__row{display:flex;align-items:center;gap:12px 16px;padding-block:8px;min-height:48px}
.cf-scrub__num{flex:none;min-width:2ch;font-family:var(--font-display);font-weight:800;font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;font-variant-numeric:tabular-nums;color:var(--accent,oklch(0.5 0.17 257));transition:color .16s ease}
.cf-scrub__item{flex:0 1 auto;min-width:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:700;line-height:1.35;color:var(--ink,oklch(0.21 0.034 263));text-wrap:pretty;transition:color .16s ease}
.cf-scrub__leader{flex:1 1 16px;min-width:16px;height:1px;background:oklch(from var(--ink,oklch(0.21 0.034 263)) l c h / 0.16)}
.cf-scrub__badge{flex:none;display:grid;place-items:center;width:28px;height:28px;margin-left:auto;border-radius:999px;background:var(--success,oklch(0.5 0.137 150));color:var(--scrub-badge-ink,#fff);transition:background-color .16s ease,transform .3s ease}
.cf-scrub__badge svg{display:block;transition:opacity .16s ease}
.cf-scrub__row:not(.is-lit) .cf-scrub__num,.cf-scrub__row:not(.is-lit) .cf-scrub__item{color:var(--muted,oklch(0.45 0.03 258))}
.cf-scrub__row:not(.is-lit) .cf-scrub__badge{background:var(--secondary,color-mix(in oklch,var(--ink,oklch(0.21 0.034 263)) 8%,var(--card,oklch(1 0 0))));transform:scale(.9)}
.cf-scrub__row:not(.is-lit) .cf-scrub__badge svg{opacity:0}
.cf-scrub__total{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:6px 24px;margin-top:28px;padding:16px 20px;border-radius:10px;background:color-mix(in oklch,var(--ink,oklch(0.21 0.034 263)) 4%,var(--card,oklch(1 0 0)))}
.cf-scrub__ledger + .cf-scrub__total{margin-top:12px}
.cf-scrub__sum{margin:0;min-width:0;font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:-0.01em;font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;color:var(--ink,oklch(0.21 0.034 263));text-wrap:balance}
.cf-scrub__count{font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));white-space:nowrap;font-variant-numeric:tabular-nums}
.cf-scrub__count b{font-family:var(--font-display);font-weight:800;color:var(--ink,oklch(0.21 0.034 263))}
@media (max-width:640px){.cf-scrub__row{align-items:flex-start;gap:12px}.cf-scrub__num{min-width:2.2ch}.cf-scrub__leader{display:none}.cf-scrub__badge{width:24px;height:24px;margin-top:1px}.cf-scrub__total{padding:14px 16px}}
@media (prefers-reduced-motion: reduce){.cf-scrub[data-scrub] .cf-scrub__w{--scrub-fill:1}.cf-scrub *{transition:none}}
`;
pieces/content/scrub-highlight-sentence/specimen.tsx 18 lines
// Specimen: Sprout Supper meal plans, the argument that dinner is a decision problem, not a cooking problem.
import ScrubHighlightSentence from "../scrub-highlight-sentence";
import steam from "../../fx/loops/steam";
export const states = ["default"];
export default function ScrubHighlightSentenceSpecimen(_props: { state?: string }) {
return (
<ScrubHighlightSentence
headline="Dinner was never the hard part. Deciding was."
paragraph="By six o’clock you’ve made decision after decision all day, and ==dinner is one decision too many==. Sprout Supper lets you ==make that call once, on Sunday==, when you actually have the head space. You pick the week’s meals in one sitting, ==the shopping list builds itself==, and every weeknight starts with ==a plan already on the counter==. The fridge stops asking questions. You stop answering them."
aside="(I know. I used to blame my recipes too.)"
summary="Decide on Sunday. Coast all week."
backdrop={steam}
copy={{ count: "{lit} of {total} lit", regionLabel: "Why Sprout Supper works" }}
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalScrubHighlightSentence |
React.ReactNode |
Default DEFAULT_HEADLINE
|
paragraph OptionalScrubHighlightSentence |
string |
Default DEFAULT_PARAGRAPH
|
aside OptionalScrubHighlightSentence |
React.ReactNode |
Default DEFAULT_ASIDE
|
summary OptionalScrubHighlightSentence |
React.ReactNode |
Default DEFAULT_SUMMARY
|
showLedger OptionalScrubHighlightSentence |
boolean |
Default true
|
scrub OptionalScrubHighlightSentence |
boolean |
Default true
|
backdrop OptionalScrubHighlightSentence |
typeof steam | null |
Default steam
|
copy OptionalScrubHighlightSentence |
{ count?: string; regionLabel?: string } |
|
className OptionalScrubHighlightSentence |
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.
--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.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.
-
3280957150211a63.webp
image/webp · 25.4 KB
- 741f8b94f6c0ae1c.webm video/webm · 168 KB
- e5a55080678e557b.mp4 video/mp4 · 186 KB