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": "glass-code-block",
"title": "Glass Code Block",
"description": "A premium frosted-glass code editor window with a regex tokenizer and line-by-line stagger reveal.",
"dependencies": ["remotion"],
"files": [
{
"path": "registry/remocn/glass-code-block/index.tsx",
"content": "\"use client\";\n\nimport { interpolate, Sequence, useCurrentFrame } from \"remotion\";\n\nexport interface GlassCodeBlockProps {\n code?: string;\n title?: string;\n width?: number;\n height?: number;\n fontSize?: number;\n glassColor?: string;\n staggerFrames?: number;\n showTrafficLights?: boolean;\n aura?: boolean;\n speed?: number;\n className?: string;\n}\n\nconst FONT_MONO =\n \"var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace\";\n\nconst DEFAULT_CODE = `import { motion } from \"remotion\";\n\n// Generate a hero scene\nexport function Hero() {\n const frame = useCurrentFrame();\n const opacity = frame / 30;\n return <h1 style={{ opacity }}>Hello</h1>;\n}`;\n\n// Minimal regex tokenizer. NOT a real syntax highlighter — just enough to\n// give the eye color anchors. Order matters: comments → strings → keywords.\nconst KEYWORDS = new Set([\n \"import\",\n \"from\",\n \"export\",\n \"function\",\n \"const\",\n \"let\",\n \"var\",\n \"return\",\n \"if\",\n \"else\",\n \"for\",\n \"while\",\n \"new\",\n \"class\",\n \"extends\",\n \"default\",\n \"true\",\n \"false\",\n \"null\",\n \"undefined\",\n]);\n\ntype Token = {\n text: string;\n kind: \"code\" | \"comment\" | \"string\" | \"keyword\" | \"number\";\n};\n\nfunction tokenizeLine(line: string): Token[] {\n // Whole-line comment.\n const trimmed = line.trimStart();\n if (trimmed.startsWith(\"//\")) {\n return [{ text: line, kind: \"comment\" }];\n }\n\n const tokens: Token[] = [];\n // Split keeping delimiters: words, strings, numbers, everything else.\n const re = /(\"[^\"]*\"|'[^']*'|`[^`]*`|\\b\\d+\\b|\\b[A-Za-z_$][\\w$]*\\b|[^\\w\"']+)/g;\n let match: RegExpExecArray | null = re.exec(line);\n while (match !== null) {\n const t = match[0];\n const first = t[0];\n if (first === '\"' || first === \"'\" || first === \"`\") {\n tokens.push({ text: t, kind: \"string\" });\n } else if (/^\\d+$/.test(t)) {\n tokens.push({ text: t, kind: \"number\" });\n } else if (/^[A-Za-z_$][\\w$]*$/.test(t) && KEYWORDS.has(t)) {\n tokens.push({ text: t, kind: \"keyword\" });\n } else {\n tokens.push({ text: t, kind: \"code\" });\n }\n match = re.exec(line);\n }\n return tokens;\n}\n\nconst TOKEN_COLORS: Record<Token[\"kind\"], string> = {\n code: \"#e4e4e7\",\n comment: \"#52525b\",\n string: \"#86efac\",\n keyword: \"#c4b5fd\",\n number: \"#fcd34d\",\n};\n\nexport function GlassCodeBlock({\n code = DEFAULT_CODE,\n title = \"hero.tsx\",\n width = 760,\n height = 460,\n fontSize = 16,\n glassColor = \"rgba(10, 10, 10, 0.6)\",\n staggerFrames = 4,\n showTrafficLights = true,\n aura = false,\n speed = 1,\n className,\n}: GlassCodeBlockProps) {\n const lines = code.split(\"\\n\");\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n {aura && <BackdropAura />}\n\n {/* 1px gradient ring acting as a microborder */}\n <div\n style={{\n position: \"relative\",\n padding: 1,\n borderRadius: 16,\n background:\n \"linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 100%)\",\n width,\n height,\n boxShadow: \"0 50px 120px rgba(0,0,0,0.55)\",\n }}\n >\n <div\n style={{\n width: \"100%\",\n height: \"100%\",\n borderRadius: 15,\n background: glassColor,\n backdropFilter: \"blur(16px)\",\n WebkitBackdropFilter: \"blur(16px)\",\n boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.06)\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n fontFamily: FONT_MONO,\n }}\n >\n {/* Chrome */}\n <div\n style={{\n height: 40,\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n padding: \"0 16px\",\n borderBottom: \"1px solid rgba(255,255,255,0.06)\",\n }}\n >\n {showTrafficLights && (\n <>\n <Light color=\"#ff5f57\" />\n <Light color=\"#febc2e\" />\n <Light color=\"#28c840\" />\n </>\n )}\n <div\n style={{\n flex: 1,\n textAlign: \"center\",\n color: \"#a1a1aa\",\n fontSize: 12,\n letterSpacing: \"0.02em\",\n }}\n >\n {title}\n </div>\n </div>\n\n {/* Code body */}\n <div\n style={{\n flex: 1,\n padding: \"20px 24px\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: 4,\n fontSize,\n lineHeight: 1.55,\n }}\n >\n {lines.map((line, i) => (\n <Sequence\n key={i}\n from={Math.round((i * staggerFrames) / speed)}\n layout=\"none\"\n >\n <CodeLine line={line} index={i} fontSize={fontSize} />\n </Sequence>\n ))}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction Light({ color }: { color: string }) {\n return (\n <div\n style={{\n width: 12,\n height: 12,\n borderRadius: \"50%\",\n background: color,\n opacity: 0.6,\n }}\n />\n );\n}\n\nfunction CodeLine({\n line,\n index,\n fontSize,\n}: {\n line: string;\n index: number;\n fontSize: number;\n}) {\n const frame = useCurrentFrame();\n const opacity = interpolate(frame, [0, 8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const ty = interpolate(frame, [0, 8], [4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const tokens = tokenizeLine(line);\n // Render an empty line as a half-height spacer so blank lines still take\n // visual space without collapsing the gap.\n if (tokens.length === 0) {\n return <div style={{ height: fontSize * 0.8, opacity }} />;\n }\n return (\n <div\n style={{\n opacity,\n translate: `0 ${ty}px`,\n whiteSpace: \"pre\",\n display: \"flex\",\n gap: 0,\n }}\n >\n <span style={{ width: 28, color: \"#3f3f46\", userSelect: \"none\" }}>\n {String(index + 1).padStart(2, \" \")}\n </span>\n <span>\n {tokens.map((t, i) => (\n <span key={i} style={{ color: TOKEN_COLORS[t.kind] }}>\n {t.text}\n </span>\n ))}\n </span>\n </div>\n );\n}\n\nfunction BackdropAura() {\n // Slow, low-amplitude blob behind the glass so the backdrop blur has\n // perceptible content to refract.\n const frame = useCurrentFrame();\n const t = frame / 60;\n const x = 50 + Math.sin(t) * 20;\n const y = 50 + Math.cos(t * 0.7) * 15;\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n background: `radial-gradient(circle at ${x}% ${y}%, rgba(56,189,248,0.22), transparent 50%), radial-gradient(circle at ${100 - x}% ${100 - y}%, rgba(168,85,247,0.18), transparent 55%)`,\n }}\n />\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/glass-code-block.tsx"
}
],
"type": "registry:component"
}