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": "wake-wipe",
"title": "Wake Wipe",
"description": "A wake-like wipe reveals 'Ship the launch video today.' with a gradient accent word.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/wake-wipe/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadFigtree } from \"@remotion/google-fonts/Figtree\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport type React from \"react\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport {\n AbsoluteFill,\n continueRender,\n delayRender,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst figtree = loadFigtree(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst mono = loadMono(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface WakeWipeProps {\n lines?: string[];\n highlight?: string;\n eyebrow?: string;\n hold?: number;\n accent?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n ink: \"#F4F3F0\",\n muted: \"#8E8D94\",\n edge: [\"#fff4ec\", \"#ffb36b\", \"#e2457a\"],\n ground: 0.5,\n grain: 0.05,\n },\n light: {\n bg: \"#F5F4F0\",\n ink: \"#111113\",\n muted: \"#6E6C67\",\n edge: [\"#ff8a3d\", \"#ff3d9a\", \"#7a5cff\"],\n ground: 0.46,\n grain: 0.035,\n },\n} as const;\n\nconst TRACK = -0.035;\nconst START = 4;\nconst WAKE_LEN = 28;\nconst REVEAL_LEN = 18;\nconst REVEAL_TAIL = 0.32;\nconst TAIL = 0.5;\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_WAKE = Easing.bezier(0.5, 0, 0.2, 1);\nconst EASE_REVEAL = Easing.bezier(0.3, 0, 0.15, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst mix = (c: string, a: number) =>\n `color-mix(in oklab, ${c} ${(Math.max(0, Math.min(1, a)) * 100).toFixed(1)}%, transparent)`;\n\nfunction measure(lines: string[]) {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return lines.map((l) => l.length * 0.52);\n ctx.font = `500 1000px \"${figtree.fontFamily}\"`;\n return lines.map(\n (l) => ctx.measureText(l).width / 1000 + TRACK * Array.from(l).length,\n );\n}\n\nfunction useWidths(lines: string[]) {\n const [widths, setWidths] = useState<number[] | null>(null);\n const [handle] = useState(() => delayRender(\"wake-wipe: measuring\"));\n const released = useRef(false);\n const key = lines.join(\"\\n\");\n useEffect(() => {\n let live = true;\n Promise.all([\n figtree.waitUntilDone(),\n mono.waitUntilDone(),\n document.fonts.load(`500 100px \"${figtree.fontFamily}\"`),\n ])\n .catch(() => undefined)\n .then(() => {\n if (!live) return;\n setWidths(measure(key.split(\"\\n\")));\n if (!released.current) {\n released.current = true;\n continueRender(handle);\n }\n });\n return () => {\n live = false;\n };\n }, [key, handle]);\n return widths;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n const id = `ww${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n style={{\n position: \"absolute\",\n inset: 0,\n opacity,\n mixBlendMode: \"overlay\",\n }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={11}\n />\n <feColorMatrix type=\"saturate\" values=\"0\" />\n </filter>\n <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n </svg>\n );\n}\n\nexport function WakeWipe({\n lines = [\n \"Animations you own.\",\n \"Transitions that land.\",\n \"Ship the launch video today.\",\n ],\n highlight = \"today.\",\n eyebrow = \"Inside remocn\",\n hold = 54,\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: WakeWipeProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const c = THEMES[theme];\n const items = lines.length ? lines : [\"\"];\n const widths = useWidths(items);\n\n if (!widths) {\n return <div style={{ position: \"absolute\", inset: 0, background: c.bg }} />;\n }\n\n const portrait = H > W;\n const padX = W * (portrait ? 0.08 : 0.085);\n const maxW = W - padX * 2;\n const widest = Math.max(...widths, 0.1);\n const maxRows = portrait ? 3 : 2;\n const F = Math.min(\n portrait ? W * 0.15 : H * 0.17,\n (maxW * maxRows * 0.9) / widest,\n );\n\n const rowsOf = (w: number) => Math.max(1, Math.ceil((w * F) / maxW - 0.02));\n const rows = Math.max(...widths.map(rowsOf), 1);\n const blockH = rows * F * 1.04;\n const ebSize = Math.max(Math.min(H, W) * 0.026, 12);\n const ebGap = F * 0.42;\n const stackH = blockH + (eyebrow ? ebSize + ebGap : 0);\n const centerY = portrait ? H * 0.56 : H * 0.5;\n const blockTop = centerY - stackH / 2 + (eyebrow ? ebSize + ebGap : 0);\n\n const cx = -W * 0.6;\n const cy = H * 0.64;\n const T = W * TAIL;\n const T2 = W * REVEAL_TAIL;\n const r0 = Math.hypot(0 - cx, 0) - 2;\n const r1 = Math.hypot(W - cx, Math.max(cy, H - cy)) + T + 2;\n\n const boxTop = blockTop - F * 0.08;\n const boxRight = (i: number) =>\n padX + Math.min(widths[i] * F, maxW) + F * 0.1;\n const boxBottom = (i: number) =>\n blockTop + rowsOf(widths[i]) * F * 1.04 + F * 0.12;\n const far = (i: number) =>\n Math.max(\n Math.hypot(boxRight(i) - cx, boxTop - cy),\n Math.hypot(boxRight(i) - cx, boxBottom(i) - cy),\n );\n const near = (i: number) =>\n Math.hypot(\n padX - F * 0.1 - cx,\n Math.min(Math.max(cy, boxTop), boxBottom(i)) - cy,\n );\n\n const last = items.length - 1;\n const startOf = (k: number) => START + k * hold;\n const rRest = Math.max(\n W * 1.06 - cx,\n last > 0 ? far(last - 1) + W * 0.03 : 0,\n );\n const frontAt = (k: number, time: number) => {\n const end = k === last ? rRest : r1;\n const p = interpolate(time, [startOf(k), startOf(k) + WAKE_LEN], [0, 1], {\n ...CLAMP,\n easing: EASE_WAKE,\n });\n const breathe =\n k === last ? Math.sin((time - startOf(k)) / 22) * W * 0.006 * p : 0;\n return r0 + (end - r0) * p + breathe;\n };\n const erasedAt = (k: number) => {\n if (k === 0) return startOf(0);\n const target = far(k - 1);\n for (let s = 0; s <= WAKE_LEN; s += 0.25)\n if (frontAt(k, startOf(k) + s) >= target) return startOf(k) + s;\n return startOf(k) + WAKE_LEN;\n };\n const revealAt = (k: number, time: number) => {\n const t0 = erasedAt(k);\n if (time < t0) return 0;\n const p = interpolate(time, [t0, t0 + REVEAL_LEN], [0, 1], {\n ...CLAMP,\n easing: EASE_REVEAL,\n });\n const r = near(k) + (far(k) + T2 - near(k)) * p;\n return Math.min(r, frontAt(k, time) - 1);\n };\n\n let k = 0;\n for (let i = 0; i < items.length; i++) if (t >= startOf(i)) k = i;\n const R = frontAt(k, t);\n const R2 = revealAt(k, t);\n const at = `circle farthest-corner at ${cx.toFixed(1)}px ${cy.toFixed(1)}px`;\n\n const deep = accent;\n const tail = (a: number) =>\n `radial-gradient(${at}, transparent ${(R - T).toFixed(1)}px, ${mix(deep, 0.55 * a)} ${(R - T * 0.5).toFixed(1)}px, ${mix(c.edge[2], 0.82 * a)} ${(R - T * 0.2).toFixed(1)}px, ${mix(c.edge[1], 0.96 * a)} ${(R - T * 0.055).toFixed(1)}px, ${mix(c.edge[0], a)} ${(R - 2.5).toFixed(1)}px, ${mix(c.edge[0], a)} ${R.toFixed(1)}px, transparent ${(R + 1).toFixed(1)}px)`;\n const revealTint = (a: number) =>\n `radial-gradient(${at}, transparent ${(R2 - T2).toFixed(1)}px, ${mix(deep, 0.6 * a)} ${(R2 - T2 * 0.55).toFixed(1)}px, ${mix(c.edge[2], 0.9 * a)} ${(R2 - T2 * 0.22).toFixed(1)}px, ${mix(c.edge[1], a)} ${(R2 - T2 * 0.06).toFixed(1)}px, ${mix(c.edge[0], a)} ${(R2 - 1).toFixed(1)}px, transparent ${(R2 + 0.5).toFixed(1)}px)`;\n const inside = `radial-gradient(${at}, #000 ${(R2 - 0.5).toFixed(1)}px, transparent ${(R2 + 0.5).toFixed(1)}px)`;\n const outside = `radial-gradient(${at}, transparent ${(R - 0.5).toFixed(1)}px, #000 ${(R + 0.5).toFixed(1)}px)`;\n\n const textBlock: React.CSSProperties = {\n position: \"absolute\",\n left: padX,\n width: maxW,\n top: blockTop,\n fontFamily: figtree.fontFamily,\n fontWeight: 500,\n fontSize: F,\n lineHeight: 1.04,\n letterSpacing: `${TRACK}em`,\n textWrap: \"balance\",\n };\n\n const revealEnd = erasedAt(last) + REVEAL_LEN;\n const settled = interpolate(t, [revealEnd - 4, revealEnd + 8], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const finalFill = `linear-gradient(100deg, ${c.edge[1]} 0%, ${c.edge[2]} 45%, ${deep} 100%)`;\n\n type Mode = \"ink\" | \"lit\" | \"final\";\n const renderLine = (i: number, mode: Mode) => {\n const text = items[i];\n const h = i === last && highlight ? text.lastIndexOf(highlight) : -1;\n if (h < 0) return mode === \"final\" ? null : text;\n const word = text.slice(h, h + highlight.length);\n const wordStyle: React.CSSProperties =\n mode === \"final\"\n ? {\n backgroundImage: finalFill,\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n color: \"transparent\",\n opacity: settled,\n }\n : mode === \"ink\"\n ? { opacity: 1 - settled }\n : {};\n return (\n <>\n {text.slice(0, h)}\n <span style={wordStyle}>{word}</span>\n {text.slice(h + highlight.length)}\n </>\n );\n };\n\n const layer = (\n key: string,\n i: number,\n mode: Mode,\n style: React.CSSProperties,\n ) => (\n <div key={key} style={{ position: \"absolute\", inset: 0, ...style }}>\n <div style={textBlock}>{renderLine(i, mode)}</div>\n </div>\n );\n\n const eyebrowP = interpolate(t, [START + 8, START + 26], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n return (\n <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n backgroundImage: tail(c.ground),\n }}\n />\n {k > 0\n ? layer(\"old\", k - 1, \"ink\", {\n color: c.ink,\n WebkitMaskImage: outside,\n maskImage: outside,\n })\n : null}\n {layer(\"new\", k, \"ink\", {\n color: c.ink,\n WebkitMaskImage: inside,\n maskImage: inside,\n })}\n {k === last && highlight\n ? layer(\"final\", k, \"final\", { color: \"transparent\" })\n : null}\n {layer(\"lit\", k, \"lit\", {\n color: \"transparent\",\n backgroundImage: revealTint(k === last ? 1 - settled : 1),\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n })}\n {eyebrow ? (\n <div\n style={{\n position: \"absolute\",\n left: padX,\n top: blockTop - ebGap - ebSize,\n lineHeight: 1,\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: ebSize,\n letterSpacing: \"0.08em\",\n textTransform: \"uppercase\",\n color: c.muted,\n opacity: eyebrowP,\n transform: `translateY(${((1 - eyebrowP) * ebSize * 0.6).toFixed(2)}px)`,\n }}\n >\n {eyebrow}\n </div>\n ) : null}\n <Grain opacity={c.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/wake-wipe.tsx"
}
],
"type": "registry:component"
}