File size: 817 Bytes
776286d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* @jsxRuntime classic */
/* @jsx h */
/* @jsxFrag Fragment */
import type { RenderElement } from 'claude-code'

import type { Kit } from '../../kit'

/**
 * `+N -M` in the diff's word colours, a side left out at zero and nothing
 * at all at 0/0 (design-system DiffStat).
 *
 * @param kit the drawing's kit; its elements draw the counts
 * @param added lines added
 * @param removed lines removed
 * @returns the inline element
 */
export function diffStat(
  kit: Kit,
  added: number,
  removed: number,
): RenderElement {
  const { Text } = kit.ui
  const hasBoth = added > 0 && removed > 0

  return (
    <Text>
      {added > 0 ? <Text color="diffAddedWord">{`+${added}`}</Text> : ''}
      {hasBoth ? ' ' : ''}
      {removed > 0 ? <Text color="diffRemovedWord">{`-${removed}`}</Text> : ''}
    </Text>
  )
}