{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "code-diff-wipe", "title": "Code Diff Wipe", "description": "Before/after code reveal via clip-path wipe with a handle marker.", "dependencies": [ "remotion" ], "files": [ { "path": "registry/remocn/code-diff-wipe/index.tsx", "content": "\"use client\";\n\nimport { Easing, interpolate, useCurrentFrame } from \"remotion\";\n\nexport interface CodeDiffWipeProps {\n before?: string;\n after?: string;\n language?: string;\n background?: string;\n accent?: string;\n transitionStart?: number;\n transitionDuration?: number;\n showHandle?: boolean;\n speed?: number;\n className?: string;\n}\n\nconst DEFAULT_BEFORE = `function getUser(id) {\n return fetch('/api/user/' + id)\n .then(function (res) {\n return res.json();\n })\n .then(function (data) {\n if (data.error) {\n throw new Error(data.error);\n }\n return data.user;\n });\n}`;\n\nconst DEFAULT_AFTER = `async function getUser(id: string) {\n const res = await fetch(\\`/api/user/\\${id}\\`);\n const { user, error } = await res.json();\n if (error) throw new Error(error);\n return user;\n}`;\n\nexport function CodeDiffWipe({\n before = DEFAULT_BEFORE,\n after = DEFAULT_AFTER,\n language = \"tsx\",\n background = \"#0a0a0a\",\n accent = \"#0ea5e9\",\n transitionStart = 20,\n transitionDuration = 60,\n showHandle = true,\n speed = 1,\n className,\n}: CodeDiffWipeProps) {\n const frame = useCurrentFrame() * speed;\n\n const progress = interpolate(\n frame,\n [transitionStart, transitionStart + transitionDuration],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.cubic),\n },\n );\n\n const wipePercent = progress * 100;\n\n return (\n \n \n {/* AFTER (bottom layer) */}\n \n\n {/* BEFORE (top layer, clipped) */}\n \n \n \n\n {/* Handle */}\n {showHandle && wipePercent > 0 && wipePercent < 100 && (\n \n \n {\"<>\"}\n \n \n )}\n \n \n );\n}\n\nfunction CodePane({\n code,\n background,\n label,\n labelColor,\n language,\n dimmed,\n}: {\n code: string;\n background: string;\n label: string;\n labelColor: string;\n language: string;\n dimmed?: boolean;\n}) {\n const lines = code.split(\"\\n\");\n return (\n \n {/* Header */}\n \n \n {language}\n \n \n {label}\n \n \n\n {/* Code */}\n \n {lines.map((line, i) => (\n
\n \n {i + 1}\n \n {line || \" \"}\n
\n ))}\n \n \n );\n}\n", "type": "registry:component", "target": "components/remocn/code-diff-wipe.tsx" } ], "type": "registry:component" }