Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "deadpan-box",
"title": "Deadpan Box",
"description": "A flat, deadpan quote in a blue box with a small attribution line.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/deadpan-box/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { loadFont as loadSchibsted } from \"@remotion/google-fonts/SchibstedGrotesk\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport {\n AbsoluteFill,\n continueRender,\n delayRender,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\n/** Newspaper-ad grotesk for the copy: deadpan, upright, no shouting. */\nconst copy = loadSchibsted(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", { weights: [\"600\"], subsets: [\"latin\"] });\n\nconst REMOCN_R_PATH =\n \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** R mark proportions, as set on remocn.dev: 0.76em tall on the baseline. */\nconst MARK_EM = 0.76;\nconst MARK_ADV = (MARK_EM * 124.06) / 134.26;\nconst MARK_GAP = 0.04;\nconst LOGO_TRACK = -0.025;\n\n/** Full logo as on remocn.dev: R mark + \"emocn\" in Manrope 600, tracking-tight. */\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n color,\n fontFamily: manrope.fontFamily,\n fontWeight: 600,\n fontSize,\n letterSpacing: `${LOGO_TRACK}em`,\n lineHeight: 1,\n whiteSpace: \"pre\",\n }}\n >\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{ height: `${MARK_EM}em`, width: \"auto\" }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span style={{ marginLeft: `${MARK_GAP}em` }}>emocn</span>\n </div>\n );\n}\n\nexport interface DeadpanBoxProps {\n /** The setup, without quote marks: curly marks are added and hung for you. */\n quote?: string;\n /** The deadpan attribution that lands the joke after a pause. */\n attribution?: string;\n /**\n * Brand the box starts as, and signs off with. \"remocn\" renders the real\n * remocn.dev logo; anything else is set as a plain wordmark.\n */\n brand?: string;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\n// Timing, in frames at speed 1.\nconst GROW_AT = 12;\nconst GROW_LEN = 24;\nconst QUOTE_AT = 28;\nconst LINE_STAGGER = 5;\nconst PUNCH_AT = 92; // after a deadpan beat of a little over a second\nconst PUNCH_LEN = 16;\nexport const DEADPAN_BOX_DURATION = 150;\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_SNAP = Easing.bezier(0.7, 0, 0.2, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst alpha = (color: string, a: number) =>\n `color-mix(in oklab, ${color} ${Math.round(a * 100)}%, transparent)`;\n\ninterface Blob {\n color: string;\n x: number;\n y: number;\n rx: number;\n ry: number;\n a: number;\n}\n\n/**\n * The box is a window onto one gradient field pinned to the frame: as the box\n * grows, it shows more of the same light instead of stretching it.\n * Dark: gradients.sh \"beam\" (deep indigo, the accent, a pale-blue bloom).\n * Light: \"pixel-glass\" (violet, the accent, a rose corner) on the off-white stage.\n */\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n grain: 0.06,\n base: (accent: string) =>\n `linear-gradient(158deg, ${accent} 0%, #2A2F9E 48%, #1A1660 100%)`,\n blobs: [\n { color: \"#8FB4FF\", x: 82, y: 12, rx: 62, ry: 78, a: 0.62 },\n { color: \"#F4F7FF\", x: 92, y: 4, rx: 28, ry: 36, a: 0.32 },\n { color: \"ACCENT\", x: 28, y: 46, rx: 70, ry: 82, a: 0.8 },\n { color: \"#1A1660\", x: 14, y: 100, rx: 60, ry: 60, a: 0.85 },\n ] as Blob[],\n },\n light: {\n bg: \"#F5F4F0\",\n grain: 0.04,\n base: (accent: string) =>\n `linear-gradient(150deg, #7A3CFF 0%, ${accent} 52%, #3D6BFF 100%)`,\n blobs: [\n { color: \"#7A3CFF\", x: 12, y: 14, rx: 60, ry: 72, a: 0.75 },\n { color: \"#FF4FB8\", x: 94, y: 96, rx: 48, ry: 58, a: 0.62 },\n { color: \"ACCENT\", x: 46, y: 52, rx: 58, ry: 66, a: 0.6 },\n { color: \"#C9B6FF\", x: 86, y: 6, rx: 30, ry: 40, a: 0.32 },\n ] as Blob[],\n },\n} as const;\n\nconst QUOTE_TRACK = -0.03;\nconst SMALL_TRACK = -0.005;\nconst LEAD = 1.04;\n\ninterface FontMetrics {\n /** Advance width of a string at 1em, in em, tracking included. */\n width: (text: string, weight: 400 | 500, track: number) => number;\n /** \"emocn\" in the logo face, in em. */\n logoWord: number;\n /** Cap height, in em. */\n cap: number;\n /** Baseline below the top of a line-height: 1 box, in em. */\n base: number;\n /** Same, for the logo's Manrope line box. */\n logoBase: number;\n logoCap: number;\n}\n\nconst PROBE = 200;\n\nfunction measureFonts(): FontMetrics | null {\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (!ctx) return null;\n const width = (text: string, weight: 400 | 500, track: number) => {\n ctx.font = `${weight} ${PROBE}px \"${copy.fontFamily}\"`;\n const n = [...text].length;\n return ctx.measureText(text).width / PROBE + track * Math.max(0, n - 1);\n };\n ctx.font = `500 ${PROBE}px \"${copy.fontFamily}\"`;\n const h = ctx.measureText(\"H\");\n const asc = h.fontBoundingBoxAscent / PROBE;\n const desc = h.fontBoundingBoxDescent / PROBE;\n const cap = h.actualBoundingBoxAscent / PROBE;\n ctx.font = `600 ${PROBE}px \"${manrope.fontFamily}\"`;\n const mh = ctx.measureText(\"H\");\n const mAsc = mh.fontBoundingBoxAscent / PROBE;\n const mDesc = mh.fontBoundingBoxDescent / PROBE;\n const word = ctx.measureText(\"emocn\").width / PROBE + LOGO_TRACK * 5;\n return {\n width,\n logoWord: word,\n cap,\n base: 0.5 + (asc - desc) / 2,\n logoBase: 0.5 + (mAsc - mDesc) / 2,\n logoCap: Math.max(MARK_EM, mh.actualBoundingBoxAscent / PROBE),\n };\n}\n\nfunction useFontMetrics() {\n const [metrics, setMetrics] = useState<FontMetrics | null>(null);\n const [handle] = useState(() => delayRender(\"deadpan-box: measuring\"));\n const released = useRef(false);\n useEffect(() => {\n let live = true;\n Promise.all([\n copy.waitUntilDone(),\n manrope.waitUntilDone(),\n document.fonts.load(`500 100px \"${copy.fontFamily}\"`),\n document.fonts.load(`400 100px \"${copy.fontFamily}\"`),\n document.fonts.load(`600 100px \"${manrope.fontFamily}\"`),\n ])\n .catch(() => undefined)\n .then(() => {\n if (!live) return;\n setMetrics(measureFonts());\n if (!released.current) {\n released.current = true;\n continueRender(handle);\n }\n });\n return () => {\n live = false;\n };\n }, [handle]);\n return metrics;\n}\n\nfunction splitQuote(quote: string, width: (s: string) => number): string[] {\n if (quote.includes(\"\\n\")) return quote.split(\"\\n\").map((l) => l.trim());\n const words = quote.trim().split(/\\s+/);\n if (words.length < 3) return [quote.trim()];\n let best = [quote.trim()];\n let bestW = Number.POSITIVE_INFINITY;\n for (let i = 1; i < words.length; i++) {\n const a = words.slice(0, i).join(\" \");\n const b = words.slice(i).join(\" \");\n const w = Math.max(width(a), width(b));\n if (w < bestW) {\n bestW = w;\n best = [a, b];\n }\n }\n return best;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={31}\n stitchTiles=\"stitch\"\n />\n <feColorMatrix values=\"0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0\" />\n </filter>\n <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n </svg>\n );\n}\n\nconst lerp = (a: number, b: number, p: number) => a + (b - a) * p;\n\nexport function DeadpanBox({\n quote = \"Nobody watches launch videos.\",\n attribution = \"Founder. Nobody watched the launch.\",\n brand = \"remocn\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: DeadpanBoxProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const c = THEMES[theme];\n const ink = \"#FFFFFF\";\n const fm = useFontMetrics();\n const isLogo = brand.trim().toLowerCase() === \"remocn\";\n\n const layout = useMemo(() => {\n if (!fm) return null;\n const qw = (s: string) => fm.width(s, 500, QUOTE_TRACK);\n // Quote lines with hung curly quotes.\n const lines = splitQuote(quote, qw).map((l, i, all) => {\n let text = l;\n if (i === 0) text = `“${text}`;\n if (i === all.length - 1) text = `${text}”`;\n return text;\n });\n const hang = qw(\"“\") + QUOTE_TRACK;\n const lineEm = lines.map((l, i) => qw(l) - (i ? 0 : hang));\n const quoteEm = Math.max(...lineEm);\n const brandEm = isLogo\n ? MARK_ADV + MARK_GAP + fm.logoWord\n : fm.width(brand, 500, -0.02);\n return { lines, hang, quoteEm, brandEm };\n }, [fm, quote, brand, isLogo]);\n\n if (!fm || !layout) {\n return <div style={{ position: \"absolute\", inset: 0, background: c.bg }} />;\n }\n const { lines, hang, quoteEm, brandEm } = layout;\n const CAP = fm.cap;\n const BASELINE = fm.base;\n\n // Sizes: the quote sets the scale, everything else follows it. The hung\n // opening mark sits inside the left padding.\n const padL = 0.3 + hang;\n const padR = 0.36;\n const small = 0.3;\n const dashEm = fm.width(\"— \", 400, SMALL_TRACK) + SMALL_TRACK;\n const rowEm = fm.width(attribution, 400, SMALL_TRACK) * small;\n const Q = Math.min(\n (W * 0.68) / (Math.max(quoteEm, rowEm) + padL + padR),\n (H * 0.6) / (CAP + LEAD * (lines.length - 1) + 0.6 + small * CAP),\n );\n const S = small * Q;\n const padTop = 0.36 * Q;\n const padBottom = 0.38 * Q;\n const rowGap = 0.6 * Q;\n\n // Text block: quote, then the attribution, centred as one block in frame.\n const boxW = (quoteEm + padL + padR) * Q;\n const quoteH = padTop + (CAP + LEAD * (lines.length - 1)) * Q + padBottom;\n const blockH = quoteH - padBottom + rowGap + CAP * S + padBottom;\n const left = (W - boxW) / 2;\n const top = (H - blockH) / 2;\n const baselines = lines.map((_, i) => padTop + (CAP + LEAD * i) * Q);\n const rowBaseline = baselines[baselines.length - 1] + rowGap + CAP * S;\n const edge = 40 * (H / 720);\n\n // The box starts as the brand's masthead, hugging its logo.\n const M = 0.46 * Q;\n const markCap = isLogo ? fm.logoCap : CAP;\n const markBase = isLogo ? fm.logoBase : BASELINE;\n const padM = 0.34;\n const mastW = (brandEm + 2 * padM) * M;\n const mastH = (markCap + 2 * padM) * M;\n const mast = {\n x: (W - mastW) / 2,\n y: (H - mastH) / 2,\n w: mastW,\n h: mastH,\n };\n\n const growW = interpolate(t, [GROW_AT, GROW_AT + GROW_LEN], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const growH = interpolate(t, [GROW_AT + 3, GROW_AT + GROW_LEN + 3], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const punch = interpolate(t, [PUNCH_AT, PUNCH_AT + PUNCH_LEN], [0, 1], {\n ...CLAMP,\n easing: EASE_SNAP,\n });\n // Setup: the masthead grows to hug the quote. Punchline: it floods the frame.\n const hugX = lerp(mast.x, left, growW);\n const hugW = lerp(mast.w, boxW, growW);\n const hugY = lerp(mast.y, top, growH);\n const hugH = lerp(mast.h, quoteH, growH);\n const box = {\n x: lerp(hugX, -4, punch),\n y: lerp(hugY, -4, punch),\n w: lerp(hugW, W + 8, punch),\n h: lerp(hugH, H + 8, punch),\n };\n const mastOut = interpolate(t, [GROW_AT + 6, GROW_AT + 15], [1, 0], {\n ...CLAMP,\n easing: Easing.bezier(0.4, 0, 1, 1),\n });\n const breathe = interpolate(t, [0, DEADPAN_BOX_DURATION], [1.03, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.2, 0, 0.4, 1),\n });\n\n const lineIn = (i: number) =>\n interpolate(\n t,\n [QUOTE_AT + i * LINE_STAGGER, QUOTE_AT + i * LINE_STAGGER + 22],\n [0, 1],\n { ...CLAMP, easing: EASE_OUT },\n );\n const rowIn = interpolate(t, [PUNCH_AT + 8, PUNCH_AT + 26], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const signIn = interpolate(t, [PUNCH_AT + 16, PUNCH_AT + 34], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n // The field drifts a couple of percent over the shot, never more.\n const field = [\n ...c.blobs.map((b, k) => {\n const x = b.x + Math.sin(t / 48 + k * 1.9) * 2.2;\n const y = b.y + Math.cos(t / 61 + k * 2.4) * 1.8;\n const col = b.color === \"ACCENT\" ? accent : b.color;\n return `radial-gradient(${b.rx}% ${b.ry}% at ${x.toFixed(2)}% ${y.toFixed(2)}%, ${alpha(col, b.a)} 0%, transparent 70%)`;\n }),\n c.base(accent),\n ].join(\", \");\n\n const sign = 26 * (H / 720);\n\n return (\n <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{ transform: `scale(${breathe})`, transformOrigin: \"50% 50%\" }}\n >\n <div\n style={{\n position: \"absolute\",\n left: box.x,\n top: box.y,\n width: box.w,\n height: box.h,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: -box.x,\n top: -box.y,\n width: W,\n height: H,\n background: field,\n }}\n />\n\n {mastOut > 0 ? (\n <div\n style={{\n position: \"absolute\",\n left: mast.x - box.x + padM * M,\n top: mast.y - box.y + (padM + markCap - markBase) * M,\n opacity: mastOut,\n transform: `translateY(${(1 - mastOut) * -0.35 * M}px)`,\n }}\n >\n {isLogo ? (\n <RemocnLogo fontSize={M} color={ink} />\n ) : (\n <div\n style={{\n fontFamily: copy.fontFamily,\n fontWeight: 500,\n fontSize: M,\n lineHeight: 1,\n letterSpacing: \"-0.02em\",\n color: ink,\n whiteSpace: \"pre\",\n }}\n >\n {brand}\n </div>\n )}\n </div>\n ) : null}\n\n {lines.map((l, i) => {\n const p = lineIn(i);\n return (\n <div\n key={`${i}-${l}`}\n style={{\n position: \"absolute\",\n left: left - box.x + (padL - (i ? 0 : hang)) * Q,\n top: top - box.y + baselines[i] - BASELINE * Q,\n height: 1.1 * Q,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n fontFamily: copy.fontFamily,\n fontWeight: 500,\n fontSize: Q,\n lineHeight: 1,\n letterSpacing: `${QUOTE_TRACK}em`,\n color: ink,\n whiteSpace: \"pre\",\n transform: `translateY(${(1 - p) * 1.1 * Q}px)`,\n }}\n >\n {l}\n </div>\n </div>\n );\n })}\n\n <div\n style={{\n position: \"absolute\",\n // the dash hangs, so the words align with the quote's left edge\n left: left - box.x + padL * Q - dashEm * S,\n top: top - box.y + rowBaseline - BASELINE * S,\n fontFamily: copy.fontFamily,\n fontWeight: 400,\n fontSize: S,\n lineHeight: 1,\n letterSpacing: `${SMALL_TRACK}em`,\n color: ink,\n whiteSpace: \"pre\",\n opacity: 0.84 * rowIn,\n transform: `translateY(${(1 - rowIn) * 0.6 * S}px)`,\n }}\n >\n <span style={{ opacity: 0.7 }}>— </span>\n {attribution}\n </div>\n <div\n style={{\n position: \"absolute\",\n right: box.x + box.w - W + edge,\n bottom: box.y + box.h - H + edge,\n opacity: signIn,\n transform: `translateY(${(1 - signIn) * 8 * (H / 720)}px)`,\n }}\n >\n {isLogo ? (\n <RemocnLogo fontSize={sign} color={ink} />\n ) : (\n <div\n style={{\n fontFamily: copy.fontFamily,\n fontWeight: 500,\n fontSize: sign,\n lineHeight: 1,\n letterSpacing: \"-0.02em\",\n color: ink,\n whiteSpace: \"pre\",\n }}\n >\n {brand}\n </div>\n )}\n </div>\n </div>\n </AbsoluteFill>\n\n <Grain opacity={c.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/deadpan-box.tsx"
}
],
"type": "registry:component"
}