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": "price-slate",
"title": "Price Slate",
"description": "A price reel spins to land on $0 with the old $29 struck through.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/price-slate/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/HankenGrotesk\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n interpolateColors,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"italic\", {\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\nexport interface PriceSlateProps {\n /** The new price, set huge. Digits roll in on reels. */\n price?: string;\n /** The old price, shown first, struck through, then set aside. */\n was?: string;\n /** Serif italic lead-in before the prices. */\n lead?: string;\n /** Small line under the price. */\n note?: string;\n /** Availability line at the foot of the slate. */\n availability?: string;\n /** Product name after the logo at the top; empty hides it. */\n product?: string;\n /** Brand at the top; \"remocn\" renders the real logo. */\n name?: string;\n /** Replaces the logo / name at the top. */\n logo?: React.ReactNode;\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\n// Hanken Grotesk 300 (fontTools, wght 300): tabular figures 0.56em, \"$\" 0.553,\n// \".\" and \",\" 0.24; cap height 0.697. Instrument Serif italic: F r o m.\nconst HANKEN: Record<string, number> = { $: 0.553, \".\": 0.24, \",\": 0.24 };\nconst DIGIT = 0.56;\nconst CAP = 0.697;\nconst TRACK = -0.02;\nconst SERIF: Record<string, number> = {\n F: 0.411,\n r: 0.368,\n o: 0.414,\n m: 0.745,\n \" \": 0.17,\n};\n\nconst isDigit = (ch: string) => ch >= \"0\" && ch <= \"9\";\nconst adv = (ch: string) => (isDigit(ch) ? DIGIT : (HANKEN[ch] ?? 0.58));\n\nfunction layoutPrice(s: string) {\n const glyphs: Array<{ ch: string; x: number; w: number }> = [];\n let x = 0;\n for (const ch of Array.from(s)) {\n glyphs.push({ ch, x, w: adv(ch) });\n x += adv(ch) + TRACK;\n }\n return { glyphs, width: Math.max(0, x - TRACK) };\n}\n\nconst serifWidth = (s: string) =>\n Array.from(s).reduce((w, ch) => w + (SERIF[ch] ?? 0.42), 0);\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_REEL = Easing.bezier(0.12, 0.6, 0.18, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\n// Beat sheet (30fps, speed 1):\n// 0–22 the old price reels in at hero size beside the serif lead-in\n// 22–34 a clean line strikes it through\n// 34–52 it steps aside: shrinks, greys out, slides left\n// 47–73 the new price reels spin into the hero slot (digits 3 frames apart)\n// 69–91 the halo gradient sweeps across it as the last reel lands\n// 71–99 note and availability rise in; poster holds to the end\nconst STRIKE_AT = 22;\nconst MOVE_AT = 34;\nconst MOVE_LEN = 18;\nconst REEL_AT = 47;\nconst REEL_LEN = 24;\n\n// gradients.sh \"halo\" (bg #030306): #fff4ec #ffb36b #e2457a #3d4dff.\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F5F4F1\",\n muted: \"#7C7B81\",\n hair: \"rgba(245,244,241,0.14)\",\n halo: [\"#FFF4EC\", \"#FFB36B\", \"#E2457A\", \"#3D4DFF\"],\n stops: [0, 0.3, 0.64, 1],\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#8A8883\",\n hair: \"rgba(18,18,20,0.12)\",\n halo: [\"#F08A2C\", \"#E2457A\", \"#9B47C9\", \"#3D4DFF\"],\n stops: [0, 0.34, 0.66, 1],\n },\n} as const;\n\n/** One reel position: spins `turns` digits and lands on `digit`. */\nfunction reel(\n t: number,\n start: number,\n len: number,\n digit: number,\n turns: number,\n) {\n const k = EASE_REEL(Math.max(0, Math.min(1, (t - start) / len)));\n return digit - turns * (1 - k);\n}\n\nexport function PriceSlate({\n price = \"$0\",\n was = \"$29\",\n lead = \"From\",\n note = \"per seat · billed yearly\",\n availability = \"Available today\",\n product = \"Pro\",\n name = \"remocn\",\n logo,\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: PriceSlateProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const p = THEMES[theme];\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n const newL = layoutPrice(price);\n const oldL = layoutPrice(was);\n const leadW = serifWidth(lead);\n\n // Final line: lead (S) · old price (S, struck) · new price (P), centred.\n const ratio = 0.4;\n const gapA = 0.26; // in S units, between lead and old price\n const gapB = 0.34; // in S units, between old price and new price\n const finalEm = (leadW + gapA + oldL.width + gapB) * ratio + newL.width;\n const P = Math.min(H * 0.4, (W * 0.78) / finalEm);\n const S = P * ratio;\n const baseline = H * 0.62;\n\n // Opening line: lead (S) · old price (P), centred.\n const openW = (leadW + gapA) * S + oldL.width * P;\n const finalW = finalEm * P;\n const leadX0 = (W - openW) / 2;\n const oldX0 = leadX0 + (leadW + gapA) * S;\n const leadX1 = (W - finalW) / 2;\n const oldX1 = leadX1 + (leadW + gapA) * S;\n const newX = oldX1 + (oldL.width + gapB) * S;\n\n const m = EASE_IO(Math.max(0, Math.min(1, (t - MOVE_AT) / MOVE_LEN)));\n const leadX = leadX0 + (leadX1 - leadX0) * m;\n const oldX = oldX0 + (oldX1 - oldX0) * m;\n const oldSize = P + (S - P) * m;\n const oldColor = interpolateColors(m, [0, 1], [p.fg, p.muted]);\n\n const leadIn = interpolate(t, [-6, 12], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const strike = interpolate(t, [STRIKE_AT, STRIKE_AT + 12], [0, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.6, 0, 0.25, 1),\n });\n // the halo sweeps in as the last reel lands\n const reels = newL.glyphs.filter((g) => isDigit(g.ch)).length;\n const landAt = REEL_AT + Math.max(0, reels - 1) * 3 + REEL_LEN + reels * 2;\n const sweep = interpolate(t, [landAt - 4, landAt + 18], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const rise = (a: number) =>\n interpolate(t, [a, a + 20], [0, 1], { ...CLAMP, easing: EASE_OUT });\n const drift = interpolate(t, [0, 130], [0, 1], CLAMP);\n\n /** Renders a price on reels; returns elements in user space. */\n const renderPrice = (\n L: ReturnType<typeof layoutPrice>,\n x0: number,\n size: number,\n start: number,\n len: number,\n turns: number,\n key: string,\n only: \"digits\" | \"marks\",\n ) => {\n const step = (CAP + 0.26) * size;\n let di = 0;\n return L.glyphs.map((g, i) => {\n const gx = x0 + (g.x + g.w / 2) * size;\n if (!isDigit(g.ch)) {\n if (only === \"digits\") return null;\n // the old price's marks are there from the first frame; the new\n // price's wait for the old one to clear the slot\n const lag = key === \"o\" ? -8 : 0;\n const k = interpolate(\n t,\n [start + lag + i * 2, start + lag + 12 + i * 2],\n [0, 1],\n {\n ...CLAMP,\n easing: EASE_OUT,\n },\n );\n return (\n <text\n key={`${key}${i}`}\n x={gx}\n y={baseline + (1 - k) * 0.35 * size}\n opacity={k}\n >\n {g.ch}\n </text>\n );\n }\n const d = Number(g.ch);\n const s0 = start + di * 3;\n const extra = turns + di * 2;\n di++;\n if (only === \"marks\") return null;\n const pos = reel(t, s0, len + di * 2, d, extra);\n const v = Math.abs(\n reel(t + 0.5, s0, len + di * 2, d, extra) -\n reel(t - 0.5, s0, len + di * 2, d, extra),\n );\n const base = Math.floor(pos);\n const f = pos - base;\n const show = interpolate(t, [s0 - 2, s0 + 6], [0, 1], CLAMP);\n const sd = Math.min(0.06, v * 0.05) * size;\n const digit = (n: number) => ((n % 10) + 10) % 10;\n return (\n <g\n key={`${key}${i}`}\n opacity={show}\n transform={`translate(0 ${-f * step})`}\n >\n <g filter={sd > 0.05 ? `url(#${uid}b${key}${i})` : undefined}>\n <text x={gx} y={baseline}>\n {digit(base)}\n </text>\n {f > 0.001 ? (\n <text x={gx} y={baseline + step}>\n {digit(base + 1)}\n </text>\n ) : null}\n </g>\n <filter\n id={`${uid}b${key}${i}`}\n filterUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <feGaussianBlur stdDeviation={`0 ${sd.toFixed(2)}`} />\n </filter>\n </g>\n );\n });\n };\n\n const newCap = CAP * P;\n const oldCap = CAP * oldSize;\n const strikeY = baseline - oldCap * 0.44;\n const strikeX0 = oldX - 0.05 * oldSize;\n const strikeX1 = oldX + (oldL.width + 0.05) * oldSize;\n const strikeT = Math.max(1.5 * u, 0.034 * oldSize);\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <svg\n width={W}\n height={H}\n viewBox={`0 0 ${W} ${H}`}\n style={{ position: \"absolute\", inset: 0 }}\n role=\"img\"\n aria-label={`${lead} ${price}, was ${was}`}\n >\n <defs>\n <linearGradient id={`${uid}feather`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={0} />\n <stop offset=\"0.14\" stopColor=\"#fff\" />\n <stop offset=\"0.86\" stopColor=\"#fff\" />\n <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0} />\n </linearGradient>\n {/* reel windows: one for the old price (it shrinks), one for the new */}\n <mask\n id={`${uid}winOld`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <rect\n x={0}\n y={baseline - oldCap - 0.14 * oldSize}\n width={W}\n height={oldCap + 0.28 * oldSize}\n fill={`url(#${uid}feather)`}\n />\n </mask>\n <mask\n id={`${uid}winNew`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <rect\n x={0}\n y={baseline - newCap - 0.14 * P}\n width={W}\n height={newCap + 0.28 * P}\n fill={`url(#${uid}feather)`}\n />\n </mask>\n <linearGradient\n id={`${uid}halo`}\n gradientUnits=\"userSpaceOnUse\"\n x1={newX - newL.width * P * (0.1 - 0.12 * drift)}\n y1={baseline - newCap}\n x2={newX + newL.width * P * (1.05 + 0.1 * drift)}\n y2={baseline}\n >\n {p.halo.map((c, i) => (\n <stop key={c} offset={p.stops[i]} stopColor={c} />\n ))}\n </linearGradient>\n {/* the gradient sweeps across the landed price, left to right */}\n <linearGradient\n id={`${uid}wipe`}\n gradientUnits=\"userSpaceOnUse\"\n x1={newX - 0.4 * P + sweep * (newL.width * P + 0.8 * P)}\n y1={0}\n x2={newX + sweep * (newL.width * P + 0.8 * P)}\n y2={0}\n >\n <stop offset=\"0\" stopColor=\"#fff\" />\n <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0} />\n </linearGradient>\n <mask\n id={`${uid}sweep`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <rect width={W} height={H} fill={`url(#${uid}wipe)`} />\n </mask>\n <linearGradient\n id={`${uid}wipeInv`}\n gradientUnits=\"userSpaceOnUse\"\n x1={newX - 0.4 * P + sweep * (newL.width * P + 0.8 * P)}\n y1={0}\n x2={newX + sweep * (newL.width * P + 0.8 * P)}\n y2={0}\n >\n <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={0} />\n <stop offset=\"1\" stopColor=\"#fff\" />\n </linearGradient>\n <mask\n id={`${uid}ink`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <rect width={W} height={H} fill={`url(#${uid}wipeInv)`} />\n </mask>\n </defs>\n\n {/* lead-in */}\n <text\n x={leadX}\n y={baseline}\n fontFamily={serif}\n fontStyle=\"italic\"\n fontWeight={400}\n fontSize={S}\n fill={p.fg}\n opacity={leadIn}\n transform={`translate(0 ${(1 - leadIn) * 0.2 * S})`}\n >\n {lead}\n </text>\n\n {/* old price, then its strike */}\n <g\n fontFamily={sans}\n fontWeight={300}\n fontSize={oldSize}\n textAnchor=\"middle\"\n fill={oldColor}\n style={{ fontVariantNumeric: \"tabular-nums\" }}\n >\n <g mask={`url(#${uid}winOld)`}>\n {renderPrice(oldL, oldX, oldSize, 0, 20, 7, \"o\", \"digits\")}\n </g>\n {renderPrice(oldL, oldX, oldSize, 0, 20, 7, \"o\", \"marks\")}\n </g>\n <line\n x1={strikeX0}\n x2={strikeX0 + (strikeX1 - strikeX0) * strike}\n y1={strikeY}\n y2={strikeY}\n stroke={interpolateColors(m, [0, 1], [p.fg, p.muted])}\n strokeWidth={strikeT}\n strokeLinecap=\"round\"\n opacity={strike > 0 ? 1 : 0}\n />\n\n {/* new price: ink while it rolls, halo gradient once it lands */}\n <g\n fontFamily={sans}\n fontWeight={300}\n fontSize={P}\n textAnchor=\"middle\"\n fill={p.fg}\n style={{ fontVariantNumeric: \"tabular-nums\" }}\n mask={sweep > 0 ? `url(#${uid}ink)` : undefined}\n >\n <g mask={`url(#${uid}winNew)`}>\n {renderPrice(newL, newX, P, REEL_AT, REEL_LEN, 13, \"n\", \"digits\")}\n </g>\n {renderPrice(newL, newX, P, REEL_AT, REEL_LEN, 13, \"n\", \"marks\")}\n </g>\n <g\n mask={`url(#${uid}sweep)`}\n fontFamily={sans}\n fontWeight={300}\n fontSize={P}\n textAnchor=\"middle\"\n fill={`url(#${uid}halo)`}\n style={{ fontVariantNumeric: \"tabular-nums\" }}\n opacity={sweep > 0 ? 1 : 0}\n >\n {newL.glyphs.map((g) => (\n <text\n key={`h${g.x}${g.ch}`}\n x={newX + (g.x + g.w / 2) * P}\n y={baseline}\n >\n {g.ch}\n </text>\n ))}\n </g>\n </svg>\n\n {/* brand + product, top */}\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: H * 0.115,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"baseline\",\n gap: 12 * u,\n opacity: rise(-8),\n transform: `translateY(${(1 - rise(-8)) * 10 * u}px)`,\n lineHeight: 1,\n }}\n >\n {logo ??\n (name.trim().toLowerCase() === \"remocn\" ? (\n <RemocnLogo fontSize={34 * u} color={p.fg} />\n ) : (\n <span\n style={{\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 34 * u,\n letterSpacing: \"-0.02em\",\n color: p.fg,\n }}\n >\n {name}\n </span>\n ))}\n {product ? (\n <span\n style={{\n fontFamily: sans,\n fontWeight: 300,\n fontSize: 34 * u,\n letterSpacing: \"-0.02em\",\n color: p.fg,\n }}\n >\n {product}\n </span>\n ) : null}\n </div>\n\n {/* note under the price */}\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: baseline + 0.2 * P,\n textAlign: \"center\",\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 30 * u,\n letterSpacing: \"-0.01em\",\n color: p.muted,\n opacity: rise(landAt - 2),\n transform: `translateY(${(1 - rise(landAt - 2)) * 12 * u}px)`,\n lineHeight: 1,\n }}\n >\n {note}\n </div>\n\n {/* availability */}\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: H * 0.855,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: 12 * u,\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 24 * u,\n letterSpacing: \"-0.005em\",\n color: p.fg,\n opacity: rise(landAt + 6),\n transform: `translateY(${(1 - rise(landAt + 6)) * 12 * u}px)`,\n lineHeight: 1,\n }}\n >\n <div\n style={{\n width: 8 * u,\n height: 8 * u,\n borderRadius: 99,\n background: accent,\n }}\n />\n {availability}\n </div>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/price-slate.tsx"
}
],
"type": "registry:component"
}