spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / views / sections / diff-stat / diff-stat.tsx
32 lines · 817 BRaw
1/* @jsxRuntime classic */
2/* @jsx h */
3/* @jsxFrag Fragment */
4import type { RenderElement } from 'claude-code'
5
6import type { Kit } from '../../kit'
7
8/**
9 * `+N -M` in the diff's word colours, a side left out at zero and nothing
10 * at all at 0/0 (design-system DiffStat).
11 *
12 * @param kit the drawing's kit; its elements draw the counts
13 * @param added lines added
14 * @param removed lines removed
15 * @returns the inline element
16 */
17export function diffStat(
18 kit: Kit,
19 added: number,
20 removed: number,
21): RenderElement {
22 const { Text } = kit.ui
23 const hasBoth = added > 0 && removed > 0
24
25 return (
26 <Text>
27 {added > 0 ? <Text color="diffAddedWord">{`+${added}`}</Text> : ''}
28 {hasBoth ? ' ' : ''}
29 {removed > 0 ? <Text color="diffRemovedWord">{`-${removed}`}</Text> : ''}
30 </Text>
31 )
32}