Spotlight Text 1
Spotlight text: an editorial spread on a dark band where a soft spotlight lights the reader's words as the pointer moves or the page scrolls.
Use it in a prompt
Use content/spotlight-text 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/spotlight-text.tsx. - Import it and pass your copy and images (Props tab):
import { SpotlightText } from "@/components/funneldna/content/spotlight-text"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/spotlight-text/component.tsx 399 lines
// layout: magazine-spread
// Spotlight text: an editorial spread on a dark band where a soft spotlight lights the reader's words as the pointer moves or the page scrolls.
// One idea of the argument is discovered, not skimmed. The real text is always readable underneath, and one key phrase stays lit in the accent.
import { useEffect, useId, useRef } from "react";
import type { ComponentProps, CSSProperties, ReactNode } from "react";
import { Backdrop, Divider, FX_HOST } from "../fx/fx";
import night from "../fx/backdrops/night";
export type SpotlightTextProps = {
/** Editorial headline on the left page of the spread (h2). */
headline?: ReactNode;
/** The spotlight paragraph: 2 to 4 big sentences. An empty string renders nothing. */
text?: string;
/** A phrase inside `text` that stays permanently lit in the accent (first match, case-insensitive). */
litPhrase?: string;
/** One short supporting line under the headline. */
note?: ReactNode;
/** Dark band (default) or light surface band. */
tone?: "dark" | "light";
/** Backdrop photo (an imported fx backdrop URL). The page's `scene` image replaces it. `null` removes it. */
backdrop?: string | null;
/** Backdrop treatment; defaults to a dark or light scrim to match the tone. */
backdropTreatment?: ComponentProps<typeof Backdrop>["treatment"];
/** Optional shaped hand-off edge at the bottom of the band (off by default: the band ends clean). */
edge?: "step" | "chevron" | "none";
/** Token of the section that follows, coloured into the edge. */
edgeTone?: ComponentProps<typeof Divider>["tone"];
/** Studio state: "hover" pins the spotlight in place for review. */
state?: "default" | "hover";
className?: string;
};
const DEFAULT_HEADLINE = "The problem was never your effort.";
const DEFAULT_TEXT =
"You followed the advice. You put in the hours, tried again, and blamed yourself when it still didn’t work. But effort was never the missing piece. The missing piece was the right plan, and that is what the rest of this page lays out.";
const DEFAULT_LIT = "the right plan";
const DEFAULT_NOTE = "Take a second with this one. Everything below builds on it.";
const EDGE_HEIGHT = 48;
export function SpotlightText(props: SpotlightTextProps) {
const {
headline = DEFAULT_HEADLINE,
text = DEFAULT_TEXT,
note = DEFAULT_NOTE,
tone = "dark",
backdrop = night,
backdropTreatment,
edge = "none",
edgeTone,
state = "default",
className,
} = props;
// The default lit phrase only applies to the default paragraph, so custom copy never inherits a stray highlight.
const litPhrase = props.litPhrase ?? (props.text === undefined ? DEFAULT_LIT : undefined);
const body = (text ?? "").trim();
const rootRef = useRef<HTMLElement>(null);
const stageRef = useRef<HTMLDivElement>(null);
const headingId = useId();
useEffect(() => {
const root = rootRef.current;
const stage = stageRef.current;
if (!root || !stage || !body) return;
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
const fine = window.matchMedia("(hover: hover) and (pointer: fine)");
const setSpot = (x: number, y: number) => {
stage.style.setProperty("--spot-x", `${x.toFixed(1)}px`);
stage.style.setProperty("--spot-y", `${y.toFixed(1)}px`);
};
const goLive = () => {
if (reduce.matches) delete root.dataset.live;
else root.dataset.live = "true";
};
if (state === "hover") {
const r = stage.getBoundingClientRect();
setSpot(r.width * 0.42, r.height * 0.36);
goLive();
reduce.addEventListener("change", goLive);
return () => {
reduce.removeEventListener("change", goLive);
delete root.dataset.live;
};
}
goLive();
let raf = 0;
let visible = false;
let pointerActive = false;
let started = false;
let cx = 0;
let cy = 0;
let tx = 0;
let ty = 0;
// Scroll mode: the light sits on a reading line at mid-viewport and sweeps gently across the lines.
const scrollTarget = () => {
const r = stage.getBoundingClientRect();
ty = window.innerHeight * 0.5 - r.top;
tx = r.width * (0.5 + 0.3 * Math.sin(ty / 150));
};
const tick = () => {
raf = 0;
if (!pointerActive) scrollTarget();
if (!started) {
cx = tx;
cy = ty;
started = true;
}
cx += (tx - cx) * 0.2;
cy += (ty - cy) * 0.2;
setSpot(cx, cy);
if (Math.abs(tx - cx) > 0.5 || Math.abs(ty - cy) > 0.5) raf = requestAnimationFrame(tick);
};
const kick = () => {
if (!raf && !reduce.matches) raf = requestAnimationFrame(tick);
};
const onScroll = () => {
if (visible) kick();
};
const onMove = (e: PointerEvent) => {
if (e.pointerType === "touch" || !fine.matches) return;
const r = stage.getBoundingClientRect();
pointerActive = true;
tx = e.clientX - r.left;
ty = e.clientY - r.top;
kick();
};
const onLeave = () => {
pointerActive = false;
kick();
};
const io = new IntersectionObserver((entries) => {
visible = entries.some((entry) => entry.isIntersecting);
if (visible) kick();
});
io.observe(stage);
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerleave", onLeave);
reduce.addEventListener("change", goLive);
return () => {
if (raf) cancelAnimationFrame(raf);
io.disconnect();
window.removeEventListener("scroll", onScroll);
window.removeEventListener("resize", onScroll);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerleave", onLeave);
reduce.removeEventListener("change", goLive);
delete root.dataset.live;
};
}, [state, body]);
if (!body) return null;
const treatment = backdropTreatment ?? (tone === "light" ? "scrim-light" : "scrim-dark");
const nextTone = edgeTone ?? (tone === "light" ? "band" : "surface");
const rootStyle = {
...FX_HOST,
overflow: "clip",
"--st-edge": edge === "none" ? "0px" : `${EDGE_HEIGHT}px`,
} as CSSProperties;
return (
<section
ref={rootRef}
className={["cf-spotlight-text", className].filter(Boolean).join(" ")}
data-tone={tone}
aria-labelledby={headline ? headingId : undefined}
style={rootStyle}
>
<style>{CSS}</style>
{backdrop ? <Backdrop src={backdrop} treatment={treatment} /> : null}
<div className="cf-spotlight-text__inner">
{headline || note ? (
<div className="cf-spotlight-text__aside cf-spotlight-text__rise">
{headline ? (
<h2 id={headingId} className="cf-spotlight-text__headline">
{headline}
</h2>
) : null}
{note ? <p className="cf-spotlight-text__note">{note}</p> : null}
</div>
) : null}
<div
ref={stageRef}
className={["cf-spotlight-text__stage", "cf-spotlight-text__rise", headline || note ? "" : "is-solo"]
.filter(Boolean)
.join(" ")}
>
<span className="cf-spotlight-text__pool" aria-hidden="true" />
<p className="cf-spotlight-text__text cf-spotlight-text__base">{renderWords(body, litPhrase, true)}</p>
<div className="cf-spotlight-text__text cf-spotlight-text__lit" aria-hidden="true">
{renderWords(body, litPhrase, false)}
</div>
</div>
</div>
{edge !== "none" && <Divider shape={edge} tone={nextTone} height={EDGE_HEIGHT} />}
</section>
);
}
export default SpotlightText;
function splitPhrase(text: string, phrase?: string): string[] {
const needle = (phrase ?? "").trim();
if (!needle) return [text];
const at = text.toLowerCase().indexOf(needle.toLowerCase());
if (at < 0) return [text];
return [text.slice(0, at), text.slice(at, at + needle.length), text.slice(at + needle.length)];
}
function renderWords(text: string, phrase: string | undefined, semantic: boolean): ReactNode {
const parts = splitPhrase(text, phrase);
if (parts.length === 1) return text;
const [before, match, after] = parts;
const Tag = semantic ? "mark" : "span";
return (
<>
{before}
<Tag className="cf-spotlight-text__mark">{match}</Tag>
{after}
</>
);
}
const CSS = `
.cf-spotlight-text {
--st-bg: var(--band, oklch(0.27 0.067 256));
--st-ink: var(--band-ink, oklch(1 0 0));
--st-dim: color-mix(in oklab, var(--band-ink, oklch(1 0 0)) 56%, var(--band, oklch(0.27 0.067 256)));
--st-soft: color-mix(in oklab, var(--band-ink, oklch(1 0 0)) 84%, var(--band, oklch(0.27 0.067 256)));
--st-pool: oklch(from var(--band-ink, oklch(1 0 0)) l c h / 0.08);
/* Highlighter: the theme's marker, held light enough for dark ink on any band; ink is a deep shade of the same hue. */
--st-mark: var(--spotlight-marker, oklch(from var(--marker, #fae37c) max(l, 0.88) c h / 1));
--st-mark-ink: var(--spotlight-marker-ink, oklch(from var(--marker, #fae37c) 0.24 min(c, 0.06) h));
/* Mask stops read alpha only; built from the text token so no fixed colour is needed. */
--st-m-on: var(--st-ink);
--st-m-half: oklch(from var(--st-ink) l c h / 0.5);
container: cf-spotlight / inline-size;
box-sizing: border-box;
inline-size: 100%;
padding-block: clamp(56px, 8vw, 112px) calc(clamp(64px, 8.5vw, 120px) + var(--st-edge, 0px));
padding-inline: clamp(16px, 5vw, 48px);
background: var(--st-bg);
color: var(--st-ink);
font-family: var(--font-body);
}
.cf-spotlight-text[data-tone="light"] {
--st-bg: var(--surface, oklch(1 0 0));
--st-ink: var(--ink, oklch(0.21 0.034 263));
--st-dim: color-mix(in oklab, var(--ink, oklch(0.21 0.034 263)) 64%, var(--surface, oklch(1 0 0)));
--st-soft: var(--muted, oklch(0.45 0.03 258));
--st-pool: oklch(from var(--accent-fill, var(--accent, oklch(0.5 0.17 257))) l c h / 0.12);
}
.cf-spotlight-text__inner {
position: relative;
z-index: 1;
max-inline-size: 1120px;
margin-inline: auto;
display: grid;
grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
gap: clamp(32px, 5vw, 72px);
align-items: start;
}
.cf-spotlight-text__inner > * { min-width: 0; }
.cf-spotlight-text__stage.is-solo { grid-column: 1 / -1; }
@container cf-spotlight (min-width: 861px) {
.cf-spotlight-text__aside { position: sticky; top: clamp(24px, 14vh, 140px); }
}
@container cf-spotlight (max-width: 860px) {
.cf-spotlight-text__inner { grid-template-columns: minmax(0, 1fr); gap: clamp(24px, 6cqi, 40px); }
}
.cf-spotlight-text__headline {
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, 4.6cqi, 3.25rem);
line-height: 1.06;
color: var(--st-ink);
text-wrap: balance;
overflow-wrap: break-word;
hyphens: manual;
}
.cf-spotlight-text__note {
margin: 16px 0 0;
max-inline-size: 40ch;
font-size: clamp(1.125rem, 1.7cqi, 1.375rem);
font-weight: 500;
line-height: 1.4;
color: var(--st-soft);
text-wrap: pretty;
overflow-wrap: break-word;
}
.cf-spotlight-text__stage {
position: relative;
container: cf-spotlight-stage / inline-size;
--spot-x: 50%;
--spot-y: -60%;
--spot-r: clamp(120px, 24cqi, 220px);
--spot-band: clamp(44px, 14cqi, 64px);
}
.cf-spotlight-text__text {
margin: 0;
max-inline-size: 30em;
font-family: var(--font-display);
font-weight: 700;
font-size: clamp(1.5rem, 5.6cqi, 2.625rem);
line-height: 1.24;
letter-spacing: -0.01em;
text-wrap: pretty;
overflow-wrap: break-word;
hyphens: manual;
}
.cf-spotlight-text__base {
position: relative;
z-index: 1;
color: var(--st-ink);
transition: color .45s ease;
}
.cf-spotlight-text__lit {
position: absolute;
inset: 0;
z-index: 2;
color: var(--st-ink);
pointer-events: none;
user-select: none;
opacity: 0;
transition: opacity .45s ease;
-webkit-mask-image: radial-gradient(circle var(--spot-r) at var(--spot-x) var(--spot-y), var(--st-m-on) 0%, var(--st-m-on) 34%, var(--st-m-half) 64%, transparent 100%);
mask-image: radial-gradient(circle var(--spot-r) at var(--spot-x) var(--spot-y), var(--st-m-on) 0%, var(--st-m-on) 34%, var(--st-m-half) 64%, transparent 100%);
}
.cf-spotlight-text__pool {
position: absolute;
left: 0;
top: 0;
z-index: 0;
inline-size: calc(var(--spot-r) * 2.6);
block-size: calc(var(--spot-r) * 2.6);
border-radius: 50%;
background: radial-gradient(closest-side, var(--st-pool), transparent);
transform: translate(calc(var(--spot-x) - 50%), calc(var(--spot-y) - 50%));
opacity: 0;
pointer-events: none;
transition: opacity .45s ease;
will-change: transform;
}
@container cf-spotlight-stage (max-width: 560px) {
.cf-spotlight-text__lit {
-webkit-mask-image: linear-gradient(to bottom, transparent calc(var(--spot-y) - var(--spot-band)), var(--st-m-on) calc(var(--spot-y) - var(--spot-band) * 0.4), var(--st-m-on) calc(var(--spot-y) + var(--spot-band) * 0.4), transparent calc(var(--spot-y) + var(--spot-band)));
mask-image: linear-gradient(to bottom, transparent calc(var(--spot-y) - var(--spot-band)), var(--st-m-on) calc(var(--spot-y) - var(--spot-band) * 0.4), var(--st-m-on) calc(var(--spot-y) + var(--spot-band) * 0.4), transparent calc(var(--spot-y) + var(--spot-band)));
}
.cf-spotlight-text__pool {
left: -15%;
inline-size: 130%;
block-size: calc(var(--spot-band) * 2.6);
transform: translate(0, calc(var(--spot-y) - 50%));
}
}
.cf-spotlight-text[data-live="true"] .cf-spotlight-text__base { color: var(--st-dim); }
.cf-spotlight-text[data-live="true"] .cf-spotlight-text__lit,
.cf-spotlight-text[data-live="true"] .cf-spotlight-text__pool { opacity: 1; }
/* One highlighter stroke behind the phrase: kept inside its own line box so it never clips the line above. */
.cf-spotlight-text__mark {
color: var(--st-mark-ink);
background: linear-gradient(to bottom, transparent 13%, var(--st-mark) 13%, var(--st-mark) 89%, transparent 89%);
padding: 0 .14em;
margin: 0 -.06em;
border-radius: .06em .2em .08em .24em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
/* The lit overlay only repaints the ink; the stroke is drawn once by the readable layer, so no doubled edge. */
.cf-spotlight-text__lit .cf-spotlight-text__mark { background: none; }
@keyframes cf-spotlight-rise {
from { opacity: .82; transform: translateY(8px); }
to { opacity: 1; transform: none; }
}
@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {
.cf-spotlight-text__rise {
animation: cf-spotlight-rise linear both;
animation-timeline: view();
animation-range: entry 0% entry 60%;
}
.cf-spotlight-text__stage.cf-spotlight-text__rise { animation-range: entry 10% entry 70%; }
}
}
@media (prefers-reduced-motion: reduce) {
.cf-spotlight-text__lit,
.cf-spotlight-text__pool { display: none; }
.cf-spotlight-text[data-live="true"] .cf-spotlight-text__base { color: var(--st-ink); }
.cf-spotlight-text__base { transition: none; }
.cf-spotlight-text__rise { animation: none; }
}
`;
pieces/content/spotlight-text/specimen.tsx 17 lines
import { SpotlightText } from "../spotlight-text";
import nature from "../../fx/backdrops/nature";
export const states = ["default", "hover"];
export default function SpotlightTextSpecimen({ state = "default" }: { state?: "default" | "hover" }) {
return (
<SpotlightText
state={state}
backdrop={nature}
headline="Your dog isn’t stubborn. He’s confused."
text="Every time you say “down” for off the couch and “down” for lie down, your dog has to guess. Guessing looks like ignoring you. Give him one word for one job, and the guessing stops. That one rule is where every Northpaw lesson starts."
litPhrase="one word for one job"
note="Northpaw coaches you first, so your dog finally has one clear voice to follow."
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalSpotlightText |
ReactNode |
|
text OptionalSpotlightText |
string |
|
litPhrase OptionalSpotlightText |
string |
|
note OptionalSpotlightText |
ReactNode |
|
tone OptionalSpotlightText |
"dark" | "light" |
|
backdrop OptionalSpotlightText |
string | null |
|
backdropTreatment OptionalSpotlightText |
ComponentProps<typeof Backdrop>["treatment"] |
|
edge OptionalSpotlightText |
"step" | "chevron" | "none" |
|
edgeTone OptionalSpotlightText |
ComponentProps<typeof Divider>["tone"] |
|
state OptionalSpotlightText |
"default" | "hover" |
|
className OptionalSpotlightText |
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.
--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.
-
7ef109748b828d4d.webp
image/webp · 22.2 KB
-
8276864f4b8e6ac1.webp
image/webp · 47 KB