A change's size as lines added and removed, "+297 −2", in green and red.
- src/api/client.ts
- maya/add-themes
- src/ui/Slider.tsx (new)
- docs/old-guide.md (deleted)
- vendor/ upgrade
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { DiffStat } from "./ui/uicontext/components/kit/DiffStat.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ list: { display: "grid", gridTemplateColumns: "minmax(0, 1fr) auto", alignItems: "center", columnGap: space.xl, rowGap: space.md, inlineSize: "min(100%, 26rem)", margin: 0 }, term: { margin: 0, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontFamily: font.mono, fontSize: font.sm, color: color.fg }, value: { margin: 0, justifySelf: "end" },})const rows = [ { name: "src/api/client.ts", stat: { additions: 112, deletions: 84 } }, { name: "maya/add-themes", stat: { additions: 297, deletions: 2, boxed: true } }, { name: "src/ui/Slider.tsx (new)", stat: { additions: 83, deletions: 0, hideZero: true } }, { name: "docs/old-guide.md (deleted)", stat: { additions: 0, deletions: 418, hideZero: true } }, { name: "vendor/ upgrade", stat: { additions: 56_591, deletions: 19_914 } },] as constexport const ChangeSizes = <M>(h: Html.H<M>) => h.dl.attrs(sx(styles.list)).children(rows.flatMap((row) => [ h.dt.key(`${row.name}:t`).attrs(sx(styles.term)).children(row.name), h.dd.key(`${row.name}:d`).attrs(sx(styles.value)).children(DiffStat(h, row.stat)), ]))Installation
pnpm dlx shadcn@latest add checkfu/uicontext/diff-statUsage
import { changeCount, DiffStat } from "./ui/uicontext/components/kit/DiffStat.ts"export const FileStat = <M>(h: Html.H<M>, before: string, after: string) => DiffStat(h, { ...changeCount(before, after), boxed: true })API reference
Options
| Name | Type | Default | Description |
|---|---|---|---|
additionsrequired | number | — | — |
deletionsrequired | number | — | — |
boxed | boolean | — | In a quiet box, as a badge beside a name |
hideZero | boolean | off | Leave out a side that's zero: "+83" rather than "+83 −0"; off by default |
size | "xs" | "sm" | — | — |
locale | string | — | — |
Accessibility
- The stat is one image named in words, "297 lines added, 2 removed", so color is never the only signal.
- Numbers use tabular figures and never shorten, so a column of stats lines up.