BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/remotionui/code-diff-wipe

code-diff-wipe

remotionui/code-diff-wipe
FreeBlock

Diff patch landing line by line: an apply front travels the file, removals collapse, additions open and write in

Live preview

live · rendered by the registry
Rendered by remotionui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://remotionui.com/r/code-diff-wipe.json

Source

registry/bases/default/scenes/code-diff-wipe/index.tsxremotionui.com/r/code-diff-wipe.json · first 6 KB
1import { loadFont } from "@remotion/google-fonts/JetBrainsMono";
2import {
3 interpolate,
4 spring,
5 useCurrentFrame,
6 useVideoConfig,
7} from "remotion";
8import { stageScale } from "@/remotion/lib/ai-composer-utils";
9import { CODE_THEMES, CodeLine, tokenizeCode } from "@/remotion/lib/code-syntax";
10import { EASING } from "@/remotion/lib/motion-tokens";
11
12const { fontFamily } = loadFont("normal", {
13 weights: ["400", "500", "700"],
14 subsets: ["latin"],
15});
16
17/** Reference stage the window is laid out against, then uniformly scaled. */
18const REF_WIDTH = 1280;
19const REF_HEIGHT = 720;
20
21const WINDOW_WIDTH = 940;
22const HEADER_HEIGHT = 46;
23const BODY_PADDING = 22;
24const ROW_HEIGHT = 34;
25const FONT_SIZE = 20;
26const GUTTER_WIDTH = 46;
27const CODE_INSET = 18;
28
29export type CodeDiffWipeProps = {
30 /** Source before the patch. */
31 before?: string;
32 /** Source after the patch. */
33 after?: string;
34 /** Filename on the window header. */
35 title?: string;
36 /** Seconds the patch front takes to travel the file. */
37 wipeSeconds?: number;
38 accentColor?: string;
39 /** Overrides the page background behind the window. */
40 backgroundColor?: string;
41 theme?: "dark" | "light";
42 /** Animation speed multiplier. */
43 speed?: number;
44};
45
46const DEFAULT_BEFORE = `export function render(scene) {
47 const frames = scene.frames;
48 return frames.map(draw);
49}`;
50
51const DEFAULT_AFTER = `export function render(scene, options) {
52 const frames = scene.frames;
53 const scale = options.scale ?? 1;
54 return frames.map((frame) => draw(frame, scale));
55}`;
56
57type DiffKind = "context" | "remove" | "add";
58
59type DiffRow = {
60 kind: DiffKind;
61 text: string;
62};
63
64/**
65 * Line-level LCS diff. Snippets in a video are a handful of lines, so the
66 * quadratic table is free and the result is the one a reader expects.
67 */
68function diffLines(before: string[], after: string[]): DiffRow[] {
69 const table: number[][] = Array.from({ length: before.length + 1 }, () =>
70 new Array(after.length + 1).fill(0),
71 );
72
73 for (let i = before.length - 1; i >= 0; i -= 1) {
74 for (let j = after.length - 1; j >= 0; j -= 1) {
75 table[i][j] =
76 before[i] === after[j]
77 ? table[i + 1][j + 1] + 1
78 : Math.max(table[i + 1][j], table[i][j + 1]);
79 }
80 }
81
82 const rows: DiffRow[] = [];
83 let i = 0;
84 let j = 0;
85
86 while (i < before.length && j < after.length) {
87 if (before[i] === after[j]) {
88 rows.push({ kind: "context", text: before[i] });
89 i += 1;
90 j += 1;
91// … truncated

Facts

Registry
remotionui
Type
registry:block
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-07
Last confirmed
4 days ago

Go to the source

Docs on remotionui remotionui.com riaz37/remotion-ui on GitHub Raw registry item This item as JSON

More from remotionui

All 127 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
ai-composer-showcaseai-composer-showcaseremotionuiBlocksFreeno deps
ai-generation-canvasai-generation-canvasremotionuiBlocksFreeno deps
animated-bar-chartanimated-bar-chartremotionuiBlocksFreeno deps
audiogram-sceneaudiogram-sceneremotionuiBlocksFreeno deps
auto-fit-titleauto-fit-titleremotionuiBlocksFreeno deps
b-roll-stackb-roll-stackremotionuiBlocksFreeno deps
bento-panbento-panremotionuiBlocksFreeno deps
browser-flowbrowser-flowremotionuiBlocksFreeno deps
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex