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": "domino-run",
"title": "Domino Run",
"description": "Dominoes fall in a chain, growing larger until a 10x stat is set off.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/domino-run/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n interpolateColors,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\nexport interface DominoRunProps {\n count?: number;\n value?: string;\n caption?: string;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 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 THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n small: \"#47464D\",\n large: \"#BDBBB6\",\n axis: \"rgba(255,255,255,0.2)\",\n // gradients.sh \"halo\": #fff4ec → #ffb36b → #e2457a → #3d4dff\n hero: [\"#FFF4EC\", \"#FFB36B\", \"#E2457A\"],\n grain: 0.06,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n small: \"#CFCDC7\",\n large: \"#55534F\",\n axis: \"rgba(18,18,20,0.22)\",\n // gradients.sh \"halo\", warm end deepened to read on off-white\n hero: [\"#F07A3A\", \"#E2457A\", \"#5A3FD8\"],\n grain: 0.045,\n },\n} as const;\n\nconst RATIO = 1.18;\nconst THICK = 0.13;\nconst GAP = 0.44;\nconst T0 = 14;\nconst TAU0 = 3.6;\nconst PUSH = 2.2;\nconst CHAIN = 1.7;\nconst DEG = 180 / Math.PI;\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 }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={23}\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\ninterface Domino {\n h: number;\n w: number;\n px: number;\n gap: number;\n start: number;\n tau: number;\n contact: number;\n}\n\nfunction layout(n: number) {\n const ds: Domino[] = [];\n let x = 0;\n let start = T0;\n for (let i = 0; i < n; i++) {\n const h = RATIO ** i;\n const w = THICK * h;\n const gap = GAP * h;\n const last = i === n - 1;\n const contact = last ? Math.PI / 2 : Math.asin(gap / h);\n const tau = TAU0 * Math.sqrt(h) * (last ? 2.1 : 1);\n ds.push({ h, w, px: x + w, gap, start, tau, contact });\n x += w + gap;\n start += tau;\n }\n const lastD = ds[n - 1];\n const extent = lastD.px + lastD.h;\n return { ds, extent };\n}\n\nfunction freeAngle(d: Domino, t: number, first: boolean, last: boolean) {\n const k = (t - d.start) / d.tau;\n if (k <= 0) return 0;\n const a = d.contact * k ** (first ? PUSH : last ? 2 : CHAIN);\n return Math.min(Math.PI / 2, a);\n}\n\nfunction poseAt(ds: Domino[], t: number) {\n const n = ds.length;\n const last = ds[n - 1];\n const angles = new Array<number>(n).fill(0);\n angles[n - 1] = freeAngle(last, t, n === 1, true);\n const impact = last.start + last.tau;\n if (t > impact) {\n const tb = t - impact;\n angles[n - 1] =\n Math.PI / 2 -\n (3.2 / DEG) * Math.abs(Math.sin((Math.PI * tb) / 7)) * Math.exp(-tb / 6);\n }\n for (let i = n - 2; i >= 0; i--) {\n const free = freeAngle(ds[i], t, i === 0, false);\n angles[i] = Math.min(free, restAngle(ds[i], ds[i + 1], angles[i + 1]));\n }\n return angles;\n}\n\nfunction topOver(ds: Domino[], angles: number[], from: number, to: number) {\n let top = 0;\n ds.forEach((d, i) => {\n const a = angles[i];\n const pts = [\n [0, 0],\n [-d.w, 0],\n [-d.w, d.h],\n [0, d.h],\n ].map(([x, y]) => [\n d.px + x * Math.cos(a) + y * Math.sin(a),\n -x * Math.sin(a) + y * Math.cos(a),\n ]);\n const xs = pts.map((q) => q[0]);\n if (Math.max(...xs) < from || Math.min(...xs) > to) return;\n for (const q of pts) top = Math.max(top, q[1]);\n });\n return top;\n}\n\nfunction restAngle(d: Domino, next: Domino, psi: number) {\n const s = d.gap + next.w;\n let best = Math.PI / 2;\n const arg = (s * Math.cos(psi) - next.w) / d.h;\n if (arg >= -1 && arg <= 1) {\n const phiA = psi + Math.asin(arg);\n const tipX = -s + d.h * Math.sin(phiA);\n const tipY = d.h * Math.cos(phiA);\n const cx = -next.w * Math.cos(psi);\n const cy = next.w * Math.sin(psi);\n const along = (tipX - cx) * Math.sin(psi) + (tipY - cy) * Math.cos(psi);\n if (along >= 0 && along <= next.h) best = Math.min(best, phiA);\n }\n const bx = s - next.w * Math.cos(psi);\n const by = next.w * Math.sin(psi);\n if (Math.hypot(bx, by) <= d.h && by > 0) {\n best = Math.min(best, Math.atan2(bx, by));\n }\n return best;\n}\n\nexport function DominoRun({\n count = 13,\n value = \"10×\",\n caption = \"Every push tips a bigger one.\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: DominoRunProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const u = Math.min(width / 1280, height / 720);\n const p = THEMES[theme];\n const n = Math.max(5, Math.min(24, Math.round(count)));\n const { ds, extent } = layout(n);\n const last = ds[n - 1];\n\n const groundY = height * 0.66;\n const avail = width * 0.84;\n const maxTall = groundY - height * 0.16;\n const S = Math.min(avail / extent, maxTall / last.h);\n const x0 = (width - extent * S) / 2;\n\n const angles = poseAt(ds, t);\n const impact = last.start + last.tau;\n const rest = poseAt(ds, impact + 400);\n\n const enter = interpolate(t, [0, 16], [0, 1], { ...CLAMP, easing: EASE_IO });\n const sw = Math.max(1, u);\n const haloId = `halo${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const drift = interpolate(t, [0, 165], [0, 1], CLAMP);\n const heroGradient = `linear-gradient(${172 - 8 * drift}deg, ${p.hero[0]} ${4 + 6 * drift}%, ${p.hero[1]} ${46 + 4 * drift}%, ${p.hero[2]} 96%)`;\n const chars = Math.max(1, value.length);\n const valueSize = Math.max(\n 96 * u,\n Math.min(200 * u, (width * 0.36) / (chars * 0.56)),\n );\n const valueW = chars * 0.56 * valueSize;\n const valueRight = x0 + (last.px + last.h) * S;\n const clearTop = topOver(ds, rest, (valueRight - valueW - x0) / S, extent);\n const valueBottom = groundY - clearTop * S - 34 * u;\n const reveal = interpolate(t, [impact + 2, impact + 22], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const capIn = interpolate(t, [impact + 12, impact + 30], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <AbsoluteFill>\n <svg\n width={width}\n height={height}\n style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n aria-hidden\n >\n <defs>\n <linearGradient id={haloId} x1=\"0\" y1=\"1\" x2=\"0\" y2=\"0\">\n <stop offset=\"0\" stopColor={accent} />\n <stop offset=\"0.55\" stopColor=\"#E2457A\" />\n <stop offset=\"1\" stopColor=\"#FFB36B\" />\n </linearGradient>\n </defs>\n <line\n x1={width / 2 - width * 0.43 * enter}\n x2={width / 2 + width * 0.43 * enter}\n y1={groundY + sw / 2}\n y2={groundY + sw / 2}\n stroke={p.axis}\n strokeWidth={sw}\n />\n {ds.map((d, i) => {\n const isLast = i === n - 1;\n const appear = interpolate(t, [2 + i * 1.2, 14 + i * 1.2], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const fill = isLast\n ? `url(#${haloId})`\n : interpolateColors(\n i / Math.max(1, n - 2),\n [0, 1],\n [p.small, p.large],\n );\n return (\n <g\n key={`d${d.h.toFixed(4)}`}\n opacity={appear}\n transform={`translate(${x0 + d.px * S} ${groundY + (1 - appear) * 10 * u}) rotate(${angles[i] * DEG})`}\n >\n <rect\n x={-d.w * S}\n y={-d.h * S}\n width={d.w * S}\n height={d.h * S}\n rx={Math.min(3 * u, d.w * S * 0.3)}\n fill={fill}\n />\n </g>\n );\n })}\n </svg>\n\n <div\n style={{\n position: \"absolute\",\n right: width - valueRight - valueSize * 0.03,\n bottom: height - valueBottom,\n fontFamily: display,\n fontWeight: 500,\n fontSize: valueSize,\n lineHeight: 0.74,\n letterSpacing: \"-0.035em\",\n backgroundImage: heroGradient,\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n color: \"transparent\",\n paddingTop: valueSize * 0.08,\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n opacity: reveal,\n filter:\n reveal < 0.99 ? `blur(${(1 - reveal) * 10 * u}px)` : undefined,\n transform: `translateY(${(1 - reveal) * 22 * u}px)`,\n }}\n >\n {value}\n </div>\n {caption ? (\n <div\n style={{\n position: \"absolute\",\n right: width - valueRight,\n top: groundY + 24 * u,\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n fontFamily: display,\n fontWeight: 400,\n fontSize: 24 * u,\n letterSpacing: \"-0.01em\",\n color: p.muted,\n whiteSpace: \"nowrap\",\n opacity: capIn,\n transform: `translateY(${(1 - capIn) * 8 * u}px)`,\n }}\n >\n <span\n style={{\n width: 10 * u,\n height: 10 * u,\n borderRadius: \"50%\",\n background: accent,\n }}\n />\n {caption}\n </div>\n ) : null}\n </AbsoluteFill>\n <Grain opacity={p.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/domino-run.tsx"
}
],
"type": "registry:component"
}