UI Callout
Callout cards route to targets on a product screen with connecting leader lines.
Source
components/kuchi/ui-callout.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/InstrumentSans";4import type React from "react";5import {6 AbsoluteFill,7 Easing,8 Img,9 interpolate,10 spring,11 useCurrentFrame,12 useVideoConfig,13} from "remotion";14import type { GradientParams } from "@/lib/kuchi/gsh/gradient-engine";15import { GshGround } from "@/lib/kuchi/gsh/gsh-ground";16import type { GshPresetId } from "@/lib/kuchi/gsh/presets";1718const { fontFamily } = loadFont("normal", {19 weights: ["400"],20 subsets: ["latin"],21});2223export type CalloutSide = "top" | "bottom" | "left" | "right";2425export interface Callout {26 x: number;27 y: number;28 title: string;29 body?: string;30 side?: CalloutSide;31 delay?: number;32}3334export interface UiCalloutProps {35 callouts?: Callout[];36 variant?: "tooltip" | "pill";37 src?: string;38 children?: React.ReactNode;39 screenshotWidth?: number;40 screenshotHeight?: number;41 stagger?: number;42 /** Button label on every card but the last. */43 nextLabel?: string;44 /** Button label on the last card. */45 doneLabel?: string;46 theme?: "light" | "dark";47 accent?: string;48 /** Text color of the callout titles; overrides the theme. */49 ink?: string;50 /** Solid fill in place of the gradient ground; "transparent" drops it. */51 background?: string;52 /** Typeface for the callouts. Load it yourself; Instrument Sans by default. */53 fontFamily?: string;54 /** Replaces the acme mark in the built-in mock's workspace switcher. */55 logo?: React.ReactNode;56 /** Size of the foreground around the frame's center. */57 scale?: number;58 /** Frames to hold the first frame before anything moves. */59 delay?: number;60 ground?: GshPresetId;61 groundParams?: Partial<GradientParams>;62 speed?: number;63}6465const DEFAULT_CALLOUTS: Callout[] = [66 {67 x: 358,68 y: 113,69 title: "Status at a glance",70 body: "Every issue carries its state, from Backlog to Done.",71 side: "bottom",72 },73 {74 x: 1333,75 y: 153,76 title: "Owners and due dates",77 body: "A name and a date on every row, so nothing slips.",78 side: "bottom",79 },80 {81 x: 40,82 y: 342,83 title: "Ship in cycles",84 body: "Unfinished work rolls into the next cycle on its own.",85 side: "bottom",86 },87];888990const INTRO = 14;91const MOVE = Easing.bezier(0.65, 0, 0.35, 1);92const ENTER = Easing.bezier(0.32, 0.72, 0, 1);93const CAMERA = Easing.bezier(0.87, 0, 0.13, 1);94const HEAVY = { mass: 1, damping: 26, stiffness: 120 };95const CARD = { mass: 0.8, damping: 18, stiffness: 160 };96const CHIP = { mass: 0.5, damping: 12, stiffness: 200 };97const MORPH = { damping: 200 };98const clamp = (v: number, lo: number, hi: number) =>99 Math.min(hi, Math.max(lo, v));100101function withAlpha(color: string, alpha: number) {102 const hex = color.replace("#", "");103 const full = hex.length === 3 ? hex.replace(/(.)/g, "$1$1") : hex;104 if (!/^[0-9a-fA-F]{6}$/.test(full)) return color;105 const n = Number.parseInt(full, 16);106 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;107}108109interface Pt {110 x: number;111 y: number;112}113interface Box {114 x: number;115 y: number;116 w: number;117 h: number;118}119interface Route {120 start: Pt;121 elbow: Pt;122 end: Pt;123 card: Box;124 attach: "left" | "right" | "top" | "bottom";125}126127const DIRS: Record<CalloutSide, Pt> = {128 top: { x: 0, y: -1 },129 bottom: { x: 0, y: 1 },130 left: { x: -1, y: 0 },131 right: { x: 1, y: 0 },132};133134function buildRoute(135 t: Pt,136 side: CalloutSide,137 l1: number,138 turn: 1 | -1,139 size: { w: number; h: number },140 u: number,141): Route {142 const d = DIRS[side];143 const start = { x: t.x + d.x * 17 * u, y: t.y + d.y * 17 * u };144 const elbow = { x: start.x + d.x * l1, y: start.y + d.y * l1 };145 const vertical = side === "top" || side === "bottom";146 const l2 = (vertical ? 36 : 30) * u;147 const end = vertical148 ? { x: elbow.x + turn * l2, y: elbow.y }149 : { x: elbow.x, y: elbow.y + turn * l2 };150 if (vertical) {151 const x = turn === 1 ? end.x : end.x - size.w;152 return {153 start,154 elbow,155 end,156 card: { x, y: end.y - size.h / 2, ...size },157 attach: turn === 1 ? "left" : "right",158 };159 }160 const x = d.x === 1 ? end.x - 26 * u : end.x - size.w + 26 * u;161 const y = turn === 1 ? end.y : end.y - size.h;162 return {163 start,164 elbow,165 end,166 card: { x, y, ...size },167 attach: turn === 1 ? "top" : "bottom",168 };169}170171const overlaps = (a: Box, b: Box, m: number) =>172 a.x < b.x + b.w + m &&173 b.x < a.x + a.w + m &&174 a.y < b.y + b.h + m &&175 b.y < a.y + a.h + m;176177function routeAll(178 targets: Pt[],179 callouts: Callout[],180 sizes: { w: number; h: number }[],181 W: number,182 H: number,183 u: number,184): Route[] {185 const placed: Route[] = [];186 targets.forEach((t, i) => {187 const towardCenter: 1 | -1 = t.x < W / 2 ? 1 : -1;188 const sides: CalloutSide[] = callouts[i].side189 ? [callouts[i].side as CalloutSide]190 : t.y < H / 2191 ? ["bottom", "top", "right", "left"]192 : ["top", "bottom", "right", "left"];193 const turns: (1 | -1)[] = [towardCenter, towardCenter === 1 ? -1 : 1];194 let best: Route | null = null;195 search: for (const side of sides) {196 for (const turn of turns) {197 for (const l1 of [56, 96, 136, 176]) {198 const r = buildRoute(199 t,200 side,201 l1 * u,202 side === "left" || side === "right" ? 1 : turn,203 sizes[i],204 u,205 );206 const c = r.card;207 const m = 16 * u;208 if (c.x < m || c.y < m || c.x + c.w > W - m || c.y + c.h > H - m)209 continue;210 if (placed.some((p) => overlaps(p.card, c, 12 * u))) continue;211 if (212 targets.some((p) =>213 overlaps(214 { x: p.x - 20 * u, y: p.y - 20 * u, w: 40 * u, h: 40 * u },215 c,216 0,217 ),218 )219 )220 continue;221 best = r;222 break search;223 }224 }225 }226 placed.push(227 best ?? buildRoute(t, sides[0], 56 * u, towardCenter, sizes[i], u),228 );229 });230 return placed;231}232233function routeTall(234 targets: Pt[],235 sizes: { w: number; h: number }[],236 slotTop: number,237 stack: boolean,238 W: number,239 u: number,240): Route[] {241 let y = slotTop;242 return targets.map((t, i) => {243 const size = sizes[i];244 const turn: 1 | -1 = t.x < W / 2 ? 1 : -1;245 const start = { x: t.x, y: t.y + 17 * u };246 const cy = y + size.h / 2;247 if (stack) y += size.h + 14 * u;248 const elbow = { x: t.x, y: cy };249 const end = { x: t.x + turn * 30 * u, y: cy };250 const m = 40 * u;251 const x =252 turn === 1253 ? Math.min(end.x, W - m - size.w)254 : Math.max(m, end.x - size.w);255 return {256 start,257 elbow,258 end,259 card: { x, y: cy - size.h / 2, ...size },260 attach: turn === 1 ? "left" : "right",261 };262 });263}264265const disc = { position: "absolute", inset: 0, borderRadius: 999 } as const;266267function Ring({268 local,269 accent,270 dark,271 u,272 fps,273 rest = 0,274}: {275 local: number;276 accent: string;277 dark: boolean;278 u: number;279 fps: number;280 rest?: number;281}) {282 const pop = spring({ frame: local, fps, config: CHIP });283 const phase = ((((local - 8) % 48) + 48) % 48) / 48;284 const size = 24 * u;285 return (286 <div287 style={{288 position: "absolute",289 left: -size / 2,290 top: -size / 2,291 width: size,292 height: size,293 opacity: 1 - 0.45 * rest,294 transform: `scale(${1 - 0.25 * rest})`,295 }}296 >297 {local > 8 && rest < 1 && (298 <div299 style={{300 ...disc,301 background: withAlpha(accent, 0.3),302 transform: `scale(${1 + ENTER(phase) * 1.1})`,303 opacity: (1 - phase) * (1 - rest),304 }}305 />306 )}307 <div308 style={{309 ...disc,310 background: withAlpha(accent, 0.16),311 boxShadow: `inset 0 0 0 ${1.5 * u}px ${withAlpha(accent, 0.55)}`,312 transform: `scale(${interpolate(pop, [0, 1], [0.4, 1])})`,313 opacity: clamp(pop * 2, 0, 1),314 ...center,315 }}316 >317 <div318 style={{319 width: 10 * u,320 height: 10 * u,321 borderRadius: 999,322 background: accent,323 boxShadow: `0 0 0 ${2 * u}px ${dark ? "#161618" : "#FFFFFF"}`,324 }}325 />326 </div>327 </div>328 );329}330331function wipeClip(attach: Route["attach"], p: number, r: number) {332 const hidden = `calc(${(1 - p) * 100}% - ${p * 48}px)`;333 const out = "-48px";334 if (attach === "left")335 return `inset(${out} ${hidden} ${out} ${out} round ${r}px)`;336 if (attach === "right")337 return `inset(${out} ${out} ${out} ${hidden} round ${r}px)`;338 if (attach === "top")339 return `inset(${out} ${out} ${hidden} ${out} round ${r}px)`;340 return `inset(${hidden} ${out} ${out} ${out} round ${r}px)`;341}342343/** The foreground at `scale`, around the frame's center; nothing extra at 1. */344function ScaleLayer({345 scale,346 children,347}: {348 scale: number;349 children: React.ReactNode;350}) {351 if (scale === 1) return children;352 return (353 <AbsoluteFill style={{ transform: `scale(${scale})` }}>354 {children}355 </AbsoluteFill>356 );357}358359export function UiCallout({360 callouts = DEFAULT_CALLOUTS,361 variant = "tooltip",362 src,363 children,364 screenshotWidth = MOCK_W,365 screenshotHeight = MOCK_H,366 stagger = 30,367 nextLabel = "Next",368 doneLabel = "Got it",369 theme = "light",370 accent = "#3B5BFD",371 ink,372 background,373 fontFamily: font = fontFamily,374 logo,375 scale = 1,376 delay = 0,377 ground,378 groundParams,379 speed = 1,380}: UiCalloutProps) {381 const frame = Math.max(0, useCurrentFrame() - delay) * speed;382 const { width: W, height: H, fps } = useVideoConfig();383 const tall = H > W;384 const u = tall ? W / 660 : Math.min(W / 1280, H / 720);385 const dark = theme === "dark";386 const pill = variant === "pill";387 const sw = screenshotWidth;388 const sh = screenshotHeight;389 const resolvedGround: GshPresetId | undefined =390 ground ??391 (groundParams ? undefined : dark ? "cobalt-rise" : "paper-crease");392393 const cardW = 330 * u;394 const sizes = callouts.map((c) => {395 if (pill) return { w: (c.title.length * 9.2 + 56) * u, h: 44 * u };396 const lines = c.body ? Math.ceil(c.body.length / 34) : 0;397 return { w: cardW, h: (118 + lines * 23) * u };398 });399 const maxCard = Math.max(...sizes.map((z) => z.h));400 const stackH = pill401 ? sizes.reduce((a, z) => a + z.h + 14 * u, -14 * u)402 : maxCard;403404 const s = ((tall ? 0.92 : 0.74) * W) / sw;405 const left = (W - sw * s) / 2;406 const winH = sh * s;407 const gapBelow = 56 * u;408 const top = tall ? (H - (winH + gapBelow + stackH)) / 2 : (H - winH) / 2;409 const radius = 12 / s;410 const enter = spring({ frame: frame + 2, fps, config: HEAVY });411412 const targets = callouts.map((c) => ({413 x: left + c.x * s,414 y: top + c.y * s,415 }));416 const routes = tall417 ? routeTall(targets, sizes, top + winH + gapBelow, pill, W, u)418 : routeAll(targets, callouts, sizes, W, H, u);419 const starts = callouts.map((c, i) => c.delay ?? INTRO + i * stagger);420 const foldAt = (i: number) =>421 starts[i + 1] === undefined422 ? 0423 : spring({424 frame: frame - starts[i + 1] - 16,425 fps,426 config: MORPH,427 });428 const drift =429 1 + 0.03 * CAMERA(clamp(frame / (starts[starts.length - 1] + 70), 0, 1));430431 const content = src ? (432 <Img433 src={src}434 style={{ width: sw, height: sh, objectFit: "cover", display: "block" }}435 />436 ) : (437 (children ?? (438 <IssuesMock439 theme={theme}440 accent={accent}441 width={sw}442 height={sh}443 logo={logo}444 />445 ))446 );447448 const card = dark449 ? {450 bg: "#1C1D21",451 depth: `0 0 0 1px rgba(255,255,255,0.1), 0 ${18 * u}px ${44 * u}px -${10 * u}px rgba(0,0,0,0.7)`,452 title: "#F3F3F5",453 body: "rgba(243,243,245,0.62)",454 dotOff: "rgba(255,255,255,0.18)",455 btnBg: "#F3F3F5",456 btnInk: "#121316",457 }458 : {459 bg: "#FFFFFF",460 depth: `0 0 0 1px rgba(16,24,40,0.07), 0 ${2 * u}px ${4 * u}px rgba(16,24,40,0.05), 0 ${18 * u}px ${44 * u}px -${10 * u}px rgba(16,24,40,0.22)`,461 title: "#141518",462 body: "rgba(20,21,24,0.62)",463 dotOff: "rgba(20,21,24,0.16)",464 btnBg: "#141518",465 btnInk: "#FFFFFF",466 };467 const cardR = 14 * u;468469 const pillEl = (c: Callout, attach: Route["attach"]) => (470 <div471 style={{472 height: 44 * u,473 boxSizing: "border-box",474 ...row,475 gap: 10 * u,476 padding: `0 ${18 * u}px 0 ${15 * u}px`,477 borderRadius: 999,478 background: dark ? "#F4F4F6" : "#16171B",479 color: ink ?? (dark ? "#121316" : "#F7F7F8"),480 fontSize: 18 * u,481 fontWeight: 400,482 letterSpacing: "-0.01em",483 whiteSpace: "nowrap",484 width: "fit-content",485 marginLeft: attach === "right" ? "auto" : undefined,486 boxShadow: dark487 ? `0 ${10 * u}px ${28 * u}px -${6 * u}px rgba(0,0,0,0.55)`488 : `0 ${2 * u}px ${4 * u}px rgba(16,24,40,0.12), 0 ${10 * u}px ${24 * u}px -${6 * u}px rgba(16,24,40,0.28)`,489 }}490 >491 <span492 style={{493 width: 8 * u,494 height: 8 * u,495 borderRadius: 9,496 background: accent,497 flexShrink: 0,498 }}499 />500 {c.title}501 </div>502 );503504 const cardEl = (c: Callout, i: number, textOp: number) => (505 <div506 style={{507 background: card.bg,508 borderRadius: cardR,509 padding: `${18 * u}px ${18 * u}px ${16 * u}px`,510 boxShadow: card.depth,511 }}512 >513 <div514 style={{515 opacity: textOp,516 transform: `translateY(${(1 - textOp) * 6 * u}px)`,517 }}518 >519 <div520 style={{521 fontSize: 21 * u,522 lineHeight: 1.25,523 fontWeight: 400,524 color: ink ?? card.title,525 letterSpacing: "-0.02em",526 }}527 >528 {c.title}529 </div>530 {c.body && (531 <div532 style={{533 marginTop: 6 * u,534 fontSize: 16.5 * u,535 lineHeight: 1.42,536 color: card.body,537 textWrap: "pretty",538 }}539 >540 {c.body}541 </div>542 )}543 <div544 style={{545 marginTop: 16 * u,546 ...row,547 justifyContent: "space-between",548 }}549 >550 <div style={{ ...row, gap: 6 * u }}>551 {callouts.map((d, j) => (552 <span553 key={`${d.title}-dot`}554 style={{555 width: j === i ? 18 * u : 6 * u,556 height: 6 * u,557 borderRadius: 6 * u,558 background: j === i ? accent : card.dotOff,559 }}560 />561 ))}562 </div>563 <span564 style={{565 height: 34 * u,566 padding: `0 ${14 * u}px`,567 borderRadius: cardR - 6 * u,568 background: card.btnBg,569 color: card.btnInk,570 fontSize: 16 * u,571 fontWeight: 400,572 ...row,573 }}574 >575 {i === callouts.length - 1 ? doneLabel : nextLabel}576 </span>577 </div>578 </div>579 </div>580 );581582 return (583 <AbsoluteFill584 style={{585 fontFamily: font,586 overflow: "hidden",587 WebkitFontSmoothing: "antialiased",588 background: background ?? (dark ? "#02040A" : "#EEECE8"),589 }}590 >591 {background === undefined ? (592 <GshGround593 preset={resolvedGround}594 params={groundParams}595 timeOffset={dark ? 3 : 6}596 timeScale={0.4}597 />598 ) : null}599 <ScaleLayer scale={scale}>600 <AbsoluteFill style={{ transform: `scale(${drift})` }}>601 <div602 style={{603 position: "absolute",604 left,605 top,606 width: sw,607 height: sh,608 transformOrigin: "0 0",609 transform: `translateY(${(1 - enter) * 40 * u}px) scale(${s})`,610 opacity: clamp(enter * 2, 0, 1),611 borderRadius: radius,612 overflow: "hidden",613 boxShadow: dark614 ? `0 0 0 ${1 / s}px rgba(255,255,255,0.1), 0 ${30 / s}px ${70 / s}px -${14 / s}px rgba(0,0,0,0.7)`615 : `0 0 0 ${1 / s}px rgba(16,24,40,0.08), 0 ${2 / s}px ${4 / s}px rgba(16,24,40,0.05), 0 ${30 / s}px ${70 / s}px -${14 / s}px rgba(16,24,40,0.24)`,616 }}617 >618 {content}619 </div>620 <svg621 width={W}622 height={H}623 style={{ position: "absolute", inset: 0, overflow: "visible" }}624 aria-hidden625 >626 {routes.map((r, i) => {627 const p =628 MOVE(clamp((frame - starts[i] - 6) / 11, 0, 1)) *629 (pill ? 1 : 1 - foldAt(i));630 if (p <= 0) return null;631 const k = 10 * u;632 const a = {633 x: r.elbow.x - Math.sign(r.elbow.x - r.start.x) * k,634 y: r.elbow.y - Math.sign(r.elbow.y - r.start.y) * k,635 };636 const b = {637 x: r.elbow.x + Math.sign(r.end.x - r.elbow.x) * k,638 y: r.elbow.y + Math.sign(r.end.y - r.elbow.y) * k,639 };640 return (641 <path642 key={`line-${callouts[i].title}`}643 d={`M ${r.start.x} ${r.start.y} L ${a.x} ${a.y} Q ${r.elbow.x} ${r.elbow.y} ${b.x} ${b.y} L ${r.end.x} ${r.end.y}`}644 pathLength={1}645 strokeDasharray="1 1"646 strokeDashoffset={1 - p}647 stroke={accent}648 strokeWidth={1.75 * u}649 strokeLinecap="round"650 fill="none"651 />652 );653 })}654 </svg>655 {routes.map((r, i) => {656 const c = callouts[i];657 const local = frame - starts[i];658 if (local < 0) return null;659 const wipe = spring({ frame: local - 15, fps, config: CARD });660 const textIn = interpolate(local, [19, 31], [0, 1], {661 extrapolateLeft: "clamp",662 extrapolateRight: "clamp",663 easing: ENTER,664 });665 const fold = pill ? 0 : foldAt(i);666 const side = r.attach === "left" || r.attach === "right";667 const origin = {668 left: "0% 50%",669 right: "100% 50%",670 top: "50% 0%",671 bottom: "50% 100%",672 }[r.attach];673 const slide =674 (1 - textIn) * 6 * u * (r.attach === "right" ? -1 : 1);675 return (676 <div key={`${c.title}-${c.x}-${c.y}`}>677 <div678 style={{679 position: "absolute",680 left: targets[i].x,681 top: targets[i].y,682 }}683 >684 <Ring685 local={local}686 accent={accent}687 dark={dark}688 u={u}689 fps={fps}690 rest={fold}691 />692 </div>693 {wipe > 0.001 && fold < 0.999 && (694 <div695 style={{696 position: "absolute",697 left: r.card.x,698 top: side ? r.end.y : r.card.y,699 width: r.card.w,700 transform: side ? "translateY(-50%)" : undefined,701 clipPath: wipeClip(702 r.attach,703 Math.min(1, wipe),704 pill ? 22 * u : cardR,705 ),706 }}707 >708 <div709 style={{710 opacity:711 (pill ? textIn : 1) * (1 - clamp(fold * 3, 0, 1)),712 transformOrigin: origin,713 transform: `translateX(${slide}px) scale(${1 - 0.08 * fold})`,714 }}715 >716 {pill ? pillEl(c, r.attach) : cardEl(c, i, textIn)}717 </div>718 </div>719 )}720 </div>721 );722 })}723 </AbsoluteFill>724 </ScaleLayer>725 </AbsoluteFill>726 );727}728729type MockTheme = "light" | "dark";730type Status = "progress" | "todo" | "backlog" | "done";731const MOCK_W = 1440;732const MOCK_H = 900;733const SB = 232;734735const PAL_KEYS = [736 "app",737 "panel",738 "border",739 "hair",740 "group",741 "text",742 "sub",743 "faint",744 "active",745 "chip",746] as const;747type Pal = Record<(typeof PAL_KEYS)[number], string>;748const pal = (hexes: string) =>749 Object.fromEntries(hexes.split(" ").map((h, i) => [PAL_KEYS[i], h])) as Pal;750const MOCK_COLORS: Record<MockTheme, Pal> = {751 light: pal(752 "#F4F4F5 #FFFFFF #E5E5E8 #F1F1F3 #F7F7F8 #1B1C1F #62656D #A1A4AB #E7E7EA #E3E3E6",753 ),754 dark: pal(755 "#0E0E10 #161618 #252528 #1E1E21 #1C1C1F #E6E6E8 #8D9098 #5F626A #222226 #2C2C30",756 ),757};758const row = { display: "flex", alignItems: "center" } as const;759const center = { ...row, justifyContent: "center" } as const;760761const GLYPHS: Record<string, string> = {762 inbox: "M2.5 9.5h3l1 1.5h3l1-1.5h3M4 3.5h8l1.5 6V13h-11V9.5z",763 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",764 cube: "M8 1.8l5.5 3v6.4L8 14.2l-5.5-3V4.8zM2.5 4.8L8 7.8l5.5-3M8 7.8v6.4",765 layers: "M8 2l6 3-6 3-6-3zM2 8.2l6 3 6-3M2 11.2l6 3 6-3",766 more: "M3.5 8h.01M8 8h.01M12.5 8h.01",767 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",768 cycle: "M13 8a5 5 0 1 1-1.6-3.7M13.2 2.6v2.6h-2.6",769 download: "M8 2.5v7.5M5 7l3 3 3-3M3 12.5h10",770 invite:771 "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",772 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",773 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",774 compose: "M7.5 2.5H3.5v10h10v-4M12.2 2.3l1.5 1.5-5.6 5.6-2 .5.5-2z",775 filter: "M2.5 4.5h11M4.5 8h7M6.5 11.5h3",776 display: "M2.5 5h6M11.5 5h2M2.5 11h2M7.5 11h6M10 3.5v3M6 9.5v3",777 chevron: "M5 6.5l3 3 3-3",778 plus: "M8 3.5v9M3.5 8h9",779 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",780 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",781};782783function Glyph({784 name,785 size = 16,786 color,787}: {788 name: string;789 size?: number;790 color: string;791}) {792 return (793 <svg794 width={size}795 height={size}796 viewBox="0 0 16 16"797 fill="none"798 style={{ flexShrink: 0 }}799 >800 <path801 d={GLYPHS[name]}802 stroke={color}803 strokeWidth={1.4}804 strokeLinecap="round"805 strokeLinejoin="round"806 />807 </svg>808 );809}810811function StatusIcon({812 status,813 accent,814 c,815}: {816 status: Status;817 accent: string;818 c: Pal;819}) {820 const col = {821 progress: "#E8B100",822 todo: c.faint,823 backlog: c.faint,824 done: accent,825 }[status];826 const done = status === "done";827 return (828 <svg width={14} height={14} viewBox="0 0 14 14" style={{ flexShrink: 0 }}>829 <circle830 cx={7}831 cy={7}832 r={done ? 6.5 : 5.8}833 fill={done ? col : "none"}834 stroke={done ? "none" : col}835 strokeWidth={1.5}836 strokeDasharray={status === "backlog" ? "1.4 1.6" : undefined}837 />838 {done && (839 <path840 d="M4.3 7.2l1.8 1.8 3.6-3.8"841 stroke="#fff"842 strokeWidth={1.5}843 fill="none"844 />845 )}846 {status === "progress" && (847 <path d="M7 3.6A3.4 3.4 0 0 1 7 10.4Z" fill={col} />848 )}849 </svg>850 );851}852853function PriorityIcon({ p, c }: { p: number; c: Pal }) {854 return (855 <svg width={14} height={14} viewBox="0 0 14 14" style={{ flexShrink: 0 }}>856 {p === 4 && (857 <rect x={0.5} y={0.5} width={13} height={13} rx={3} fill="#F2683C" />858 )}859 {p === 4 && (860 <path861 d="M7 3.5v4.2M7 10.2v.1"862 stroke="#fff"863 strokeWidth={1.8}864 strokeLinecap="round"865 />866 )}867 {p === 0 &&868 [2.5, 7, 11.5].map((x) => (869 <circle key={x} cx={x} cy={7} r={1.1} fill={c.faint} />870 ))}871 {p > 0 &&872 p < 4 &&873 [0, 1, 2].map((i) => (874 <rect875 key={i}876 x={1.5 + i * 4}877 y={9 - i * 3}878 width={3}879 height={4 + i * 3}880 rx={0.8}881 fill={i < p ? c.sub : c.chip}882 />883 ))}884 </svg>885 );886}887888const TINTS = [889 "#E0795B",890 "#5B8DEF",891 "#9B6BDF",892 "#3FA47A",893 "#D9A23B",894 "#D9608F",895];896897function Avatar({ name, size = 20 }: { name?: string; size?: number }) {898 const tint = name899 ? TINTS[(name.charCodeAt(0) + name.length) % TINTS.length]900 : "";901 return (902 <div903 style={{904 ...center,905 width: size,906 height: size,907 flexShrink: 0,908 boxSizing: "border-box",909 borderRadius: size,910 border: name ? undefined : "1.3px dashed #9A9DA4",911 background: name912 ? `linear-gradient(140deg, ${tint}, ${tint}B0)`913 : undefined,914 color: "#fff",915 fontSize: size * 0.42,916 fontWeight: 400,917 }}918 >919 {name?.split(" ").map((w) => w[0])}920 </div>921 );922}923924const LABEL_COLORS: Record<string, string> = Object.fromEntries(925 "Feature:#8B5CF6 Bug:#EF4444 Motion:#0EA5E9 Docs:#3B82F6 Infra:#F97316 Captions:#EC4899 Marketing:#22C55E Research:#A1A1AA"926 .split(" ")927 .map((kv) => kv.split(":")),928);929930const ISSUE_DATA = `931#progress|In Progress|4932ACM-142|4|Spring presets for page transitions|Feature,Motion|v1.4 Launch|Maya Chen|Oct 28933ACM-139|3|Fix flicker in zoom-blur at 60fps|Bug|Transitions|Leo Park|Oct 26934ACM-137|2|Docs: theme-flip props and examples|Docs|v1.4 Launch|Priya Raman|Oct 30935ACM-131|1|Render queue retries for long templates|Infra||Jonah Reyes|Nov 2936#todo|Todo|5937ACM-148|3|Caption timing editor in Studio|Feature,Captions|Captions|Maya Chen|Nov 4938ACM-146|1|Add Lumen and Fernway to the logo wall|Marketing||Ava Kim|Nov 5939ACM-145|2|Export presets for 9:16 and 1:1|Feature|v1.4 Launch|Leo Park|Nov 6940ACM-144|2|Audit spring damping across primitives|Motion||Priya Raman|Nov 8941#backlog|Backlog|3942ACM-151|0|Lottie import for the icon set|Research|||943ACM-150|1|Keyboard shortcuts cheat sheet|Docs||Ava Kim|944ACM-149|0|Audio-reactive backgrounds|Research,Motion|||945#done|Done|17946ACM-128|3|Ship captions tab with 31 styles|Feature,Captions|Captions|Maya Chen|Oct 21947ACM-127|2|Build registry artifacts in CI|Infra||Jonah Reyes|Oct 20948ACM-125|1|Sponsors page with tiers|Marketing||Ava Kim|Oct 18949ACM-121|2|Zoom blur transition|Motion|Transitions|Leo Park|Oct 15950ACM-119|3|Agent-readable docs for every component|Docs||Priya Raman|Oct 12951ACM-117|2|Remotion Studio integration|Feature||Leo Park|Oct 9`;952953const MOCK_GROUPS = ISSUE_DATA.trim()954 .split("#")955 .filter(Boolean)956 .map((block) => {957 const [head, ...lines] = block.trim().split("\n");958 const [status, name, count] = head.split("|");959 const issues = lines.map((l) => {960 const [id, p, title, labels, project, who, date] = l.split("|");961 return {962 id,963 p: Number(p),964 title,965 labels: labels ? labels.split(",") : [],966 project,967 who,968 date,969 };970 });971 return { status: status as Status, name, count, issues };972 });973974const NAV =975 "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";976977function NavItem({ spec, c }: { spec: string; c: Pal }) {978 if (spec.startsWith("-"))979 return (980 <div981 style={{982 ...row,983 height: 24,984 marginTop: 16,985 padding: "0 16px",986 gap: 4,987 color: c.faint,988 fontSize: 12,989 }}990 >991 {spec.slice(1)}992 <Glyph name="chevron" size={12} color={c.faint} />993 </div>994 );995 const team = spec.startsWith("=");996 const nested = spec.startsWith(">");997 const active = spec.includes("*");998 const [icon, label, badge] = spec.replace(/^[=>]?\*?/, "").split(":");999 return (1000 <div1001 style={{1002 ...row,1003 height: 28,1004 margin: "0 8px",1005 padding: `0 8px 0 ${nested ? 24 : 8}px`,1006 gap: 9,1007 borderRadius: 6,1008 background: active ? c.active : "transparent",1009 color: active || team ? c.text : c.sub,1010 fontSize: 13,1011 fontWeight: 400,1012 }}1013 >1014 {team ? (1015 <div1016 style={{1017 ...center,1018 width: 15,1019 height: 15,1020 borderRadius: 4,1021 background: "#1FA463",1022 color: "#fff",1023 fontSize: 9,1024 }}1025 >1026 E1027 </div>1028 ) : (1029 <Glyph name={icon} size={15} color={active ? c.text : c.sub} />1030 )}1031 <span style={{ flex: team ? undefined : 1 }}>{team ? icon : label}</span>1032 {team && <Glyph name="chevron" size={12} color={c.faint} />}1033 {badge && <span style={{ fontSize: 11.5, color: c.faint }}>{badge}</span>}1034 </div>1035 );1036}10371038type MockIssue = (typeof MOCK_GROUPS)[number]["issues"][number];10391040function IssueRow({1041 issue,1042 status,1043 accent,1044 c,1045}: {1046 issue: MockIssue;1047 status: Status;1048 accent: string;1049 c: Pal;1050}) {1051 const chip = {1052 ...row,1053 height: 22,1054 padding: "0 9px",1055 gap: 6,1056 borderRadius: 11,1057 border: `1px solid ${c.chip}`,1058 fontSize: 12,1059 };1060 return (1061 <div1062 style={{1063 ...row,1064 height: 40,1065 boxSizing: "border-box",1066 padding: "0 20px",1067 borderBottom: `1px solid ${c.hair}`,1068 }}1069 >1070 <PriorityIcon p={issue.p} c={c} />1071 <span style={{ width: 70, marginLeft: 14, color: c.sub, fontSize: 13 }}>1072 {issue.id}1073 </span>1074 <StatusIcon status={status} accent={accent} c={c} />1075 <span1076 style={{1077 marginLeft: 10,1078 flex: 1,1079 fontSize: 13,1080 fontWeight: 400,1081 whiteSpace: "nowrap",1082 }}1083 >1084 {issue.title}1085 </span>1086 <div style={{ ...row, gap: 6, color: c.sub }}>1087 {issue.labels.map((l) => (1088 <span key={l} style={chip}>1089 <span1090 style={{1091 width: 7,1092 height: 7,1093 borderRadius: 4,1094 background: LABEL_COLORS[l],1095 }}1096 />1097 {l}1098 </span>1099 ))}1100 {issue.project && (1101 <span style={chip}>1102 <Glyph name="cube" size={12} color={c.sub} />1103 {issue.project}1104 </span>1105 )}1106 </div>1107 <div style={{ width: 20, marginLeft: 12 }}>1108 <Avatar name={issue.who || undefined} />1109 </div>1110 <span1111 style={{1112 width: 56,1113 marginLeft: 12,1114 textAlign: "right",1115 color: c.sub,1116 fontSize: 12.5,1117 }}1118 >1119 {issue.date}1120 </span>1121 </div>1122 );1123}11241125interface IssuesMockProps {1126 theme?: MockTheme;1127 accent?: string;1128 width?: number;1129 height?: number;1130 headerExtra?: React.ReactNode;1131 logo?: React.ReactNode;1132}11331134function IssuesMock({1135 theme = "light",1136 accent = "#3B5BFD",1137 width = MOCK_W,1138 height = MOCK_H,1139 headerExtra,1140 logo,1141}: IssuesMockProps) {1142 const c = MOCK_COLORS[theme];1143 const box = (size: number) => ({1144 ...center,1145 width: size,1146 height: size,1147 borderRadius: 7,1148 border: `1px solid ${c.border}`,1149 });1150 return (1151 <div1152 style={{1153 width,1154 height,1155 background: c.app,1156 display: "flex",1157 fontFamily,1158 color: c.text,1159 position: "relative",1160 overflow: "hidden",1161 }}1162 >1163 <div1164 style={{1165 width: SB,1166 flexShrink: 0,1167 display: "flex",1168 flexDirection: "column",1169 }}1170 >1171 <div1172 style={{1173 ...row,1174 height: 44,1175 marginTop: 4,1176 marginBottom: 4,1177 padding: "0 12px 0 16px",1178 gap: 8,1179 }}1180 >1181 <div1182 style={{1183 ...center,1184 width: 20,1185 height: 20,1186 borderRadius: 5,1187 background: accent,1188 }}1189 >1190 {logo ?? (1191 <svg viewBox="0 0 124.06 134.26" height={10} aria-hidden>1192 <circle cx="62.03" cy="67.13" r="56" fill="#FFFFFF" />1193 </svg>1194 )}1195 </div>1196 <span style={{ fontSize: 13.5, fontWeight: 400 }}>acme</span>1197 <Glyph name="chevron" size={12} color={c.sub} />1198 <div style={{ flex: 1 }} />1199 <Glyph name="search" size={15} color={c.sub} />1200 <div style={{ ...box(28), background: c.panel }}>1201 <Glyph name="compose" size={15} color={c.text} />1202 </div>1203 </div>1204 {NAV.split("|").map((spec) => (1205 <NavItem key={spec} spec={spec} c={c} />1206 ))}1207 <div style={{ flex: 1 }} />1208 <div1209 style={{1210 margin: 10,1211 padding: "10px 12px",1212 borderRadius: 8,1213 border: `1px solid ${c.border}`,1214 background: c.panel,1215 }}1216 >1217 <div style={{ fontSize: 11.5, color: c.sub }}>What’s new</div>1218 <div style={{ fontSize: 12.5, fontWeight: 400, marginTop: 3 }}>1219 Captions in Studio1220 </div>1221 </div>1222 </div>1223 <div1224 style={{1225 position: "absolute",1226 inset: `8px 8px 8px ${SB}px`,1227 background: c.panel,1228 border: `1px solid ${c.border}`,1229 borderRadius: 10,1230 overflow: "hidden",1231 }}1232 >1233 <div1234 style={{1235 ...row,1236 height: 48,1237 boxSizing: "border-box",1238 padding: "0 12px 0 14px",1239 gap: 4,1240 borderBottom: `1px solid ${c.hair}`,1241 }}1242 >1243 {["All issues", "Active", "Backlog"].map((t, i) => (1244 <span1245 key={t}1246 style={{1247 ...row,1248 height: 26,1249 padding: "0 10px",1250 borderRadius: 6,1251 fontSize: 12.5,1252 fontWeight: 400,1253 color: i === 0 ? c.text : c.sub,1254 background: i === 0 ? c.active : "transparent",1255 }}1256 >1257 {t}1258 </span>1259 ))}1260 <div style={{ flex: 1 }} />1261 {headerExtra}1262 {["filter", "display"].map((g) => (1263 <div key={g} style={{ ...box(28), marginLeft: 4, borderRadius: 6 }}>1264 <Glyph name={g} size={15} color={c.sub} />1265 </div>1266 ))}1267 </div>1268 {MOCK_GROUPS.map((g) => (1269 <div key={g.name}>1270 <div1271 style={{1272 ...row,1273 height: 36,1274 boxSizing: "border-box",1275 padding: "0 20px",1276 gap: 10,1277 background: c.group,1278 fontSize: 13,1279 }}1280 >1281 <Glyph name="chevron" size={12} color={c.faint} />1282 <StatusIcon status={g.status} accent={accent} c={c} />1283 <span>{g.name}</span>1284 <span style={{ color: c.faint, flex: 1 }}>{g.count}</span>1285 <Glyph name="plus" size={15} color={c.faint} />1286 </div>1287 {g.issues.map((issue) => (1288 <IssueRow1289 key={issue.id}1290 issue={issue}1291 status={g.status}1292 accent={accent}1293 c={c}1294 />1295 ))}1296 </div>1297 ))}1298 </div>1299 </div>1300 );1301}









