Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [
{
"name": "@remotion/google-fonts",
"version": null
}
],
"dimensions": null,
"displayName": "Sankey Flow",
"initialProps": null,
"slug": "sankey-flow",
"sourceCode": "import { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: sans } = loadGeist(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n weights: [\"600\"],\n subsets: [\"latin\"],\n});\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/** Full logo as on remocn.dev: R mark (0.76em tall, baseline-aligned) + \"emocn\" in Manrope 600. */\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: \"-0.025em\",\n lineHeight: 1,\n }}\n >\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{ height: \"0.76em\", width: \"auto\" }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n </div>\n );\n}\n\n/** gradients.sh \"beam\" palette: light to deep. The mid stop takes the accent. */\nconst BEAM = [\"#f4f7ff\", \"#8fb4ff\", \"#3d5bff\", \"#1a1660\"] as const;\n\ninterface SankeySource {\n label: string;\n value: number;\n}\n\ninterface SankeyFlowProps {\n sources?: SankeySource[];\n target?: string;\n total?: number;\n label?: string;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst DEFAULT_SOURCES: SankeySource[] = [\n { label: \"Kitebase\", value: 4100 },\n { label: \"Lumen\", value: 3200 },\n { label: \"Fernway\", value: 2400 },\n { label: \"Quarry\", value: 1700 },\n { label: \"Halcyon\", value: 1000 },\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 EASE_FLOW = Easing.bezier(0.5, 0, 0.3, 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 node: \"#6E6D73\",\n band: \"#8B8A90\",\n bandA: 0.26,\n accentA: 0.5,\n grain: 0.06,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n node: \"#9C9A94\",\n band: \"#8E8C86\",\n bandA: 0.28,\n accentA: 0.45,\n grain: 0.045,\n },\n} as const;\n\nconst NODE_START = 2;\nconst NODE_STAGGER = 3;\nconst FLOW_START = 16;\nconst FLOW_STAGGER = 6;\nconst FLOW_LEN = 34;\nconst FEATHER = 0.16;\n\nfunction fmt(n: number) {\n if (n >= 1000) return `${(n / 1000).toFixed(1)}k`;\n return `${Math.round(n)}`;\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 }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={41}\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\nfunction SankeyFlowBase({\n sources = DEFAULT_SOURCES,\n target = \"remocn\",\n total,\n label = \"videos rendered\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: SankeyFlowProps) {\n const t = useCurrentFrame() * speed;\n const { width, height, fps } = useVideoConfig();\n const u = Math.min(width / 1280, height / 720);\n const p = THEMES[theme];\n const id = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const list = sources.slice(0, 6);\n const sum = list.reduce((s, x) => s + Math.max(0, x.value), 0) || 1;\n const shown = total ?? sum;\n\n const srcX = width * 0.25;\n const nodeW = 10 * u;\n const tgtX = width * 0.6;\n const tgtW = 14 * u;\n const cy = height / 2;\n const gap = 16 * u;\n const colH = height * 0.62;\n const scale = (colH - gap * (list.length - 1)) / sum;\n const tgtH = sum * scale;\n\n let sy = cy - colH / 2;\n let ty = cy - tgtH / 2;\n const nodes = list.map((s, i) => {\n const h = Math.max(0, s.value) * scale;\n const node = {\n ...s,\n i,\n y0: sy,\n y1: sy + h,\n t0: ty,\n t1: ty + h,\n inAt: NODE_START + i * NODE_STAGGER,\n flowAt: FLOW_START + i * FLOW_STAGGER,\n };\n sy += h + gap;\n ty += h;\n return node;\n });\n\n const xs = srcX + nodeW;\n const xt = tgtX;\n const mx = (xs + xt) / 2;\n const L = xt - xs;\n const lastFlow = FLOW_START + (list.length - 1) * FLOW_STAGGER + FLOW_LEN;\n const HIT = lastFlow - 4;\n\n const land = spring({\n frame: t - HIT,\n fps,\n config: { damping: 18, stiffness: 150, mass: 0.8 },\n });\n const landO = interpolate(t, [HIT, HIT + 8], [0, 1], CLAMP);\n const blur = interpolate(t, [HIT, HIT + 14], [1, 0], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const count = interpolate(t, [HIT, HIT + 26], [0.82, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.22, 1, 0.36, 1),\n });\n const cap = interpolate(t, [HIT + 10, HIT + 28], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const settle = interpolate(t, [HIT - 4, HIT + 18], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const push = interpolate(t, [0, 150], [0.965, 1.005], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const stage = interpolate(t, [0, 8], [0.5, 1], CLAMP);\n\n const numSize = 136 * u;\n const blockLeft = tgtX + tgtW + 40 * u;\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n transform: `scale(${push})`,\n transformOrigin: \"50% 50%\",\n opacity: stage,\n }}\n >\n <svg\n width={width}\n height={height}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n <defs>\n <linearGradient\n id={`${id}f`}\n gradientUnits=\"userSpaceOnUse\"\n x1={xs}\n y1={0}\n x2={xt}\n y2={0}\n >\n <stop\n offset={0}\n stopColor={p.band}\n stopOpacity={p.bandA * (1 - 0.2 * settle)}\n />\n <stop\n offset={0.34}\n stopColor={p.band}\n stopOpacity={p.bandA * (1 - 0.2 * settle)}\n />\n <stop\n offset={0.62}\n stopColor={theme === \"dark\" ? BEAM[2] : BEAM[1]}\n stopOpacity={theme === \"dark\" ? 0.38 + 0.12 * settle : 0.6}\n />\n <stop\n offset={0.86}\n stopColor={accent}\n stopOpacity={0.78 + 0.12 * settle}\n />\n <stop\n offset={1}\n stopColor={theme === \"dark\" ? BEAM[1] : BEAM[2]}\n stopOpacity={0.9 + 0.1 * settle}\n />\n </linearGradient>\n <linearGradient\n id={`${id}t`}\n gradientUnits=\"userSpaceOnUse\"\n x1={0}\n y1={nodes[0]?.t0 ?? 0}\n x2={0}\n y2={nodes[nodes.length - 1]?.t1 ?? height}\n >\n <stop\n offset={0}\n stopColor={theme === \"dark\" ? BEAM[0] : BEAM[1]}\n />\n <stop\n offset={0.4}\n stopColor={theme === \"dark\" ? BEAM[1] : accent}\n />\n <stop\n offset={1}\n stopColor={theme === \"dark\" ? accent : BEAM[3]}\n />\n </linearGradient>\n {nodes.map((n) => {\n const front = interpolate(\n t,\n [n.flowAt, n.flowAt + FLOW_LEN],\n [0, 1 + FEATHER],\n { ...CLAMP, easing: EASE_FLOW },\n );\n const fx = xs + L * Math.max(front, 0.001);\n const soft = Math.max(0, 1 - (L * FEATHER) / (fx - xs));\n return (\n <linearGradient\n key={n.label}\n id={`${id}m${n.i}`}\n gradientUnits=\"userSpaceOnUse\"\n x1={xs}\n y1={0}\n x2={fx}\n y2={0}\n >\n <stop offset={0} stopColor=\"#fff\" stopOpacity={1} />\n <stop offset={soft} stopColor=\"#fff\" stopOpacity={1} />\n <stop offset={1} stopColor=\"#fff\" stopOpacity={0} />\n </linearGradient>\n );\n })}\n {nodes.map((n) => (\n <mask key={n.label} id={`${id}k${n.i}`}>\n <rect\n x={0}\n y={0}\n width={width}\n height={height}\n fill={`url(#${id}m${n.i})`}\n />\n </mask>\n ))}\n </defs>\n\n {nodes.map((n) => {\n if (t < n.flowAt) return null;\n const d = [\n `M${xs} ${n.y0}`,\n `C${mx} ${n.y0} ${mx} ${n.t0} ${xt} ${n.t0}`,\n `L${xt} ${n.t1}`,\n `C${mx} ${n.t1} ${mx} ${n.y1} ${xs} ${n.y1}`,\n \"Z\",\n ].join(\" \");\n return (\n <path\n key={n.label}\n d={d}\n fill={`url(#${id}f)`}\n stroke={p.bg}\n strokeWidth={1.5 * u}\n strokeLinejoin=\"round\"\n mask={`url(#${id}k${n.i})`}\n />\n );\n })}\n\n {nodes.map((n) => {\n const k = interpolate(t, [n.inAt, n.inAt + 16], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const h = (n.y1 - n.y0) * (0.4 + 0.6 * k);\n const mid = (n.y0 + n.y1) / 2;\n return (\n <rect\n key={n.label}\n x={srcX}\n y={mid - h / 2}\n width={nodeW}\n height={h}\n rx={2 * u}\n fill={p.node}\n opacity={k}\n />\n );\n })}\n\n {nodes.map((n) => {\n const front = interpolate(\n t,\n [n.flowAt, n.flowAt + FLOW_LEN],\n [0, 1 + FEATHER],\n { ...CLAMP, easing: EASE_FLOW },\n );\n const a = interpolate(front, [0.9, 1.1], [0, 1], CLAMP);\n if (a <= 0) return null;\n const first = n.i === 0;\n const last = n.i === nodes.length - 1;\n return (\n <rect\n key={n.label}\n x={tgtX - (1 - a) * 6 * u}\n y={n.t0}\n width={tgtW}\n height={n.t1 - n.t0}\n rx={first || last ? 2 * u : 0}\n fill={`url(#${id}t)`}\n opacity={a}\n />\n );\n })}\n </svg>\n\n {nodes.map((n) => {\n const k = interpolate(t, [n.inAt + 2, n.inAt + 18], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n return (\n <div\n key={n.label}\n style={{\n position: \"absolute\",\n right: width - srcX + 16 * u,\n top: (n.y0 + n.y1) / 2,\n transform: `translate(${(1 - k) * 10 * u}px, -50%)`,\n opacity: k * (1 - 0.35 * settle),\n display: \"flex\",\n alignItems: \"baseline\",\n gap: 10 * u,\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 19 * u,\n letterSpacing: \"-0.01em\",\n color: p.fg,\n }}\n >\n {n.label}\n </span>\n <span\n style={{\n fontFamily: mono,\n fontWeight: 400,\n fontSize: 14 * u,\n color: p.muted,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {fmt(n.value)}\n </span>\n </div>\n );\n })}\n\n <div\n style={{\n position: \"absolute\",\n left: blockLeft,\n top: cy,\n transform: `translateY(${-numSize * 0.62}px)`,\n }}\n >\n <div\n style={{\n fontFamily: sans,\n fontWeight: 500,\n fontSize: numSize,\n lineHeight: 0.9,\n letterSpacing: \"-0.05em\",\n color: p.fg,\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n opacity: landO,\n filter: blur > 0.01 ? `blur(${blur * 8 * u}px)` : undefined,\n transform: `translateX(${(1 - land) * -24 * u}px)`,\n }}\n >\n {fmt(shown * count)}\n </div>\n <div\n style={{\n marginTop: 22 * u,\n opacity: cap,\n transform: `translateY(${(1 - cap) * 8 * u}px)`,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 10 * u,\n whiteSpace: \"nowrap\",\n }}\n >\n {target.trim().toLowerCase() === \"remocn\" ? (\n <RemocnLogo fontSize={26 * u} color={p.fg} />\n ) : (\n <div\n style={{\n fontFamily: sans,\n fontWeight: 500,\n fontSize: 24 * u,\n letterSpacing: \"-0.02em\",\n color: p.fg,\n }}\n >\n {target}\n </div>\n )}\n <div\n style={{\n fontFamily: mono,\n fontWeight: 400,\n fontSize: 14 * u,\n letterSpacing: \"0.04em\",\n textTransform: \"uppercase\",\n color: p.muted,\n }}\n >\n {label}\n </div>\n </div>\n </div>\n </AbsoluteFill>\n\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse 80% 80% at 50% 50%, transparent 62%, ${p.bg} 100%)`,\n opacity: 0.6,\n }}\n />\n <Grain opacity={p.grain} />\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"dark\",\n variants: {\n dark: {},\n light: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n target: {\n type: \"text-content\",\n default: \"remocn\",\n description: \"Target\",\n },\n label: {\n type: \"text-content\",\n default: \"videos rendered\",\n description: \"Label\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"theme\",\"accent\",\"target\",\"label\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n target: \"remocn\",\n label: \"videos rendered\",\n speed: 1,\n};\n\ntype SankeyFlowElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SankeyFlowBase>;\n\nconst SankeyFlowInner = forwardRef<\n HTMLDivElement,\n SankeyFlowElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SankeyFlow>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SankeyFlowBase\n {...(componentProps as unknown as ComponentProps<typeof SankeyFlowBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SankeyFlow = Interactive.withSchema({\n Component: SankeyFlowInner,\n componentName: \"<SankeyFlow>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 98,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 98
}