From f3da73553c45f17e04b1e77cb13eb0fca714d1bd Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 30 May 2025 20:47:56 -0400 Subject: sync --- app/packages/web/src/components/DiffView.tsx | 73 ---------------------------- 1 file changed, 73 deletions(-) delete mode 100644 app/packages/web/src/components/DiffView.tsx (limited to 'app/packages/web/src/components/DiffView.tsx') diff --git a/app/packages/web/src/components/DiffView.tsx b/app/packages/web/src/components/DiffView.tsx deleted file mode 100644 index 44feef140..000000000 --- a/app/packages/web/src/components/DiffView.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { type Component, createSignal, onMount } from "solid-js" -import { diffLines } from "diff" -import CodeBlock from "./CodeBlock" -import styles from "./diffview.module.css" - -type DiffRow = { - left: string - right: string - type: "added" | "removed" | "unchanged" -} - -interface DiffViewProps { - oldCode: string - newCode: string - lang?: string - class?: string -} - -const DiffView: Component = (props) => { - const [rows, setRows] = createSignal([]) - - onMount(() => { - const chunks = diffLines(props.oldCode, props.newCode) - const diffRows: DiffRow[] = [] - - for (const chunk of chunks) { - const lines = chunk.value.split(/\r?\n/) - if (lines.at(-1) === "") lines.pop() - - for (const line of lines) { - diffRows.push({ - left: chunk.removed ? line : chunk.added ? "" : line, - right: chunk.added ? line : chunk.removed ? "" : line, - type: chunk.added - ? "added" - : chunk.removed - ? "removed" - : "unchanged", - }) - } - } - - setRows(diffRows) - }) - - return ( -
-
- {rows().map((r) => ( - - ))} -
- -
- {rows().map((r) => ( - - ))} -
-
- ) -} - -export default DiffView -- cgit v1.2.3