summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src/components/diff-changes.tsx
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-10-27 15:35:47 -0500
committerAdam <[email protected]>2025-10-27 15:37:07 -0500
commitfc115ea367dd034c7b989819d4f547c5d7519253 (patch)
tree653401ef94212e161334108449a11f60ba54dc86 /packages/desktop/src/components/diff-changes.tsx
parentd03b79e61eef0be1cca669e5e6a13df78cc4be85 (diff)
downloadopencode-fc115ea367dd034c7b989819d4f547c5d7519253.tar.gz
opencode-fc115ea367dd034c7b989819d4f547c5d7519253.zip
wip: desktop work
Diffstat (limited to 'packages/desktop/src/components/diff-changes.tsx')
-rw-r--r--packages/desktop/src/components/diff-changes.tsx20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/desktop/src/components/diff-changes.tsx b/packages/desktop/src/components/diff-changes.tsx
new file mode 100644
index 000000000..3b633f70f
--- /dev/null
+++ b/packages/desktop/src/components/diff-changes.tsx
@@ -0,0 +1,20 @@
+import { 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() + deletions())
+ return (
+ <Show when={total() > 0}>
+ <div class="flex gap-2 justify-end items-center">
+ <span class="text-12-mono text-right text-text-diff-add-base">{`+${additions()}`}</span>
+ <span class="text-12-mono text-right text-text-diff-delete-base">{`-${deletions()}`}</span>
+ </div>
+ </Show>
+ )
+}