Code Diff Viewer
A unified code diff viewer in the site's dark terminal window style: a file header bar shows the filename and a "+N -M" change summary, and each line below carries a leading +/-/space gutter with green or red tinting for additions and deletions. Built for changelogs, PR summaries, and before/after code walkthroughs.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/code-diff-viewer.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools3.tsx instead.
Usage
The file also exports devtools3Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Devtools3, devtools3Demo } from "@/components/blocks/devtools/devtools3"; export default function Page() { return <Devtools3 {...devtools3Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Code Diff Viewer" | Section heading. |
| description | string | undefined | Section intro text below the heading. |
| fileName | string | "src/utils/formatCurrency.ts" | Filename shown in the panel's header bar. |
| additions | number | 0 | Count shown in the header's "+N" summary. |
| deletions | number | 0 | Count shown in the header's "-M" summary. |
| lines | DiffLine[] | [] | Diff lines rendered in order inside the panel. |
| className | string | none | Extra classes for the outer section element. |
Types
type DiffLineKind = "add" | "remove" | "context"; type DiffLine = { kind: DiffLineKind; content: string };
Behavior notes
- Entirely static; no client-side interactivity, no real diffing algorithm, no syntax highlighting beyond the add/remove/context tint.
- additions and deletions in the header are plain numbers supplied by the caller; the component does not count +/- lines itself, so they can be set independently of what lines actually contains.
- Long lines scroll horizontally within the panel (overflow-x-auto) rather than wrapping, matching how real diff viewers preserve line structure.
- The dark panel is a deliberate exception to the site's semantic color tokens, matching the repo's established terminal-window convention, and stays dark regardless of site theme.
More DevTools Blocks
View all →api-endpoints-sample-call
API Endpoints With Sample Call
Reference list of API endpoints paired with a live sample request and response panel.
cicd-pipeline-status
CI/CD Pipeline Status
Recent CI/CD pipeline runs with per-stage status chips and overall run badges.
keyboard-shortcuts-reference
Keyboard Shortcuts Reference
Grouped keyboard shortcut reference with keycap-styled key combos.
performance-waterfall
Performance Waterfall
Network request waterfall chart with cascading timing bars colored by duration.
service-health-board
Service Health Board
Infrastructure status board with a live summary strip and per-service uptime, latency, and health.
queue-monitor
Queue Monitor
Background job queue monitor with processed/pending/failed counts and a per-queue capacity bar.