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": "toolbar-unfurl",
"title": "Toolbar Unfurl",
"description": "A round tap button unfurls into a tool strip while captions list each tool over a glowing ribbon.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/toolbar-unfurl/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadFigtree } from \"@remotion/google-fonts/Figtree\";\nimport type { CSSProperties } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n interpolateColors,\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 figtree = loadFigtree(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst LIGHT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst SWAY = Easing.bezier(0.45, 0, 0.55, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst TILE = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst GLIDE = { mass: 0.8, damping: 22, stiffness: 150 };\n\nconst B = {\n pop: -8,\n unfurl: [6, 10, 14],\n disc: 18,\n hops: [42, 62, 78],\n retract: 94,\n punch: 106,\n caption: 100,\n end: 150,\n};\n\nexport const TOOLBAR_UNFURL_DURATION = B.end;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst ramp = (f: number, start: number, dur: number, easing = ENTER) =>\n interpolate(f, [start, start + dur], [0, 1], { ...CLAMP, easing });\n\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nconst ICONS = {\n select:\n \"M9 3.75H7.75a4 4 0 0 0-4 4V9M3.75 13.25v1M14.5 3.75h1.75a4 4 0 0 1 4 4V9M9 20.25H7.75a4 4 0 0 1-4-4V15M12 11.5l7.5 2.9-3.3 1.2-1.3 3.4z\",\n text: \"M5.5 6.5V4.75h13V6.5M12 4.75v14.5M9.25 19.25h5.5\",\n draw: \"M15.25 4.75l4 4L8.5 19.5H4.5v-4zM13 7l4 4\",\n comment:\n \"M5.25 5h13.5a1.75 1.75 0 0 1 1.75 1.75v8.5A1.75 1.75 0 0 1 18.75 17H12l-4.25 3.25V17h-2.5A1.75 1.75 0 0 1 3.5 15.25v-8.5A1.75 1.75 0 0 1 5.25 5z\",\n};\n\ntype ToolId = keyof typeof ICONS;\nconst ORDER: ToolId[] = [\"select\", \"text\", \"draw\", \"comment\"];\n\nfunction ToolIcon({\n id,\n size,\n color,\n}: {\n id: ToolId;\n size: number;\n color: string;\n}) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width={size}\n height={size}\n style={{ display: \"block\" }}\n aria-hidden\n >\n <path\n d={ICONS[id]}\n fill=\"none\"\n stroke={color}\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nexport interface ToolbarUnfurlProps {\n theme?: \"dark\" | \"light\";\n accent?: string;\n lines?: string[];\n finalLine?: string;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nexport function ToolbarUnfurl({\n theme = \"dark\",\n accent = \"#3B5BFD\",\n lines = [\n \"Leave a note.\",\n \"Sketch the shot.\",\n \"Type on the frame.\",\n \"Select any layer.\",\n ],\n finalLine = \"Every tool, one tap away.\",\n ground,\n groundParams,\n}: ToolbarUnfurlProps) {\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 ink = dark ? \"#f2f3f7\" : \"#13151b\";\n const iconIdle = dark ? \"rgba(236,238,245,0.82)\" : \"rgba(20,22,30,0.78)\";\n const pillBg = dark ? \"rgba(22,23,28,0.84)\" : \"rgba(255,255,255,0.9)\";\n const pillShadow = dark\n ? \"0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.06), 0 12px 32px rgba(0,0,0,0.45)\"\n : \"0 0 0 1px rgba(16,18,30,0.06), 0 1px 2px rgba(16,20,40,0.06), 0 14px 36px rgba(16,20,40,0.12)\";\n\n const slot = portrait ? 176 : 96;\n const pad = portrait ? 16 : 9;\n const thick = slot + pad * 2;\n const disc = slot - (portrait ? 12 : 6);\n const outerR = portrait ? 56 : 30;\n const discR = outerR - pad - (slot - disc) / 2;\n const iconSize = portrait ? 64 : 34;\n const capSize = portrait ? 108 : 66;\n const N = ORDER.length;\n const last = N - 1;\n\n const centerX = stageW / 2;\n const centerY = portrait ? 1150 : 278;\n const captionTop = portrait ? 686 : centerY + 118;\n const caretW = portrait ? 92 : 50;\n\n const pop = spring({ frame: frame - B.pop, fps, config: CHIP });\n const unfurl = ORDER.slice(0, last).map((_, i) =>\n spring({ frame: frame - B.unfurl[i], fps, config: TILE }),\n );\n const retract = Math.min(\n 1,\n spring({ frame: frame - B.retract, fps, config: HEAVY }),\n );\n\n const spanOut = Math.max(\n 0,\n ...ORDER.slice(0, last).map((_, i) => (last - i) * slot * unfurl[i]),\n );\n const span = spanOut * (1 - retract);\n const pillLen = slot + pad * 2 + span;\n const extra = caretW * Math.max(0, retract);\n const caretIn = ramp(frame, B.retract + 8, 12, LIGHT);\n\n const pos = (i: number) => {\n const retracted = i * slot * (1 - retract);\n if (retract > 0) return -span / 2 + retracted;\n const off = i < last ? -(last - i) * slot * unfurl[i] : 0;\n return span / 2 + off;\n };\n\n const discK = B.hops.reduce(\n (acc, h) => acc + spring({ frame: frame - h, fps, config: CHIP }),\n 0,\n );\n const discKPrev = B.hops.reduce(\n (acc, h) => acc + spring({ frame: frame - 1 - h, fps, config: CHIP }),\n 0,\n );\n const discSlot = last - discK;\n const vel = Math.abs(discK - discKPrev);\n const discIn = spring({ frame: frame - B.disc, fps, config: CHIP });\n const discPos =\n retract > 0\n ? pos(0)\n : interpolate(\n discSlot,\n ORDER.map((_, i) => i),\n ORDER.map((_, i) => pos(i)),\n { extrapolateLeft: \"extend\", extrapolateRight: \"extend\" },\n );\n const stretch = 1 + Math.min(0.22, vel * 0.6);\n const squash = 1 - Math.min(0.1, vel * 0.3);\n const punch = spring({ frame: frame - B.punch, fps, config: CHIP });\n const punchS =\n frame >= B.punch ? 1 + 0.05 * Math.sin(Math.min(1, punch) * Math.PI) : 1;\n\n const toolPresence = (i: number) => {\n const anchor = retract > 0 ? 0 : last;\n if (i === anchor) return 1;\n return interpolate(\n Math.abs(pos(i) - pos(anchor)),\n [slot * 0.2, slot * 0.85],\n [0, 1],\n CLAMP,\n );\n };\n\n const along = (v: number) => `translate(${v}px, 0px)`;\n\n const lineStarts = [B.disc, ...B.hops];\n const capItems = lines.slice(0, N).map((text, i) => {\n const start = lineStarts[i];\n const nextStart = i < N - 1 ? lineStarts[i + 1] : B.retract;\n const enter = ramp(frame, start + (i === 0 ? 0 : 3), 12);\n const exit = ramp(frame, nextStart, 7, EXIT);\n return { text, enter, exit, key: `l${i.toString()}` };\n });\n const finalEnter = ramp(frame, B.caption, 14);\n\n const push = 1 + 0.04 * ramp(frame, 0, B.end, SWAY);\n const lift = Math.min(\n 1,\n spring({ frame: frame - B.retract - 2, fps, config: HEAVY }),\n );\n const groupY = mix(0, portrait ? 0 : 24, lift);\n const fold = 1 + 0.16 * lift;\n\n const cursorPts = [\n { f: -4, x: centerX + 260, y: centerY + 260 },\n { f: B.disc - 4, x: 0, y: 0, tool: last },\n { f: B.disc + 2, x: 0, y: 0, tool: last },\n ...B.hops.flatMap((h, i) => [\n { f: h - 5, x: 0, y: 0, tool: last - 1 - i },\n { f: h + 2, x: 0, y: 0, tool: last - 1 - i },\n ]),\n { f: B.retract + 14, x: centerX + 220, y: centerY + 230 },\n ];\n const resolvePt = (p: (typeof cursorPts)[number]) => {\n if (p.tool === undefined) return { x: p.x, y: p.y };\n const o = pos(p.tool);\n return { x: centerX + o + slot * 0.12, y: centerY + slot * 0.12 };\n };\n let cx = cursorPts[0].x;\n let cy = cursorPts[0].y;\n for (let i = 0; i < cursorPts.length - 1; i++) {\n const a = cursorPts[i];\n const b = cursorPts[i + 1];\n if (frame >= a.f) {\n const t = spring({\n frame: frame - a.f,\n fps,\n config: GLIDE,\n durationInFrames: Math.max(4, b.f - a.f),\n });\n const pa = resolvePt(a);\n const pb = resolvePt(b);\n const dx = pb.x - pa.x;\n const dy = pb.y - pa.y;\n const bow = Math.sin(Math.PI * Math.min(1, t)) * 0.16;\n cx = mix(pa.x, pb.x, t) - dy * bow;\n cy = mix(pa.y, pb.y, t) + dx * bow;\n }\n }\n const clicks = [B.disc, ...B.hops];\n const pressAt = (c: number) =>\n Math.max(\n 0,\n spring({ frame: frame - c + 2, fps, config: CHIP }) -\n spring({ frame: frame - c - 2, fps, config: CHIP }),\n );\n const press = clicks.reduce((acc, c) => Math.max(acc, pressAt(c)), 0);\n const cursorFade = 1 - ramp(frame, B.retract + 4, 10, EXIT);\n\n const resolvedGround: GshPresetId | undefined =\n ground ?? (groundParams ? undefined : dark ? \"afterhours\" : \"glasswork\");\n\n const pillStyle: CSSProperties = {\n left: centerX - pillLen / 2,\n top: centerY - thick / 2,\n width: pillLen + extra,\n height: thick,\n };\n\n const discColor = accent;\n\n return (\n <AbsoluteFill\n style={{ fontFamily: figtree.fontFamily, overflow: \"hidden\" }}\n >\n <GshGround\n preset={resolvedGround}\n params={groundParams}\n timeOffset={dark ? 9 : 5}\n timeScale={0.45}\n style={\n portrait\n ? { transform: \"scaleY(1.55)\", transformOrigin: \"50% 0%\" }\n : undefined\n }\n />\n <AbsoluteFill\n style={{\n background: dark\n ? \"linear-gradient(180deg, rgba(8,9,12,0.62) 0%, rgba(8,9,12,0.42) 55%, rgba(8,9,12,0.3) 100%)\"\n : \"linear-gradient(180deg, rgba(248,248,250,0.5) 0%, rgba(248,248,250,0.15) 70%, rgba(248,248,250,0) 100%)\",\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}) translateY(${groupY}px)`,\n transformOrigin: `50% ${(centerY / stageH) * 100}%`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translateX(${-extra / 2}px) scale(${fold})`,\n transformOrigin: `${centerX}px ${centerY}px`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n ...pillStyle,\n borderRadius: outerR,\n background: pillBg,\n boxShadow: pillShadow,\n backdropFilter: \"blur(24px)\",\n transform: `scale(${mix(0.55, 1, pop) * punchS})`,\n opacity: ramp(frame, B.pop, 6, LIGHT),\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: centerX - disc / 2,\n top: centerY - disc / 2,\n width: disc,\n height: disc,\n borderRadius: discR,\n background: discColor,\n boxShadow: `inset 0 1px 0 rgba(255,255,255,0.22), 0 1px 2px rgba(0,0,0,${dark ? 0.35 : 0.14})`,\n transform: `${along(discPos)} scale(${stretch * discIn * punchS}, ${squash * discIn * punchS})`,\n opacity: Math.min(1, discIn * 1.4),\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: stageW,\n height: stageH,\n clipPath: `inset(0 ${stageW - centerX - pillLen / 2 + 2}px 0 ${centerX - pillLen / 2 + 2}px round ${outerR}px)`,\n }}\n >\n {ORDER.map((id, i) => {\n const near = Math.max(\n 0,\n 1 -\n Math.abs((retract > 0 ? 0 : discSlot) - i) *\n (retract > 0 ? 99 : 1.6),\n );\n const lit = (retract > 0 ? (i === 0 ? 1 : 0) : near) * discIn;\n const c = interpolateColors(lit, [0, 1], [iconIdle, \"#ffffff\"]);\n const hit =\n last - i < clicks.length ? pressAt(clicks[last - i]) : 0;\n return (\n <div\n key={id}\n style={{\n position: \"absolute\",\n left: centerX - slot / 2,\n top: centerY - slot / 2,\n width: slot,\n height: slot,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `${along(pos(i))} scale(${mix(0.55, 1, pop) * (1 - 0.04 * hit)})`,\n opacity: toolPresence(i),\n zIndex: i === last ? 2 : 1,\n }}\n >\n <ToolIcon id={id} size={iconSize} color={c} />\n </div>\n );\n })}\n </div>\n {caretIn > 0 ? (\n <div\n style={{\n position: \"absolute\",\n left: centerX + pillLen / 2 - pad,\n top: centerY - slot / 2,\n width: caretW,\n height: slot,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n opacity: caretIn,\n transform: `translateY(${mix(-6, 0, caretIn)}px) scale(${punchS})`,\n }}\n >\n <svg\n viewBox=\"0 0 24 24\"\n width={iconSize * 0.72}\n height={iconSize * 0.72}\n style={{ display: \"block\" }}\n aria-hidden\n >\n <path\n d=\"M7 10l5 5 5-5\"\n fill=\"none\"\n stroke={iconIdle}\n strokeWidth={1.8}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n ) : null}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: captionTop,\n height: capSize * (portrait ? 2.5 : 1.3),\n textAlign: \"center\",\n fontSize: capSize,\n fontWeight: 300,\n letterSpacing: \"-0.035em\",\n lineHeight: 1.15,\n textWrap: \"balance\",\n color: ink,\n }}\n >\n {capItems.map((c) =>\n c.enter > 0 && c.exit < 1 ? (\n <div\n key={c.key}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n padding: portrait ? \"0 80px 0.12em\" : \"0 0 0.12em\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: portrait ? \"flex-end\" : \"flex-start\",\n }}\n >\n <div\n style={{\n transform: `translateY(${mix(105, 0, c.enter) - 110 * c.exit}%)`,\n filter:\n c.enter < 1 || c.exit > 0\n ? `blur(${(1 - c.enter) * 6 + c.exit * 6}px)`\n : undefined,\n opacity: 1 - c.exit,\n }}\n >\n {c.text}\n </div>\n </div>\n ) : null,\n )}\n {finalEnter > 0 ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n padding: portrait ? \"0 80px 0.12em\" : \"0 0 0.12em\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: portrait ? \"flex-end\" : \"flex-start\",\n }}\n >\n <div\n style={{\n transform: `translateY(${mix(100, 0, finalEnter)}%)`,\n filter:\n finalEnter < 1\n ? `blur(${(1 - finalEnter) * 6}px)`\n : undefined,\n }}\n >\n {finalLine}\n </div>\n </div>\n ) : null}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: cx - 6,\n top: cy - 4,\n opacity: cursorFade * ramp(frame, -4, 6, LIGHT),\n transform: `scale(${1 - 0.04 * press})`,\n transformOrigin: \"20% 15%\",\n }}\n >\n <svg\n viewBox=\"0 0 24 24\"\n width={portrait ? 56 : 30}\n height={portrait ? 56 : 30}\n style={{\n display: \"block\",\n filter: \"drop-shadow(0 3px 5px rgba(0,0,0,0.35))\",\n }}\n aria-hidden\n >\n <path\n d=\"M5 3.2v15.6l4.3-4.1 2.7 6.1 2.6-1.1-2.7-6h6z\"\n fill=\"#0d0f10\"\n stroke=\"#fff\"\n strokeWidth={1.4}\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n </div>\n </AbsoluteFill>\n );\n}\n\nexport default ToolbarUnfurl;\n",
"type": "registry:component",
"target": "components/remocn/toolbar-unfurl.tsx"
}
],
"type": "registry:component"
}