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": "card-fan",
"title": "Card Fan",
"description": "Colourful format cards fan out of a stack with a \"Your top formats\" caption.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/card-fan/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont } from \"@remotion/google-fonts/Onest\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n spring,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst onest = loadFont(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst serif = loadSerif(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\nconst mono = loadMono(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\ntype Glyph = \"launch\" | \"list\" | \"play\" | \"cursor\" | \"spark\";\n\nexport interface FanCard {\n label: string;\n color: string;\n meta?: string;\n glyph?: Glyph;\n}\n\nexport interface CardFanProps {\n title?: string;\n accentWord?: number;\n cards?: FanCard[];\n pick?: number;\n caption?: string;\n theme?: \"dark\" | \"light\";\n ink?: string;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nconst DEFAULT_CARDS: FanCard[] = [\n {\n label: \"Launch\",\n color: \"#e0583f\",\n meta: \"24 scenes · 1:12\",\n glyph: \"launch\",\n },\n {\n label: \"Changelog\",\n color: \"#3a9e7c\",\n meta: \"18 scenes · 0:48\",\n glyph: \"list\",\n },\n {\n label: \"Teaser\",\n color: \"#4a58c4\",\n meta: \"12 scenes · 0:21\",\n glyph: \"play\",\n },\n {\n label: \"Demo\",\n color: \"#34363d\",\n meta: \"31 scenes · 2:05\",\n glyph: \"cursor\",\n },\n];\n\nconst THEMES = {\n dark: {\n ink: \"#eef6f4\",\n sub: \"rgba(238,246,244,0.6)\",\n card: \"#141618\",\n cardInk: \"#f1f4f3\",\n cardSub: \"rgba(241,244,243,0.52)\",\n ring: \"inset 0 0 0 1px rgba(255,255,255,0.07), inset 0 1px 0 rgba(255,255,255,0.08)\",\n ground: \"riptide\" as GshPresetId | undefined,\n groundParams: undefined as Partial<GradientParams> | undefined,\n shadowRgb: \"0,8,8\",\n shadowK: 1,\n },\n light: {\n ink: \"#16171c\",\n sub: \"rgba(22,23,28,0.56)\",\n card: \"#fcfbf9\",\n cardInk: \"#16171c\",\n cardSub: \"rgba(22,23,28,0.5)\",\n ring: \"inset 0 0 0 1px rgba(0,0,0,0.06)\",\n ground: \"paper-crease\" as GshPresetId | undefined,\n groundParams: undefined as Partial<GradientParams> | undefined,\n shadowRgb: \"26,30,60\",\n shadowK: 0.5,\n },\n};\n\nconst BEATS = [\n { id: \"title\", at: 0 },\n { id: \"drop\", at: 4 },\n { id: \"fan\", at: 18 },\n { id: \"pick\", at: 60 },\n { id: \"caption\", at: 72 },\n { id: \"end\", at: 132 },\n] as const;\nconst beat = (id: (typeof BEATS)[number][\"id\"]) =>\n BEATS.find((b) => b.id === id)?.at ?? 0;\n\nconst EASE_ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst EASE_CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst SPRING_CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst SPRING_HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst SPRING_MORPH = { damping: 200 };\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction shade(color: string, pct: number, to: string) {\n return `color-mix(in oklab, ${color} ${100 - pct}%, ${to})`;\n}\n\nfunction GlyphIcon({ glyph, size }: { glyph: Glyph; size: number }) {\n const paths: Record<Glyph, string> = {\n launch: \"M7 17 17 7M9 7h8v8\",\n list: \"M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01\",\n play: \"M8 5.5v13l10.5-6.5z\",\n cursor: \"M5.5 3.5 19 10l-6 2-2 6z\",\n spark: \"M12 3v5M12 16v5M3 12h5M16 12h5\",\n };\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n >\n <path d={paths[glyph]} vectorEffect=\"non-scaling-stroke\" />\n </svg>\n );\n}\n\nexport function CardFan({\n title = \"Your top formats\",\n accentWord = 2,\n cards = DEFAULT_CARDS,\n pick = 0,\n caption = \"Launch films are 41% of this month’s renders\",\n theme = \"dark\",\n ink,\n ground,\n groundParams,\n}: CardFanProps) {\n const frame = useCurrentFrame();\n const { width: W, height: H, fps } = useVideoConfig();\n const t = THEMES[theme];\n const light = theme === \"light\";\n const fg = ink ?? t.ink;\n const preset = ground ?? (groundParams ? undefined : t.ground);\n const gParams = groundParams ?? t.groundParams;\n const portrait = H > W;\n const N = Math.max(2, Math.min(6, cards.length));\n const list = cards.slice(0, N);\n const pickIdx = Math.min(Math.max(0, pick), N - 1);\n\n const cx = W / 2;\n const cardW = portrait ? W * 0.44 : W * 0.2;\n const pad = cardW * 0.045;\n const coverS = cardW - pad * 2;\n const cardH = pad + coverS + cardW * 0.31;\n const radius = cardW * 0.075;\n const cy = portrait ? H * 0.53 : H * 0.575;\n const spread = portrait ? cardW * 0.3 : cardW * 0.6;\n const titleSize = portrait ? W * 0.092 : W * 0.052;\n const titleY = portrait ? H * 0.15 : H * 0.14;\n const capSize = portrait ? W * 0.04 : H * 0.034;\n const capY = portrait ? H * 0.865 : H * 0.92;\n const pull = portrait ? 0.8 : 0.45;\n\n const drop = spring({\n frame: frame - beat(\"drop\"),\n fps,\n config: SPRING_HEAVY,\n });\n const lift = spring({\n frame: frame - beat(\"pick\"),\n fps,\n config: SPRING_CARD,\n });\n const liftSettle = spring({\n frame: frame - beat(\"pick\"),\n fps,\n config: SPRING_MORPH,\n });\n const push = interpolate(frame, [0, beat(\"end\")], [1, 1.035], {\n ...CLAMP,\n easing: EASE_CAMERA,\n });\n const sway = Math.sin(frame / 24) * 2;\n\n const titleWords = title.split(\" \");\n const capWords = caption.split(\" \");\n\n const cardState = (j: number) => {\n const m = N - 1 - j;\n const open = spring({\n frame: frame - (beat(\"fan\") + m * 3),\n fps,\n config: SPRING_CARD,\n });\n const isFront = j === N - 1;\n const openX = cx + (j - (N - 1) / 2) * spread;\n const openY = cy + (portrait ? (j - (N - 1) / 2) * cardH * 0.1 : 0);\n const stackX = cx + m * 4;\n const stackY = cy + m * 3;\n let x = stackX + (openX - stackX) * open;\n let y = stackY + (openY - stackY) * open;\n let rz = (-3 - m * 1.5) * (1 - open) + (-9 + j * 2.2) * open;\n let ry = 3 * (1 - open) + (14 + sway) * open;\n let rx = 5 * open;\n let z = 0;\n let scale = 1;\n let blur = 0;\n let dim = 1;\n const fall = 1 - drop;\n y += fall * H * 0.7;\n rz += fall * 10;\n if (j === pickIdx) {\n const tx = x + (cx - x) * pull;\n x += (tx - x) * lift;\n y += -cardH * (portrait ? 0.1 : 0.12) * lift;\n rz += (-2 - rz) * liftSettle;\n ry += (4 - ry) * liftSettle;\n rx *= 1 - liftSettle;\n z = 140 * lift;\n scale = 1 + 0.1 * lift;\n } else {\n const side = j < pickIdx ? -1 : 1;\n x += side * cardW * (portrait ? 0.08 : 0.16) * lift;\n y += cardH * 0.06 * lift;\n z = -60 * lift;\n blur = 3 * Math.min(1, lift);\n dim = 1 - 0.3 * Math.min(1, lift);\n }\n const hidden = !isFront && frame < beat(\"drop\") + 6;\n return { x, y, rz, ry, rx, z, scale, blur, dim, hidden };\n };\n\n const order = list\n .map((_, j) => j)\n .sort((a, b) =>\n a === pickIdx && lift > 0.3\n ? 1\n : b === pickIdx && lift > 0.3\n ? -1\n : a - b,\n );\n\n const k = t.shadowK;\n const shadow = `0 1px 2px rgba(${t.shadowRgb},${0.24 * k}), 0 ${cardH * 0.05}px ${cardH * 0.12}px rgba(${t.shadowRgb},${0.26 * k}), 0 ${cardH * 0.16}px ${cardH * 0.4}px rgba(${t.shadowRgb},${0.32 * k})`;\n\n return (\n <AbsoluteFill style={{ overflow: \"hidden\" }}>\n <GshGround\n preset={preset}\n params={gParams}\n timeOffset={light ? 2.2 : 3}\n timeScale={0.6}\n />\n <AbsoluteFill style={{ transform: `scale(${push})` }}>\n <AbsoluteFill\n style={{\n perspective: portrait ? 2200 : 1400,\n perspectiveOrigin: `50% ${(cy / H) * 100}%`,\n }}\n >\n {order.map((j) => {\n const c = list[j] as FanCard;\n const s = cardState(j);\n if (s.hidden) return null;\n return (\n <div\n key={`card-${c.label}-${j}`}\n style={{\n position: \"absolute\",\n left: s.x - cardW / 2,\n top: s.y - cardH / 2,\n width: cardW,\n height: cardH,\n borderRadius: radius,\n transform: `translateZ(${s.z}px) rotateX(${s.rx}deg) rotateY(${s.ry}deg) rotateZ(${s.rz}deg) scale(${s.scale})`,\n filter:\n s.blur > 0.01\n ? `blur(${s.blur}px) brightness(${s.dim})`\n : undefined,\n boxShadow: shadow,\n backgroundColor: t.card,\n fontFamily: onest.fontFamily,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: pad,\n top: pad,\n width: coverS,\n height: coverS,\n borderRadius: radius - pad,\n backgroundImage: `linear-gradient(160deg, ${shade(c.color, 18, \"#fff\")} 0%, ${c.color} 46%, ${shade(c.color, 38, \"#000\")} 100%)`,\n boxShadow: \"inset 0 0 0 1px rgba(255,255,255,0.12)\",\n color: \"rgba(255,255,255,0.92)\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: coverS * 0.09,\n bottom: coverS * 0.09,\n }}\n >\n <GlyphIcon\n glyph={c.glyph ?? \"spark\"}\n size={coverS * 0.24}\n />\n </div>\n </div>\n <div\n style={{\n position: \"absolute\",\n left: pad + cardW * 0.02,\n right: pad,\n top: pad + coverS + cardW * 0.06,\n color: t.cardInk,\n }}\n >\n <div\n style={{\n fontSize: cardW * 0.1,\n fontWeight: 400,\n letterSpacing: \"-0.025em\",\n lineHeight: 1.1,\n whiteSpace: \"nowrap\",\n }}\n >\n {c.label}\n </div>\n {c.meta ? (\n <div\n style={{\n marginTop: cardW * 0.025,\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: Math.max(cardW * 0.066, H * 0.022),\n letterSpacing: \"-0.01em\",\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n color: t.cardSub,\n }}\n >\n {c.meta}\n </div>\n ) : null}\n </div>\n </div>\n );\n })}\n </AbsoluteFill>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n width: W,\n top: titleY - titleSize * 0.55,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"baseline\",\n columnGap: \"0.24em\",\n fontFamily: onest.fontFamily,\n fontWeight: 300,\n fontSize: titleSize,\n lineHeight: 1.1,\n letterSpacing: \"-0.04em\",\n color: fg,\n }}\n >\n {titleWords.map((word, i) => {\n const s = beat(\"title\") + i * 3;\n const p = interpolate(frame, [s, s + 14], [0, 1], {\n ...CLAMP,\n easing: EASE_ENTER,\n });\n const accent = i === accentWord;\n return (\n <span\n key={`${word}-${i}`}\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n padding: \"0.04em 0.08em 0.18em\",\n margin: \"-0.04em -0.08em -0.18em\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `translateY(${(1 - p) * 120}%)`,\n fontFamily: accent ? serif.fontFamily : undefined,\n fontStyle: accent ? \"italic\" : undefined,\n fontWeight: 400,\n fontSize: accent ? \"1.12em\" : undefined,\n letterSpacing: accent ? \"-0.02em\" : undefined,\n lineHeight: 1,\n }}\n >\n {word}\n </span>\n </span>\n );\n })}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: W * 0.08,\n width: W * 0.84,\n top: capY - capSize * 0.6,\n display: \"flex\",\n flexWrap: \"wrap\",\n justifyContent: \"center\",\n columnGap: \"0.26em\",\n fontFamily: onest.fontFamily,\n fontWeight: 300,\n fontSize: capSize,\n letterSpacing: \"-0.01em\",\n fontVariantNumeric: \"tabular-nums\",\n color: t.sub,\n }}\n >\n {capWords.map((word, i) => {\n const s = beat(\"caption\") + i * 2;\n const p = interpolate(frame, [s, s + 12], [0, 1], {\n ...CLAMP,\n easing: EASE_ENTER,\n });\n return (\n <span\n key={`${word}-${i}`}\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n padding: \"0.04em 0.04em 0.18em\",\n margin: \"-0.04em -0.04em -0.18em\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `translateY(${(1 - p) * 120}%)`,\n color: /\\d/.test(word) ? fg : undefined,\n }}\n >\n {word}\n </span>\n </span>\n );\n })}\n </div>\n </AbsoluteFill>\n </AbsoluteFill>\n );\n}\n\nexport default CardFan;\n",
"type": "registry:component",
"target": "components/remocn/card-fan.tsx"
}
],
"type": "registry:component"
}