Viewport Quote 1
Viewport quote: one founder or speaker quotation fitted to fill a full-height dark stage, so a single belief stops the scroll.
Use it in a prompt
Use content/viewport-quote 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/viewport-quote.tsx. - Import it and pass your copy and images (Props tab):
import { ViewportQuote } from "@/components/funneldna/content/viewport-quote"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/viewport-quote/component.tsx 349 lines
// layout: scroll-panels
// Viewport quote: one founder or speaker quotation fitted to fill a full-height dark stage, so a single belief stops the scroll.
// A fit routine sizes the type to the box (short and long quotes both fill it, never overflow); lines rise through a mask on entry.
import React from 'react';
import { FX_HOST, Glow, Divider } from '../fx/fx';
import torn from '../fx/dividers/torn';
export type ViewportQuoteProps = {
/** The quotation, without quotation marks (the marks are set in the type). Empty renders nothing. */
quote?: string;
/** Optional phrase inside the quote, set in the mark colour. */
emphasis?: string;
/** Speaker name. */
name?: string;
/** Speaker role or company. */
role?: string;
/** presenter slot: a portrait or texture shown behind a strong scrim (optional). */
portraitImage?: string;
/** Alt text for the portrait; empty keeps it decorative. */
portraitAlt?: string;
/** object-position of the portrait at desktop widths. */
portraitPosition?: string;
/** object-position of the portrait on phones (tall crop). */
portraitPositionPhone?: string;
/** Largest quote size the fit routine may choose, in px. */
maxSize?: number;
/** Smallest quote size the fit routine may choose, in px. */
minSize?: number;
/** Torn paper edge into the next light (surface) section. Off by default (house style avoids torn edges); opt in only when the page's family asks for it. */
tornEdge?: boolean;
className?: string;
};
type Token = { text: string; em: boolean };
type Fit = { size: number; lines: number[][] };
const HANG = 0.62;
const useIsoLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
export function ViewportQuote({
quote = '',
emphasis = '',
name = '',
role = '',
portraitImage,
portraitAlt = '',
portraitPosition = '68% 24%',
portraitPositionPhone = '66% 20%',
maxSize = 168,
minSize = 22,
tornEdge = false,
className,
}: ViewportQuoteProps) {
const text = React.useMemo(() => cleanQuote(quote), [quote]);
const tokens = React.useMemo(() => tokenize(text, emphasis), [text, emphasis]);
const speaker = name.trim();
const speakerRole = role.trim();
const hasCap = Boolean(speaker || speakerRole);
const rootRef = React.useRef<HTMLElement>(null);
const innerRef = React.useRef<HTMLElement>(null);
const stageRef = React.useRef<HTMLDivElement>(null);
const measureRef = React.useRef<HTMLParagraphElement>(null);
const probeRef = React.useRef<HTMLSpanElement>(null);
const capRef = React.useRef<HTMLElement>(null);
const [fit, setFit] = React.useState<Fit | null>(null);
const [armed, setArmed] = React.useState(false);
const [inView, setInView] = React.useState(false);
// Binary-search the largest size whose wrapped text fits the box, then read the line breaks.
const measure = React.useCallback(() => {
const root = rootRef.current;
const stage = stageRef.current;
const m = measureRef.current;
const probe = probeRef.current;
const inner = innerRef.current;
if (!root || !stage || !m || !probe || !inner) return;
const cs = getComputedStyle(root);
const bandH = probe.getBoundingClientRect().height || window.innerHeight;
const cap = capRef.current;
const capH = cap ? cap.getBoundingClientRect().height : 0;
const gap = cap ? parseFloat(getComputedStyle(inner).rowGap) || 0 : 0;
const H = Math.max(120, bandH - (parseFloat(cs.paddingTop) || 0) - (parseFloat(cs.paddingBottom) || 0) - capH - gap);
const W = stage.clientWidth;
if (W <= 0) return;
const lo0 = Math.max(12, minSize);
const hi0 = Math.max(lo0, maxSize);
const tryAt = (s: number) => {
const w = Math.max(40, Math.floor(W - s * HANG));
m.style.fontSize = s + 'px';
m.style.width = w + 'px';
return m.scrollHeight <= H + 1 && m.scrollWidth <= w + 1;
};
let best = lo0;
if (tryAt(hi0)) {
best = hi0;
} else {
let lo = lo0;
let hi = hi0;
for (let i = 0; i < 16 && hi - lo > 0.5; i++) {
const mid = (lo + hi) / 2;
if (tryAt(mid)) {
best = mid;
lo = mid;
} else {
hi = mid;
}
}
}
best = Math.floor(best * 2) / 2;
tryAt(best);
const spans = m.querySelectorAll<HTMLElement>('[data-w]');
const lines: number[][] = [];
let top = -Infinity;
spans.forEach((sp, i) => {
const t = sp.offsetTop;
if (t > top + best * 0.4 || lines.length === 0) {
lines.push([i]);
top = t;
} else {
lines[lines.length - 1].push(i);
}
});
setFit((prev) => (prev && prev.size === best && linesKey(prev.lines) === linesKey(lines) ? prev : { size: best, lines }));
}, [minSize, maxSize]);
useIsoLayoutEffect(() => {
if (!text) return;
let raf = 0;
let alive = true;
const run = () => {
cancelAnimationFrame(raf);
raf = requestAnimationFrame(() => {
if (alive) measure();
});
};
measure();
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(run) : null;
if (ro && rootRef.current) ro.observe(rootRef.current);
window.addEventListener('resize', run);
const fonts = typeof document !== 'undefined' ? document.fonts : undefined;
if (fonts) {
fonts.ready.then(() => {
if (alive) run();
});
fonts.addEventListener('loadingdone', run);
}
return () => {
alive = false;
cancelAnimationFrame(raf);
if (ro) ro.disconnect();
window.removeEventListener('resize', run);
if (fonts) fonts.removeEventListener('loadingdone', run);
};
}, [text, tokens, measure, speaker, speakerRole]);
// Arm the masked line reveal only when motion is allowed; reveal once when the band enters view.
useIsoLayoutEffect(() => {
if (!text) return;
const el = rootRef.current;
if (!el || typeof IntersectionObserver === 'undefined') return;
if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
setArmed(true);
const io = new IntersectionObserver(
(entries) => {
if (entries.some((e) => e.isIntersecting)) {
setInView(true);
io.disconnect();
}
},
{ threshold: 0.25, rootMargin: '0px 0px -8% 0px' }
);
io.observe(el);
return () => io.disconnect();
}, [text]);
if (!text) return null;
const renderToken = (t: Token, i: number) => {
const cls = t.em ? 'cf-vq__em' : undefined;
if (i === tokens.length - 1) {
return (
<span className='cf-vq__tail' data-w=''>
<span className={cls}>{t.text}</span>
<span className='cf-vq__close' aria-hidden='true'>{'\u201D'}</span>
</span>
);
}
return (
<span className={cls} data-w=''>
{t.text}
</span>
);
};
const joined = tokens.map((t, i) => (
<React.Fragment key={i}>
{i > 0 ? ' ' : null}
{renderToken(t, i)}
</React.Fragment>
));
const showLines = Boolean(fit && fit.lines.reduce((n, l) => n + l.length, 0) === tokens.length);
const rootStyle = {
...FX_HOST,
...(fit ? { '--vq-size': fit.size + 'px' } : {}),
'--vq-pos': portraitPosition,
'--vq-pos-sm': portraitPositionPhone,
} as React.CSSProperties;
const classes = ['cf-vq', tornEdge ? 'cf-vq--torn' : '', armed ? 'is-armed' : '', inView ? 'is-in' : '', className || '']
.filter(Boolean)
.join(' ');
return (
<section ref={rootRef} className={classes} style={rootStyle}>
<style>{CSS}</style>
{portraitImage ? (
<div className='cf-vq__photo'>
<img src={portraitImage} alt={portraitAlt} width={1600} height={1000} loading='lazy' decoding='async' />
</div>
) : null}
{portraitImage ? <div className='cf-vq__scrim' aria-hidden='true' /> : null}
<div className='cf-vq__light' aria-hidden='true'>
<Glow />
</div>
{tornEdge ? <Divider shape='torn' src={torn} tone='surface' height={40} /> : null}
<span ref={probeRef} className='cf-vq__probe' aria-hidden='true' />
<figure ref={innerRef} className='cf-vq__inner'>
<div ref={stageRef} className='cf-vq__stage'>
<blockquote className='cf-vq__quote cf-vq__type'>
<span className='cf-vq__open' aria-hidden='true'>{'\u201C'}</span>
<p className='cf-vq__text'>
{showLines && fit ? (
<>
<span className='cf-vq__sr'>{text}</span>
<span className='cf-vq__lines' aria-hidden='true'>
{fit.lines.map((line, li) => (
<span key={li} className='cf-vq__line'>
<span className='cf-vq__line-in' style={{ '--d': Math.min(li * 0.07, 0.28) + 's' } as React.CSSProperties}>
{line.map((ti, j) => (
<React.Fragment key={ti}>
{j > 0 ? ' ' : null}
{renderToken(tokens[ti], ti)}
</React.Fragment>
))}
</span>
</span>
))}
</span>
</>
) : (
<span className='cf-vq__plain'>{joined}</span>
)}
</p>
</blockquote>
<p ref={measureRef} className='cf-vq__measure cf-vq__type' aria-hidden='true'>
{joined}
</p>
</div>
{hasCap ? (
<figcaption ref={capRef} className='cf-vq__cap'>
<span className='cf-vq__rule' aria-hidden='true' />
<span className='cf-vq__who'>
{speaker ? <cite className='cf-vq__name'>{speaker}</cite> : null}
{speakerRole ? <span className='cf-vq__role'>{speakerRole}</span> : null}
</span>
</figcaption>
) : null}
</figure>
</section>
);
}
export default ViewportQuote;
function cleanQuote(q: string) {
return (q || '')
.replace(/\s+/g, ' ')
.trim()
.replace(/^[\u0022\u201C\u201D\u201E]+\s*/, '')
.replace(/\s*[\u0022\u201C\u201D]+$/, '')
.trim();
}
function tokenize(text: string, emphasis: string): Token[] {
const phrase = cleanQuote(emphasis).toLowerCase();
const at = phrase ? text.toLowerCase().indexOf(phrase) : -1;
const end = at + phrase.length;
const out: Token[] = [];
const re = /\S+/g;
let m: RegExpExecArray | null;
while ((m = re.exec(text)) !== null) {
const s = m.index;
const e = s + m[0].length;
out.push({ text: m[0], em: at >= 0 && s < end && e > at });
}
return out;
}
function linesKey(lines: number[][]) {
return lines.map((l) => l.join(',')).join('|');
}
const CSS = `
.cf-vq{--vq-band-h:clamp(560px,100vh,1080px);--vq-size:clamp(2.25rem,5.2vw,5rem);--vq-hang:.62;--vq-mark:color-mix(in oklab,var(--accent-fill,var(--accent,#2563eb)) 50%,var(--band-ink,#ffffff));--vq-soft:color-mix(in oklch,var(--band-ink,#ffffff) 80%,var(--band,#14213d));position:relative;isolation:isolate;overflow:hidden;box-sizing:border-box;display:grid;align-content:center;min-height:var(--vq-band-h);padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) clamp(64px,8.5vw,120px);background:var(--band,#14213d);color:var(--band-ink,#ffffff);font-family:var(--font-body,system-ui,sans-serif)}
@supports (height:100svh){.cf-vq{--vq-band-h:clamp(560px,100svh,1080px)}}
.cf-vq--torn{padding-bottom:calc(clamp(64px,8.5vw,120px) + 40px)}
.cf-vq *,.cf-vq *::before,.cf-vq *::after{box-sizing:border-box}
.cf-vq__photo{position:absolute;inset:0;z-index:0;margin:0;overflow:hidden;background:var(--band,#14213d)}
.cf-vq__photo img{display:block;width:100%;height:100%;object-fit:cover;object-position:var(--vq-pos,68% 24%);mix-blend-mode:luminosity;transform-origin:70% 30%}
.cf-vq__scrim{position:absolute;inset:0;z-index:1;background:oklch(from var(--band,#14213d) l c h / .82)}
.cf-vq__light{position:absolute;inset:0;z-index:1;pointer-events:none}
.cf-vq__probe{position:absolute;top:0;left:0;width:1px;height:var(--vq-band-h);visibility:hidden;pointer-events:none}
.cf-vq__inner{position:relative;z-index:2;width:min(100%,1240px);margin:0 auto;display:grid;gap:clamp(24px,3vw,40px);min-width:0}
.cf-vq__stage{position:relative;min-width:0}
.cf-vq__type{font-family:var(--font-display,system-ui,sans-serif);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);line-height:1.06;font-kerning:normal}
.cf-vq__quote{position:relative;margin:0;padding:0 0 0 calc(var(--vq-size) * var(--vq-hang));font-size:var(--vq-size);color:var(--band-ink,#ffffff)}
.cf-vq__text{margin:0;text-wrap:pretty}
.cf-vq__open{position:absolute;top:0;left:0;width:calc(var(--vq-size) * var(--vq-hang));text-align:right;font-size:1.6em;line-height:.9;color:var(--vq-mark);transform:translate(-.03em,-.04em);user-select:none}
.cf-vq__close{font-size:1.6em;line-height:0;vertical-align:-.26em;margin-left:.03em;color:var(--vq-mark);user-select:none}
.cf-vq__tail{white-space:nowrap}
.cf-vq__em{color:var(--vq-mark)}
.cf-vq__lines{display:block}
.cf-vq__line{display:block;white-space:nowrap;overflow:hidden;overflow:clip;padding:.1em .06em .16em;margin:-.1em -.06em -.16em}
.cf-vq__line-in{display:inline-block}
.cf-vq__sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.cf-vq__measure{position:absolute;top:0;left:0;margin:0;visibility:hidden;pointer-events:none;white-space:normal;text-wrap:pretty;overflow-wrap:normal;word-break:normal}
.cf-vq__cap{--vq-hw:calc(var(--vq-size) * var(--vq-hang));--vq-name:clamp(1.3125rem,1.8vw,1.625rem);display:grid;grid-template-columns:var(--vq-hw) minmax(0,1fr);align-items:start;margin:0;min-width:0}
.cf-vq__rule{justify-self:end;width:min(40px,calc(var(--vq-hw) * .55));height:3px;margin-top:calc(var(--vq-name) * .575 - 1.5px);margin-inline-end:min(16px,calc(var(--vq-hw) * .3));border-radius:999px;background:var(--vq-mark)}
.cf-vq__who{display:grid;gap:4px;min-width:0}
.cf-vq__name{font-family:var(--font-display,system-ui,sans-serif);font-style:normal;font-weight:var(--display-weight,800);font-size:var(--vq-name);line-height:1.15;letter-spacing:-0.01em;color:var(--band-ink,#ffffff);text-wrap:balance}
.cf-vq__role{font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.4;font-weight:500;color:var(--vq-soft);text-wrap:pretty}
@media (max-width:640px){.cf-vq__photo img{object-position:var(--vq-pos-sm,66% 20%)}}
@media (prefers-reduced-motion:no-preference){
.cf-vq.is-armed .cf-vq__line-in{transform:translate3d(0,120%,0);transition:transform .6s cubic-bezier(.2,.7,.2,1) var(--d,0s)}
.cf-vq.is-armed.is-in .cf-vq__line-in{transform:none}
.cf-vq.is-armed .cf-vq__open{opacity:.82;transform:translate(-.03em,calc(-.04em + 8px));transition:opacity .45s cubic-bezier(.2,.7,.2,1),transform .45s cubic-bezier(.2,.7,.2,1)}
.cf-vq.is-armed.is-in .cf-vq__open{opacity:1;transform:translate(-.03em,-.04em)}
.cf-vq.is-armed .cf-vq__cap{opacity:.82;transform:translateY(8px);transition:opacity .45s cubic-bezier(.2,.7,.2,1),transform .45s cubic-bezier(.2,.7,.2,1)}
.cf-vq.is-armed.is-in .cf-vq__cap{opacity:1;transform:none;transition-delay:.35s}
.cf-vq.is-armed .cf-vq__photo img{transform:scale(1.04);transition:transform 1.2s cubic-bezier(.2,.7,.2,1)}
.cf-vq.is-armed.is-in .cf-vq__photo img{transform:none}
}
`;
pieces/content/viewport-quote/specimen.tsx 23 lines
import __studioImage3fb007af from "../assets/ccdbad616807c629.webp";
import { ViewportQuote } from '../viewport-quote';
import { slot } from '../../slots';
export const states = ['default'];
export default function ViewportQuoteSpecimen(_props: { state?: string }) {
return (
<ViewportQuote
quote="I started Hearth & Pantry for the six o'clock version of me: tired, hungry, staring into a fridge full of good intentions. Every box we pack is the dinner I wished someone had already planned."
emphasis="the dinner I wished someone had already planned"
name="Maren Okafor"
role="Founder, Hearth & Pantry"
portraitImage={slot(
'presenter',
__studioImage3fb007af
)}
portraitAlt=""
portraitPosition="74% 26%"
portraitPositionPhone="72% 22%"
/>
);
}
| Name | Type | Details |
|---|---|---|
quote OptionalViewportQuote |
string |
Default ''
|
emphasis OptionalViewportQuote |
string |
Default ''
|
name OptionalViewportQuote |
string |
Default ''
|
role OptionalViewportQuote |
string |
Default ''
|
portraitImage OptionalViewportQuote |
string |
|
portraitAlt OptionalViewportQuote |
string |
Default ''
|
portraitPosition OptionalViewportQuote |
string |
Default '68% 24%'
|
portraitPositionPhone OptionalViewportQuote |
string |
Default '66% 20%'
|
maxSize OptionalViewportQuote |
number |
Default 168
|
minSize OptionalViewportQuote |
number |
Default 22
|
tornEdge OptionalViewportQuote |
boolean |
Default false
|
className OptionalViewportQuote |
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.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
presenter- A photo of the host, coach or founder.
-
9a2ebdab5ff4fcc4.webp
image/webp · 3.64 KB
-
ccdbad616807c629.webp
image/webp · 44.8 KB