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": "Activity Rings",
"initialProps": null,
"slug": "activity-rings",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/Sora\";\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 } = loadFont(\"normal\", {\n weights: [\"300\", \"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\n/** gradients.sh \"beam\" (#f4f7ff #8fb4ff #3d5bff #1a1660): the hero ring's light. */\nconst BEAM = {\n stops: [\"#C4D6FF\", \"#8FB4FF\", \"#3D5BFF\", \"#3A2FC4\"],\n css: \"linear-gradient(135deg, #C4D6FF, #8FB4FF 30%, #3D5BFF 66%, #3A2FC4)\",\n};\n\ninterface ActivityRing {\n label: string;\n /** The number the label counts up to. */\n value: number;\n /** Optional suffix after the value: \"h\", \"k\". */\n unit?: string;\n /** How far past the goal the ring laps, as a fraction: 1.14 = 114%. */\n goal?: number;\n}\n\ninterface ActivityRingsProps {\n /** Up to three rings, outermost first. */\n rings?: ActivityRing[];\n /** Small heading above the readouts. */\n title?: string;\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_RINGS: ActivityRing[] = [\n { label: \"Renders\", value: 1284, goal: 1.14 },\n { label: \"Templates\", value: 42, goal: 1.08 },\n { label: \"Hours saved\", value: 310, goal: 1.05 },\n];\n\nconst EASE_FILL = Easing.bezier(0.55, 0, 0.18, 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 key: \"radial-gradient(ellipse 38% 62% at 36% 50%, rgba(61,91,255,0.16), rgba(26,22,96,0.10) 55%, transparent 100%)\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n hair: \"rgba(255,255,255,0.12)\",\n neutrals: [\"#BEBCB6\", \"#6A686E\"],\n track: 0.13,\n capShadow: \"rgba(0,0,0,0.65)\",\n grain: 0.07,\n },\n light: {\n bg: \"#F5F4F0\",\n key: \"radial-gradient(ellipse 50% 70% at 36% 46%, rgba(255,255,255,0.95), transparent 70%)\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n hair: \"rgba(18,18,20,0.12)\",\n neutrals: [\"#5E5C57\", \"#B3B0A8\"],\n track: 0.11,\n capShadow: \"rgba(30,24,16,0.4)\",\n grain: 0.045,\n },\n} as const;\n\nfunction rgb(hex: string): number[] | null {\n const m = /^#([0-9a-f]{6})$/i.exec(hex);\n if (!m) return null;\n const v = Number.parseInt(m[1], 16);\n return [(v >> 16) & 255, (v >> 8) & 255, v & 255];\n}\n\nfunction alpha(color: string, a: number) {\n const c = rgb(color);\n if (c) return `rgba(${c[0]},${c[1]},${c[2]},${a})`;\n const m = /^rgb\\((\\d+),(\\d+),(\\d+)\\)$/.exec(color);\n if (m) return `rgba(${m[1]},${m[2]},${m[3]},${a})`;\n return color;\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={3}\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 fmt = (v: number) => Math.round(v).toLocaleString(\"en-US\");\n\n/** Point on a ring at progress `p` (0 = 12 o'clock, clockwise). */\nfunction at(cx: number, cy: number, r: number, p: number) {\n const a = p * Math.PI * 2;\n return { x: cx + r * Math.sin(a), y: cy - r * Math.cos(a), a };\n}\n\nfunction Ring({\n cx,\n cy,\n r,\n sw,\n p,\n color,\n lapColor,\n track,\n shadow,\n uid,\n u,\n}: {\n cx: number;\n cy: number;\n r: number;\n sw: number;\n p: number;\n color: string;\n lapColor: string;\n track: string;\n shadow: string;\n uid: string;\n u: number;\n}) {\n const C = 2 * Math.PI * r;\n const clipId = `${uid}c`;\n const blurId = `${uid}b`;\n const base = Math.min(p, 1);\n const lap = Math.max(0, p - 1);\n // the end cap casts a soft shadow forward onto the ring it is about to cover\n const capP = p > 0.75 ? p : 0;\n const end = at(cx, cy, r, capP);\n const fwd = 2.6 * u;\n const capOpacity = interpolate(p, [0.8, 1], [0, 1], CLAMP);\n const rot = `rotate(-90 ${cx} ${cy})`;\n return (\n <g>\n <defs>\n <clipPath id={clipId}>\n <path\n clipRule=\"evenodd\"\n d={`M ${cx - r - sw / 2} ${cy} a ${r + sw / 2} ${r + sw / 2} 0 1 0 ${2 * r + sw} 0 a ${r + sw / 2} ${r + sw / 2} 0 1 0 ${-(2 * r + sw)} 0 Z M ${cx - r + sw / 2} ${cy} a ${r - sw / 2} ${r - sw / 2} 0 1 0 ${2 * r - sw} 0 a ${r - sw / 2} ${r - sw / 2} 0 1 0 ${-(2 * r - sw)} 0 Z`}\n />\n </clipPath>\n <filter id={blurId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur stdDeviation={2.6 * u} />\n </filter>\n </defs>\n <circle\n cx={cx}\n cy={cy}\n r={r}\n fill=\"none\"\n stroke={track}\n strokeWidth={sw}\n />\n {base > 0.001 ? (\n <circle\n cx={cx}\n cy={cy}\n r={r}\n fill=\"none\"\n stroke={color}\n strokeWidth={sw}\n strokeLinecap={base >= 1 ? \"butt\" : \"round\"}\n strokeDasharray={base >= 1 ? undefined : `${base * C} ${C}`}\n transform={rot}\n />\n ) : null}\n {capP > 0 ? (\n <g clipPath={`url(#${clipId})`} opacity={capOpacity}>\n <circle\n cx={end.x + Math.cos(end.a) * fwd}\n cy={end.y + Math.sin(end.a) * fwd}\n r={sw / 2}\n fill={shadow}\n filter={`url(#${blurId})`}\n />\n </g>\n ) : null}\n {lap > 0.0005 ? (\n <circle\n cx={cx}\n cy={cy}\n r={r}\n fill=\"none\"\n stroke={lapColor}\n strokeWidth={sw}\n strokeLinecap=\"round\"\n strokeDasharray={`${lap * C} ${C}`}\n transform={rot}\n />\n ) : capP > 0 ? (\n // redraw the cap over its own shadow while still inside the first lap\n <circle cx={end.x} cy={end.y} r={sw / 2} fill={color} />\n ) : null}\n </g>\n );\n}\n\nfunction ActivityRingsBase({\n rings = DEFAULT_RINGS,\n title = \"This month\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: ActivityRingsProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const t = frame * speed;\n const u = Math.min(width / 1280, height / 720);\n const c = THEMES[theme];\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const list = rings.slice(0, 3);\n\n // hero ring carries the gradient; the others stay neutral so the data reads\n const gradId = `${uid}beam`;\n const colors = [accent, c.neutrals[0], c.neutrals[1]];\n const paints = [`url(#${gradId})`, c.neutrals[0], c.neutrals[1]];\n const swatches = [BEAM.css, c.neutrals[0], c.neutrals[1]];\n\n const cx = width * 0.355;\n const cy = height * 0.5;\n const sw = 26 * u;\n const gap = 8 * u;\n const R0 = 182 * u;\n const radius = (i: number) => R0 - i * (sw + gap);\n\n // timeline\n const FILL_START = 16;\n const fillEnd = (i: number) => 58 + i * 4; // every ring closes, outermost first\n const HIT = fillEnd(list.length - 1);\n\n const stageIn = interpolate(t, [0, 22], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n const progress = (i: number) => {\n const goal = Math.max(1, list[i].goal ?? 1);\n const p1 = interpolate(t, [FILL_START + i * 4, fillEnd(i)], [0, 1], {\n ...CLAMP,\n easing: EASE_FILL,\n });\n if (t < HIT) return p1;\n const s = spring({\n frame: t - HIT - i * 2,\n fps,\n config: { damping: 15, mass: 0.9, stiffness: 120 },\n });\n return 1 + (goal - 1) * s;\n };\n\n // the hit: a small bump of the whole object and a check in the centre\n const bump = interpolate(t, [HIT, HIT + 5, HIT + 16], [0, 1, 0], {\n ...CLAMP,\n easing: Easing.bezier(0.65, 0, 0.35, 1),\n });\n const check = spring({\n frame: t - HIT - 1,\n fps,\n config: { damping: 13, mass: 0.6, stiffness: 160 },\n });\n const checkDraw = interpolate(t, [HIT + 3, HIT + 13], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const pulse = interpolate(t, [HIT, HIT + 20], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n const push = interpolate(t, [0, HIT + 60], [0, 1], CLAMP);\n const innerR = radius(list.length - 1) - sw / 2;\n const badge = Math.min(32 * u, innerR * 0.42);\n\n // readouts\n const rowX = width * 0.6;\n const rowH = 108 * u;\n const rowsTop = cy - (list.length * rowH) / 2 + 18 * u;\n const row = (k: number, d = 0) =>\n interpolate(t, [8 + k * 4 + d, 26 + k * 4 + d], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n return (\n <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n background: c.key,\n }}\n />\n\n {/* rings plane: moves a touch more than the readouts for parallax */}\n <AbsoluteFill\n style={{\n transform: `translateX(${-push * 10 * u}px) scale(${(0.94 + stageIn * 0.06) * (1 + push * 0.02) * (1 + bump * 0.016)})`,\n transformOrigin: `${cx}px ${cy}px`,\n opacity: stageIn,\n }}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n <defs>\n {/* fixed in space, drifting a few degrees: light falls from the top right */}\n <linearGradient\n id={gradId}\n gradientUnits=\"userSpaceOnUse\"\n x1={cx + R0 * Math.cos(-0.9 + push * 0.25)}\n y1={cy + R0 * Math.sin(-0.9 + push * 0.25)}\n x2={cx - R0 * Math.cos(-0.9 + push * 0.25)}\n y2={cy - R0 * Math.sin(-0.9 + push * 0.25)}\n >\n {BEAM.stops.map((col, k) => (\n <stop\n key={col}\n offset={k / (BEAM.stops.length - 1)}\n stopColor={col}\n />\n ))}\n </linearGradient>\n </defs>\n {list.map((ring, i) => (\n <Ring\n key={ring.label}\n cx={cx}\n cy={cy}\n r={radius(i)}\n sw={sw}\n p={progress(i)}\n color={paints[i]}\n lapColor={paints[i]}\n track={alpha(i === 0 ? BEAM.stops[2] : colors[i], c.track)}\n shadow={c.capShadow}\n uid={`${uid}r${i}`}\n u={u}\n />\n ))}\n {/* hit pulse just outside the outer ring */}\n {t >= HIT ? (\n <circle\n cx={cx}\n cy={cy}\n r={R0 + sw / 2 + 6 * u + pulse * 26 * u}\n fill=\"none\"\n stroke={accent}\n strokeWidth={Math.max(1, 1.5 * u)}\n opacity={(1 - pulse) * 0.45}\n />\n ) : null}\n {/* centre check */}\n {t >= HIT ? (\n <g\n transform={`translate(${cx} ${cy}) scale(${0.82 + check * 0.18})`}\n opacity={Math.min(1, check * 1.6)}\n >\n <circle r={badge} fill={`url(#${gradId})`} />\n <path\n d={`M ${-badge * 0.36} ${badge * 0.02} L ${-badge * 0.1} ${badge * 0.28} L ${badge * 0.38} ${-badge * 0.24}`}\n fill=\"none\"\n stroke=\"#FFFFFF\"\n strokeWidth={badge * 0.15}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n pathLength={1}\n strokeDasharray=\"1 1\"\n strokeDashoffset={1 - checkDraw}\n />\n </g>\n ) : null}\n </svg>\n </AbsoluteFill>\n\n {/* readouts */}\n <AbsoluteFill\n style={{\n transform: `translateX(${-push * 5 * u}px)`,\n fontFamily: sans,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: rowX,\n top: rowsTop - 58 * u,\n display: \"flex\",\n alignItems: \"center\",\n gap: 12 * u,\n opacity: row(0, -6),\n transform: `translateY(${(1 - row(0, -6)) * 10 * u}px)`,\n }}\n >\n <span\n style={{\n color: c.fg,\n fontWeight: 500,\n fontSize: 18 * u,\n letterSpacing: \"-0.01em\",\n }}\n >\n {title}\n </span>\n <span\n style={{\n width: 200 * u * row(0, -2),\n height: Math.max(1, u),\n background: c.hair,\n }}\n />\n </div>\n {list.map((ring, i) => {\n const p = progress(i);\n const v = ring.value * Math.min(1, p);\n const over = Math.round((p - 1) * 100);\n const overIn = interpolate(\n t,\n [HIT + 4 + i * 3, HIT + 16 + i * 3],\n [0, 1],\n {\n ...CLAMP,\n easing: EASE_OUT,\n },\n );\n const r = row(i + 1);\n return (\n <div\n key={ring.label}\n style={{\n position: \"absolute\",\n left: rowX,\n top: rowsTop + i * rowH,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 6 * u,\n overflow: \"hidden\",\n paddingBottom: 4 * u,\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n transform: `translateY(${(1 - r) * 120}%)`,\n }}\n >\n <span\n style={{\n width: 10 * u,\n height: 10 * u,\n borderRadius: \"50%\",\n background: swatches[i],\n }}\n />\n <span\n style={{\n color: c.muted,\n fontWeight: 400,\n fontSize: 17 * u,\n letterSpacing: \"-0.005em\",\n }}\n >\n {ring.label}\n </span>\n </div>\n <div\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n gap: 12 * u,\n transform: `translateY(${(1 - r) * 110}%)`,\n }}\n >\n <span\n style={{\n fontWeight: 400,\n fontSize: 64 * u,\n lineHeight: 1,\n letterSpacing: \"-0.045em\",\n fontVariantNumeric: \"tabular-nums\",\n color: c.fg,\n }}\n >\n {fmt(v)}\n {ring.unit ? (\n <span style={{ color: c.muted, fontSize: 30 * u }}>\n {ring.unit}\n </span>\n ) : null}\n </span>\n {over > 0 ? (\n <span\n style={{\n fontWeight: 400,\n fontSize: 16 * u,\n color: c.muted,\n fontVariantNumeric: \"tabular-nums\",\n opacity: overIn,\n transform: `translateY(${(1 - overIn) * 8 * u}px)`,\n }}\n >\n +{over}% of goal\n </span>\n ) : null}\n </div>\n </div>\n );\n })}\n </AbsoluteFill>\n\n <Grain opacity={c.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 title: {\n type: \"text-content\",\n default: \"This month\",\n description: \"Title\",\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\",\"title\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n title: \"This month\",\n speed: 1,\n};\n\ntype ActivityRingsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ActivityRingsBase>;\n\nconst ActivityRingsInner = forwardRef<\n HTMLDivElement,\n ActivityRingsElementProps & { 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 ?? \"<ActivityRings>\"}\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 <ActivityRingsBase\n {...(componentProps as unknown as ComponentProps<typeof ActivityRingsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ActivityRings = Interactive.withSchema({\n Component: ActivityRingsInner,\n componentName: \"<ActivityRings>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 90,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 90
}