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": "rim-draw-card",
"title": "Rim Draw Card",
"description": "A settings card gets its rim drawn in light, revealing a brand-voice toggle and text field.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/rim-draw-card/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadHanken } from \"@remotion/google-fonts/HankenGrotesk\";\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 hanken = loadHanken(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst mono = loadMono(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst DRAW = Easing.bezier(0.22, 1, 0.36, 1);\nconst MOVE = Easing.bezier(0.65, 0, 0.35, 1);\nconst SWAY = Easing.bezier(0.45, 0, 0.55, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst PRESS = { mass: 0.5, damping: 14, stiffness: 260 };\n\nconst B = {\n words: -8,\n stroke: 18,\n strokeLen: 30,\n erase: 20,\n slide: 18,\n chip: 24,\n tail: 32,\n tailLen: 16,\n body: 36,\n pan: 36,\n title: 42,\n field: 48,\n footer: 54,\n type: 60,\n chips: 66,\n preview: 78,\n press: 96,\n saved: 99,\n end: 138,\n};\n\nexport const RIM_DRAW_CARD_DURATION = B.end;\n\nconst ramp = (f: number, start: number, dur: number, easing = ENTER) =>\n interpolate(f, [start, start + dur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nexport interface RimDrawCardProps {\n theme?: \"dark\" | \"light\";\n accent?: string;\n primary?: string;\n line?: string;\n command?: string;\n title?: string;\n subtitle?: string;\n label?: string;\n instructions?: string;\n action?: string;\n limit?: number;\n done?: string;\n uses?: string[];\n preview?: string;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nfunction Icon({\n d,\n size,\n color,\n width = 1.5,\n}: {\n d: string;\n size: number;\n color: string;\n width?: number;\n}) {\n return (\n <svg viewBox=\"0 0 24 24\" width={size} height={size} aria-hidden>\n <path\n d={d}\n fill=\"none\"\n stroke={color}\n strokeWidth={width}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nconst CHECK = \"m5 12.5 4.5 4.5L19 7.5\";\n\nexport function RimDrawCard({\n theme = \"dark\",\n accent,\n primary,\n line = \"Just tell it once.\",\n command = \"/brand-voice\",\n title = \"Brand voice\",\n subtitle = \"Used every time you write launch copy.\",\n label = \"Instructions\",\n instructions = \"Short, calm sentences. Name the feature first, then what it saves you.\",\n action = \"Save skill\",\n limit = 600,\n done = \"Saved\",\n uses = [\"Launch posts\", \"Changelog\", \"Release emails\"],\n preview = \"Scenes now render three times faster. Ship the reel tonight.\",\n ground,\n groundParams,\n}: RimDrawCardProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const dark = theme === \"dark\";\n const portrait = height > width * 1.2;\n const stageW = portrait ? 1080 : 1280;\n const stageH = portrait ? 1920 : 720;\n const sc = width / stageW;\n\n const acc = accent ?? (dark ? \"#9cc2ff\" : \"#2a5cff\");\n const prim = primary ?? (dark ? \"#3B5BFD\" : \"#1f4fff\");\n const ink = dark ? \"#f2f6ff\" : \"#0f1320\";\n const cardInk = dark ? \"#eef2fa\" : \"#121624\";\n const muted = dark ? \"rgba(222,230,246,0.58)\" : \"rgba(18,22,36,0.56)\";\n const hair = dark ? \"rgba(255,255,255,0.09)\" : \"rgba(16,22,48,0.11)\";\n\n const cw = portrait ? 880 : 680;\n const u = portrait ? 1.76 : 1.18;\n const ch = (portrait ? 622 : 368) * u;\n const r = 16 * u;\n const pad = 24 * u;\n const lead = stageW * 0.75;\n const fontSize = portrait ? 92 : 50;\n\n const len1 = cw + lead - r;\n const total = len1 + 2 * Math.PI * r + 2 * (ch - 2 * r) + (cw - 2 * r);\n const tailEnd = lead + r;\n const pathD = `M ${cw + lead} 0 L ${r} 0 A ${r} ${r} 0 0 0 0 ${r} L 0 ${ch - r} A ${r} ${r} 0 0 0 ${r} ${ch} L ${cw - r} ${ch} A ${r} ${r} 0 0 0 ${cw} ${ch - r} L ${cw} ${r} A ${r} ${r} 0 0 0 ${cw - r} 0`;\n\n const head = ramp(frame, B.stroke, B.strokeLen, DRAW) * total;\n const tail = ramp(frame, B.tail, B.tailLen, MOVE) * tailEnd;\n const drawn = ramp(frame, B.stroke + B.strokeLen - 6, 6, MOVE);\n const settle = ramp(frame, B.body + 6, 24, MOVE);\n const visible = Math.max(0, head - tail);\n const hotLen = Math.min(visible, 90 * u);\n\n const bodyIn = ramp(frame, B.body, 12, DRAW);\n const chipIn = spring({ frame: frame - B.chip, fps, config: CHIP });\n const chipHot = ramp(frame, B.chip, 6) * (1 - 0.7 * bodyIn);\n\n const pan = spring({ frame: frame - B.pan, fps, config: HEAVY });\n const slide = spring({ frame: frame - B.slide, fps, config: HEAVY });\n const offX = portrait ? 0 : mix(300, 0, pan);\n const offY = portrait ? mix(300, 0, pan) : 0;\n const lineX = portrait ? 0 : mix(0, -330, slide);\n const lineY = portrait ? mix(0, -560, slide) : 0;\n\n const brighten = ramp(frame, B.body - 4, 24, SWAY);\n const push = 1 + 0.035 * ramp(frame, B.pan, B.end - B.pan, SWAY);\n\n const typed = Math.round(\n interpolate(\n frame,\n [B.type, B.type + instructions.length / 2.2],\n [0, instructions.length],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n ),\n );\n const caret =\n frame >= B.field + 6 &&\n frame < B.press &&\n (typed < instructions.length || Math.floor(frame / 8) % 2 === 0);\n const focus = ramp(frame, B.type - 6, 8) * (1 - ramp(frame, B.press, 8));\n const press =\n spring({ frame: frame - B.press, fps, config: PRESS }) -\n spring({ frame: frame - B.press - 4, fps, config: PRESS });\n const savedIn = spring({ frame: frame - B.saved, fps, config: CHIP });\n const savedOn = frame >= B.saved;\n\n const item = (start: number) => {\n const p = ramp(frame, start, 12);\n return {\n opacity: p,\n transform: `translateY(${mix(10 * u, 0, p)}px)`,\n filter: p < 1 ? `blur(${(1 - p) * 4}px)` : undefined,\n };\n };\n\n const letters = Array.from(line);\n const n = letters.length;\n\n const resolvedGround: GshPresetId =\n ground ?? (dark ? \"film-blue\" : \"paper-crease\");\n\n const surface = dark\n ? \"linear-gradient(180deg, #131722 0%, #0d1018 100%)\"\n : \"#ffffff\";\n\n return (\n <AbsoluteFill style={{ fontFamily: hanken.fontFamily, overflow: \"hidden\" }}>\n <GshGround\n preset={resolvedGround}\n params={groundParams}\n timeOffset={5}\n timeScale={0.55}\n />\n <AbsoluteFill\n style={{\n background: dark ? \"#02050c\" : \"#f4f3f0\",\n opacity: mix(dark ? 0.58 : 0.55, dark ? 0.12 : 0.3, brighten),\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: stageW,\n height: stageH,\n transform: `scale(${sc})`,\n transformOrigin: \"0 0\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `scale(${push})`,\n transformOrigin: \"50% 50%\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n transform: `translate(-50%, -50%) translate(${lineX}px, ${lineY}px)`,\n display: \"flex\",\n whiteSpace: \"pre\",\n fontSize,\n fontWeight: 300,\n letterSpacing: \"-0.035em\",\n lineHeight: 1.1,\n color: ink,\n }}\n >\n {letters.map((ch_, i) => {\n const rise = ramp(frame, B.words + Math.floor(i / 3), 14);\n const k = n - 1 - i;\n const gone = ramp(frame, B.erase + k * 0.72, 7, MOVE);\n return (\n <span\n key={`${ch_}-${i.toString()}`}\n style={{\n display: \"inline-block\",\n opacity: rise * (1 - gone),\n transform: `translateY(${mix(0.5, 0, rise)}em) translateX(${gone * 0.18}em)`,\n filter:\n rise < 1 || gone > 0\n ? `blur(${(1 - rise) * 6 + gone * 10}px)`\n : undefined,\n }}\n >\n {ch_}\n </span>\n );\n })}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: stageW / 2 - cw / 2 + offX,\n top: stageH / 2 - ch / 2 + offY,\n width: cw,\n height: ch,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: r,\n background: surface,\n boxShadow: dark\n ? `0 0 0 1px rgba(255,255,255,0.08), 0 ${28 * u}px ${70 * u}px -${10 * u}px rgba(0,2,10,0.6)`\n : `0 0 0 1px rgba(16,22,48,0.07), 0 1px 3px rgba(16,22,48,0.06), 0 ${26 * u}px ${60 * u}px -${14 * u}px rgba(16,22,48,0.22)`,\n opacity: bodyIn,\n transform: `scale(${mix(0.985, 1, bodyIn)})`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n padding: pad,\n display: \"flex\",\n flexDirection: \"column\",\n color: cardInk,\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n height: 30 * u,\n padding: `0 ${10 * u}px`,\n borderRadius: 7 * u,\n fontFamily: mono.fontFamily,\n fontSize: 15 * u,\n color: dark\n ? `color-mix(in oklab, ${acc} 80%, white)`\n : acc,\n background: `color-mix(in oklab, ${acc} ${Math.round((dark ? 12 : 9) + 10 * chipHot)}%, transparent)`,\n opacity: ramp(frame, B.chip, 4),\n transform: `scale(${mix(0.7, 1, chipIn)})`,\n transformOrigin: \"0% 50%\",\n }}\n >\n {command}\n </div>\n </div>\n\n <div\n style={{\n ...item(B.title),\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n marginTop: 22 * u,\n }}\n >\n <div\n style={{\n fontSize: 30 * u,\n letterSpacing: \"-0.025em\",\n lineHeight: 1.15,\n }}\n >\n {title}\n </div>\n </div>\n <div\n style={{\n ...item(B.title + 3),\n fontSize: 18 * u,\n color: muted,\n marginTop: 6 * u,\n textWrap: \"pretty\",\n }}\n >\n {subtitle}\n </div>\n\n <div\n style={{\n ...item(B.field),\n fontSize: 16 * u,\n color: muted,\n marginTop: 22 * u,\n }}\n >\n {label}\n </div>\n <div\n style={{\n ...item(B.field + 2),\n marginTop: 8 * u,\n position: \"relative\",\n height: (portrait ? 112 : 96) * u,\n borderRadius: 10 * u,\n border: `1px solid ${focus > 0 ? `color-mix(in oklab, ${acc} ${Math.round(focus * 60)}%, ${hair})` : hair}`,\n boxShadow: `0 0 0 ${3 * u * focus}px color-mix(in oklab, ${acc} ${Math.round(focus * 16)}%, transparent)`,\n background: dark ? \"rgba(255,255,255,0.035)\" : \"#fbfcff\",\n padding: `${12 * u}px ${14 * u}px`,\n fontSize: 18 * u,\n lineHeight: 1.45,\n color: typed > 0 ? cardInk : muted,\n }}\n >\n {typed > 0\n ? instructions.slice(0, typed)\n : \"Describe how this skill should write\"}\n <span\n style={{\n display: \"inline-block\",\n width: 2 * u,\n height: 20 * u,\n marginLeft: 2 * u,\n verticalAlign: \"-0.18em\",\n background: acc,\n opacity: caret ? 1 : 0,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n right: 12 * u,\n bottom: 9 * u,\n fontFamily: mono.fontFamily,\n fontSize: 14 * u,\n lineHeight: 1,\n color: muted,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {`${typed} / ${limit}`}\n </div>\n </div>\n\n {portrait ? (\n <>\n <div\n style={{\n ...item(B.chips - 4),\n fontSize: 16 * u,\n color: muted,\n marginTop: 24 * u,\n }}\n >\n Use it for\n </div>\n <div\n style={{\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: 8 * u,\n marginTop: 10 * u,\n }}\n >\n {uses.map((c, i) => {\n const s = spring({\n frame: frame - B.chips - i * 3,\n fps,\n config: CHIP,\n });\n return (\n <div\n key={c}\n style={{\n padding: `${7 * u}px ${12 * u}px`,\n borderRadius: 99,\n border: `1px solid ${hair}`,\n background: dark\n ? \"rgba(255,255,255,0.04)\"\n : \"#f6f7fb\",\n fontSize: 16 * u,\n opacity: ramp(frame, B.chips + i * 3, 4),\n transform: `scale(${mix(0.6, 1, s)})`,\n }}\n >\n {c}\n </div>\n );\n })}\n </div>\n <div\n style={{\n ...item(B.preview),\n fontSize: 16 * u,\n color: muted,\n marginTop: 24 * u,\n }}\n >\n Preview\n </div>\n <div\n style={{\n ...item(B.preview + 3),\n marginTop: 10 * u,\n display: \"flex\",\n gap: 12 * u,\n padding: `${14 * u}px ${16 * u}px`,\n borderRadius: 10 * u,\n background: `color-mix(in oklab, ${acc} ${dark ? 9 : 7}%, transparent)`,\n fontSize: 18 * u,\n lineHeight: 1.45,\n }}\n >\n <div\n style={{\n width: 3 * u,\n borderRadius: 2 * u,\n background: acc,\n flexShrink: 0,\n }}\n />\n {preview}\n </div>\n </>\n ) : null}\n\n <div\n style={{\n ...item(B.footer),\n marginTop: \"auto\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-end\",\n fontSize: 17 * u,\n }}\n >\n <div\n style={{ display: \"flex\", alignItems: \"center\", gap: 10 * u }}\n >\n <div\n style={{\n padding: `${8 * u}px ${12 * u}px`,\n color: muted,\n }}\n >\n Cancel\n </div>\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6 * u,\n padding: `${8 * u}px ${16 * u}px`,\n borderRadius: 8 * u,\n background: prim,\n color: \"#fff\",\n transform: `scale(${1 - 0.04 * press})`,\n boxShadow: `inset 0 1px 0 rgba(255,255,255,0.22), 0 1px 2px rgba(0,0,0,0.2)`,\n }}\n >\n <div\n style={{\n width: savedOn ? 18 * u : 0,\n overflow: \"hidden\",\n transform: `scale(${savedIn})`,\n display: \"flex\",\n }}\n >\n <Icon d={CHECK} size={18 * u} color=\"#fff\" width={2.2} />\n </div>\n {savedOn ? done : action}\n </div>\n </div>\n </div>\n </div>\n\n <svg\n width={cw + lead + 40}\n height={ch + 40}\n viewBox={`-20 -20 ${cw + lead + 40} ${ch + 40}`}\n style={{\n position: \"absolute\",\n left: -20,\n top: -20,\n overflow: \"visible\",\n pointerEvents: \"none\",\n }}\n aria-hidden\n >\n <defs>\n <filter\n id=\"rim-glow\"\n x=\"-20%\"\n y=\"-20%\"\n width=\"140%\"\n height=\"140%\"\n >\n <feGaussianBlur stdDeviation={5 * u} />\n </filter>\n </defs>\n <g opacity={visible > 0.5 ? 1 : 0}>\n <path\n d={pathD}\n fill=\"none\"\n stroke={acc}\n strokeWidth={7 * u}\n strokeLinecap=\"round\"\n strokeDasharray={`${visible} ${total * 2}`}\n strokeDashoffset={-tail}\n filter=\"url(#rim-glow)\"\n opacity={mix(dark ? 0.5 : 0.3, 0, settle)}\n />\n <path\n d={pathD}\n fill=\"none\"\n stroke={dark ? `color-mix(in oklab, ${acc} 70%, white)` : acc}\n strokeWidth={mix(1.8, 1.1, settle)}\n strokeLinecap=\"round\"\n strokeDasharray={`${visible} ${total * 2}`}\n strokeDashoffset={-tail}\n opacity={mix(1, 0, settle)}\n />\n <path\n d={pathD}\n fill=\"none\"\n stroke={dark ? \"#ffffff\" : acc}\n strokeWidth={3 * u}\n strokeLinecap=\"round\"\n strokeDasharray={`${hotLen} ${total * 2}`}\n strokeDashoffset={-(head - hotLen)}\n filter=\"url(#rim-glow)\"\n opacity={1 - drawn}\n />\n <path\n d={pathD}\n fill=\"none\"\n stroke=\"#ffffff\"\n strokeWidth={2.2}\n strokeLinecap=\"round\"\n strokeDasharray={`${hotLen * 0.5} ${total * 2}`}\n strokeDashoffset={-(head - hotLen * 0.5)}\n opacity={(1 - drawn) * (dark ? 1 : 0.9)}\n />\n </g>\n </svg>\n </div>\n </div>\n </div>\n </AbsoluteFill>\n );\n}\n\nexport default RimDrawCard;\n",
"type": "registry:component",
"target": "components/remocn/rim-draw-card.tsx"
}
],
"type": "registry:component"
}