summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/diff-changes.tsx
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-10-30 07:26:06 -0500
committerAdam <[email protected]>2025-10-30 12:02:49 -0500
commit30f4c2cf4c6c01339434c617fb9d930f6e960883 (patch)
treedb5da342a227724e11609e05f9e3c1fd6e2e7741 /packages/ui/src/components/diff-changes.tsx
parent3541fdcb2019676fb82351e909a8e9b740cb8237 (diff)
downloadopencode-30f4c2cf4c6c01339434c617fb9d930f6e960883.tar.gz
opencode-30f4c2cf4c6c01339434c617fb9d930f6e960883.zip
wip: desktop work
Diffstat (limited to 'packages/ui/src/components/diff-changes.tsx')
-rw-r--r--packages/ui/src/components/diff-changes.tsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/ui/src/components/diff-changes.tsx b/packages/ui/src/components/diff-changes.tsx
new file mode 100644
index 000000000..7661a9741
--- /dev/null
+++ b/packages/ui/src/components/diff-changes.tsx
@@ -0,0 +1,24 @@
+import type { FileDiff } from "@opencode-ai/sdk"
+import { createMemo, Show } from "solid-js"
+
+export function DiffChanges(props: { diff: FileDiff | FileDiff[] }) {
+ const additions = createMemo(() =>
+ Array.isArray(props.diff)
+ ? props.diff.reduce((acc, diff) => acc + (diff.additions ?? 0), 0)
+ : props.diff.additions,
+ )
+ const deletions = createMemo(() =>
+ Array.isArray(props.diff)
+ ? props.diff.reduce((acc, diff) => acc + (diff.deletions ?? 0), 0)
+ : props.diff.deletions,
+ )
+ const total = createMemo(() => (additions() ?? 0) + (deletions() ?? 0))
+ return (
+ <Show when={total() > 0}>
+ <div data-component="diff-changes">
+ <span data-slot="additions">{`+${additions()}`}</span>
+ <span data-slot="deletions">{`-${deletions()}`}</span>
+ </div>
+ </Show>
+ )
+}