Screenshot Tour
The camera tours a product screenshot, zooming in on regions of an issue tracker.
Source
components/kuchi/screenshot-tour.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/Geist";4import { loadFont as loadMono } from "@remotion/google-fonts/GeistMono";5import type React from "react";6import {7 AbsoluteFill,8 Easing,9 Img,10 interpolate,11 spring,12 useCurrentFrame,13 useVideoConfig,14} from "remotion";15import type { GradientParams } from "@/lib/kuchi/gsh/gradient-engine";16import { GshGround } from "@/lib/kuchi/gsh/gsh-ground";17import type { GshPresetId } from "@/lib/kuchi/gsh/presets";1819const { fontFamily: sans } = loadFont("normal", {20 weights: ["300", "400"],21 subsets: ["latin"],22});23const { fontFamily: mono } = loadMono("normal", {24 weights: ["400"],25 subsets: ["latin"],26});272829export interface TourStop {30 /** Focus rect in screenshot pixel coordinates. */31 x: number;32 y: number;33 width: number;34 height: number;35 label: string;36}3738export interface ScreenshotTourProps {39 /** Screenshot URL. Falls back to `children`, then to the built-in mock. */40 src?: string;41 children?: React.ReactNode;42 /** Natural size of the screenshot (or of the `children` box). */43 screenshotWidth?: number;44 screenshotHeight?: number;45 stops?: TourStop[];46 framesPerStop?: number;47 /** Strength of the veil over everything outside the focus, 0..1. */48 dim?: number;49 /** Pull back to the full shot after the last stop. */50 pullBack?: boolean;51 /** Workspace name in the built-in mock's sidebar. */52 brand?: string;53 /** Replaces the acme mark in the built-in mock's sidebar. */54 logo?: React.ReactNode;55 theme?: "light" | "dark";56 accent?: string;57 /** Text color of the stop labels; overrides the theme ink. */58 ink?: string;59 /** Solid fill in place of the gradient ground; "transparent" drops it. */60 background?: string;61 /** Typeface for the stop labels. Load it yourself; Geist by default. */62 fontFamily?: string;63 /** Size of the screenshot and labels, around the frame's center. */64 scale?: number;65 /** Frames to hold the first frame before anything moves. */66 delay?: number;67 speed?: number;68 /** gradients.sh preset for the ground. Defaults to "earthshine" (dark) or "glasswork" (light). */69 ground?: GshPresetId;70 groundParams?: Partial<GradientParams>;71}7273const DEFAULT_STOPS: TourStop[] = [74 {75 x: 240,76 y: 63,77 width: 660,78 height: 182,79 label: "Every issue, grouped by status",80 },81 {82 x: 1004,83 y: 99,84 width: 412,85 height: 146,86 label: "Labels, owners and due dates",87 },88 {89 x: 8,90 y: 244,91 width: 216,92 height: 172,93 label: "Each team gets its own space",94 },95];9697const ESTABLISH = 18;98const RETURN = 24;99const DRIFT = 0.025;100const MOVE = Easing.bezier(0.65, 0, 0.35, 1);101const EXIT = Easing.bezier(0.55, 0, 1, 0.45);102const HEAVY = { mass: 1, damping: 26, stiffness: 120 };103const CARD = { mass: 0.8, damping: 18, stiffness: 160 };104105interface Cam {106 x: number;107 y: number;108 s: number;109}110111const clamp = (v: number, lo: number, hi: number) =>112 Math.min(hi, Math.max(lo, v));113114function travel(a: Cam, b: Cam, p: number, pull: number): Cam {115 const s =116 Math.exp(Math.log(a.s) + (Math.log(b.s) - Math.log(a.s)) * p) *117 (1 - pull * Math.sin(Math.PI * p));118 const dx = b.x - a.x;119 const dy = b.y - a.y;120 const bend = Math.sin(Math.PI * p) * 0.16;121 return { x: a.x + dx * p - dy * bend, y: a.y + dy * p + dx * bend, s };122}123124/** The foreground at `scale`, around the frame's center; nothing extra at 1. */125function ScaleLayer({126 scale,127 children,128}: {129 scale: number;130 children: React.ReactNode;131}) {132 if (scale === 1) return children;133 return (134 <AbsoluteFill style={{ transform: `scale(${scale})` }}>135 {children}136 </AbsoluteFill>137 );138}139140export function ScreenshotTour({141 src,142 children,143 screenshotWidth = MOCK_W,144 screenshotHeight = MOCK_H,145 stops = DEFAULT_STOPS,146 framesPerStop = 45,147 dim = 0.55,148 pullBack = true,149 brand = "acme",150 logo,151 theme = "light",152 accent = "#3B5BFD",153 ink,154 background,155 fontFamily = sans,156 scale: layerScale = 1,157 delay = 0,158 speed = 1,159 ground,160 groundParams,161}: ScreenshotTourProps) {162 const frame = Math.max(0, useCurrentFrame() - delay) * speed;163 const { width: W, height: H, fps } = useVideoConfig();164 const sw = screenshotWidth;165 const sh = screenshotHeight;166 const tall = H > W * 1.2;167 const u = Math.min(W / 1280, H / 720);168 const dark = theme === "dark";169 const n = stops.length;170 const F = framesPerStop;171 const T = Math.round(Math.min(20, F * 0.45));172173 const s0 = tall174 ? (W * 0.88) / sw175 : Math.min((W * 0.72) / sw, (H * 0.74) / sh);176 const cy = tall ? H * 0.6 : H * 0.5;177 const home: Cam = { x: sw / 2, y: sh / 2, s: s0 };178 const labelRoom = tall ? 0 : 64 * u;179 const camFor = (st: TourStop): Cam => {180 const fit = tall181 ? Math.min((W * 0.84) / st.width, (H * 0.36) / st.height)182 : Math.min((W * 0.6) / st.width, (H * 0.5) / st.height);183 const s = clamp(fit, s0 * 1.9, s0 * 2.3);184 return {185 x: st.x + st.width / 2,186 y: st.y + st.height / 2 + labelRoom / 2 / s,187 s,188 };189 };190 const keys = [home, ...stops.map(camFor)];191 const drifted = (i: number): Cam => ({192 ...keys[i],193 s: keys[i].s * (1 + (i === 0 ? 0.012 : DRIFT)),194 });195196 let cam: Cam;197 let spotRect: TourStop = stops[0] ?? {198 x: 0,199 y: 0,200 width: sw,201 height: sh,202 label: "",203 };204 let spotAmount = 0;205 const tourEnd = ESTABLISH + n * F;206 if (frame < ESTABLISH || n === 0) {207 cam = { ...home, s: home.s * (1 + 0.012 * clamp(frame / ESTABLISH, 0, 1)) };208 } else if (frame < tourEnd) {209 const i = Math.floor((frame - ESTABLISH) / F);210 const local = frame - ESTABLISH - i * F;211 const p = MOVE(clamp(local / T, 0, 1));212 cam = travel(drifted(i), keys[i + 1], p, i > 0 ? 0.12 : 0);213 cam.s *= 1 + DRIFT * clamp((local - T) / (F - T), 0, 1);214 const prev = stops[Math.max(0, i - 1)];215 const next = stops[i];216 spotRect = {217 x: prev.x + (next.x - prev.x) * p,218 y: prev.y + (next.y - prev.y) * p,219 width: prev.width + (next.width - prev.width) * p,220 height: prev.height + (next.height - prev.height) * p,221 label: next.label,222 };223 spotAmount =224 i === 0225 ? interpolate(p, [0.3, 1], [0, 1], { extrapolateLeft: "clamp" })226 : 1;227 } else {228 const p = MOVE(clamp((frame - tourEnd) / RETURN, 0, 1));229 spotRect = stops[n - 1];230 cam = pullBack ? travel(drifted(n), home, p, 0) : drifted(n);231 spotAmount = pullBack ? 1 - p : 1;232 }233234 const enter = spring({ frame: frame + 2, fps, config: HEAVY });235 const enterScale = interpolate(enter, [0, 1], [0.94, 1]);236 const scale = cam.s * enterScale;237 const lift = (1 - enter) * 0.05 * H;238239 const toScreen = (x: number, y: number) => ({240 x: (x - cam.x) * scale + W / 2,241 y: (y - cam.y) * scale + cy + lift,242 });243244 const content = src ? (245 <Img246 src={src}247 style={{ width: sw, height: sh, objectFit: "cover", display: "block" }}248 />249 ) : (250 (children ?? (251 <IssuesMock252 theme={theme}253 accent={accent}254 width={sw}255 height={sh}256 brand={brand}257 logo={logo}258 />259 ))260 );261262 const pad = 12;263 const arrivals = stops.map((_, i) =>264 spring({265 frame: frame - (ESTABLISH + i * F + T - 5),266 fps,267 config: CARD,268 }),269 );270 const activeIdx = clamp(Math.floor((frame - ESTABLISH) / F), 0, n - 1);271 const settle = frame >= tourEnd ? 1 : arrivals[activeIdx];272 const slack = (1 - settle) * 8 * u;273 const tl = toScreen(spotRect.x - pad / 2, spotRect.y - pad / 2);274 const ring = {275 x: tl.x - slack,276 y: tl.y - slack,277 w: (spotRect.width + pad) * scale + slack * 2,278 h: (spotRect.height + pad) * scale + slack * 2,279 };280 const r = 10 * u;281 // Scaled down, the veil's outer edge would show; reach past the frame instead.282 const outer =283 layerScale === 1284 ? `M0 0H${W}V${H}H0Z`285 : `M${-W} ${-H}H${2 * W}V${2 * H}H${-W}Z`;286 const hole = `${outer} M${ring.x + r} ${ring.y}H${ring.x + ring.w - r}A${r} ${r} 0 0 1 ${ring.x + ring.w} ${ring.y + r}V${ring.y + ring.h - r}A${r} ${r} 0 0 1 ${ring.x + ring.w - r} ${ring.y + ring.h}H${ring.x + r}A${r} ${r} 0 0 1 ${ring.x} ${ring.y + ring.h - r}V${ring.y + r}A${r} ${r} 0 0 1 ${ring.x + r} ${ring.y}Z`;287288 const zoomed = clamp((cam.s / s0 - 1) / 0.8, 0, 1);289 const veil = dark ? "#040507" : "#F3F3F5";290 const card = {291 bg: dark ? "#1B1C20" : "#141518",292 ink: "#F4F4F5",293 sub: "rgba(244,244,245,0.5)",294 edge: dark295 ? "inset 0 0 0 1px rgba(255,255,255,0.09), inset 0 1px 0 rgba(255,255,255,0.06), 0 12px 32px -8px rgba(0,0,0,0.6)"296 : "inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 4px rgba(16,24,40,0.12), 0 14px 32px -8px rgba(16,24,40,0.35)",297 };298 const total = String(n).padStart(2, "0");299 const step = (i: number) => `${String(i + 1).padStart(2, "0")} / ${total}`;300301 return (302 <AbsoluteFill303 style={{304 fontFamily,305 overflow: "hidden",306 WebkitFontSmoothing: "antialiased",307 background:308 background === undefined ? (dark ? "#02040a" : "#eef0f6") : undefined,309 }}310 >311 {background === undefined ? (312 <AbsoluteFill style={{ transform: `scale(${1.04 + 0.06 * zoomed})` }}>313 <GshGround314 preset={ground ?? (dark ? "earthshine" : "glasswork")}315 params={groundParams}316 timeOffset={3}317 timeScale={0.5}318 />319 </AbsoluteFill>320 ) : (321 <AbsoluteFill322 style={{323 background: background === "transparent" ? undefined : background,324 }}325 />326 )}327 <ScaleLayer scale={layerScale}>328 <div329 style={{330 position: "absolute",331 left: 0,332 top: 0,333 width: sw,334 height: sh,335 transformOrigin: "0 0",336 transform: `translate(${W / 2 - cam.x * scale}px, ${cy + lift - cam.y * scale}px) scale(${scale})`,337 opacity: interpolate(enter, [0, 0.5], [0, 1], {338 extrapolateRight: "clamp",339 }),340 }}341 >342 <div343 style={{344 position: "relative",345 width: sw,346 height: sh,347 borderRadius: 14,348 overflow: "hidden",349 boxShadow: dark350 ? "0 0 0 1px rgba(255,255,255,0.1), 0 30px 80px -20px rgba(0,0,0,0.8)"351 : "0 0 0 1px rgba(16,24,40,0.08), 0 2px 4px rgba(16,24,40,0.05), 0 30px 80px -24px rgba(16,24,40,0.28)",352 }}353 >354 {content}355 </div>356 </div>357 {spotAmount > 0 && n > 0 && (358 <>359 <svg360 width={W}361 height={H}362 style={{363 position: "absolute",364 inset: 0,365 overflow: layerScale === 1 ? undefined : "visible",366 }}367 aria-hidden368 >369 <path370 d={hole}371 fillRule="evenodd"372 fill={veil}373 opacity={dim * spotAmount}374 />375 </svg>376 <div377 style={{378 position: "absolute",379 left: ring.x,380 top: ring.y,381 width: ring.w,382 height: ring.h,383 boxSizing: "border-box",384 borderRadius: r,385 border: `${1.5 * u}px solid ${accent}`,386 opacity: spotAmount,387 }}388 />389 </>390 )}391 {tall && n > 0 ? (392 <div393 style={{394 position: "absolute",395 left: W * 0.08,396 right: W * 0.08,397 top: H * 0.1,398 }}399 >400 {stops.map((st, i) => {401 const a = arrivals[i];402 const exitAt =403 i < n - 1404 ? ESTABLISH + (i + 1) * F405 : pullBack406 ? tourEnd407 : Number.POSITIVE_INFINITY;408 const e = EXIT(clamp((frame - exitAt) / 6, 0, 1));409 const opacity = clamp(a, 0, 1) * (1 - e);410 if (opacity <= 0.001) return null;411 return (412 <div413 key={`${st.label}-${i}`}414 style={{415 position: "absolute",416 left: 0,417 right: 0,418 top: 0,419 opacity,420 transform: `translateY(${((1 - a) * 0.03 - e * 0.02) * H}px)`,421 }}422 >423 <div424 style={{425 fontFamily: mono,426 fontSize: 0.024 * H,427 letterSpacing: "0.04em",428 color: dark429 ? "rgba(244,244,245,0.55)"430 : "rgba(20,21,24,0.5)",431 fontVariantNumeric: "tabular-nums",432 }}433 >434 {step(i)}435 </div>436 <div437 style={{438 marginTop: 0.018 * H,439 fontSize: 0.042 * H,440 fontWeight: 300,441 lineHeight: 1.08,442 letterSpacing: "-0.03em",443 color: ink ?? (dark ? "#F4F4F5" : "#141518"),444 textWrap: "balance",445 }}446 >447 {st.label}448 </div>449 </div>450 );451 })}452 {pullBack453 ? stops.map((st, i) => {454 const a = spring({455 frame: frame - (tourEnd + 4 + i * 3),456 fps,457 config: CARD,458 });459 if (a <= 0.001) return null;460 return (461 <div462 key={`recap-${st.label}`}463 style={{464 position: "absolute",465 left: 0,466 right: 0,467 top: i * 0.072 * H,468 display: "flex",469 alignItems: "baseline",470 gap: 0.03 * W,471 paddingBottom: 0.022 * H,472 borderBottom: `1px solid ${dark ? "rgba(255,255,255,0.12)" : "rgba(20,21,24,0.12)"}`,473 opacity: clamp(a, 0, 1),474 transform: `translateY(${(1 - a) * 0.025 * H}px)`,475 }}476 >477 <span478 style={{479 fontFamily: mono,480 fontSize: 0.022 * H,481 color: dark482 ? "rgba(244,244,245,0.5)"483 : "rgba(20,21,24,0.45)",484 fontVariantNumeric: "tabular-nums",485 }}486 >487 {String(i + 1).padStart(2, "0")}488 </span>489 <span490 style={{491 fontSize: 0.03 * H,492 fontWeight: 300,493 letterSpacing: "-0.02em",494 whiteSpace: "nowrap",495 color: ink ?? (dark ? "#F4F4F5" : "#141518"),496 }}497 >498 {st.label}499 </span>500 </div>501 );502 })503 : null}504 </div>505 ) : null}506 {!tall &&507 stops.map((st, i) => {508 const a = arrivals[i];509 const exitAt =510 i < n - 1511 ? ESTABLISH + (i + 1) * F512 : pullBack513 ? tourEnd514 : Number.POSITIVE_INFINITY;515 const e = EXIT(clamp((frame - exitAt) / 6, 0, 1));516 const opacity = clamp(a, 0, 1) * (1 - e);517 if (opacity <= 0.001) return null;518 const fs = 18 * u;519 const cardW = (st.label.length * fs * 0.5 + 92 * u) | 0;520 const cardH = 48 * u;521 const gap = 14 * u;522 const bottom = toScreen(523 st.x + st.width / 2,524 st.y + st.height + pad,525 );526 const top = toScreen(st.x, st.y - pad);527 const below = bottom.y + gap + cardH < H - 20 * u;528 const y = below ? bottom.y + gap : top.y - gap - cardH;529 const x = clamp(530 bottom.x,531 cardW / 2 + 24 * u,532 W - cardW / 2 - 24 * u,533 );534 return (535 <div536 key={`${st.label}-${i}`}537 style={{538 position: "absolute",539 left: x,540 top: y,541 height: cardH,542 boxSizing: "border-box",543 transformOrigin: below ? "50% 0%" : "50% 100%",544 transform: `translate(-50%, ${((1 - a) * 10 - e * 6) * u * (below ? 1 : -1)}px) scale(${interpolate(a, [0, 1], [0.94, 1])})`,545 opacity,546 display: "flex",547 alignItems: "center",548 gap: 14 * u,549 padding: `0 ${18 * u}px`,550 borderRadius: 12 * u,551 whiteSpace: "nowrap",552 background: card.bg,553 boxShadow: card.edge,554 color: ink ?? card.ink,555 fontSize: fs,556 fontWeight: 400,557 letterSpacing: "-0.01em",558 }}559 >560 <span561 style={{562 fontFamily: mono,563 fontSize: 16 * u,564 color: card.sub,565 fontVariantNumeric: "tabular-nums",566 }}567 >568 {step(i)}569 </span>570 <span571 style={{572 width: 1,573 alignSelf: "stretch",574 margin: `${14 * u}px 0`,575 background: "rgba(255,255,255,0.12)",576 }}577 />578 {st.label}579 </div>580 );581 })}582 </ScaleLayer>583 </AbsoluteFill>584 );585}586587type MockTheme = "light" | "dark";588type Status = "progress" | "todo" | "backlog" | "done";589const MOCK_W = 1440;590const MOCK_H = 900;591const SB = 232;592593const PAL_KEYS = [594 "app",595 "panel",596 "border",597 "hair",598 "group",599 "text",600 "sub",601 "faint",602 "active",603 "chip",604] as const;605type Pal = Record<(typeof PAL_KEYS)[number], string>;606const pal = (hexes: string) =>607 Object.fromEntries(hexes.split(" ").map((h, i) => [PAL_KEYS[i], h])) as Pal;608const MOCK_COLORS: Record<MockTheme, Pal> = {609 light: pal(610 "#F4F4F5 #FFFFFF #E5E5E8 #F1F1F3 #F7F7F8 #1B1C1F #62656D #A1A4AB #E7E7EA #E3E3E6",611 ),612 dark: pal(613 "#0E0E10 #161618 #252528 #1E1E21 #1C1C1F #E6E6E8 #8D9098 #5F626A #222226 #2C2C30",614 ),615};616const row = { display: "flex", alignItems: "center" } as const;617const center = { ...row, justifyContent: "center" } as const;618619const GLYPHS: Record<string, string> = {620 inbox: "M2.5 9.5h3l1 1.5h3l1-1.5h3M4 3.5h8l1.5 6V13h-11V9.5z",621 user: "M8 8.5a2.75 2.75 0 1 0 0-5.5 2.75 2.75 0 0 0 0 5.5zM3 13.5c.9-2.2 2.8-3.2 5-3.2s4.1 1 5 3.2",622 cube: "M8 1.8l5.5 3v6.4L8 14.2l-5.5-3V4.8zM2.5 4.8L8 7.8l5.5-3M8 7.8v6.4",623 layers: "M8 2l6 3-6 3-6-3zM2 8.2l6 3 6-3M2 11.2l6 3 6-3",624 more: "M3.5 8h.01M8 8h.01M12.5 8h.01",625 issues: "M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11zM5.6 8l1.7 1.7 3.1-3.3",626 cycle: "M13 8a5 5 0 1 1-1.6-3.7M13.2 2.6v2.6h-2.6",627 download: "M8 2.5v7.5M5 7l3 3 3-3M3 12.5h10",628 invite:629 "M6 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM1.5 13.5c.6-2 2.3-3 4.5-3s3.9 1 4.5 3M12.5 5v4M10.5 7h4",630 link: "M6.8 9.2l2.4-2.4M7.2 4.6l1-1a2.6 2.6 0 0 1 3.7 3.7l-1 1M8.8 11.4l-1 1a2.6 2.6 0 0 1-3.7-3.7l1-1",631 search: "M7 11.5a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9zM10.4 10.4L14 14",632 compose: "M7.5 2.5H3.5v10h10v-4M12.2 2.3l1.5 1.5-5.6 5.6-2 .5.5-2z",633 filter: "M2.5 4.5h11M4.5 8h7M6.5 11.5h3",634 display: "M2.5 5h6M11.5 5h2M2.5 11h2M7.5 11h6M10 3.5v3M6 9.5v3",635 chevron: "M5 6.5l3 3 3-3",636 plus: "M8 3.5v9M3.5 8h9",637 sun: "M8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM8 1.5V3M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1 1M11.6 11.6l1 1M3.4 12.6l1-1M11.6 4.4l1-1",638 moon: "M13.2 9.6A5.5 5.5 0 0 1 6.4 2.8a5.5 5.5 0 1 0 6.8 6.8z",639};640641function Glyph({642 name,643 size = 16,644 color,645}: {646 name: string;647 size?: number;648 color: string;649}) {650 return (651 <svg652 width={size}653 height={size}654 viewBox="0 0 16 16"655 fill="none"656 style={{ flexShrink: 0 }}657 >658 <path659 d={GLYPHS[name]}660 stroke={color}661 strokeWidth={1.5}662 strokeLinecap="round"663 strokeLinejoin="round"664 />665 </svg>666 );667}668669function StatusIcon({670 status,671 accent,672 c,673}: {674 status: Status;675 accent: string;676 c: Pal;677}) {678 const col = {679 progress: "#E8B100",680 todo: c.faint,681 backlog: c.faint,682 done: accent,683 }[status];684 const done = status === "done";685 return (686 <svg width={14} height={14} viewBox="0 0 14 14" style={{ flexShrink: 0 }}>687 <circle688 cx={7}689 cy={7}690 r={done ? 6.5 : 5.8}691 fill={done ? col : "none"}692 stroke={done ? "none" : col}693 strokeWidth={1.5}694 strokeDasharray={status === "backlog" ? "1.4 1.6" : undefined}695 />696 {done && (697 <path698 d="M4.3 7.2l1.8 1.8 3.6-3.8"699 stroke="#fff"700 strokeWidth={1.5}701 fill="none"702 />703 )}704 {status === "progress" && (705 <path d="M7 3.6A3.4 3.4 0 0 1 7 10.4Z" fill={col} />706 )}707 </svg>708 );709}710711function PriorityIcon({ p, c }: { p: number; c: Pal }) {712 return (713 <svg width={14} height={14} viewBox="0 0 14 14" style={{ flexShrink: 0 }}>714 {p === 4 && (715 <rect x={0.5} y={0.5} width={13} height={13} rx={3} fill="#F2683C" />716 )}717 {p === 4 && (718 <path719 d="M7 3.5v4.2M7 10.2v.1"720 stroke="#fff"721 strokeWidth={1.8}722 strokeLinecap="round"723 />724 )}725 {p === 0 &&726 [2.5, 7, 11.5].map((x) => (727 <circle key={x} cx={x} cy={7} r={1.1} fill={c.faint} />728 ))}729 {p > 0 &&730 p < 4 &&731 [0, 1, 2].map((i) => (732 <rect733 key={i}734 x={1.5 + i * 4}735 y={9 - i * 3}736 width={3}737 height={4 + i * 3}738 rx={0.8}739 fill={i < p ? c.sub : c.chip}740 />741 ))}742 </svg>743 );744}745746const TINTS = [747 "#B86A52",748 "#4F6FA8",749 "#7A63A8",750 "#3F8466",751 "#A8823C",752 "#A85878",753];754755function Avatar({ name, size = 20 }: { name?: string; size?: number }) {756 const tint = name757 ? TINTS[(name.charCodeAt(0) + name.length) % TINTS.length]758 : "";759 return (760 <div761 style={{762 ...center,763 width: size,764 height: size,765 flexShrink: 0,766 boxSizing: "border-box",767 borderRadius: size,768 border: name ? undefined : "1.3px dashed #9A9DA4",769 background: name ? tint : undefined,770 color: "#fff",771 fontSize: size * 0.42,772 fontWeight: 400,773 }}774 >775 {name?.split(" ").map((w) => w[0])}776 </div>777 );778}779780const LABEL_COLORS: Record<string, string> = Object.fromEntries(781 "Feature:#8B5CF6 Bug:#EF4444 Motion:#0EA5E9 Docs:#3B82F6 Infra:#F97316 Captions:#EC4899 Marketing:#22C55E Research:#A1A1AA"782 .split(" ")783 .map((kv) => kv.split(":")),784);785786const ISSUE_DATA = `787#progress|In Progress|4788ACM-142|4|Spring presets for page transitions|Feature,Motion|v1.4 Launch|Maya Chen|Oct 28789ACM-139|3|Fix flicker in zoom-blur at 60fps|Bug|Transitions|Leo Park|Oct 26790ACM-137|2|Docs: theme-flip props and examples|Docs|v1.4 Launch|Priya Raman|Oct 30791ACM-131|1|Render queue retries for long templates|Infra||Jonah Reyes|Nov 2792#todo|Todo|5793ACM-148|3|Caption timing editor in Studio|Feature,Captions|Captions|Maya Chen|Nov 4794ACM-146|1|Add Lumen and Fernway to the logo wall|Marketing||Ava Kim|Nov 5795ACM-145|2|Export presets for 9:16 and 1:1|Feature|v1.4 Launch|Leo Park|Nov 6796ACM-144|2|Audit spring damping across primitives|Motion||Priya Raman|Nov 8797#backlog|Backlog|3798ACM-151|0|Lottie import for the icon set|Research|||799ACM-150|1|Keyboard shortcuts cheat sheet|Docs||Ava Kim|800ACM-149|0|Audio-reactive backgrounds|Research,Motion|||801#done|Done|17802ACM-128|3|Ship captions tab with 31 styles|Feature,Captions|Captions|Maya Chen|Oct 21803ACM-127|2|Build registry artifacts in CI|Infra||Jonah Reyes|Oct 20804ACM-125|1|Sponsors page with tiers|Marketing||Ava Kim|Oct 18805ACM-121|2|Zoom blur transition|Motion|Transitions|Leo Park|Oct 15806ACM-119|3|Agent-readable docs for every component|Docs||Priya Raman|Oct 12807ACM-117|2|Remotion Studio integration|Feature||Leo Park|Oct 9`;808809const MOCK_GROUPS = ISSUE_DATA.trim()810 .split("#")811 .filter(Boolean)812 .map((block) => {813 const [head, ...lines] = block.trim().split("\n");814 const [status, name, count] = head.split("|");815 const issues = lines.map((l) => {816 const [id, p, title, labels, project, who, date] = l.split("|");817 return {818 id,819 p: Number(p),820 title,821 labels: labels ? labels.split(",") : [],822 project,823 who,824 date,825 };826 });827 return { status: status as Status, name, count, issues };828 });829830const NAV =831 "inbox:Inbox:3|user:My issues|-Workspace|cube:Projects|layers:Views|more:More|-Your teams|=Engineering|>*issues:Issues|>cycle:Cycles|>cube:Projects|>layers:Views|-Try|download:Import issues|invite:Invite people|link:Connect GitHub";832833function NavItem({ spec, c }: { spec: string; c: Pal }) {834 if (spec.startsWith("-"))835 return (836 <div837 style={{838 ...row,839 height: 24,840 marginTop: 16,841 padding: "0 16px",842 gap: 4,843 color: c.faint,844 fontSize: 12,845 }}846 >847 {spec.slice(1)}848 <Glyph name="chevron" size={12} color={c.faint} />849 </div>850 );851 const team = spec.startsWith("=");852 const nested = spec.startsWith(">");853 const active = spec.includes("*");854 const [icon, label, badge] = spec.replace(/^[=>]?\*?/, "").split(":");855 return (856 <div857 style={{858 ...row,859 height: 28,860 margin: "0 8px",861 padding: `0 8px 0 ${nested ? 24 : 8}px`,862 gap: 9,863 borderRadius: 6,864 background: active ? c.active : "transparent",865 color: active || team ? c.text : c.sub,866 fontSize: 13,867 fontWeight: 400,868 }}869 >870 {team ? (871 <div872 style={{873 ...center,874 width: 15,875 height: 15,876 borderRadius: 4,877 background: "#1FA463",878 color: "#fff",879 fontSize: 9,880 }}881 >882 E883 </div>884 ) : (885 <Glyph name={icon} size={15} color={active ? c.text : c.sub} />886 )}887 <span style={{ flex: team ? undefined : 1 }}>{team ? icon : label}</span>888 {team && <Glyph name="chevron" size={12} color={c.faint} />}889 {badge && <span style={{ fontSize: 11.5, color: c.faint }}>{badge}</span>}890 </div>891 );892}893894type MockIssue = (typeof MOCK_GROUPS)[number]["issues"][number];895896function IssueRow({897 issue,898 status,899 accent,900 c,901}: {902 issue: MockIssue;903 status: Status;904 accent: string;905 c: Pal;906}) {907 const chip = {908 ...row,909 height: 22,910 padding: "0 9px",911 gap: 6,912 borderRadius: 11,913 border: `1px solid ${c.chip}`,914 fontSize: 12,915 };916 return (917 <div918 style={{919 ...row,920 height: 40,921 boxSizing: "border-box",922 padding: "0 20px",923 borderBottom: `1px solid ${c.hair}`,924 }}925 >926 <PriorityIcon p={issue.p} c={c} />927 <span style={{ width: 70, marginLeft: 14, color: c.sub, fontSize: 13 }}>928 {issue.id}929 </span>930 <StatusIcon status={status} accent={accent} c={c} />931 <span932 style={{933 marginLeft: 10,934 flex: 1,935 fontSize: 13,936 fontWeight: 400,937 whiteSpace: "nowrap",938 }}939 >940 {issue.title}941 </span>942 <div style={{ ...row, gap: 6, color: c.sub }}>943 {issue.labels.map((l) => (944 <span key={l} style={chip}>945 <span946 style={{947 width: 7,948 height: 7,949 borderRadius: 4,950 background: LABEL_COLORS[l],951 }}952 />953 {l}954 </span>955 ))}956 {issue.project && (957 <span style={chip}>958 <Glyph name="cube" size={12} color={c.sub} />959 {issue.project}960 </span>961 )}962 </div>963 <div style={{ width: 20, marginLeft: 12 }}>964 <Avatar name={issue.who || undefined} />965 </div>966 <span967 style={{968 width: 56,969 marginLeft: 12,970 textAlign: "right",971 color: c.sub,972 fontSize: 12.5,973 }}974 >975 {issue.date}976 </span>977 </div>978 );979}980981interface IssuesMockProps {982 theme?: MockTheme;983 accent?: string;984 width?: number;985 height?: number;986 headerExtra?: React.ReactNode;987 brand?: string;988 logo?: React.ReactNode;989}990991function IssuesMock({992 theme = "light",993 accent = "#5E6AD2",994 width = MOCK_W,995 height = MOCK_H,996 headerExtra,997 brand = "acme",998 logo,999}: IssuesMockProps) {1000 const c = MOCK_COLORS[theme];1001 const box = (size: number) => ({1002 ...center,1003 width: size,1004 height: size,1005 borderRadius: 7,1006 border: `1px solid ${c.border}`,1007 });1008 return (1009 <div1010 style={{1011 width,1012 height,1013 background: c.app,1014 display: "flex",1015 fontFamily: sans,1016 color: c.text,1017 position: "relative",1018 overflow: "hidden",1019 }}1020 >1021 <div1022 style={{1023 width: SB,1024 flexShrink: 0,1025 display: "flex",1026 flexDirection: "column",1027 }}1028 >1029 <div1030 style={{1031 ...row,1032 height: 44,1033 marginTop: 4,1034 marginBottom: 4,1035 padding: "0 12px 0 16px",1036 gap: 8,1037 }}1038 >1039 <div1040 style={{1041 ...center,1042 width: 20,1043 height: 20,1044 borderRadius: 5,1045 background: accent,1046 }}1047 >1048 {logo ?? (1049 <svg viewBox="0 0 124.06 134.26" height={11} aria-hidden>1050 <circle cx="62.03" cy="67.13" r="56" fill="#fff" />1051 </svg>1052 )}1053 </div>1054 <span style={{ fontSize: 13.5, fontWeight: 400 }}>{brand}</span>1055 <Glyph name="chevron" size={12} color={c.sub} />1056 <div style={{ flex: 1 }} />1057 <Glyph name="search" size={15} color={c.sub} />1058 <div style={{ ...box(28), background: c.panel }}>1059 <Glyph name="compose" size={15} color={c.text} />1060 </div>1061 </div>1062 {NAV.split("|").map((spec) => (1063 <NavItem key={spec} spec={spec} c={c} />1064 ))}1065 <div style={{ flex: 1 }} />1066 <div1067 style={{1068 margin: 10,1069 padding: "10px 12px",1070 borderRadius: 8,1071 border: `1px solid ${c.border}`,1072 background: c.panel,1073 }}1074 >1075 <div style={{ fontSize: 11.5, color: c.sub }}>What’s new</div>1076 <div style={{ fontSize: 12.5, fontWeight: 400, marginTop: 3 }}>1077 Captions in Studio1078 </div>1079 </div>1080 </div>1081 <div1082 style={{1083 position: "absolute",1084 inset: `8px 8px 8px ${SB}px`,1085 background: c.panel,1086 border: `1px solid ${c.border}`,1087 borderRadius: 10,1088 overflow: "hidden",1089 }}1090 >1091 <div1092 style={{1093 ...row,1094 height: 48,1095 boxSizing: "border-box",1096 padding: "0 12px 0 14px",1097 gap: 4,1098 borderBottom: `1px solid ${c.hair}`,1099 }}1100 >1101 {["All issues", "Active", "Backlog"].map((t, i) => (1102 <span1103 key={t}1104 style={{1105 ...row,1106 height: 26,1107 padding: "0 10px",1108 borderRadius: 6,1109 fontSize: 12.5,1110 fontWeight: 400,1111 color: i === 0 ? c.text : c.sub,1112 background: i === 0 ? c.active : "transparent",1113 }}1114 >1115 {t}1116 </span>1117 ))}1118 <div style={{ flex: 1 }} />1119 {headerExtra}1120 {["filter", "display"].map((g) => (1121 <div key={g} style={{ ...box(28), marginLeft: 4, borderRadius: 6 }}>1122 <Glyph name={g} size={15} color={c.sub} />1123 </div>1124 ))}1125 </div>1126 {MOCK_GROUPS.map((g) => (1127 <div key={g.name}>1128 <div1129 style={{1130 ...row,1131 height: 36,1132 boxSizing: "border-box",1133 padding: "0 20px",1134 gap: 10,1135 background: c.group,1136 fontSize: 13,1137 }}1138 >1139 <Glyph name="chevron" size={12} color={c.faint} />1140 <StatusIcon status={g.status} accent={accent} c={c} />1141 <span style={{ fontWeight: 400 }}>{g.name}</span>1142 <span style={{ color: c.faint, flex: 1 }}>{g.count}</span>1143 <Glyph name="plus" size={15} color={c.faint} />1144 </div>1145 {g.issues.map((issue) => (1146 <IssueRow1147 key={issue.id}1148 issue={issue}1149 status={g.status}1150 accent={accent}1151 c={c}1152 />1153 ))}1154 </div>1155 ))}1156 </div>1157 </div>1158 );1159}









