Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
docs(blog): add timeline view post with interactive demos
Richie McIlroy3976e4e44253
diff --git a/apps/web/app/(site)/blog/[slug]/page.tsx b/apps/web/app/(site)/blog/[slug]/page.tsxindex 79438b139..1aab643ea 100644--- a/apps/web/app/(site)/blog/[slug]/page.tsx+++ b/apps/web/app/(site)/blog/[slug]/page.tsx@@ -6,6 +6,7 @@ import { notFound } from "next/navigation";import { MDXRemote } from "next-mdx-remote/rsc";import { AuthorByline } from "@/components/blog/AuthorByline";import { BlogTemplate } from "@/components/blog/BlogTemplate";+import { getPostComponents } from "@/components/blog/post-components";import { ReadyToGetStarted } from "@/components/ReadyToGetStarted";import { ogImageUrl } from "@/lib/og/url";import { getBlogPosts } from "@/utils/blog";@@ -122,7 +123,10 @@ export default async function PostPage(props: PostProps) {</p></header><hr className="my-6" />- <MDXRemote source={post.content} />+ <MDXRemote+ source={post.content}+ components={getPostComponents(post.slug)}+ />{"author" in post.metadata && post.metadata.author && (<AuthorByline authors={post.metadata.author} />)}diff --git a/apps/web/components/blog/post-components.tsx b/apps/web/components/blog/post-components.tsxnew file mode 100644index 000000000..1181dca16--- /dev/null+++ b/apps/web/components/blog/post-components.tsx@@ -0,0 +1,25 @@+import type { ComponentType } from "react";+import { BranchesDemo } from "./timeline/BranchesDemo";+import { ReplyDemo } from "./timeline/ReplyDemo";+import { ToggleDemo } from "./timeline/ToggleDemo";++/**+ * Components an individual MDX post may use.+ *+ * Scoped by slug rather than merged into one global map: these are client+ * components, and only the post that actually renders them should pull their+ * chunks. A post whose slug is not listed gets plain MDX, exactly as before.+ */+type PostComponents = Record<string, ComponentType>;++const POST_COMPONENTS: Record<string, PostComponents> = {+ "timeline-view": {+ BranchesDemo,+ ReplyDemo,+ ToggleDemo,+ },+};++export function getPostComponents(slug: string): PostComponents | undefined {+ return POST_COMPONENTS[slug];+}diff --git a/apps/web/components/blog/timeline/BranchesDemo.tsx b/apps/web/components/blog/timeline/BranchesDemo.tsxnew file mode 100644index 000000000..2157e603e--- /dev/null+++ b/apps/web/components/blog/timeline/BranchesDemo.tsx@@ -0,0 +1,184 @@+"use client";++import { AnimatePresence, motion, useReducedMotion } from "motion/react";+import { useMemo, useState } from "react";+import {+ AnchorLine,+ BranchNode,+ Clock,+ CommentCard,+ CommentRow,+ LANE_STEM,+ MIN_NODE_GAP,+ NODE_SIZE,+ TransportButton,+} from "./DemoBits";+import { DemoButton, DemoPanel } from "./DemoPanel";+import {+ DemoPlayhead,+ DemoStrip,+ FULL_WINDOW,+ useMeasuredWidth,+} from "./DemoStrip";+import { layoutDemoNodes } from "./demo-layout";+import { MockFrame } from "./MockFrame";+import { DEMO_COMMENTS } from "./scene";+import { useDemoClock } from "./useDemoClock";++/** How close the playhead has to be for a node to read as "now", in seconds. */+const ACTIVE_WINDOW = 2;++/**+ * The whole idea in one control: take the six comments out of the list and hang+ * them off the moments they are about. Two of them collide, which is what the+ * second lane and the cluster node are for.+ */+export function BranchesDemo() {+ const reduceMotion = useReducedMotion() ?? false;+ const clock = useDemoClock({ initial: 0 });+ const [onTimeline, setOnTimeline] = useState(false);+ const [openId, setOpenId] = useState<string | null>(null);+ const [ref, width] = useMeasuredWidth<HTMLDivElement>();++ const nodes = useMemo(+ () =>+ onTimeline+ ? layoutDemoNodes(DEMO_COMMENTS, FULL_WINDOW, width, MIN_NODE_GAP)+ : [],+ [onTimeline, width],+ );++ const shelfHeight =+ nodes.length > 0+ ? Math.max(...nodes.map((node) => LANE_STEM[node.lane])) ++ NODE_SIZE / 2 ++ 12+ : 0;++ const open = nodes.find((node) => node.comment.id === openId) ?? null;++ return (+ <DemoPanel+ title="Comments, hung off the moment"+ hint={+ onTimeline+ ? "Press play and watch them come up. Click a node to open it and jump there."+ : "Move the six comments out of the list and onto the recording."+ }+ action={+ <DemoButton+ variant={onTimeline ? "ghost" : "solid"}+ onClick={() => {+ setOnTimeline((value) => !value);+ setOpenId(null);+ }}+ >+ {onTimeline ? "Back to the list" : "Move onto the timeline"}+ </DemoButton>+ }+ caption="Nothing was summarised, sorted or thrown away. The same six comments are simply drawn where they happened. Two of them land three seconds apart, so the later one drops to a second lane, and the third folds into it as a count."+ >+ <div className="overflow-hidden rounded-xl border border-gray-4 bg-white">+ <div className="relative aspect-video bg-[hsl(224,71.4%,4.1%)]">+ <MockFrame time={clock.time} className="absolute inset-0 size-full" />+ </div>++ <div ref={ref}>+ <DemoStrip+ time={clock.time}+ onSeek={(t) => {+ clock.pause();+ clock.seek(t);+ }}+ >+ <DemoPlayhead time={clock.time} />+ </DemoStrip>+ </div>++ {/* The shelf: collapses to nothing when there is nothing on it, which+ is exactly what the real one does. */}+ <div+ className="relative transition-[height] duration-300"+ style={{ height: shelfHeight }}+ >+ {nodes.length > 0 && <AnchorLine />}++ {nodes.map((node, index) => (+ <BranchNode+ key={node.comment.id}+ node={node}+ delay={index * 0.045}+ active={+ openId === node.comment.id ||+ Math.abs(clock.time - node.comment.t) < ACTIVE_WINDOW+ }+ onSelect={() => {+ clock.pause();+ clock.seek(node.comment.t);+ setOpenId((current) =>+ current === node.comment.id ? null : node.comment.id,+ );+ }}+ />+ ))}++ {/* Positioning stays on a plain wrapper: motion writes its own+ inline `transform` for the entry animation, which would drop the+ class-based -translate-x-1/2 and push the card off the panel. */}+ {open && (+ <div+ className="absolute bottom-full z-40 mb-2 -translate-x-1/2"+ style={{+ left: `clamp(8.5rem, ${open.percent}%, 100% - 8.5rem)`,+ }}+ >+ <AnimatePresence>+ <motion.div+ key={open.comment.id}+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 6 }}+ animate={{ opacity: 1, y: 0 }}+ exit={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 6 }}+ transition={{ duration: 0.16 }}+ >+ <CommentCard comments={open.members} />+ </motion.div>+ </AnimatePresence>+ </div>+ )}+ </div>++ <div className="flex items-center gap-2 border-t border-gray-4 bg-white px-2 py-2 sm:px-3">+ <TransportButton playing={clock.playing} onClick={clock.toggle} />+ <span className="flex-1" />+ <Clock time={clock.time} />+ </div>+ </div>++ <div className="mt-4 rounded-xl border border-gray-4 bg-gray-1 p-1.5">+ <div className="px-2 py-1.5 text-[11px] font-medium uppercase tracking-[0.08em] text-gray-10">+ {onTimeline+ ? "The sidebar, now"+ : `Comments · ${DEMO_COMMENTS.length}`}+ </div>+ {onTimeline ? (+ <div className="px-2 pb-2 text-[13px] leading-relaxed text-gray-10">+ Empty. Every one of them is up there, on the second it belongs to.+ </div>+ ) : (+ <div className="flex flex-col">+ {DEMO_COMMENTS.map((comment) => (+ <CommentRow+ key={comment.id}+ comment={comment}+ onClick={() => {+ clock.pause();+ clock.seek(comment.t);+ }}+ />+ ))}+ </div>+ )}+ </div>+ </DemoPanel>+ );+}diff --git a/apps/web/components/blog/timeline/DemoBits.tsx b/apps/web/components/blog/timeline/DemoBits.tsxnew file mode 100644index 000000000..a8b62bec6--- /dev/null+++ b/apps/web/components/blog/timeline/DemoBits.tsx@@ -0,0 +1,364 @@+"use client";++import clsx from "clsx";+import { motion, useReducedMotion } from "motion/react";+import { seekKeyHandler, useSeekHandlers } from "./DemoStrip";+import type { DemoNode } from "./demo-layout";+import { clamp, DEMO_DURATION, type DemoComment, formatClock } from "./scene";++/** Node diameter, matching the product's `NODE_SIZE`. */+export const NODE_SIZE = 30;+/** Anchor line to node centre, per lane. */+export const LANE_STEM: readonly [number, number] = [26, 62];+export const MIN_NODE_GAP = 34;++export function Avatar({+ comment,+ className,+}: {+ comment: DemoComment;+ className?: string;+}) {+ return (+ <span+ className={clsx(+ "flex shrink-0 items-center justify-center rounded-full font-medium text-white",+ comment.tone,+ className ?? "size-7 text-[11px]",+ )}+ >+ {comment.initials}+ </span>+ );+}++export const PlayGlyph = () => (+ <svg viewBox="0 0 12 12" className="size-4 fill-current" aria-hidden>+ <title>Video reply</title>+ <path d="M4 2.6c0-.5.5-.8.9-.5l4 3.4c.3.3.3.7 0 1l-4 3.4c-.4.3-.9 0-.9-.5V2.6Z" />+ </svg>+);++export const MicGlyph = () => (+ <svg viewBox="0 0 12 12" className="size-4 fill-current" aria-hidden>+ <title>Voice note</title>+ <path d="M6 1.2a1.6 1.6 0 0 0-1.6 1.6v2.6a1.6 1.6 0 1 0 3.2 0V2.8A1.6 1.6 0 0 0 6 1.2Z" />+ <path d="M3 5.2a.5.5 0 0 0-1 0 4 4 0 0 0 3.5 3.97v1.13a.5.5 0 0 0 1 0V9.17A4 4 0 0 0 10 5.2a.5.5 0 0 0-1 0 3 3 0 0 1-6 0Z" />+ </svg>+);++/** What sits inside a node: avatar, emoji, or a media glyph. */+export function NodeFace({ comment }: { comment: DemoComment }) {+ if (comment.kind === "emoji") {+ return (+ <span aria-hidden className="font-emoji text-[19px] leading-none">+ {comment.text}+ </span>+ );+ }+ if (comment.kind === "voice") return <MicGlyph />;+ if (comment.kind === "video") return <PlayGlyph />;+ return <Avatar comment={comment} className="size-[26px] text-[11px]" />;+}++export function nodeClassName(comment: DemoComment, count: number) {+ if (count > 1) return "bg-white text-gray-12 ring-1 ring-gray-5";+ if (comment.kind === "emoji") return "text-[19px] leading-none";+ if (comment.kind === "voice") return "bg-blue-9 text-white";+ return "bg-white text-gray-12 ring-1 ring-gray-5";+}++/**+ * One branch: a hairline dropping off the anchor line with the node parked on+ * the end of it. Positioned by the caller in the shelf's coordinate space.+ */+export function BranchNode({+ node,+ active,+ delay = 0,+ onSelect,+ onHover,+}: {+ node: DemoNode;+ active?: boolean;+ /** Staggers the drop-in, so they arrive left to right. */+ delay?: number;+ onSelect?: () => void;+ onHover?: (hovering: boolean) => void;+}) {+ const reduceMotion = useReducedMotion() ?? false;+ const stem = LANE_STEM[node.lane];+ const { comment, count } = node;+ const label =+ count > 1+ ? `${count} comments around ${formatClock(comment.t)}`+ : `${comment.author} at ${formatClock(comment.t)}`;++ return (+ <motion.div+ className="pointer-events-none absolute top-0 z-30 w-0"+ style={{+ left: `clamp(${NODE_SIZE / 2}px, ${node.percent}%, 100% - ${NODE_SIZE / 2}px)`,+ transformOrigin: "top",+ }}+ initial={+ reduceMotion ? { opacity: 0 } : { opacity: 0, scaleY: 0.4, y: -6 }+ }+ animate={reduceMotion ? { opacity: 1 } : { opacity: 1, scaleY: 1, y: 0 }}+ transition={+ reduceMotion+ ? { duration: 0 }+ : { type: "spring", stiffness: 420, damping: 30, delay }+ }+ >+ <span+ aria-hidden+ className="absolute left-0 top-0 w-px -translate-x-1/2 bg-gradient-to-b from-gray-7 to-transparent"+ style={{ height: Math.max(0, stem - NODE_SIZE / 2) }}+ />+ <button+ type="button"+ aria-label={label}+ title={label}+ onClick={onSelect}+ onPointerEnter={() => onHover?.(true)}+ onPointerLeave={() => onHover?.(false)}+ onFocus={() => onHover?.(true)}+ onBlur={() => onHover?.(false)}+ className={clsx(+ "pointer-events-auto absolute left-0 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full shadow-[0_1px_3px_rgba(18,22,31,0.10)] transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ nodeClassName(comment, count),+ active && "ring-2 ring-blue-9",+ )}+ style={{ top: stem, width: NODE_SIZE, height: NODE_SIZE }}+ >+ {count > 1 ? (+ <span className="text-[12px] font-medium">{count}</span>+ ) : (+ <NodeFace comment={comment} />+ )}+ </button>+ </motion.div>+ );+}++/** The hairline the stems hang from. */+export function AnchorLine() {+ return (+ <div aria-hidden className="absolute inset-x-0 top-0 h-px bg-gray-5" />+ );+}++/** The card a node opens: what the reader would see on hover in the product. */+export function CommentCard({+ comments,+ className,+}: {+ comments: DemoComment[];+ className?: string;+}) {+ return (+ <div+ className={clsx(+ "w-64 rounded-xl border border-gray-4 bg-white p-3 shadow-[0_8px_24px_rgba(18,22,31,0.10)] sm:w-72",+ className,+ )}+ >+ <div className="flex flex-col gap-2.5">+ {comments.map((comment) => (+ <div key={comment.id} className="flex gap-2.5">+ <Avatar comment={comment} />+ <div className="min-w-0 flex-1">+ <div className="flex items-baseline gap-1.5">+ <span className="truncate text-[13px] font-medium text-gray-12">+ {comment.author}+ </span>+ <span className="text-[11px] text-gray-10">+ {formatClock(comment.t)}+ </span>+ </div>+ <div className="mt-0.5 text-[13px] leading-snug text-gray-11">+ {comment.kind === "voice"+ ? `Voice note · ${formatClock(comment.mediaDuration ?? 0)}`+ : comment.kind === "video"+ ? `Video reply · ${formatClock(comment.mediaDuration ?? 0)}`+ : comment.text}+ </div>+ </div>+ </div>+ ))}+ </div>+ </div>+ );+}++/** Play/pause, in either tone. */+export function TransportButton({+ playing,+ onClick,+ tone = "light",+}: {+ playing: boolean;+ onClick: () => void;+ tone?: "light" | "dark";+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ aria-label={playing ? "Pause" : "Play"}+ className={clsx(+ "flex size-8 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ tone === "dark"+ ? "text-white hover:bg-white/15"+ : "text-gray-12 hover:bg-gray-3",+ )}+ >+ {playing ? (+ <svg viewBox="0 0 16 16" className="size-4 fill-current" aria-hidden>+ <title>Pause</title>+ <rect x="4" y="3" width="3" height="10" rx="1" />+ <rect x="9" y="3" width="3" height="10" rx="1" />+ </svg>+ ) : (+ <svg viewBox="0 0 16 16" className="size-4 fill-current" aria-hidden>+ <title>Play</title>+ <path d="M5.5 3.3c0-.6.7-1 1.2-.6l6 4.2c.5.3.5 1 0 1.3l-6 4.2c-.5.4-1.2 0-1.2-.6V3.3Z" />+ </svg>+ )}+ </button>+ );+}++/** `0:42 / 2:48`, the readout the transport carries. */+export function Clock({+ time,+ tone = "light",+}: {+ time: number;+ tone?: "light" | "dark";+}) {+ return (+ <span+ className={clsx(+ "shrink-0 font-mono text-[12px] tabular-nums",+ tone === "dark" ? "text-white/80" : "text-gray-11",+ )}+ >+ {formatClock(time)}+ <span className={tone === "dark" ? "text-white/50" : "text-gray-9"}>+ {" / "}+ {formatClock(DEMO_DURATION)}+ </span>+ </span>+ );+}++/**+ * The seek bar every video player has: a track, a fill, a knob, and no+ * information about the recording whatsoever. Half this post is about what it+ * costs you.+ */+export function PlainSeekBar({+ time,+ onSeek,+ tone = "light",+ className,+}: {+ time: number;+ onSeek?: (time: number) => void;+ /** "dark" for a bar sitting over the video, the way classic playback does. */+ tone?: "light" | "dark";+ className?: string;+}) {+ const handlers = useSeekHandlers({ onSeek });+ const percent = clamp(time / DEMO_DURATION, 0, 1) * 100;+ const dark = tone === "dark";++ const semantics = onSeek+ ? {+ role: "slider" as const,+ tabIndex: 0,+ "aria-label": "Seek",+ "aria-valuemin": 0,+ "aria-valuemax": Math.round(DEMO_DURATION),+ "aria-valuenow": Math.round(time),+ onKeyDown: seekKeyHandler(time, onSeek),+ }+ : { "aria-hidden": true };++ return (+ <div+ className={clsx(+ "relative flex h-5 w-full touch-none select-none items-center",+ onSeek && "cursor-pointer",+ className,+ )}+ {...handlers}+ {...semantics}+ >+ <div+ className={clsx(+ "relative h-1.5 w-full rounded-full",+ dark ? "bg-white/30" : "bg-gray-6",+ )}+ >+ <div+ className={clsx(+ "absolute inset-y-0 left-0 rounded-full",+ dark ? "bg-white" : "bg-gray-12",+ )}+ style={{ width: `${percent}%` }}+ />+ <span+ className={clsx(+ "absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full",+ dark ? "bg-white" : "bg-gray-12 ring-2 ring-white",+ )}+ style={{ left: `clamp(6px, ${percent}%, 100% - 6px)` }}+ />+ </div>+ </div>+ );+}++/** The list a comment sidebar gives you: a row per comment, sorted by time. */+export function CommentRow({+ comment,+ active,+ onClick,+}: {+ comment: DemoComment;+ active?: boolean;+ onClick?: () => void;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ className={clsx(+ "flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ active ? "bg-blue-9/10" : "hover:bg-gray-3",+ )}+ >+ <Avatar comment={comment} />+ <span className="min-w-0 flex-1">+ <span className="flex items-baseline gap-1.5">+ <span className="truncate text-[13px] font-medium text-gray-12">+ {comment.author}+ </span>+ <span className="shrink-0 rounded bg-gray-3 px-1 py-px font-mono text-[11px] text-gray-11">+ {formatClock(comment.t)}+ </span>+ </span>+ <span className="mt-0.5 block text-[13px] leading-snug text-gray-11">+ {comment.kind === "voice"+ ? `Voice note · ${formatClock(comment.mediaDuration ?? 0)}`+ : comment.kind === "emoji"+ ? `Reacted ${comment.text}`+ : comment.text}+ </span>+ </span>+ </button>+ );+}diff --git a/apps/web/components/blog/timeline/DemoPanel.tsx b/apps/web/components/blog/timeline/DemoPanel.tsxnew file mode 100644index 000000000..3db8ca08d--- /dev/null+++ b/apps/web/components/blog/timeline/DemoPanel.tsx@@ -0,0 +1,103 @@+import clsx from "clsx";+import type { ReactNode } from "react";++/**+ * The frame every interactive in the timeline post sits in.+ *+ * Two things it has to do: break out of the 65ch prose column without ever+ * introducing a horizontal scrollbar (hence `92vw`, not `100vw`), and mark+ * itself `not-prose` so blog typography stops at its edge. Note that the demos+ * avoid `p`, `a` and `li` entirely — globals.css sizes those inside `.prose`+ * with `!important`, which `not-prose` cannot undo.+ */+export function DemoPanel({+ title,+ hint,+ action,+ caption,+ bodyClassName,+ children,+}: {+ /** Names the thing being demonstrated, e.g. "The timestamp list". */+ title: string;+ /** One line telling the reader what to do. */+ hint?: string;+ /** Header-right slot: reset buttons and the like. */+ action?: ReactNode;+ /** Runs under the panel, in the voice of the post. */+ caption?: ReactNode;+ bodyClassName?: string;+ children: ReactNode;+}) {+ return (+ <div className="not-prose relative left-1/2 my-10 w-[min(92vw,56rem)] -translate-x-1/2 sm:my-14">+ <div className="overflow-hidden rounded-2xl border border-gray-4 bg-white shadow-[0_10px_30px_rgba(18,22,31,0.05)]">+ <div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-b border-gray-4 bg-gray-2 px-4 py-3 sm:px-5">+ <div className="min-w-0">+ <div className="flex items-center gap-2">+ <span className="inline-block size-1.5 shrink-0 rounded-full bg-blue-9" />+ <span className="text-[11px] font-medium uppercase tracking-[0.08em] text-gray-10">+ Interactive+ </span>+ </div>+ <div className="mt-0.5 truncate text-sm font-medium text-gray-12">+ {title}+ </div>+ </div>+ {action}+ </div>++ <div className={clsx("p-4 sm:p-6", bodyClassName)}>+ {hint && (+ <div className="mb-4 text-[13px] leading-relaxed text-gray-10">+ {hint}+ </div>+ )}+ {children}+ </div>+ </div>++ {caption && (+ <div className="mx-1 mt-3 text-[13px] leading-relaxed text-gray-10">+ {caption}+ </div>+ )}+ </div>+ );+}++/** Small neutral button, used for resets and mode switches inside demos. */+export function DemoButton({+ onClick,+ children,+ variant = "ghost",+ disabled,+ className,+ title,+}: {+ onClick: () => void;+ children: ReactNode;+ variant?: "ghost" | "solid";+ disabled?: boolean;+ className?: string;+ title?: string;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ disabled={disabled}+ title={title}+ className={clsx(+ "inline-flex shrink-0 items-center justify-center gap-1.5 rounded-full px-3 py-1.5 text-[13px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ variant === "solid"+ ? "bg-gray-12 text-white hover:bg-gray-12/90"+ : "border border-gray-5 bg-white text-gray-12 hover:bg-gray-3",+ disabled && "cursor-not-allowed opacity-50",+ className,+ )}+ >+ {children}+ </button>+ );+}diff --git a/apps/web/components/blog/timeline/DemoStrip.tsx b/apps/web/components/blog/timeline/DemoStrip.tsxnew file mode 100644index 000000000..9be5d4516--- /dev/null+++ b/apps/web/components/blog/timeline/DemoStrip.tsx@@ -0,0 +1,328 @@+"use client";++import clsx from "clsx";+import {+ memo,+ type ReactNode,+ type PointerEvent as ReactPointerEvent,+ useCallback,+ useMemo,+ useRef,+ useState,+} from "react";+import {+ filmstripTileCount,+ filmstripWindowTimes,+} from "@/app/s/[videoId]/_components/timeline/filmstrip-math";+import { MockFrame } from "./MockFrame";+import { clamp, DEMO_DURATION, speechEnergy } from "./scene";++/**+ * The strip itself: drawn frames laid end to end, the speech envelope over+ * them, a played wash and the playhead. Same geometry as the real thing (tile+ * count comes from the product's own `filmstripTileCount`), minus everything+ * that needs a video element.+ *+ * Controlled: the parent owns `time` and the zoom window, so every demo can put+ * its own chrome around the same strip.+ */++/**+ * Width of an element, as a callback ref rather than a mount effect: demos+ * mount and unmount their strip when the reader flips a view, and a+ * `useEffect` that ran once against an empty ref would leave the branch layout+ * measuring zero and stacking every comment into one cluster.+ */+export function useMeasuredWidth<T extends HTMLElement>() {+ const [width, setWidth] = useState(0);+ const observer = useRef<ResizeObserver | null>(null);++ const ref = useCallback((node: T | null) => {+ observer.current?.disconnect();+ observer.current = null;+ if (!node) return;++ setWidth(node.clientWidth);+ if (typeof ResizeObserver === "undefined") return;+ const next = new ResizeObserver((entries) => {+ for (const entry of entries) setWidth(entry.contentRect.width);+ });+ next.observe(node);+ observer.current = next;+ }, []);++ return [ref, width] as const;+}++export interface DemoWindow {+ start: number;+ end: number;+}++export const FULL_WINDOW: DemoWindow = { start: 0, end: DEMO_DURATION };++export const fractionInWindow = (t: number, window: DemoWindow) => {+ const span = window.end - window.start;+ return span > 0 ? (t - window.start) / span : 0;+};++/**+ * Pointer plumbing shared by the strip and the plain seek bar: press to seek,+ * drag to scrub, and report hover to whoever wants a preview. Pointer events+ * (plus `touch-none`) cover mouse and touch in one path.+ */+export function useSeekHandlers({+ onSeek,+ onHoverTime,+ window = FULL_WINDOW,+}: {+ onSeek?: (time: number) => void;+ onHoverTime?: (time: number | null) => void;+ window?: DemoWindow;+}) {+ const scrubbing = useRef(false);++ const timeAt = useCallback(+ (clientX: number, element: HTMLElement) => {+ const rect = element.getBoundingClientRect();+ if (rect.width <= 0) return window.start;+ const fraction = clamp((clientX - rect.left) / rect.width, 0, 1);+ return window.start + fraction * (window.end - window.start);+ },+ [window],+ );++ const endScrub = (event: ReactPointerEvent<HTMLElement>) => {+ scrubbing.current = false;+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {+ event.currentTarget.releasePointerCapture(event.pointerId);+ }+ };++ return {+ onPointerDown: (event: ReactPointerEvent<HTMLElement>) => {+ if (!onSeek || event.button !== 0) return;+ event.currentTarget.setPointerCapture(event.pointerId);+ scrubbing.current = true;+ onSeek(timeAt(event.clientX, event.currentTarget));+ },+ onPointerMove: (event: ReactPointerEvent<HTMLElement>) => {+ const at = timeAt(event.clientX, event.currentTarget);+ if (scrubbing.current && onSeek) onSeek(at);+ else if (event.pointerType !== "touch") onHoverTime?.(at);+ },+ onPointerUp: endScrub,+ onPointerCancel: endScrub,+ onPointerLeave: () => onHoverTime?.(null),+ };+}++export function seekKeyHandler(+ time: number,+ onSeek?: (time: number) => void,+): ((event: React.KeyboardEvent) => void) | undefined {+ if (!onSeek) return undefined;+ return (event) => {+ if (event.key === "ArrowLeft") {+ event.preventDefault();+ onSeek(clamp(time - 5, 0, DEMO_DURATION));+ }+ if (event.key === "ArrowRight") {+ event.preventDefault();+ onSeek(clamp(time + 5, 0, DEMO_DURATION));+ }+ };+}++interface DemoStripProps {+ time: number;+ window?: DemoWindow;+ onSeek?: (time: number) => void;+ /** Fires with the time under a fine pointer, and null when it leaves. */+ onHoverTime?: (time: number | null) => void;+ waveform?: boolean;+ /** Drawn frames off, so the reader sees what a bare seek bar gives them. */+ film?: boolean;+ heightClass?: string;+ className?: string;+ /** Overlays that share the strip's coordinate space (playhead, ghosts). */+ children?: ReactNode;+ label?: string;+}++export function DemoStrip({+ time,+ window = FULL_WINDOW,+ onSeek,+ onHoverTime,+ waveform = true,+ film = true,+ heightClass = "h-12 sm:h-16",+ className,+ children,+ label = "Seek",+}: DemoStripProps) {+ const [ref, width] = useMeasuredWidth<HTMLDivElement>();+ const handlers = useSeekHandlers({ onSeek, onHoverTime, window });++ const tileCount = filmstripTileCount(width);+ const progress = clamp(fractionInWindow(time, window), 0, 1) * 100;++ // A strip with nothing to seek (the zoom and reply demos use one as a+ // backdrop) is decoration, so it announces itself as nothing at all rather+ // than as a slider that ignores you.+ const semantics = onSeek+ ? {+ role: "slider" as const,+ tabIndex: 0,+ "aria-label": label,+ "aria-valuemin": 0,+ "aria-valuemax": Math.round(DEMO_DURATION),+ "aria-valuenow": Math.round(time),+ onKeyDown: seekKeyHandler(time, onSeek),+ }+ : { "aria-hidden": true };++ return (+ <div+ ref={ref}+ className={clsx(+ "relative w-full touch-none select-none overflow-hidden bg-gray-3",+ heightClass,+ onSeek && "cursor-pointer",+ className,+ )}+ {...handlers}+ {...semantics}+ >+ {film ? (+ <FilmTiles count={tileCount} start={window.start} end={window.end} />+ ) : (+ <div aria-hidden className="absolute inset-0 bg-gray-4" />+ )}++ {waveform && <Envelope start={window.start} end={window.end} />}++ <div+ aria-hidden+ className="absolute inset-0 bg-gray-12/10"+ style={{ clipPath: `inset(0 ${100 - progress}% 0 0)` }}+ />+ <div+ aria-hidden+ className="absolute inset-x-0 bottom-0 h-[3px] bg-gray-12"+ style={{ clipPath: `inset(0 ${100 - progress}% 0 0)` }}+ />++ {children}+ </div>+ );+}++/**+ * Memoised on the window alone: scrubbing must not redraw twenty-odd SVG+ * frames, exactly as the real strip never re-renders its tiles during playback.+ */+const FilmTiles = memo(function FilmTiles({+ count,+ start,+ end,+}: {+ count: number;+ start: number;+ end: number;+}) {+ const times = useMemo(+ () => filmstripWindowTimes(count, start, end, DEMO_DURATION),+ [count, start, end],+ );++ if (count <= 0) {+ return (+ <div aria-hidden className="absolute inset-0 animate-pulse bg-gray-4" />+ );+ }++ return (+ <>+ <div aria-hidden className="absolute inset-0 flex">+ {times.map((t, index) => (+ <div+ key={`${index}-${t.toFixed(2)}`}+ className="relative h-full min-w-0 flex-1 overflow-hidden"+ >+ <MockFrame+ time={t}+ className="absolute inset-0 size-full saturate-[.9]"+ />+ </div>+ ))}+ </div>+ <div aria-hidden className="absolute inset-0 bg-white/20" />+ </>+ );+});++/**+ * Speech energy over the window, drawn symmetrically about the middle. The real+ * timeline derives this from the transcript rather than from decoded audio;+ * this one derives it from `speechEnergy`, which is the same shape of lie.+ */+const Envelope = memo(function Envelope({+ start,+ end,+}: {+ start: number;+ end: number;+}) {+ const path = useMemo(() => {+ const samples = 240;+ const top: string[] = [];+ const bottom: string[] = [];+ for (let index = 0; index <= samples; index++) {+ const x = (index / samples) * 1000;+ const t = start + (index / samples) * (end - start);+ const amplitude = clamp(speechEnergy(t), 0, 1) * 38;+ top.push(`${x.toFixed(1)},${(50 - amplitude).toFixed(1)}`);+ bottom.push(`${x.toFixed(1)},${(50 + amplitude).toFixed(1)}`);+ }+ bottom.reverse();+ return `M${top.join("L")}L${bottom.join("L")}Z`;+ }, [start, end]);++ return (+ <svg+ aria-hidden+ viewBox="0 0 1000 100"+ preserveAspectRatio="none"+ className="absolute inset-0 size-full"+ >+ <title>Speech energy across the recording</title>+ <path d={path} fill="rgba(18,22,31,0.34)" />+ </svg>+ );+});++/** The needle, in the strip's coordinate space. */+export function DemoPlayhead({+ time,+ window = FULL_WINDOW,+}: {+ time: number;+ window?: DemoWindow;+}) {+ const fraction = fractionInWindow(time, window);+ if (fraction < -0.02 || fraction > 1.02) return null;++ return (+ <div+ aria-hidden+ className="pointer-events-none absolute inset-y-0 z-20 w-px bg-gray-12"+ style={{+ left: `clamp(1px, ${(fraction * 100).toFixed(3)}%, 100% - 1px)`,+ }}+ >+ <span className="absolute -top-px left-1/2 size-2 -translate-x-1/2 rounded-full bg-gray-12 ring-2 ring-white" />+ </div>+ );+}diff --git a/apps/web/components/blog/timeline/ListDemo.tsx b/apps/web/components/blog/timeline/ListDemo.tsxnew file mode 100644index 000000000..d19ebe305--- /dev/null+++ b/apps/web/components/blog/timeline/ListDemo.tsx@@ -0,0 +1,77 @@+"use client";++import { useState } from "react";+import { Clock, CommentRow, PlainSeekBar, TransportButton } from "./DemoBits";+import { DemoPanel } from "./DemoPanel";+import { MockFrame } from "./MockFrame";+import { DEMO_COMMENTS } from "./scene";+import { useDemoClock } from "./useDemoClock";++/**+ * Where everyone starts: a video, a seek bar, and the feedback parked in a+ * sidebar next to it. Everything works. Nothing about the bar tells you that+ * three of the six comments land within six seconds of each other.+ */+export function ListDemo() {+ const clock = useDemoClock({ initial: 12 });+ const [activeId, setActiveId] = useState<string | null>(null);++ return (+ <DemoPanel+ title="The list you already have"+ hint="Click a comment to jump to it. Then, from the bar alone, try to tell where the other five are."+ caption="Every comment is a number you have to go and check. The bar is 168 seconds of nothing, and the sidebar is sorted by time, which is only useful once you already know what happened when."+ >+ <div className="flex flex-col gap-4 lg:flex-row">+ <div className="min-w-0 flex-1">+ <div className="overflow-hidden rounded-xl bg-[hsl(224,71.4%,4.1%)]">+ <div className="relative aspect-video">+ <MockFrame+ time={clock.time}+ className="absolute inset-0 size-full"+ />+ <div className="absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/60 to-transparent" />+ <div className="absolute inset-x-0 bottom-0 flex items-center gap-2 px-2 pb-2 sm:px-3 sm:pb-3">+ <TransportButton+ playing={clock.playing}+ onClick={clock.toggle}+ tone="dark"+ />+ <PlainSeekBar+ time={clock.time}+ onSeek={(t) => {+ clock.pause();+ clock.seek(t);+ setActiveId(null);+ }}+ tone="dark"+ />+ <Clock time={clock.time} tone="dark" />+ </div>+ </div>+ </div>+ </div>++ <div className="shrink-0 rounded-xl border border-gray-4 bg-gray-1 p-1.5 lg:w-72">+ <div className="px-2 py-1.5 text-[11px] font-medium uppercase tracking-[0.08em] text-gray-10">+ Comments · {DEMO_COMMENTS.length}+ </div>+ <div className="flex flex-col">+ {DEMO_COMMENTS.map((comment) => (+ <CommentRow+ key={comment.id}+ comment={comment}+ active={activeId === comment.id}+ onClick={() => {+ clock.pause();+ clock.seek(comment.t);+ setActiveId(comment.id);+ }}+ />+ ))}+ </div>+ </div>+ </div>+ </DemoPanel>+ );+}diff --git a/apps/web/components/blog/timeline/MockFrame.tsx b/apps/web/components/blog/timeline/MockFrame.tsxnew file mode 100644index 000000000..ef594faa1--- /dev/null+++ b/apps/web/components/blog/timeline/MockFrame.tsx@@ -0,0 +1,207 @@+import { clamp, DEMO_DURATION } from "./scene";++/**+ * A drawn frame of the fictional recording, at a given second.+ *+ * The post needs a film that visibly changes across its length — a filmstrip of+ * six identical gradients teaches nothing — but shipping a real video to a blog+ * post is a lot of bytes for a texture. So the "recording" is an SVG of a small+ * app being demoed, driven entirely by time: charts fill in, a cursor crosses to+ * a button, a dialog opens (with the flickering logo two of the demo comments+ * complain about), then it closes on a success state.+ *+ * `slice` cropping means the same component works as a 160x90 preview or as a+ * narrow filmstrip tile.+ */++const ACT_2 = 0.25;+const ACT_3 = 0.41;+const ACT_4 = 0.72;++interface Waypoint {+ p: number;+ x: number;+ y: number;+}++/** Where the cursor is, so it travels continuously across the whole scene. */+const CURSOR_PATH: readonly Waypoint[] = [+ { p: 0, x: 55, y: 72 },+ { p: ACT_2, x: 78, y: 55 },+ { p: ACT_3, x: 137, y: 20 },+ { p: 0.5, x: 110, y: 42 },+ { p: ACT_4, x: 96, y: 62 },+ { p: 1, x: 122, y: 74 },+];++function cursorAt(p: number) {+ for (let i = 1; i < CURSOR_PATH.length; i++) {+ const from = CURSOR_PATH[i - 1];+ const to = CURSOR_PATH[i];+ if (!from || !to) break;+ if (p > to.p) continue;+ const span = to.p - from.p;+ const k = span <= 0 ? 1 : (p - from.p) / span;+ // Ease so it settles on each target rather than sliding at constant speed.+ const eased = k < 0.5 ? 2 * k * k : 1 - (-2 * k + 2) ** 2 / 2;+ return {+ x: from.x + (to.x - from.x) * eased,+ y: from.y + (to.y - from.y) * eased,+ };+ }+ const last = CURSOR_PATH[CURSOR_PATH.length - 1];+ return { x: last?.x ?? 0, y: last?.y ?? 0 };+}++/** 0 outside the range, ramping to 1 just inside each edge. */+const band = (p: number, start: number, end: number, ramp = 0.02) =>+ clamp(Math.min((p - start) / ramp, (end - p) / ramp), 0, 1);++const BAR_HEIGHTS = [22, 34, 27, 41];++export function MockFrame({+ time,+ className,+}: {+ time: number;+ className?: string;+}) {+ const p = clamp(time / DEMO_DURATION, 0, 1);+ const cursor = cursorAt(p);+ // Never fully empty: a filmstrip tile at t=0 should still look like an app.+ const grow = 0.4 + 0.6 * clamp(p / 0.2, 0, 1);+ const dialog = band(p, ACT_3, ACT_4, 0.015);+ const success = band(p, ACT_4 + 0.02, 1.2, 0.03);+ const buttonHot = band(p, ACT_3 - 0.05, ACT_3 + 0.01, 0.03);+ // The defect Sam and Priya are pointing at: while the dialog is up, the mark+ // in its corner drops out every other beat.+ const flicker = dialog > 0 && Math.sin(time * 7.5) > 0.35 ? 0.25 : 1;++ return (+ <svg+ viewBox="0 0 160 90"+ preserveAspectRatio="xMidYMid slice"+ className={className}+ aria-hidden+ >+ <title>A frame of the example recording</title>+ <rect width="160" height="90" fill="#ffffff" />++ {/* Window chrome */}+ <rect width="160" height="11" fill="#f3f5f9" />+ <circle cx="7" cy="5.5" r="1.6" fill="#e0e4ec" />+ <circle cx="12.5" cy="5.5" r="1.6" fill="#e0e4ec" />+ <circle cx="18" cy="5.5" r="1.6" fill="#e0e4ec" />+ <rect x="26" y="3" width="62" height="5" rx="2.5" fill="#e7eaf0" />++ {/* Sidebar */}+ <rect y="11" width="30" height="79" fill="#f7f8fb" />+ {[18, 26, 34, 42].map((y, index) => (+ <rect+ key={y}+ x="6"+ y={y}+ width={index === 0 ? 17 : 13 + index * 2}+ height="3"+ rx="1.5"+ fill={index === 1 ? "var(--blue-9, #4785ff)" : "#e1e5ee"}+ opacity={index === 1 ? 0.5 : 1}+ />+ ))}++ {/* Content header + the button the cursor is heading for */}+ <rect x="38" y="19" width="44" height="5" rx="2.5" fill="#dfe3ec" />+ <rect x="38" y="28" width="30" height="3" rx="1.5" fill="#eaedf3" />+ <rect+ x="124"+ y="18"+ width="28"+ height="9"+ rx="4.5"+ fill="var(--blue-9, #4785ff)"+ opacity={0.55 + 0.45 * buttonHot}+ />++ {/* The chart being talked through */}+ {BAR_HEIGHTS.map((height, index) => {+ const appears = index === 3 ? success : 1;+ const h = height * grow * appears;+ return (+ <rect+ key={height}+ x={40 + index * 15}+ y={78 - h}+ width="10"+ height={Math.max(0, h)}+ rx="2"+ fill="var(--blue-9, #4785ff)"+ opacity={0.25 + index * 0.2}+ />+ );+ })}+ <rect x="38" y="80" width="114" height="1.5" rx="0.75" fill="#e7eaf0" />++ {/* Success state after the dialog closes */}+ {success > 0 && (+ <g opacity={success}>+ <circle cx="139" cy="63" r="8" fill="#10b981" opacity="0.14" />+ <path+ d="M135 63.5l2.8 2.8 5.4-5.6"+ stroke="#10b981"+ strokeWidth="1.8"+ strokeLinecap="round"+ strokeLinejoin="round"+ fill="none"+ />+ </g>+ )}++ {/* The dialog */}+ {dialog > 0 && (+ <g opacity={dialog}>+ <rect y="11" width="160" height="79" fill="#12161f" opacity="0.22" />+ <rect+ x="44"+ y="24"+ width="80"+ height="46"+ rx="5"+ fill="#ffffff"+ stroke="#e1e5ee"+ />+ <rect+ x="50"+ y="30"+ width="8"+ height="8"+ rx="2.5"+ fill="var(--blue-9, #4785ff)"+ opacity={flicker}+ />+ <rect x="62" y="32" width="30" height="4" rx="2" fill="#dfe3ec" />+ <rect x="50" y="44" width="60" height="3" rx="1.5" fill="#eaedf3" />+ <rect x="50" y="51" width="44" height="3" rx="1.5" fill="#eaedf3" />+ <rect+ x="88"+ y="58"+ width="30"+ height="8"+ rx="4"+ fill="var(--blue-9, #4785ff)"+ />+ </g>+ )}++ {/* Cursor */}+ <g transform={`translate(${cursor.x.toFixed(2)} ${cursor.y.toFixed(2)})`}>+ <path+ d="M0 0l0 9.5 2.4-2.4 1.6 3.4 1.8-.9-1.6-3.3 3.3-.1z"+ fill="#12161f"+ stroke="#ffffff"+ strokeWidth="0.6"+ strokeLinejoin="round"+ />+ </g>+ </svg>+ );+}diff --git a/apps/web/components/blog/timeline/ReplyDemo.tsx b/apps/web/components/blog/timeline/ReplyDemo.tsxnew file mode 100644index 000000000..b3ee24822--- /dev/null+++ b/apps/web/components/blog/timeline/ReplyDemo.tsx@@ -0,0 +1,252 @@+"use client";++import clsx from "clsx";+import { motion, useReducedMotion } from "motion/react";+import { useEffect, useState } from "react";+import { AnchorLine, BranchNode, CommentCard, MicGlyph } from "./DemoBits";+import { DemoButton, DemoPanel } from "./DemoPanel";+import { DemoPlayhead, DemoStrip } from "./DemoStrip";+import type { DemoNode } from "./demo-layout";+import { MockFrame } from "./MockFrame";+import { DEMO_DURATION, type DemoComment, formatClock } from "./scene";++/** Where the reply lands: just after the dialog closes. */+const REPLY_AT = 96;+const MAX_TAKE = 8;++type Kind = "screen" | "camera" | "voice";+type Phase = "idle" | "recording" | "done";++const KINDS: { kind: Kind; label: string }[] = [+ { kind: "screen", label: "Record screen" },+ { kind: "camera", label: "Record camera" },+ { kind: "voice", label: "Record voice note" },+];++/**+ * Answering in the same medium as the question. The capture is mimed — no+ * permission prompt, no camera, no upload — but the shape of the flow and where+ * the result lands are the real ones.+ */+export function ReplyDemo() {+ const reduceMotion = useReducedMotion() ?? false;+ const [phase, setPhase] = useState<Phase>("idle");+ const [kind, setKind] = useState<Kind>("screen");+ const [elapsed, setElapsed] = useState(0);++ useEffect(() => {+ if (phase !== "recording") return;+ const started = performance.now();+ const id = window.setInterval(() => {+ const seconds = (performance.now() - started) / 1000;+ if (seconds >= MAX_TAKE) {+ setElapsed(MAX_TAKE);+ setPhase("done");+ return;+ }+ setElapsed(seconds);+ }, 100);+ return () => window.clearInterval(id);+ }, [phase]);++ const reply: DemoComment = {+ id: "you",+ author: "You",+ initials: "Y",+ tone: "bg-gray-12",+ t: REPLY_AT,+ kind: kind === "voice" ? "voice" : "video",+ text: "Reply",+ mediaDuration: Math.max(1, Math.round(elapsed)),+ };++ const node: DemoNode = {+ comment: reply,+ lane: 0,+ percent: (REPLY_AT / DEMO_DURATION) * 100,+ count: 1,+ members: [reply],+ };++ return (+ <DemoPanel+ title="Reply with a recording"+ hint="Pick a way to answer. Nothing here touches your camera or microphone; it is a drawing of the flow."+ action={+ phase === "idle" ? undefined : (+ <DemoButton+ onClick={() => {+ setPhase("idle");+ setElapsed(0);+ }}+ >+ Start over+ </DemoButton>+ )+ }+ caption="The reply is a comment, not a second video: it lands on 1:36 of this recording, it shows up in the sidebar and in the notification, and it is deleted with the comment. Recording one needs you signed in, and the owner of the video on Cap Pro."+ >+ <div className="overflow-hidden rounded-xl border border-gray-4 bg-white">+ <div className="relative aspect-video bg-[hsl(224,71.4%,4.1%)]">+ <MockFrame time={REPLY_AT} className="absolute inset-0 size-full" />++ {phase === "recording" && (+ <div className="absolute inset-0 flex items-center justify-center bg-black/45 p-4">+ <div className="w-full max-w-xs rounded-xl border border-white/15 bg-[hsl(224,71.4%,4.1%)] p-3 shadow-xl">+ <TakePreview kind={kind} reduceMotion={reduceMotion} />+ <div className="mt-3 flex items-center gap-2">+ <motion.span+ className="size-2 shrink-0 rounded-full bg-red-500"+ animate={+ reduceMotion ? undefined : { opacity: [1, 0.3, 1] }+ }+ transition={{ repeat: Infinity, duration: 1.2 }}+ />+ <span className="font-mono text-[12px] tabular-nums text-white/80">+ {formatClock(elapsed)}+ </span>+ <button+ type="button"+ onClick={() => setPhase("done")}+ className="ml-auto rounded-full bg-white px-3 py-1 text-[12px] font-medium text-gray-12 transition-colors hover:bg-white/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9"+ >+ Stop+ </button>+ </div>+ </div>+ </div>+ )}+ </div>++ <DemoStrip time={REPLY_AT} film waveform>+ <DemoPlayhead time={REPLY_AT} />+ </DemoStrip>++ <div className="relative" style={{ height: phase === "done" ? 53 : 0 }}>+ {phase === "done" && (+ <>+ <AnchorLine />+ <BranchNode node={node} active />+ <div+ className="absolute bottom-full z-40 mb-2 -translate-x-1/2"+ style={{+ left: `clamp(8.5rem, ${node.percent}%, 100% - 8.5rem)`,+ }}+ >+ <CommentCard comments={[reply]} />+ </div>+ </>+ )}+ </div>++ <div className="flex flex-wrap items-center gap-2 border-t border-gray-4 bg-white px-2 py-2.5 sm:px-3">+ <div className="flex h-8 min-w-0 flex-1 items-center rounded-full border border-gray-5 px-3 text-[13px] text-gray-9">+ Comment at {formatClock(REPLY_AT)}+ </div>+ {KINDS.map((option) => (+ <button+ key={option.kind}+ type="button"+ disabled={phase === "recording"}+ aria-label={option.label}+ title={option.label}+ onClick={() => {+ setKind(option.kind);+ setElapsed(0);+ setPhase("recording");+ }}+ className={clsx(+ "flex size-8 shrink-0 items-center justify-center rounded-full border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ phase === "recording"+ ? "cursor-not-allowed border-gray-4 text-gray-8"+ : "border-gray-5 text-gray-11 hover:bg-gray-3 hover:text-gray-12",+ )}+ >+ <KindGlyph kind={option.kind} />+ </button>+ ))}+ </div>+ </div>+ </DemoPanel>+ );+}++function KindGlyph({ kind }: { kind: Kind }) {+ if (kind === "voice") return <MicGlyph />;+ if (kind === "camera") {+ return (+ <svg viewBox="0 0 16 16" className="size-4 fill-current" aria-hidden>+ <title>Camera</title>+ <rect x="1.5" y="4" width="9" height="8" rx="2" />+ <path d="M11.5 7.4l2.6-1.7c.3-.2.7 0 .7.4v3.8c0 .4-.4.6-.7.4l-2.6-1.7V7.4Z" />+ </svg>+ );+ }+ return (+ <svg viewBox="0 0 16 16" className="size-4 fill-current" aria-hidden>+ <title>Screen</title>+ <path d="M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4Zm3.5 9.5h5a.5.5 0 1 1 0 1h-5a.5.5 0 0 1 0-1Z" />+ </svg>+ );+}++/** What the recorder shows you mid-take, per kind. */+function TakePreview({+ kind,+ reduceMotion,+}: {+ kind: Kind;+ reduceMotion: boolean;+}) {+ if (kind === "voice") {+ return (+ <div className="flex h-20 items-center justify-center gap-1.5">+ {[0, 1, 2, 3, 4, 5, 6].map((index) => (+ <motion.span+ key={index}+ className="w-1.5 rounded-full bg-blue-9"+ style={{ height: 44 }}+ initial={{ scaleY: 0.3 }}+ animate={+ reduceMotion+ ? { scaleY: 0.6 }+ : { scaleY: [0.25, 1, 0.4, 0.8, 0.3] }+ }+ transition={+ reduceMotion+ ? { duration: 0 }+ : {+ repeat: Infinity,+ duration: 1.4,+ delay: index * 0.11,+ ease: "easeInOut",+ }+ }+ />+ ))}+ </div>+ );+ }++ if (kind === "camera") {+ return (+ <div className="flex h-20 items-center justify-center rounded-lg bg-white/10">+ <svg viewBox="0 0 48 48" className="h-16" aria-hidden>+ <title>Camera preview</title>+ <circle cx="24" cy="18" r="7.5" fill="rgba(255,255,255,0.5)" />+ <path+ d="M9 44c1.5-9 7.8-13.5 15-13.5S37.5 35 39 44Z"+ fill="rgba(255,255,255,0.5)"+ />+ </svg>+ </div>+ );+ }++ return (+ <div className="relative h-20 overflow-hidden rounded-lg">+ <MockFrame time={REPLY_AT + 6} className="absolute inset-0 size-full" />+ <div className="absolute inset-0 ring-2 ring-inset ring-red-500/70" />+ </div>+ );+}diff --git a/apps/web/components/blog/timeline/StripDemo.tsx b/apps/web/components/blog/timeline/StripDemo.tsxnew file mode 100644index 000000000..37b8f4a9d--- /dev/null+++ b/apps/web/components/blog/timeline/StripDemo.tsx@@ -0,0 +1,76 @@+"use client";++import { useState } from "react";+import { Clock, TransportButton } from "./DemoBits";+import { DemoPanel } from "./DemoPanel";+import { DemoPlayhead, DemoStrip } from "./DemoStrip";+import { MockFrame } from "./MockFrame";+import { clamp, DEMO_DURATION, formatClock } from "./scene";+import { useDemoClock } from "./useDemoClock";++/**+ * The same bar, with the video's own frames in it. Hovering previews without+ * committing — the product's hover ghost — and dragging scrubs.+ */+export function StripDemo() {+ const clock = useDemoClock({ initial: 30 });+ const [hover, setHover] = useState<number | null>(null);++ return (+ <DemoPanel+ title="The strip"+ hint="Drag across the film. On a mouse, hover it first: the preview follows without moving the video."+ caption="Same 168 seconds, same pixel width. The difference is that you can now see the dialog open, and you can aim at it."+ >+ <div className="overflow-hidden rounded-xl border border-gray-4">+ <div className="relative aspect-video bg-[hsl(224,71.4%,4.1%)]">+ <MockFrame time={clock.time} className="absolute inset-0 size-full" />+ </div>++ <div className="relative">+ <DemoStrip+ time={clock.time}+ waveform={false}+ onSeek={(t) => {+ clock.pause();+ clock.seek(t);+ }}+ onHoverTime={setHover}+ label="Scrub the recording"+ >+ <DemoPlayhead time={clock.time} />+ </DemoStrip>++ {hover !== null && (+ <div+ className="pointer-events-none absolute bottom-full z-30 mb-2 w-32 -translate-x-1/2 sm:w-40"+ style={{+ left: `clamp(4.5rem, ${(+ clamp(hover / DEMO_DURATION, 0, 1) * 100+ ).toFixed(2)}%, 100% - 4.5rem)`,+ }}+ >+ <div className="overflow-hidden rounded-lg border border-gray-5 bg-white shadow-[0_8px_24px_rgba(18,22,31,0.18)]">+ <div className="relative aspect-video">+ <MockFrame+ time={hover}+ className="absolute inset-0 size-full"+ />+ </div>+ <div className="px-2 py-1 text-center font-mono text-[11px] tabular-nums text-gray-11">+ {formatClock(hover)}+ </div>+ </div>+ </div>+ )}+ </div>++ <div className="flex items-center gap-2 border-t border-gray-4 bg-white px-2 py-2 sm:px-3">+ <TransportButton playing={clock.playing} onClick={clock.toggle} />+ <span className="flex-1" />+ <Clock time={clock.time} />+ </div>+ </div>+ </DemoPanel>+ );+}diff --git a/apps/web/components/blog/timeline/ToggleDemo.tsx b/apps/web/components/blog/timeline/ToggleDemo.tsxnew file mode 100644index 000000000..de2607468--- /dev/null+++ b/apps/web/components/blog/timeline/ToggleDemo.tsx@@ -0,0 +1,203 @@+"use client";++import { motion, useReducedMotion } from "motion/react";+import { useEffect, useMemo, useRef, useState } from "react";+import {+ type ShareView,+ ShareViewToggle,+} from "@/app/s/[videoId]/_components/ShareViewToggle";+import {+ AnchorLine,+ BranchNode,+ Clock,+ LANE_STEM,+ MIN_NODE_GAP,+ NODE_SIZE,+ PlainSeekBar,+ TransportButton,+} from "./DemoBits";+import { DemoPanel } from "./DemoPanel";+import {+ DemoPlayhead,+ DemoStrip,+ FULL_WINDOW,+ useMeasuredWidth,+} from "./DemoStrip";+import { layoutDemoNodes } from "./demo-layout";+import { MockFrame } from "./MockFrame";+import { DEMO_COMMENTS } from "./scene";+import { useDemoClock } from "./useDemoClock";++/**+ * The two views, side by side in time. Same recording, same position, same+ * controls — the seek bar is simply replaced by the strip, and the transport+ * moves out from over the video into the row that closes the card.+ *+ * The `T` shortcut is bound only while the pointer is over this demo, so the+ * rest of the page keeps its keyboard.+ */+export function ToggleDemo() {+ const reduceMotion = useReducedMotion() ?? false;+ const clock = useDemoClock({ initial: 44 });+ const [view, setView] = useState<ShareView>("classic");+ const [hovering, setHovering] = useState(false);+ const containerRef = useRef<HTMLDivElement | null>(null);+ const [stripRef, width] = useMeasuredWidth<HTMLDivElement>();++ useEffect(() => {+ if (!hovering) return;+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key !== "t" && event.key !== "T") return;+ if (event.metaKey || event.ctrlKey || event.altKey) return;+ const target = event.target as HTMLElement | null;+ if (+ target instanceof HTMLInputElement ||+ target instanceof HTMLTextAreaElement ||+ target?.isContentEditable+ ) {+ return;+ }+ event.preventDefault();+ setView((current) => (current === "classic" ? "timeline" : "classic"));+ };+ window.addEventListener("keydown", onKeyDown);+ return () => window.removeEventListener("keydown", onKeyDown);+ }, [hovering]);++ const nodes = useMemo(+ () =>+ view === "timeline"+ ? layoutDemoNodes(DEMO_COMMENTS, FULL_WINDOW, width, MIN_NODE_GAP)+ : [],+ [view, width],+ );++ const shelfHeight =+ nodes.length > 0+ ? Math.max(...nodes.map((node) => LANE_STEM[node.lane])) ++ NODE_SIZE / 2 ++ 12+ : 0;++ return (+ <DemoPanel+ title="One player, two views"+ hint="Flip between them. With your pointer over this demo you can also just press T, the way you would on a Cap link."+ caption="The video element never reloads, so the position, the volume and a running playback survive the switch. Going fullscreen puts the controls back over the video, because there is no card to dock them to."+ >+ <div+ ref={containerRef}+ onPointerEnter={() => setHovering(true)}+ onPointerLeave={() => setHovering(false)}+ >+ <motion.div+ layout={!reduceMotion}+ transition={+ reduceMotion+ ? { duration: 0 }+ : { type: "spring", stiffness: 260, damping: 32 }+ }+ className="overflow-hidden rounded-xl border border-gray-4 bg-white"+ >+ {view === "timeline" && (+ <div className="flex h-12 items-center justify-between gap-3 border-b border-gray-4 px-3 sm:px-4">+ <div className="flex min-w-0 items-center gap-2">+ <span className="flex size-7 shrink-0 items-center justify-center rounded-full bg-blue-9 text-[11px] font-medium text-white">+ R+ </span>+ <span className="truncate text-[13px] font-medium text-gray-12">+ Q3 walkthrough+ </span>+ </div>+ <ShareViewToggle view={view} onChange={setView} />+ </div>+ )}++ <div className="relative aspect-video bg-[hsl(224,71.4%,4.1%)]">+ <MockFrame+ time={clock.time}+ className="absolute inset-0 size-full"+ />++ {view === "classic" && (+ <>+ <div className="absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/60 to-transparent" />+ <div className="absolute inset-x-0 bottom-0 flex items-center gap-2 px-2 pb-2 sm:px-3 sm:pb-3">+ <TransportButton+ playing={clock.playing}+ onClick={clock.toggle}+ tone="dark"+ />+ <PlainSeekBar+ time={clock.time}+ onSeek={(t) => {+ clock.pause();+ clock.seek(t);+ }}+ tone="dark"+ />+ <Clock time={clock.time} tone="dark" />+ </div>+ </>+ )}+ </div>++ {view === "timeline" && (+ <>+ <div ref={stripRef}>+ <DemoStrip+ time={clock.time}+ onSeek={(t) => {+ clock.pause();+ clock.seek(t);+ }}+ >+ <DemoPlayhead time={clock.time} />+ </DemoStrip>+ </div>+ <div className="relative" style={{ height: shelfHeight }}>+ {nodes.length > 0 && <AnchorLine />}+ {nodes.map((node, index) => (+ <BranchNode+ key={node.comment.id}+ node={node}+ delay={index * 0.04}+ onSelect={() => {+ clock.pause();+ clock.seek(node.comment.t);+ }}+ />+ ))}+ </div>+ <div className="flex items-center gap-2 border-t border-gray-4 px-2 py-2 sm:px-3">+ <TransportButton+ playing={clock.playing}+ onClick={clock.toggle}+ />+ <span className="flex-1" />+ <Clock time={clock.time} />+ </div>+ </>+ )}+ </motion.div>++ {view === "classic" && (+ <div className="mt-3 flex items-center gap-3">+ <ShareViewToggle view={view} onChange={setView} />+ <span className="text-[13px] text-gray-10">+ Or press <Key>T</Key>+ </span>+ </div>+ )}+ </div>+ </DemoPanel>+ );+}++function Key({ children }: { children: React.ReactNode }) {+ return (+ <span className="inline-flex h-5 min-w-5 items-center justify-center rounded border border-gray-5 bg-gray-2 px-1 font-mono text-[11px] text-gray-12">+ {children}+ </span>+ );+}diff --git a/apps/web/components/blog/timeline/WaveformDemo.tsx b/apps/web/components/blog/timeline/WaveformDemo.tsxnew file mode 100644index 000000000..6f60aa19b--- /dev/null+++ b/apps/web/components/blog/timeline/WaveformDemo.tsx@@ -0,0 +1,116 @@+"use client";++import clsx from "clsx";+import { useState } from "react";+import { DemoButton, DemoPanel } from "./DemoPanel";+import { DemoPlayhead, DemoStrip } from "./DemoStrip";+import { DEMO_DURATION, formatClock, QUIET_GAP } from "./scene";++const [GAP_START, GAP_END] = QUIET_GAP;+/** Generous: the point is to notice the hole, not to hit a frame. */+const TOLERANCE = 2;++/**+ * A small game, because "the waveform shows you where the talking is" is a+ * sentence people nod at and don't believe until they've tried to find a pause+ * without one.+ */+export function WaveformDemo() {+ const [waveform, setWaveform] = useState(false);+ const [guess, setGuess] = useState<number | null>(null);+ const [attempts, setAttempts] = useState(0);++ const hit =+ guess !== null &&+ guess >= GAP_START - TOLERANCE &&+ guess <= GAP_END + TOLERANCE;+ const reveal = hit || attempts >= 3;++ return (+ <DemoPanel+ title="The waveform"+ hint="Somewhere in this recording the talking stops for nine seconds. Click where you think it is, then turn the waveform on and try again."+ action={+ <DemoButton+ onClick={() => setWaveform((value) => !value)}+ variant={waveform ? "solid" : "ghost"}+ >+ <span+ className={clsx(+ "size-1.5 rounded-full",+ waveform ? "bg-emerald-400" : "bg-gray-8",+ )}+ />+ Waveform {waveform ? "on" : "off"}+ </DemoButton>+ }+ caption="Cap draws this from the transcript rather than from decoded audio, so it is a map of speech, not of sound. Good for finding the part where someone answers your question; it will not show you the backing music."+ >+ <div className="relative overflow-hidden rounded-xl border border-gray-4">+ <DemoStrip+ time={guess ?? 0}+ waveform={waveform}+ onSeek={(t) => {+ setGuess(t);+ setAttempts((count) => count + 1);+ }}+ heightClass="h-16 sm:h-20"+ label="Guess where the pause is"+ >+ {reveal && (+ <div+ className="pointer-events-none absolute inset-y-0 z-20 border-x-2 border-emerald-500 bg-emerald-500/25"+ style={{+ left: `${(GAP_START / DEMO_DURATION) * 100}%`,+ width: `${((GAP_END - GAP_START) / DEMO_DURATION) * 100}%`,+ }}+ />+ )}+ {guess !== null && <DemoPlayhead time={guess} />}+ </DemoStrip>+ </div>++ <div+ className={clsx(+ "mt-3 flex min-h-9 items-center gap-2 rounded-lg px-3 py-2 text-[13px]",+ guess === null && "bg-gray-2 text-gray-10",+ guess !== null && hit && "bg-emerald-500/10 text-emerald-700",+ guess !== null && !hit && "bg-gray-2 text-gray-11",+ )}+ >+ {guess === null ? (+ <span>Click anywhere on the strip.</span>+ ) : hit ? (+ <span>+ Found it. Nobody says a word between{" "}+ <span className="font-medium">{formatClock(GAP_START)}</span> and{" "}+ <span className="font-medium">{formatClock(GAP_END)}</span>. They+ are switching apps.+ </span>+ ) : (+ <span>+ Still talking at{" "}+ <span className="font-medium">{formatClock(guess)}</span>.+ {attempts >= 3+ ? " The quiet stretch is marked above."+ : waveform+ ? " Look for the flat part."+ : " Try turning the waveform on."}+ </span>+ )}+ {guess !== null && (+ <button+ type="button"+ onClick={() => {+ setGuess(null);+ setAttempts(0);+ }}+ className="ml-auto shrink-0 text-[13px] font-medium text-gray-11 underline-offset-2 hover:underline"+ >+ Reset+ </button>+ )}+ </div>+ </DemoPanel>+ );+}diff --git a/apps/web/components/blog/timeline/ZoomDemo.tsx b/apps/web/components/blog/timeline/ZoomDemo.tsxnew file mode 100644index 000000000..fe441aaea--- /dev/null+++ b/apps/web/components/blog/timeline/ZoomDemo.tsx@@ -0,0 +1,282 @@+"use client";++import clsx from "clsx";+import {+ type PointerEvent as ReactPointerEvent,+ useMemo,+ useRef,+ useState,+} from "react";+import {+ AnchorLine,+ BranchNode,+ CommentCard,+ LANE_STEM,+ MIN_NODE_GAP,+ NODE_SIZE,+} from "./DemoBits";+import { DemoPanel } from "./DemoPanel";+import { DemoStrip, type DemoWindow, useMeasuredWidth } from "./DemoStrip";+import { layoutDemoNodes } from "./demo-layout";+import { clamp, DEMO_COMMENTS, DEMO_DURATION, formatClock } from "./scene";++/** Floor on the zoom window, in seconds — the product's `MIN_WINDOW_S`. */+const MIN_WINDOW = 10;+const ZOOM_STEP = 1.5;++const FULL: DemoWindow = { start: 0, end: DEMO_DURATION };++/**+ * What happens when three people comment on the same three seconds. At Fit they+ * are a stack; zoom in and they are three separate remarks again.+ */+export function ZoomDemo() {+ const [window, setWindow] = useState<DemoWindow>(FULL);+ const [openId, setOpenId] = useState<string | null>(null);+ const [ref, width] = useMeasuredWidth<HTMLDivElement>();++ const span = window.end - window.start;+ const atFit = span >= DEMO_DURATION - 0.5;++ // Functional: two quick presses of + must compound, not both zoom out of the+ // same starting span.+ const applyZoom = (factor: number, at?: number) => {+ setWindow((current) => {+ const currentSpan = current.end - current.start;+ const focus = at ?? current.start + currentSpan / 2;+ const nextSpan = clamp(currentSpan / factor, MIN_WINDOW, DEMO_DURATION);+ const focusFraction =+ currentSpan > 0 ? (focus - current.start) / currentSpan : 0.5;+ const start = clamp(+ focus - focusFraction * nextSpan,+ 0,+ DEMO_DURATION - nextSpan,+ );+ return { start, end: start + nextSpan };+ });+ };++ const nodes = useMemo(+ () => layoutDemoNodes(DEMO_COMMENTS, window, width, MIN_NODE_GAP),+ [window, width],+ );++ const shelfHeight =+ nodes.length > 0+ ? Math.max(...nodes.map((node) => LANE_STEM[node.lane])) ++ NODE_SIZE / 2 ++ 12+ : 0;++ const open = nodes.find((node) => node.comment.id === openId) ?? null;++ return (+ <DemoPanel+ title="Zoom"+ hint="Three people commented within six seconds, so two of them are stacked. Zoom in until they come apart, then drag the lit region below to move along the recording."+ caption={+ <>+ In Cap you zoom by pinching the strip, or by holding ⌘/Ctrl and+ scrolling on it, and double-click puts it back to Fit. The lit region+ here stands in for that. The zoom window is a slice of the recording,+ not a different recording.+ </>+ }+ >+ <div className="overflow-hidden rounded-xl border border-gray-4 bg-white">+ <div ref={ref}>+ <DemoStrip time={window.start} window={window} film waveform />+ </div>++ <div+ className="relative transition-[height] duration-200"+ style={{ height: shelfHeight }}+ >+ {nodes.length > 0 && <AnchorLine />}+ {nodes.map((node) => (+ <BranchNode+ key={`${node.comment.id}-${node.count}`}+ node={node}+ active={openId === node.comment.id}+ onSelect={() =>+ setOpenId((current) =>+ current === node.comment.id ? null : node.comment.id,+ )+ }+ />+ ))}++ {open && (+ <div+ className="absolute bottom-full z-40 mb-2 -translate-x-1/2"+ style={{ left: `clamp(8.5rem, ${open.percent}%, 100% - 8.5rem)` }}+ >+ <CommentCard comments={open.members} />+ </div>+ )}+ </div>++ <div className="flex items-center justify-between gap-3 border-t border-gray-4 bg-white px-2 py-2 sm:px-3">+ <span className="font-mono text-[12px] tabular-nums text-gray-11">+ {formatClock(window.start)}–{formatClock(window.end)}+ <span className="ml-2 text-gray-9">+ {atFit ? "whole recording" : `${Math.round(span)}s window`}+ </span>+ </span>+ <div className="flex shrink-0 items-center gap-1">+ <ZoomButton+ label="Fit"+ disabled={atFit}+ onClick={() => setWindow(FULL)}+ >+ Fit+ </ZoomButton>+ <ZoomButton+ label="Zoom out"+ disabled={atFit}+ onClick={() => applyZoom(1 / ZOOM_STEP)}+ >+ <svg+ viewBox="0 0 16 16"+ className="size-4 fill-current"+ aria-hidden+ >+ <title>Zoom out</title>+ <rect x="3" y="7.25" width="10" height="1.5" rx="0.75" />+ </svg>+ </ZoomButton>+ <ZoomButton+ label="Zoom in"+ disabled={span <= MIN_WINDOW + 0.5}+ onClick={() => applyZoom(ZOOM_STEP)}+ >+ <svg+ viewBox="0 0 16 16"+ className="size-4 fill-current"+ aria-hidden+ >+ <title>Zoom in</title>+ <rect x="3" y="7.25" width="10" height="1.5" rx="0.75" />+ <rect x="7.25" y="3" width="1.5" height="10" rx="0.75" />+ </svg>+ </ZoomButton>+ </div>+ </div>+ </div>++ <Minimap window={window} onChange={setWindow} />+ </DemoPanel>+ );+}++function ZoomButton({+ children,+ label,+ disabled,+ onClick,+}: {+ children: React.ReactNode;+ label: string;+ disabled?: boolean;+ onClick: () => void;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ disabled={disabled}+ aria-label={label}+ title={label}+ className={clsx(+ "flex h-7 min-w-7 items-center justify-center rounded-full px-2 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",+ disabled+ ? "cursor-not-allowed text-gray-8"+ : "text-gray-12 hover:bg-gray-3",+ )}+ >+ {children}+ </button>+ );+}++/**+ * The whole recording, with the part currently on the strip lit up. Draggable,+ * standing in for the pinch and ⌘-scroll gestures a blog post has no business+ * hijacking.+ */+function Minimap({+ window,+ onChange,+}: {+ window: DemoWindow;+ onChange: (next: DemoWindow) => void;+}) {+ const drag = useRef<{ x: number; start: number } | null>(null);+ const span = window.end - window.start;+ const full = span >= DEMO_DURATION - 0.5;++ const move = (clientX: number, element: HTMLElement, fromDrag: boolean) => {+ const rect = element.getBoundingClientRect();+ if (rect.width <= 0) return;+ if (fromDrag && drag.current) {+ const deltaT = ((clientX - drag.current.x) / rect.width) * DEMO_DURATION;+ const start = clamp(drag.current.start + deltaT, 0, DEMO_DURATION - span);+ onChange({ start, end: start + span });+ return;+ }+ const centre = ((clientX - rect.left) / rect.width) * DEMO_DURATION;+ const start = clamp(centre - span / 2, 0, DEMO_DURATION - span);+ onChange({ start, end: start + span });+ };++ return (+ <div className="mt-4">+ <div className="mb-1.5 text-[11px] font-medium uppercase tracking-[0.08em] text-gray-10">+ The whole recording+ </div>+ <div+ className="relative h-7 w-full cursor-grab touch-none select-none rounded-lg bg-gray-3"+ onPointerDown={(event: ReactPointerEvent<HTMLDivElement>) => {+ if (full || event.button !== 0) return;+ event.currentTarget.setPointerCapture(event.pointerId);+ const rect = event.currentTarget.getBoundingClientRect();+ const at = ((event.clientX - rect.left) / rect.width) * DEMO_DURATION;+ const inside = at >= window.start && at <= window.end;+ if (inside) drag.current = { x: event.clientX, start: window.start };+ else move(event.clientX, event.currentTarget, false);+ }}+ onPointerMove={(event: ReactPointerEvent<HTMLDivElement>) => {+ if (!drag.current) return;+ move(event.clientX, event.currentTarget, true);+ }}+ onPointerUp={(event: ReactPointerEvent<HTMLDivElement>) => {+ drag.current = null;+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {+ event.currentTarget.releasePointerCapture(event.pointerId);+ }+ }}+ onPointerCancel={() => {+ drag.current = null;+ }}+ >+ {DEMO_COMMENTS.map((comment) => (+ <span+ key={comment.id}+ className="absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-gray-9"+ style={{ left: `${(comment.t / DEMO_DURATION) * 100}%` }}+ />+ ))}+ <div+ className={clsx(+ "absolute inset-y-0 rounded-lg border-2 border-gray-12 bg-gray-12/10",+ full && "opacity-40",+ )}+ style={{+ left: `${(window.start / DEMO_DURATION) * 100}%`,+ width: `${(span / DEMO_DURATION) * 100}%`,+ }}+ />+ </div>+ </div>+ );+}diff --git a/apps/web/components/blog/timeline/demo-layout.ts b/apps/web/components/blog/timeline/demo-layout.tsnew file mode 100644index 000000000..ec72a98a3--- /dev/null+++ b/apps/web/components/blog/timeline/demo-layout.ts@@ -0,0 +1,70 @@+import type { DemoWindow } from "./DemoStrip";+import { fractionInWindow } from "./DemoStrip";+import type { DemoComment } from "./scene";++/**+ * A cut-down version of the timeline's branch layout: nodes hang off the moment+ * they belong to, drop to a second lane when they would touch, and fold into a+ * cluster once even that is full. The real one lives in+ * `_components/timeline/timeline-layout.ts` and handles a good deal more; this+ * exists so the demos can lay out six comments without dragging the share+ * page's domain types into a blog post.+ */++export interface DemoNode {+ comment: DemoComment;+ lane: 0 | 1;+ /** Position across the strip, 0-100. */+ percent: number;+ /** Comments folded into this node, including itself. */+ count: number;+ /** The folded comments, for the cluster card. */+ members: DemoComment[];+}++export function layoutDemoNodes(+ comments: readonly DemoComment[],+ window: DemoWindow,+ trackWidth: number,+ minGap: number,+): DemoNode[] {+ const visible = comments+ .filter((comment) => comment.t >= window.start && comment.t <= window.end)+ .sort((a, b) => a.t - b.t);++ const nodes: DemoNode[] = [];+ const lastX: [number, number] = [+ Number.NEGATIVE_INFINITY,+ Number.NEGATIVE_INFINITY,+ ];++ for (const comment of visible) {+ const fraction = fractionInWindow(comment.t, window);+ const x = fraction * trackWidth;++ const lane: 0 | 1 | null =+ x - lastX[0] >= minGap ? 0 : x - lastX[1] >= minGap ? 1 : null;++ if (lane === null) {+ // Nowhere left to put it: it joins the node it collided with.+ const host = nodes[nodes.length - 1];+ if (host) {+ host.count += 1;+ host.members.push(comment);+ continue;+ }+ }++ const resolved: 0 | 1 = lane ?? 0;+ lastX[resolved] = x;+ nodes.push({+ comment,+ lane: resolved,+ percent: fraction * 100,+ count: 1,+ members: [comment],+ });+ }++ return nodes;+}diff --git a/apps/web/components/blog/timeline/scene.ts b/apps/web/components/blog/timeline/scene.tsnew file mode 100644index 000000000..eebaddc7f--- /dev/null+++ b/apps/web/components/blog/timeline/scene.ts@@ -0,0 +1,138 @@+/**+ * The worked example every demo in the timeline post shares: one 2:48 product+ * walkthrough, six pieces of feedback on it, and a synthetic soundtrack.+ *+ * Keeping a single scene across every demo is the point — the reader meets the+ * same six comments as a flat list, then watches them land on the video, then+ * untangles the three that collide. Nothing here talks to the network or to a+ * real recording; the frames are drawn (see `MockFrame`) and the waveform is a+ * deterministic function of time, so every demo agrees with every other one.+ */++/** Length of the fictional recording, in seconds. */+export const DEMO_DURATION = 168;++export type DemoCommentKind = "text" | "emoji" | "video" | "voice";++export interface DemoComment {+ id: string;+ author: string;+ /** Avatar letter; the demo has no real images to sign. */+ initials: string;+ /** Tailwind background class for the avatar. */+ tone: string;+ /** Seconds into the recording. */+ t: number;+ kind: DemoCommentKind;+ /** Comment body, or the emoji itself for reactions. */+ text: string;+ /** Media length for video/voice replies, in seconds. */+ mediaDuration?: number;+}++/**+ * Three of these sit inside six seconds of each other on purpose: that pile-up+ * is what the lanes, the cluster and the zoom demo all exist to explain.+ */+export const DEMO_COMMENTS: readonly DemoComment[] = [+ {+ id: "c1",+ author: "Maya",+ initials: "M",+ tone: "bg-blue-9",+ t: 12,+ kind: "text",+ text: "Can we open on the problem rather than the dashboard?",+ },+ {+ id: "c2",+ author: "Dev",+ initials: "D",+ tone: "bg-emerald-500",+ t: 44,+ kind: "emoji",+ text: "🔥",+ },+ {+ id: "c3",+ author: "Sam",+ initials: "S",+ tone: "bg-violet-500",+ t: 72,+ kind: "text",+ text: "The logo flickers the moment the dialog opens.",+ },+ {+ id: "c4",+ author: "Priya",+ initials: "P",+ tone: "bg-amber-500",+ t: 75,+ kind: "text",+ text: "Same, but only on Safari for me.",+ },+ {+ id: "c5",+ author: "Jo",+ initials: "J",+ tone: "bg-rose-500",+ t: 78,+ kind: "voice",+ text: "Voice note",+ mediaDuration: 14,+ },+ {+ id: "c6",+ author: "Alex",+ initials: "A",+ tone: "bg-sky-600",+ t: 151,+ kind: "text",+ text: "Ship it. I'll take the copy pass.",+ },+];++/**+ * When someone is talking. The two holes are the pauses the waveform demo asks+ * the reader to find: 1:01–1:10 (switching apps) and 2:09–2:18.+ */+export const SPEECH_SEGMENTS: readonly (readonly [number, number])[] = [+ [2, 61],+ [70, 129],+ [138, 166],+];++/** The gap the waveform demo scores against. */+export const QUIET_GAP: readonly [number, number] = [61, 70];++const hash = (n: number) => {+ const x = Math.sin(n * 12.9898 + 78.233) * 43758.5453;+ return x - Math.floor(x);+};++const isSpeaking = (t: number) =>+ SPEECH_SEGMENTS.some(([start, end]) => t >= start && t <= end);++/**+ * Loudness at a moment, 0-1. Two layers so it reads as a voice rather than as+ * noise: a slow syllable swell, and a per-50ms grain on top. Room tone under+ * the pauses, because a flat zero looks like a broken render.+ */+export function speechEnergy(t: number): number {+ const grain = hash(Math.round(t * 20));+ if (!isSpeaking(t)) return 0.04 + 0.05 * grain;++ const syllable = 0.55 + 0.45 * Math.sin(t * 2.7);+ const phrase = 0.75 + 0.25 * Math.sin(t * 0.6 + 1.2);+ return Math.min(1, 0.2 + 0.8 * syllable * phrase * (0.82 + 0.32 * grain));+}++export function formatClock(seconds: number): string {+ const safe = Number.isFinite(seconds) ? Math.max(0, seconds) : 0;+ const mins = Math.floor(safe / 60);+ const secs = Math.floor(safe % 60);+ return `${mins}:${secs.toString().padStart(2, "0")}`;+}++export const clamp = (value: number, min: number, max: number) =>+ Math.min(max, Math.max(min, value));diff --git a/apps/web/components/blog/timeline/useDemoClock.ts b/apps/web/components/blog/timeline/useDemoClock.tsnew file mode 100644index 000000000..d63fe5775--- /dev/null+++ b/apps/web/components/blog/timeline/useDemoClock.ts@@ -0,0 +1,58 @@+"use client";++import { useCallback, useEffect, useRef, useState } from "react";+import { clamp, DEMO_DURATION } from "./scene";++/**+ * A playhead without a video behind it.+ *+ * The fictional recording is 2:48, which nobody is going to sit through inside a+ * blog post, so demos run the clock fast by default — long enough to watch the+ * playhead cross a comment, short enough that a full pass is a few seconds.+ */+export function useDemoClock({+ initial = 0,+ rate = 6,+}: {+ initial?: number;+ rate?: number;+} = {}) {+ const [time, setTime] = useState(initial);+ const [playing, setPlaying] = useState(false);+ const timeRef = useRef(initial);++ const seek = useCallback((next: number) => {+ const value = clamp(next, 0, DEMO_DURATION);+ timeRef.current = value;+ setTime(value);+ }, []);++ useEffect(() => {+ if (!playing) return;+ if (timeRef.current >= DEMO_DURATION) seek(0);++ let frame = 0;+ let last = performance.now();++ const tick = (now: number) => {+ const delta = (now - last) / 1000;+ last = now;+ const next = timeRef.current + delta * rate;+ if (next >= DEMO_DURATION) {+ seek(DEMO_DURATION);+ setPlaying(false);+ return;+ }+ seek(next);+ frame = requestAnimationFrame(tick);+ };++ frame = requestAnimationFrame(tick);+ return () => cancelAnimationFrame(frame);+ }, [playing, rate, seek]);++ const toggle = useCallback(() => setPlaying((value) => !value), []);+ const pause = useCallback(() => setPlaying(false), []);++ return { time, seek, playing, toggle, pause };+}diff --git a/apps/web/content/blog/timeline-view.mdx b/apps/web/content/blog/timeline-view.mdxnew file mode 100644index 000000000..2fe92fd42--- /dev/null+++ b/apps/web/content/blog/timeline-view.mdx@@ -0,0 +1,59 @@+---+title: Introducing Timeline view+description: Timeline view is a new way to collaborate on the videos you share. Comments sit on the timeline at the moment they're about, and your team or clients can reply with their screen, camera, or voice.+publishedAt: "2026-08-05"+category: Product+image: /blog/timeline-view.jpg+author: Richie McIlroy+tags: Product, Timeline, Collaboration+---++Hey everyone,++Today we're shipping Timeline view: a new way to collaborate on the videos you share.++Most Caps aren't just watched. They're reviewed. You send a walkthrough to your team, a cut to a client, a bug report to an engineer, and what comes back is comments like this:++> **Sam** 1:12 The logo flickers the moment the dialog opens.+>+> **Priya** 1:15 Same, but only on Safari for me.++Those two comments are about the same three seconds of video, but they sit in a sidebar next to the player, and connecting the numbers to the moments is your job. Nothing on the page knows they belong together.++Timeline view fixes that. Comments now sit on the video's timeline, at the moment they're about, and the people you shared with can reply with their screen, their camera, or their voice. The whole review happens on the video, instead of next to it.++Here's how it works.++## Comments, where they happened++This is a small working version of the real thing. Press play:++<BranchesDemo />++Every comment hangs off the second it was left at, and comes up as you reach it. Threads collapse into their parent, emoji reactions get their own markers, and when a few comments land on the same moment they group together until you zoom in (pinch, or hold ⌘ and scroll; double-click zooms back out).++The bar itself is built from your recording: real frames from the video so you can find things by sight, and a speech envelope drawn from the transcript so you can see where the talking is and skip the dead air.++## Reply with a recording++This is the part I'm most excited about. Most feedback on a video is about something visual, and typing it out is the clumsiest way to give it. A teammate describing a bug, a client explaining which part of the design they mean: now they can just show you.++<ReplyDemo />++Signed-in viewers can reply at any timestamp with their screen, their camera, or a voice note. Replies upload while you record, the same way instant recordings do, so they're ready about as soon as you stop talking.++Recording a reply requires the video's owner to be on Cap Pro. Watching them is open to everyone.++## Still one player++Timeline view isn't a separate page or a mode you have to commit to. It's the same player with a different set of controls:++<ToggleDemo />++Hit **Timeline** under any shared recording, or press <kbd>T</kbd>. Switch mid-playback and nothing resets. It's live now on every shared Cap with comments enabled, for everyone watching, signed in or not.++Try it with your team on something you've already shared, and tell me what you think. If the timeline doesn't show you something the comment list didn't, I want to know.++Richie McIlroy++Founder of Capdiff --git a/apps/web/public/blog/timeline-view.jpg b/apps/web/public/blog/timeline-view.jpgnew file mode 100644index 000000000..beaa3f400Binary files /dev/null and b/apps/web/public/blog/timeline-view.jpg differ