Rewriting Question 1
Rewriting question: the reader's own question retypes itself into sharper versions and lands on the reframe the page answers, with every earlier version struck below as a trail.
Use it in a prompt
Use content/rewriting-question 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/rewriting-question.tsx. - Import it and pass your copy and images (Props tab):
import { RewritingQuestion } from "@/components/funneldna/content/rewriting-question"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/rewriting-question/component.tsx 416 lines
// layout: number-rail
// Rewriting question: the reader's own question retypes itself into sharper versions and lands on the reframe the page answers, with every earlier version struck below as a trail.
import React, { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Divider, FX_HOST, Pattern } from "../fx/fx";
type DividerTone = React.ComponentProps<typeof Divider>["tone"];
export type RewritingQuestionProps = {
/** The question the reader is already asking. */
question?: string;
/** Up to four sharper rewrites, in order; the last one is the reframe and holds in the accent colour. */
rewrites?: string[];
/** Optional short line under the trail that hands the reader to the next section. */
note?: React.ReactNode;
/** Accessible name of the list of earlier versions. */
trailLabel?: string;
/** "band" = dark stage (default), "surface" = light page band. */
tone?: "band" | "surface";
/** Curved section edge at the bottom of the band, leading down into the next section; on by default for the dark band. */
edge?: boolean;
/** Token of the section below this one: the colour of the curved edge. */
edgeTone?: DividerTone;
/** Set false to show the finished composition without the typing. */
animate?: boolean;
className?: string;
};
export function RewritingQuestion({
question = "Why is my calendar empty?",
rewrites = DEFAULT_REWRITES,
note,
trailLabel = "Earlier versions of the question",
tone = "band",
edge,
edgeTone = "surface" as DividerTone,
animate = true,
className = "",
}: RewritingQuestionProps) {
const key = JSON.stringify([question, ...(rewrites ?? [])]);
const versions = useMemo(
() => [question, ...(rewrites ?? []).slice(0, 4)].map((v) => (v ?? "").trim()).filter(Boolean),
// eslint-disable-next-line react-hooks/exhaustive-deps
[key],
);
const last = versions.length - 1;
const finalText = versions[last] ?? "";
const single = last < 1;
const showEdge = edge ?? tone === "band";
const rootRef = useRef<HTMLElement>(null);
const timers = useRef<number[]>([]);
const headingId = useId();
// The finished composition is the default render: readable before any script runs.
const [text, setText] = useState(finalText);
const [step, setStep] = useState(last);
const [trail, setTrail] = useState(last);
const [armed, setArmed] = useState(false);
const [done, setDone] = useState(true);
const clear = () => {
timers.current.forEach((t) => window.clearTimeout(t));
timers.current = [];
};
useIsoLayoutEffect(() => {
clear();
setText(finalText);
setStep(last);
setTrail(last);
setDone(true);
setArmed(false);
const node = rootRef.current;
if (!animate || last < 1 || !node || typeof IntersectionObserver === "undefined") return;
const mq = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
if (mq && mq.matches) return;
// Rewind to the first version while it is still off screen, then type when it comes into view.
setText(versions[0]);
setStep(0);
setTrail(0);
setDone(false);
setArmed(true);
const later = (fn: () => void, ms: number) => {
timers.current.push(window.setTimeout(fn, ms));
};
const run = () => {
let i = 0;
let current = versions[0];
const advance = () => {
if (i >= last) {
setDone(true);
return;
}
const target = versions[i + 1];
const keep = keepLength(current, target);
setTrail(i + 1);
const erase = () => {
if (current.length > keep) {
current = current.slice(0, -1);
setText(current);
later(erase, DELETE_MS);
} else {
i += 1;
setStep(i);
later(type, PAUSE_MS);
}
};
const type = () => {
if (current.length < target.length) {
current = target.slice(0, current.length + 1);
setText(current);
later(type, TYPE_MS);
} else {
later(advance, i >= last ? 0 : HOLD_MS);
}
};
erase();
};
later(advance, FIRST_HOLD_MS);
};
let started = false;
const io = new IntersectionObserver(
(entries) => {
if (started || !entries.some((e) => e.isIntersecting)) return;
started = true;
io.disconnect();
run();
},
{ threshold: 0.3 },
);
io.observe(node);
const onMotion = () => {
if (mq && mq.matches) {
io.disconnect();
clear();
setText(finalText);
setStep(last);
setTrail(last);
setDone(true);
setArmed(false);
}
};
mq?.addEventListener?.("change", onMotion);
return () => {
io.disconnect();
mq?.removeEventListener?.("change", onMotion);
clear();
};
}, [key, animate]);
if (versions.length === 0) return null;
const isFinal = step === last;
const rootClass = [
"cf-rewriting-question",
`cf-rq--${tone}`,
single ? "cf-rq--single" : "",
isFinal ? "is-final" : "",
showEdge ? "has-edge" : "",
className,
]
.filter(Boolean)
.join(" ");
return (
<section ref={rootRef} className={rootClass} style={FX_HOST} aria-labelledby={headingId}>
<style>{CSS}</style>
<Pattern name="rings" fade="corner" />
<div className="cf-rq__inner">
<h2 id={headingId} className="cf-rq__sr">
{finalText}
</h2>
<div className="cf-rq__lead" aria-hidden="true">
{!single && (
<span key={step} className={`cf-rq__numeral${armed ? " is-pop" : ""}`}>
{pad(step + 1)}
</span>
)}
<div className="cf-rq__question">
{versions.map((v, i) => (
<span key={i} className="cf-rq__ghost">
{v}
</span>
))}
<span className="cf-rq__live">
{text}
{armed && <span className="cf-rq__caret" data-done={done ? "true" : "false"} />}
</span>
</div>
</div>
{!single && (
<ol className="cf-rq__trail" aria-label={trailLabel} data-empty={trail === 0 ? "true" : "false"}>
{versions.slice(0, last).map((v, i) => (
<li key={i} className="cf-rq__item" data-shown={i < trail ? "true" : "false"}>
<div className="cf-rq__clip">
<div className="cf-rq__row">
<span className="cf-rq__num" aria-hidden="true">
{pad(i + 1)}
</span>
<s className="cf-rq__old">{v}</s>
</div>
</div>
</li>
))}
</ol>
)}
{note ? <p className="cf-rq__note">{note}</p> : null}
</div>
{showEdge && <Divider shape="curve" tone={edgeTone} height={EDGE_HEIGHT} />}
</section>
);
}
export default RewritingQuestion;
const DEFAULT_REWRITES = [
"Why is my calendar empty when my work is good?",
"Why is my calendar empty when nobody sees the work?",
"What would fill it?",
];
const TYPE_MS = 42;
const DELETE_MS = 22;
const PAUSE_MS = 160;
const HOLD_MS = 1150;
const FIRST_HOLD_MS = 900;
const EDGE_HEIGHT = 56;
const useIsoLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
function pad(n: number) {
return String(n).padStart(2, "0");
}
// How much of the current line survives: the shared start, backed up to a word edge so the caret never splits a word.
function keepLength(from: string, to: string) {
let n = 0;
while (n < from.length && n < to.length && from[n] === to[n]) n++;
const isWord = (c?: string) => !!c && (c.toLowerCase() !== c.toUpperCase() || "0123456789'".includes(c));
if (n > 0 && n < to.length && isWord(to[n]) && isWord(to[n - 1])) n = to.lastIndexOf(" ", n - 1) + 1;
return n;
}
const CSS = `
.cf-rewriting-question {
--rq-rail: clamp(4.5rem, 11vw, 9.5rem);
--rq-gap: clamp(16px, 3vw, 40px);
--rq-ease: cubic-bezier(.2,.7,.2,1);
position: relative;
overflow: hidden;
color: var(--rq-ink);
font-family: var(--font-body);
padding: clamp(56px, 8vw, 112px) clamp(16px, 5vw, 48px) clamp(64px, 8.5vw, 120px);
}
.cf-rewriting-question.has-edge { padding-bottom: calc(clamp(64px, 8.5vw, 120px) + 56px); }
.cf-rq--band {
background: var(--band);
--rq-ink: var(--band-ink);
--rq-quiet: color-mix(in oklch, var(--band-ink) 78%, var(--band));
--rq-final: oklch(from color-mix(in oklab, var(--accent-fill, var(--accent)) 60%, var(--band-ink)) l calc(c * 1.35) h);
--rq-rule: oklch(from var(--band-ink) l c h / .16);
}
.cf-rq--surface {
background: var(--surface);
--rq-ink: var(--ink);
--rq-quiet: var(--muted);
--rq-final: var(--accent);
--rq-rule: oklch(from var(--ink) l c h / .14);
}
.cf-rq__inner { position: relative; z-index: 1; max-width: 1120px; margin-inline: auto; }
.cf-rq__sr {
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.cf-rq__lead {
display: grid;
grid-template-columns: var(--rq-rail) minmax(0, 1fr);
column-gap: var(--rq-gap);
align-items: start;
}
.cf-rq--single .cf-rq__lead { grid-template-columns: minmax(0, 1fr); }
.cf-rq__numeral {
display: block;
padding-top: .04em;
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
font-size: clamp(3rem, 7.4vw, 7rem);
line-height: .86;
letter-spacing: -0.04em;
font-variant-numeric: tabular-nums;
color: var(--rq-quiet);
transition: color .3s ease;
}
.is-final .cf-rq__numeral { color: var(--rq-final, var(--rq-ink)); }
.cf-rq__numeral.is-pop { animation: cf-rq-pop .3s var(--rq-ease) both; }
.cf-rq__question {
display: grid;
margin: 0;
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.25rem, 5.4vw, 4.875rem);
line-height: 1.04;
text-wrap: balance;
}
.cf-rq__question > span { grid-area: 1 / 1; min-width: 0; }
.cf-rq__ghost { visibility: hidden; }
.cf-rq__ghost::after { content: ""; display: inline-block; width: .14em; }
.cf-rq__live { color: var(--rq-ink); transition: color .35s ease; }
.is-final .cf-rq__live { color: var(--rq-final, var(--rq-ink)); }
.cf-rq__caret {
display: inline-block;
width: .07em;
height: .86em;
margin-left: .06em;
vertical-align: -.08em;
border-radius: 1px;
background: currentColor;
}
.cf-rq__caret[data-done="true"] { animation: cf-rq-caret 1.05s steps(1, end) 3 forwards; }
.cf-rq__trail {
list-style: none;
margin: clamp(32px, 4vw, 48px) 0 0;
padding: 0;
border-bottom: 1px solid var(--rq-rule);
transition: margin-top .45s var(--rq-ease), border-color .3s ease;
}
.cf-rq__trail[data-empty="true"] { margin-top: 0; border-bottom-color: transparent; }
.cf-rq__item {
display: grid;
grid-template-rows: 1fr;
border-top: 1px solid var(--rq-rule);
transition: grid-template-rows .45s var(--rq-ease), opacity .45s var(--rq-ease), border-color .3s ease;
}
.cf-rq__item[data-shown="false"] { grid-template-rows: 0fr; opacity: 0; border-top-color: transparent; }
.cf-rq__clip { min-height: 0; overflow: hidden; }
.cf-rq__row {
display: grid;
grid-template-columns: var(--rq-rail) minmax(0, 1fr);
column-gap: var(--rq-gap);
align-items: baseline;
padding-block: 16px;
transition: transform .45s var(--rq-ease);
}
.cf-rq__item[data-shown="false"] .cf-rq__row { transform: translateY(8px); }
.cf-rq__num {
font-family: var(--font-display);
font-weight: var(--display-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(--rq-quiet);
}
.cf-rq__old {
--rq-strike: oklch(from var(--rq-quiet) l c h / .8);
font-size: clamp(1.125rem, 1.5vw, 1.375rem);
line-height: 1.4;
font-weight: 500;
color: var(--rq-quiet);
text-decoration: none;
background-image: linear-gradient(var(--rq-strike), var(--rq-strike));
background-repeat: no-repeat;
background-position: 0 60%;
background-size: 100% .07em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
transition: background-size .5s var(--rq-ease) .2s;
text-wrap: pretty;
}
.cf-rq__item[data-shown="false"] .cf-rq__old { background-size: 0% .07em; }
.cf-rq__note {
margin: clamp(32px, 4vw, 48px) 0 0 calc(var(--rq-rail) + var(--rq-gap));
max-width: 54ch;
font-size: clamp(1.125rem, 1.5vw, 1.375rem);
line-height: 1.4;
font-weight: 500;
color: var(--rq-ink);
text-wrap: pretty;
}
.cf-rq--single .cf-rq__note { margin-left: 0; }
@keyframes cf-rq-pop { from { transform: scale(.9); opacity: .82; } to { transform: none; opacity: 1; } }
@keyframes cf-rq-caret { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 0; } }
@media (max-width: 640px) {
.cf-rewriting-question { --rq-rail: 2.75rem; --rq-gap: 12px; }
.cf-rq__lead { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
.cf-rq__numeral { font-size: 3rem; }
.cf-rq__question { font-size: 2rem; line-height: 1.08; }
.cf-rq__trail { margin-top: 24px; }
.cf-rq__num { font-size: 1.125rem; }
.cf-rq__row { padding-block: 12px; }
.cf-rq__note { margin-left: 0; margin-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
.cf-rewriting-question .cf-rq__numeral,
.cf-rewriting-question .cf-rq__live,
.cf-rewriting-question .cf-rq__trail,
.cf-rewriting-question .cf-rq__item,
.cf-rewriting-question .cf-rq__row { animation: none; transition: none; }
.cf-rewriting-question .cf-rq__item[data-shown] { grid-template-rows: 1fr; opacity: 1; border-top-color: var(--rq-rule); }
.cf-rewriting-question .cf-rq__item[data-shown] .cf-rq__row { transform: none; }
.cf-rewriting-question .cf-rq__item[data-shown] .cf-rq__old { background-size: 100% .07em; transition: none; }
.cf-rewriting-question .cf-rq__caret { display: none; }
}
`;
pieces/content/rewriting-question/specimen.tsx 19 lines
import { RewritingQuestion } from "../rewriting-question";
export const states = ["default"];
export default function RewritingQuestionSpecimen(_props: { state?: "default" }) {
return (
<RewritingQuestion
question="Why is my crew sitting idle in April?"
rewrites={[
"Why is my crew sitting idle when my lawns look this good?",
"Why is my crew sitting idle when nobody sees those lawns?",
"What would put every finished lawn to work for me?",
]}
note="Greenway Landscaping stopped asking why the phone was quiet. Everything below answers the last question."
trailLabel="How Greenway's question changed"
edgeTone="surface"
/>
);
}
| Name | Type | Details |
|---|---|---|
question OptionalRewritingQuestion |
string |
Default "Why is my calendar empty?"
|
rewrites OptionalRewritingQuestion |
string[] |
Default DEFAULT_REWRITES
|
note OptionalRewritingQuestion |
React.ReactNode |
|
trailLabel OptionalRewritingQuestion |
string |
Default "Earlier versions of the question"
|
tone OptionalRewritingQuestion |
"band" | "surface" |
Default "band"
|
edge OptionalRewritingQuestion |
boolean |
|
edgeTone OptionalRewritingQuestion |
DividerTone |
Default "surface" as DividerTone
|
animate OptionalRewritingQuestion |
boolean |
Default true
|
className OptionalRewritingQuestion |
string |
Default ""
|
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.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.