Data display
CodeDiff
Two versions of a text side by side, with the changed lines and words marked. Read only. It has the same entry as CodeEditor, @percentsa/ui/code-editor, and the same look.
import { CodeDiff } from "@percentsa/ui/code-editor";Examples
Code
export function CodeDiffExample() {
const t = useT();
return <CodeDiff before={CONFIG} after={CONFIG.replace("web:1.4", "web:1.5").replace("8080:80", "8081:80")} label={t("Settings before and after", "الإعدادات قبل التعديل وبعده")} className="w-full max-w-3xl" />;
}
const clock = (i: number) => `10:${String(Math.floor(i / 60)).padStart(2, "0")}:${String(i % 60).padStart(2, "0")}`;
const BUILD_ROWS: LogRow[] =
Array.from({ length: 40 }, (_, i) => ({
key: `b${i}`,
at: clock(i),
source: i % 2 ? "bundler" : "compiler",
text: i === 12 || i === 31 ? `error: cannot find module "./missing-${i}"` : `step ${i + 1} of 40 done`,
error: i === 12 || i === 31,
}));