Download packages/ui/src/v2/components/diff-changes-v2.tsx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 981 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/ui/src/v2/components/diff-changes-v2.tsx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/ui/src/v2/components/diff-changes-v2.tsx
-
curl -L -o diff-changes-v2.tsx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/ui/src/v2/components/diff-changes-v2.tsx
981 Bytes
| import { createMemo, Show } from "solid-js" | |
| import "./diff-changes-v2.css" | |
| export function DiffChanges(props: { | |
| class?: string | |
| changes: { additions: number; deletions: number } | { additions: number; deletions: number }[] | |
| }) { | |
| const additions = createMemo(() => | |
| Array.isArray(props.changes) | |
| ? props.changes.reduce((acc, diff) => acc + (diff.additions ?? 0), 0) | |
| : props.changes.additions, | |
| ) | |
| const deletions = createMemo(() => | |
| Array.isArray(props.changes) | |
| ? props.changes.reduce((acc, diff) => acc + (diff.deletions ?? 0), 0) | |
| : props.changes.deletions, | |
| ) | |
| const total = createMemo(() => (additions() ?? 0) + (deletions() ?? 0)) | |
| return ( | |
| <Show when={total() > 0}> | |
| <div data-component="diff-changes" classList={{ [props.class ?? ""]: true }}> | |
| <span data-slot="diff-changes-additions">{`+${additions()}`}</span> | |
| <span data-slot="diff-changes-deletions">{`-${deletions()}`}</span> | |
| </div> | |
| </Show> | |
| ) | |
| } | |