Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(ui): one share bar and one neutral palette for every proportion (#3326)

Raghav Chamadiyab01021505f1c
diff --git a/packages/ui/__tests__/costs/savings-card.test.tsx b/packages/ui/__tests__/costs/savings-card.test.tsx
index 10dd8897a..7714ba7b6 100644
--- a/packages/ui/__tests__/costs/savings-card.test.tsx
+++ b/packages/ui/__tests__/costs/savings-card.test.tsx
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
-import { render, screen } from "@testing-library/react";
+import { render, screen, within } from "@testing-library/react";
import { SavingsCard, type SavingsData } from "../../src/costs/savings-card";
function makeData(overrides: Partial<SavingsData> = {}): SavingsData {
@@ -62,8 +62,9 @@ describe("SavingsCard", () => {
expect(screen.getAllByText(/Measured/).length).toBeGreaterThanOrEqual(1);
expect(screen.getAllByText(/Inferred/).length).toBeGreaterThanOrEqual(1);
// The legend carries the actual split, not just the labels.
- expect(screen.getByText("65K")).toBeInTheDocument();
- expect(screen.getByText("39K")).toBeInTheDocument();
+ const legend = within(screen.getByRole("list", { name: "Tokens saved by evidence" }));
+ expect(legend.getByText("65K")).toBeInTheDocument();
+ expect(legend.getByText("39K")).toBeInTheDocument();
});
it("says how much of the total the dollar figure covers when some is unpriced", () => {
diff --git a/packages/ui/__tests__/health/code-health-lede.test.tsx b/packages/ui/__tests__/health/code-health-lede.test.tsx
index ea33b7585..949507699 100644
--- a/packages/ui/__tests__/health/code-health-lede.test.tsx
+++ b/packages/ui/__tests__/health/code-health-lede.test.tsx
@@ -140,7 +140,7 @@ describe("CodeHealthLede: what the first screen shows", () => {
const toggle = screen.getByText("Breakdown");
const details = toggle.closest("details")!;
expect(details.open).toBe(false);
- expect(details.textContent).toContain("50% at risk");
+ expect(details.textContent).toContain("At risk50%");
expect(details.textContent).toContain("comes from change history");
});
diff --git a/packages/ui/__tests__/health/distribution-badge.test.tsx b/packages/ui/__tests__/health/distribution-badge.test.tsx
index c19375a75..2e6387ef5 100644
--- a/packages/ui/__tests__/health/distribution-badge.test.tsx
+++ b/packages/ui/__tests__/health/distribution-badge.test.tsx
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
-import { render, screen } from "@testing-library/react";
+import { render, screen, within } from "@testing-library/react";
import type { HealthDistribution } from "@repowise-dev/types/health";
import { HealthDistributionBar } from "../../src/health/health-distribution-bar.js";
import { HealthBadge } from "../../src/health/health-badge.js";
@@ -19,11 +19,13 @@ const DIST: HealthDistribution = {
describe("HealthDistributionBar", () => {
it("renders the NLOC-weighted per-band shares", () => {
render(<HealthDistributionBar distribution={DIST} />);
- expect(screen.getByText(/50% excellent/)).toBeInTheDocument();
- expect(screen.getByText(/20% good/)).toBeInTheDocument();
- expect(screen.getByText(/15% fair/)).toBeInTheDocument();
- expect(screen.getByText(/5% needs work/)).toBeInTheDocument();
- expect(screen.getByText(/10% at risk/)).toBeInTheDocument();
+ const legend = within(screen.getByRole("list", { name: "Code volume by health band" }));
+ const text = legend.getAllByRole("listitem").map((li) => li.textContent);
+ expect(text).toContain("Excellent50% · 4 files");
+ expect(text).toContain("Good20% · 2 files");
+ expect(text).toContain("Fair15% · 2 files");
+ expect(text).toContain("Needs work5% · 1 file");
+ expect(text).toContain("At risk10% · 1 file");
});
it("shows an empty state when no files are analyzed", () => {
@@ -51,8 +53,10 @@ describe("HealthDistributionBar", () => {
bands: { excellent: { files: 6, nloc: 700, pct: 70 } },
} as unknown as HealthDistribution;
render(<HealthDistributionBar distribution={partial} />);
- expect(screen.getByText(/70% excellent/)).toBeInTheDocument();
- expect(screen.getByText(/0% at risk/)).toBeInTheDocument();
+ expect(screen.getByText("Excellent")).toBeInTheDocument();
+ expect(screen.getByText("70% · 6 files")).toBeInTheDocument();
+ // Absent bands are left out of the split rather than drawn as empty.
+ expect(screen.queryByText("At risk")).not.toBeInTheDocument();
});
it("does not report a repo with a three-band payload as empty in every band", () => {
diff --git a/packages/ui/__tests__/owners/ownership-distribution-bar.test.tsx b/packages/ui/__tests__/owners/ownership-distribution-bar.test.tsx
new file mode 100644
index 000000000..61aa4ae2e
--- /dev/null
+++ b/packages/ui/__tests__/owners/ownership-distribution-bar.test.tsx
@@ -0,0 +1,41 @@
+import { describe, it, expect } from "vitest";
+import { render, screen, within } from "@testing-library/react";
+import type { OwnerListEntry } from "@repowise-dev/types/owners";
+
+import { OwnershipDistributionBar } from "../../src/owners/ownership-distribution-bar";
+
+const owner = (name: string, files: number): OwnerListEntry => ({
+ key: name,
+ name,
+ email: null,
+ files_owned: files,
+ hotspots_owned: 0,
+ silo_modules: 0,
+ dead_code_files_owned: 0,
+ dead_code_lines_owned: 0,
+ commit_count_90d: null,
+ last_commit_at: null,
+ bus_factor_risk_files: 0,
+});
+
+describe("OwnershipDistributionBar", () => {
+ it("names the top five, links them, and folds every other contributor", () => {
+ const owners = [10, 60, 5, 40, 30, 20, 2].map((n, i) => owner(`dev${i}`, n));
+ const { container } = render(
+ <OwnershipDistributionBar
+ owners={owners}
+ totalContributors={40}
+ hrefFor={(o) => `/owners/${o.key}`}
+ />,
+ );
+ const items = within(screen.getByRole("list", { name: "Owned files by contributor" }))
+ .getAllByRole("listitem")
+ .map((li) => li.textContent);
+ // 167 owned files across the seven loaded contributors.
+ expect(items).toEqual(["dev136%", "dev324%", "dev418%", "dev512%", "dev06%", "35 others4%"]);
+ expect(screen.getByRole("link", { name: /dev1/ })).toHaveAttribute("href", "/owners/dev1");
+ // The same neutral share steps as every other proportion, never the accent.
+ expect(container.innerHTML).toContain("--color-share-1");
+ expect(container.innerHTML).not.toContain("accent");
+ });
+});
diff --git a/packages/ui/__tests__/refactoring/structural-field.test.tsx b/packages/ui/__tests__/refactoring/structural-field.test.tsx
index 4e829b75c..d4c049247 100644
--- a/packages/ui/__tests__/refactoring/structural-field.test.tsx
+++ b/packages/ui/__tests__/refactoring/structural-field.test.tsx
@@ -128,8 +128,8 @@ describe("salience", () => {
"var(--color-neutral-1)",
"var(--color-neutral-2)",
]);
- // globals.css reserves --color-ramp-* for magnitude; these are categories.
- expect(fills.some((f) => f.includes("ramp"))).toBe(false);
+ // globals.css reserves --color-share-* for shares of a whole; these are categories.
+ expect(fills.some((f) => f.includes("share"))).toBe(false);
});
it("breaks a count tie deterministically", () => {
diff --git a/packages/ui/__tests__/shared/proportion-bar.test.tsx b/packages/ui/__tests__/shared/proportion-bar.test.tsx
new file mode 100644
index 000000000..8eab61b3e
--- /dev/null
+++ b/packages/ui/__tests__/shared/proportion-bar.test.tsx
@@ -0,0 +1,105 @@
+import { describe, it, expect, vi } from "vitest";
+import { render, screen, fireEvent, within } from "@testing-library/react";
+
+import { ProportionBar, shareColor, SHARE_TAIL } from "../../src/shared/proportion-bar";
+
+const seg = (key: string, value: number) => ({ key, label: key, value });
+
+function legendItems(label: string) {
+ return within(screen.getByRole("list", { name: label })).getAllByRole("listitem");
+}
+
+function fills(container: HTMLElement) {
+ const bar = container.querySelector("[aria-hidden='true'], [role='img']")!;
+ return Array.from(bar.children).map((el) => (el as HTMLElement).getAttribute("style") ?? "");
+}
+
+describe("ProportionBar", () => {
+ it("orders largest first and steps down the share palette", () => {
+ const { container } = render(
+ <ProportionBar label="Split" segments={[seg("b", 10), seg("a", 60), seg("c", 30)]} />,
+ );
+ expect(legendItems("Split").map((li) => li.textContent)).toEqual(["a60%", "c30%", "b10%"]);
+ const styles = fills(container);
+ expect(styles[0]).toContain("--color-share-1");
+ expect(styles[1]).toContain("--color-share-2");
+ expect(styles[2]).toContain("--color-share-3");
+ });
+
+ it("folds the long tail into one named tail segment", () => {
+ render(
+ <ProportionBar
+ label="Split"
+ maxSegments={2}
+ segments={[seg("a", 50), seg("b", 30), seg("c", 15), seg("d", 5)]}
+ />,
+ );
+ const items = legendItems("Split").map((li) => li.textContent);
+ expect(items).toEqual(["a50%", "b30%", "2 others20%"]);
+ });
+
+ it("keeps the given order and semantic colours when sorting is off", () => {
+ const { container } = render(
+ <ProportionBar
+ label="Bands"
+ sort={false}
+ segments={[
+ { key: "good", label: "Good", value: 10, color: "var(--color-success)" },
+ { key: "bad", label: "Bad", value: 90, color: "var(--color-error)" },
+ ]}
+ />,
+ );
+ expect(legendItems("Bands").map((li) => li.textContent)).toEqual(["Good10%", "Bad90%"]);
+ const styles = fills(container);
+ expect(styles[0]).toContain("--color-success");
+ expect(styles[1]).toContain("--color-error");
+ });
+
+ it("drops empty segments and renders nothing for an empty whole", () => {
+ const { container, rerender } = render(
+ <ProportionBar label="Split" segments={[seg("a", 3), seg("b", 0)]} />,
+ );
+ expect(legendItems("Split")).toHaveLength(1);
+ rerender(<ProportionBar label="Split" segments={[seg("a", 0)]} />);
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it("summarises the split on the bar when the legend is off", () => {
+ render(
+ <ProportionBar
+ label="Findings"
+ legend={false}
+ segments={[seg("high", 1), { ...seg("low", 299), detail: "299" }]}
+ />,
+ );
+ expect(screen.getByRole("img", { name: "Findings: low 299, high <1%" })).toBeInTheDocument();
+ expect(screen.queryByRole("list")).not.toBeInTheDocument();
+ });
+
+ it("links or selects from the legend", () => {
+ const onSelect = vi.fn();
+ render(
+ <ProportionBar
+ label="Split"
+ segments={[
+ { ...seg("a", 2), href: "/a" },
+ { ...seg("b", 1), onSelect },
+ ]}
+ />,
+ );
+ expect(screen.getByRole("link", { name: /a/ })).toHaveAttribute("href", "/a");
+ fireEvent.click(screen.getByRole("button", { name: /b/ }));
+ expect(onSelect).toHaveBeenCalledOnce();
+ });
+
+ it("puts an explicit tail last in the tail step", () => {
+ render(
+ <ProportionBar
+ label="Split"
+ segments={[{ key: "rest", label: "Others", value: 80, tail: true }, seg("a", 20)]}
+ />,
+ );
+ expect(legendItems("Split").map((li) => li.textContent)).toEqual(["a20%", "Others80%"]);
+ expect(shareColor(5)).toBe(SHARE_TAIL);
+ });
+});
diff --git a/packages/ui/scripts/contrast-check.py b/packages/ui/scripts/contrast-check.py
index 73e4cd34e..ff84fd57e 100755
--- a/packages/ui/scripts/contrast-check.py
+++ b/packages/ui/scripts/contrast-check.py
@@ -138,14 +138,18 @@ LIGHT = {
"community-4": "#6B7A3D", "community-5": "#B06A86", "community-6": "#4A5D7A",
"community-7": "#A8821F", "community-8": "#8A7A66", "community-9": "#7A2F4A",
"community-10": "#B85A38", "community-11": "#2F6B66", "community-12": "#5E5360",
+ # Share steps (light): --color-text-primary mixed into --color-bg-inset at
+ # 86/74/63/54/47%. The tail (20%) is exempt: it is always named.
+ "share-1": "#413846", "share-2": "#59515C", "share-3": "#6F6871",
+ "share-4": "#827B82", "share-5": "#90898F",
}
DARK = {
- "bg-root": "#17131D",
- "bg-surface": "#211B29",
- "bg-elevated": "#2A2335",
- "bg-inset": "#110D17",
- "bg-canvas": "#110D17", # --color-bg-canvas → var(--color-bg-inset)
+ "bg-root": "#0E0E0F",
+ "bg-surface": "#141416",
+ "bg-elevated": "#191A1C",
+ "bg-inset": "#0A0A0B",
+ "bg-canvas": "#0A0A0B", # --color-bg-canvas → var(--color-bg-inset)
"text-primary": "#EEEAF4",
"text-secondary": "#A79DB3",
"text-tertiary": "#786F84",
@@ -179,6 +183,9 @@ DARK = {
"community-4": "#A9BB6F", "community-5": "#D795B1", "community-6": "#8FA3C0",
"community-7": "#D9B04A", "community-8": "#B8A68E", "community-9": "#C4708F",
"community-10": "#EBA585", "community-11": "#6FB3AB", "community-12": "#A79DB3",
+ # Share steps (dark): 86/71/58/48/40%; tail (18%) exempt.
+ "share-1": "#D2D2D3", "share-2": "#AFAFB0", "share-3": "#919192",
+ "share-4": "#79797A", "share-5": "#676768",
}
# (fg, bg, floor, label) — floor is the WCAG ratio the pair must meet.
@@ -217,6 +224,12 @@ CHECKS = [
(f"community-{n}", "bg-canvas", 3.0, f"Community {n} hub on canvas")
for n in range(1, 13)
],
+ # Share-bar segments and legend swatches are non-text UI on page and card.
+ *[
+ (f"share-{n}", bg, 3.0, f"Share step {n} on {where}")
+ for n in range(1, 6)
+ for bg, where in (("bg-root", "page"), ("bg-surface", "card"))
+ ],
]
diff --git a/packages/ui/src/c4/panels/ProjectOverview.tsx b/packages/ui/src/c4/panels/ProjectOverview.tsx
index 577354ef6..14066d2dd 100644
--- a/packages/ui/src/c4/panels/ProjectOverview.tsx
+++ b/packages/ui/src/c4/panels/ProjectOverview.tsx
@@ -5,6 +5,7 @@ import { Compass, LogIn } from "lucide-react";
import { useArchitectureStore } from "../store/use-architecture-store";
import { getTone } from "../../graph-primitives/tone-styles";
import { THEME } from "../theme/theme-variables";
+import { ProportionBar } from "../../shared/proportion-bar";
import { Section, Title, Sub, Pill, ActionButton } from "./panel-atoms";
export function ProjectOverview() {
@@ -199,31 +200,17 @@ export function ProjectOverview() {
{totalComplexity > 0 && (
<Section title="Complexity">
- <div style={{ display: "flex", gap: 2, height: 10, borderRadius: 4, overflow: "hidden" }}>
- {complexityCounts.simple > 0 && (
- <div
- aria-label={`${complexityCounts.simple} simple`}
- style={{ flex: complexityCounts.simple, background: THEME.complexity.simple }}
- />
- )}
- {complexityCounts.moderate > 0 && (
- <div
- aria-label={`${complexityCounts.moderate} moderate`}
- style={{ flex: complexityCounts.moderate, background: THEME.complexity.moderate }}
- />
- )}
- {complexityCounts.complex > 0 && (
- <div
- aria-label={`${complexityCounts.complex} complex`}
- style={{ flex: complexityCounts.complex, background: THEME.complexity.complex }}
- />
- )}
- </div>
- <div style={{ display: "flex", justifyContent: "space-between", marginTop: 4, fontSize: 10, opacity: 0.6 }}>
- <span>Simple: {complexityCounts.simple}</span>
- <span>Moderate: {complexityCounts.moderate}</span>
- <span>Complex: {complexityCounts.complex}</span>
- </div>
+ <ProportionBar
+ label="Nodes by complexity"
+ sort={false}
+ segments={(["simple", "moderate", "complex"] as const).map((k) => ({
+ key: k,
+ label: k.charAt(0).toUpperCase() + k.slice(1),
+ value: complexityCounts[k],
+ detail: complexityCounts[k].toLocaleString(),
+ color: THEME.complexity[k],
+ }))}
+ />
</Section>
)}
diff --git a/packages/ui/src/commits/code-evolution-chart.tsx b/packages/ui/src/commits/code-evolution-chart.tsx
index a7ac54c7d..cdaf5b557 100644
--- a/packages/ui/src/commits/code-evolution-chart.tsx
+++ b/packages/ui/src/commits/code-evolution-chart.tsx
@@ -42,7 +42,7 @@ interface CategoryMeta {
// Drawn bottom-to-top in STACK_ORDER; "feature" anchors the base so the growth
// band reads as the foundation the rest of the work sits on.
//
-// Two hues, then neutrals. This used to paint Feature in --color-success and
+// No hue per category. This used to paint Feature in --color-success and
// Fix in --color-error, which reads intuitively for about a second and then
// costs more than it gives: those two tokens carry a health band on every
// other surface in the app, so a reader arriving from Code Health has been
@@ -52,19 +52,18 @@ interface CategoryMeta {
// ceiling for everything under it, leaving the review-priority pills in the
// table competing with the chart instead of leading.
//
-// Fix keeps the accent because it is the series this chart exists to show;
-// Feature takes the plum secondary, a pairing globals.css already sanctions
-// (--color-savings-distill / --color-savings-mcp are exactly these two). The
-// rest are context, so they recede — which is also the honest encoding, since
-// the categories were never equally interesting.
+// A share over time, so it takes the share steps like every other proportion:
+// no hue. Fix gets the strongest step because it is the series this chart
+// exists to show; the rest step down in rough order of interest, and the
+// unclassified remainder sits on the well.
const CATEGORY_META: Record<CommitCategory, CategoryMeta> = {
- feature: { label: "Feature", color: "var(--color-accent-secondary)", blurb: "new capability" },
- fix: { label: "Fix", color: "var(--color-ramp-1)", blurb: "bug / regression" },
- refactor: { label: "Refactor", color: "var(--color-ramp-3)", blurb: "reshape / perf" },
- docs: { label: "Docs", color: "var(--color-neutral-1)", blurb: "documentation" },
- test: { label: "Test", color: "var(--color-ramp-5)", blurb: "tests / coverage" },
- deps: { label: "Deps", color: "var(--color-neutral-2)", blurb: "dependency bumps" },
- chore: { label: "Chore", color: "var(--color-neutral-3)", blurb: "tooling / CI / release" },
+ feature: { label: "Feature", color: "var(--color-share-2)", blurb: "new capability" },
+ fix: { label: "Fix", color: "var(--color-share-1)", blurb: "bug / regression" },
+ refactor: { label: "Refactor", color: "var(--color-share-3)", blurb: "reshape / perf" },
+ docs: { label: "Docs", color: "var(--color-share-4)", blurb: "documentation" },
+ test: { label: "Test", color: "var(--color-share-5)", blurb: "tests / coverage" },
+ deps: { label: "Deps", color: "var(--color-share-tail)", blurb: "dependency bumps" },
+ chore: { label: "Chore", color: "var(--color-share-tail)", blurb: "tooling / CI / release" },
other: { label: "Other", color: "var(--color-bg-inset)", blurb: "unclassified" },
};
diff --git a/packages/ui/src/costs/savings-card.tsx b/packages/ui/src/costs/savings-card.tsx
index e7e01c018..bf527ca9c 100644
--- a/packages/ui/src/costs/savings-card.tsx
+++ b/packages/ui/src/costs/savings-card.tsx
@@ -4,6 +4,7 @@ import { Scissors, Sparkles, Zap } from "lucide-react";
import { Card, CardContent } from "../ui/card";
import { Skeleton, SkeletonRegion } from "../ui/skeleton";
import { formatCost, formatTokens } from "../lib/format";
+import { ProportionBar } from "../shared/proportion-bar";
export interface SavingsBreakdownRow {
group: string | null;
@@ -168,8 +169,6 @@ export function SavingsCard({ data }: SavingsCardProps) {
const measured = data.measured_saved_input_tokens;
const inferred = data.inferred_saved_input_tokens;
- const measuredPct = total > 0 ? Math.round((measured / total) * 100) : 0;
- const inferredPct = 100 - measuredPct;
const topOperations = data.per_operation.slice(0, 5);
const topSurfaces = data.per_surface.slice(0, 5);
const missed = (data.missed_tokens_est ?? 0) > 0;
@@ -231,32 +230,15 @@ export function SavingsCard({ data }: SavingsCardProps) {
</div>
{/* Evidence mix — the distinction the headline must not flatten. */}
- <div className="mt-4 flex h-2.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {measured > 0 && (
- <div
- className="h-full bg-[var(--color-savings-distill)]"
- style={{ width: `${measuredPct}%` }}
- title={`Measured — ${formatTokens(measured)} (${measuredPct}%)`}
- />
- )}
- {inferred > 0 && (
- <div
- className="h-full bg-[var(--color-savings-mcp)]"
- style={{ width: `${inferredPct}%` }}
- title={`Inferred — ${formatTokens(inferred)} (${inferredPct}%)`}
- />
- )}
- </div>
- <div className="mt-1.5 flex items-center gap-4 text-xs text-[var(--color-text-secondary)]">
- <span className="flex items-center gap-1.5">
- <span className="h-2 w-2 rounded-full bg-[var(--color-savings-distill)]" /> Measured{" "}
- {formatTokens(measured)}
- </span>
- <span className="flex items-center gap-1.5">
- <span className="h-2 w-2 rounded-full bg-[var(--color-savings-mcp)]" /> Inferred{" "}
- {formatTokens(inferred)}
- </span>
- </div>
+ <ProportionBar
+ className="mt-4"
+ label="Tokens saved by evidence"
+ sort={false}
+ segments={[
+ { key: "measured", label: "Measured", value: measured, detail: formatTokens(measured) },
+ { key: "inferred", label: "Inferred", value: inferred, detail: formatTokens(inferred) },
+ ]}
+ />
{/* Where the savings came from */}
<div className="mt-4 grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2">
diff --git a/packages/ui/src/dashboard/health-overview-card.tsx b/packages/ui/src/dashboard/health-overview-card.tsx
index b0dbddbf0..7c565162a 100644
--- a/packages/ui/src/dashboard/health-overview-card.tsx
+++ b/packages/ui/src/dashboard/health-overview-card.tsx
@@ -13,7 +13,8 @@ import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { fileEntityPath } from "../shared/entity/routes";
import { AllClearStat } from "../shared/empty-state";
import { truncatePath } from "../lib/format";
-import { healthBand } from "../health/tokens";
+import { healthBand, SEVERITY_LABEL, SEVERITY_SEGMENT, type Severity } from "../health/tokens";
+import { ProportionBar } from "../shared/proportion-bar";
import { formatScore } from "@repowise-dev/types/health";
import { Sparkline } from "../health/sparkline";
@@ -75,13 +76,7 @@ interface HealthOverviewCardProps {
className?: string;
}
-const SEVERITY_ORDER = ["critical", "high", "medium", "low"] as const;
-const SEVERITY_COLOR: Record<string, string> = {
- critical: "var(--color-error)",
- high: "var(--color-accent-fill)",
- medium: "var(--color-warning)",
- low: "var(--color-text-tertiary)",
-};
+const SEVERITY_ORDER: Severity[] = ["critical", "high", "medium", "low"];
function TrendChip({ delta }: { delta: number | null | undefined }) {
if (delta == null || Math.abs(delta) < 0.05) return null;
@@ -110,12 +105,10 @@ function TrendChip({ delta }: { delta: number | null | undefined }) {
function FindingsLine({
href,
segments,
- total,
count,
}: {
href: string;
- segments: { key: string; count: number; color: string }[];
- total: number;
+ segments: { key: Severity; count: number }[];
count: number;
}) {
return (
@@ -127,18 +120,20 @@ function FindingsLine({
<ShieldAlert className="h-3 w-3" />
Open findings
</span>
- <span
- className="flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-[var(--color-bg-inset)]"
- title={segments.map((s) => `${s.key}: ${s.count.toLocaleString()}`).join(" · ")}
- >
- {segments.map((s) => (
- <span
- key={s.key}
- className="h-full"
- style={{ width: `${(s.count / total) * 100}%`, background: s.color }}
- />
- ))}
- </span>
+ <ProportionBar
+ className="flex-1"
+ label="Open findings by severity"
+ size="sm"
+ sort={false}
+ legend={false}
+ segments={segments.map((s) => ({
+ key: s.key,
+ label: SEVERITY_LABEL[s.key],
+ value: s.count,
+ detail: s.count.toLocaleString(),
+ color: SEVERITY_SEGMENT[s.key],
+ }))}
+ />
<span className="shrink-0 tabular-nums text-[var(--color-text-secondary)]">
{count.toLocaleString()}
</span>
@@ -262,7 +257,6 @@ export function HealthOverviewCard({
const severities = SEVERITY_ORDER.map((key) => ({
key,
count: data.severity_breakdown[key] ?? 0,
- color: SEVERITY_COLOR[key]!,
})).filter((s) => s.count > 0);
const severityTotal = severities.reduce((s, x) => s + x.count, 0);
@@ -331,7 +325,6 @@ export function HealthOverviewCard({
<FindingsLine
href={`${reportHref}?tab=triage`}
segments={severities}
- total={severityTotal}
count={data.open_findings}
/>
) : (
diff --git a/packages/ui/src/dashboard/kpi-strip.tsx b/packages/ui/src/dashboard/kpi-strip.tsx
index 7ad0258d2..8141a88d5 100644
--- a/packages/ui/src/dashboard/kpi-strip.tsx
+++ b/packages/ui/src/dashboard/kpi-strip.tsx
@@ -41,7 +41,7 @@ function Gauge({ value }: { value: number }) {
return (
<div className="h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
<div
- className="h-full rounded-full bg-[var(--color-accent-fill)]"
+ className="h-full rounded-full bg-[var(--color-share-1)]"
style={{ width: `${clamped}%` }}
/>
</div>
diff --git a/packages/ui/src/dashboard/savings-mini.tsx b/packages/ui/src/dashboard/savings-mini.tsx
index df5346a02..9d2598d15 100644
--- a/packages/ui/src/dashboard/savings-mini.tsx
+++ b/packages/ui/src/dashboard/savings-mini.tsx
@@ -1,6 +1,7 @@
import { Sparkles } from "lucide-react";
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { formatCost, formatTokens } from "../lib/format";
+import { ProportionBar } from "../shared/proportion-bar";
/** Structural slice of the savings report this tile renders — the full
* savings payload and the overview-summary headline both fit. */
@@ -45,8 +46,6 @@ export function SavingsMini({ data, repoId, trackable = true }: SavingsMiniProps
const hasData = !!data?.available && total > 0;
const costsHref = `/repos/${repoId}/costs`;
- const measuredPct = total > 0 ? Math.round((measured / total) * 100) : 0;
- const inferredPct = 100 - measuredPct;
return (
<Card>
@@ -85,48 +84,15 @@ export function SavingsMini({ data, repoId, trackable = true }: SavingsMiniProps
) : null}
</p>
- <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {measured > 0 && (
- <div
- className="h-full"
- style={{ width: `${measuredPct}%`, background: "var(--color-accent-fill)" }}
- title={`Measured — ${formatTokens(measured)}`}
- />
- )}
- {inferred > 0 && (
- <div
- className="h-full"
- style={{ width: `${inferredPct}%`, background: "var(--color-accent-secondary)" }}
- title={`Inferred — ${formatTokens(inferred)}`}
- />
- )}
- </div>
- <div className="space-y-1 text-xs">
- <div className="flex items-center justify-between gap-2">
- <span className="flex items-center gap-1.5 text-[var(--color-text-secondary)] whitespace-nowrap">
- <span
- className="h-2 w-2 rounded-full shrink-0"
- style={{ background: "var(--color-accent-fill)" }}
- />{" "}
- Measured
- </span>
- <span className="tabular-nums text-[var(--color-text-tertiary)] shrink-0">
- {formatTokens(measured)}
- </span>
- </div>
- <div className="flex items-center justify-between gap-2">
- <span className="flex items-center gap-1.5 text-[var(--color-text-secondary)] whitespace-nowrap">
- <span
- className="h-2 w-2 rounded-full shrink-0"
- style={{ background: "var(--color-accent-secondary)" }}
- />{" "}
- Inferred
- </span>
- <span className="tabular-nums text-[var(--color-text-tertiary)] shrink-0">
- {formatTokens(inferred)}
- </span>
- </div>
- </div>
+ {/* Measured leads in either order: it is the stronger claim. */}
+ <ProportionBar
+ label="Tokens saved by evidence"
+ sort={false}
+ segments={[
+ { key: "measured", label: "Measured", value: measured, detail: formatTokens(measured) },
+ { key: "inferred", label: "Inferred", value: inferred, detail: formatTokens(inferred) },
+ ]}
+ />
</div>
) : (
<div className="space-y-2 py-1">
diff --git a/packages/ui/src/doc-drift/doc-drift-lede.tsx b/packages/ui/src/doc-drift/doc-drift-lede.tsx
index f27ecbe68..cd93e59d6 100644
--- a/packages/ui/src/doc-drift/doc-drift-lede.tsx
+++ b/packages/ui/src/doc-drift/doc-drift-lede.tsx
@@ -20,6 +20,7 @@ import {
} from "@repowise-dev/types/doc-drift";
import { PageLede } from "../shared/page-lede";
+import { ProportionBar } from "../shared/proportion-bar";
import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
import { formatNumber } from "../lib/format";
@@ -153,9 +154,8 @@ export function DocDriftLede({
}
/**
- * How the pile splits by confidence. Stepped down from one family rather than
- * reaching for three hues, because confidence is an ordered scale and not
- * three categories; amber leads because drift is an attention state.
+ * How the pile splits by confidence. An ordered scale, so it keeps its order
+ * (near-certain first) and steps down the share palette in that order.
*/
function ConfidenceSplit({
high,
@@ -166,43 +166,16 @@ function ConfidenceSplit({
medium: number;
low: number;
}) {
- const total = high + medium + low;
- const segments = [
- { key: "high", label: "near-certain", count: high, bar: "bg-[var(--color-warning)]" },
- {
- key: "medium",
- label: "medium",
- count: medium,
- bar: "bg-[color-mix(in_srgb,var(--color-warning)_45%,var(--color-bg-inset))]",
- },
- {
- key: "low",
- label: "low",
- count: low,
- bar: "bg-[color-mix(in_srgb,var(--color-warning)_18%,var(--color-bg-inset))]",
- },
- ].filter((s) => s.count > 0);
-
return (
- <div className="space-y-1.5">
- <div className="flex h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {segments.map((s) => (
- <div
- key={s.key}
- className={s.bar}
- style={{ width: `${(s.count / total) * 100}%` }}
- aria-label={`${s.count} ${s.label} confidence`}
- />
- ))}
- </div>
- <div className="flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[var(--color-text-tertiary)]">
- {segments.map((s) => (
- <span key={s.key} className="inline-flex items-center gap-1 tabular-nums">
- <span className={`inline-block h-1.5 w-1.5 rounded-full ${s.bar}`} />
- {formatNumber(s.count)} {s.label}
- </span>
- ))}
- </div>
- </div>
+ <ProportionBar
+ label="Drift findings by confidence"
+ size="sm"
+ sort={false}
+ segments={[
+ { key: "high", label: "near-certain", value: high },
+ { key: "medium", label: "medium", value: medium },
+ { key: "low", label: "low", value: low },
+ ].map((s) => ({ ...s, detail: formatNumber(s.value) }))}
+ />
);
}
diff --git a/packages/ui/src/files/file-history-tab.tsx b/packages/ui/src/files/file-history-tab.tsx
index 41967b89f..a1a0d1f6e 100644
--- a/packages/ui/src/files/file-history-tab.tsx
+++ b/packages/ui/src/files/file-history-tab.tsx
@@ -3,7 +3,7 @@ import { GitBranch } from "lucide-react";
import { EmptyState } from "../shared/empty-state";
import { CommitCategorySparkline } from "../git/commit-category-sparkline";
import { AgentTierBar } from "../git/agent-tier-bar";
-import { OwnershipDonut } from "../git/ownership-donut";
+import { ProportionBar } from "../shared/proportion-bar";
import { ChangeHistoryCard } from "../git/change-history-card";
import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
import { summarizeFixHistory } from "../lib/fix-history";
@@ -171,8 +171,13 @@ export function FileHistoryTab({
Author attribution lands with the next index.
</p>
) : (
- <OwnershipDonut
- slices={git.top_authors.map((a) => ({ name: a.name, value: a.commit_count }))}
+ <ProportionBar
+ label="Commits by author"
+ segments={git.top_authors.map((a) => ({
+ key: a.email || a.name,
+ label: a.name,
+ value: a.commit_count,
+ }))}
/>
)}
</div>
diff --git a/packages/ui/src/git/agent-tier-bar.tsx b/packages/ui/src/git/agent-tier-bar.tsx
index 16838d747..1ab8d5b6f 100644
--- a/packages/ui/src/git/agent-tier-bar.tsx
+++ b/packages/ui/src/git/agent-tier-bar.tsx
@@ -1,6 +1,6 @@
"use client";
-import { cn } from "../lib/cn";
+import { ProportionBar } from "../shared/proportion-bar";
/**
* Canonical autonomy-tier labels. The same numeric tiers surface on file
@@ -13,12 +13,6 @@ export const AGENT_TIER_LABELS: Record<string, string> = {
"3": "assisted",
};
-const TIER_TONE: Record<string, string> = {
- "1": "bg-[var(--color-accent-primary)]",
- "2": "bg-[var(--color-info)]",
- "3": "bg-[var(--color-accent-secondary)]",
-};
-
const TIER_ORDER = ["1", "2", "3"];
export interface AgentTierBarProps {
@@ -33,40 +27,19 @@ export interface AgentTierBarProps {
* `tier_counts` data on file history, owner profiles, and commit detail.
*/
export function AgentTierBar({ tierCounts, className }: AgentTierBarProps) {
- const entries = TIER_ORDER.map((tier) => ({
- tier,
- count: tierCounts[tier] ?? 0,
- })).filter((e) => e.count > 0);
-
- const total = entries.reduce((s, e) => s + e.count, 0);
- if (total === 0) return null;
-
return (
- <div className={cn("space-y-2", className)}>
- <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {entries.map((e) => (
- <div
- key={e.tier}
- className={cn("h-full", TIER_TONE[e.tier] ?? "bg-[var(--color-accent-primary)]")}
- style={{ width: `${(e.count / total) * 100}%` }}
- title={`${AGENT_TIER_LABELS[e.tier] ?? `tier ${e.tier}`}: ${e.count}`}
- />
- ))}
- </div>
- <div className="flex flex-wrap gap-x-3 gap-y-1 text-xs text-[var(--color-text-tertiary)]">
- {entries.map((e) => (
- <span key={e.tier} className="inline-flex items-center gap-1.5">
- <span
- className={cn(
- "h-2 w-2 rounded-full",
- TIER_TONE[e.tier] ?? "bg-[var(--color-accent-primary)]",
- )}
- />
- {AGENT_TIER_LABELS[e.tier] ?? `tier ${e.tier}`}
- <span className="tabular-nums text-[var(--color-text-secondary)]">{e.count}</span>
- </span>
- ))}
- </div>
- </div>
+ <ProportionBar
+ className={className}
+ label="Agent commits by autonomy tier"
+ segments={TIER_ORDER.map((tier) => {
+ const count = tierCounts[tier] ?? 0;
+ return {
+ key: tier,
+ label: AGENT_TIER_LABELS[tier] ?? `tier ${tier}`,
+ value: count,
+ detail: count.toLocaleString(),
+ };
+ })}
+ />
);
}
diff --git a/packages/ui/src/git/commit-category-sparkline.tsx b/packages/ui/src/git/commit-category-sparkline.tsx
index 0d399b4c8..248030d37 100644
--- a/packages/ui/src/git/commit-category-sparkline.tsx
+++ b/packages/ui/src/git/commit-category-sparkline.tsx
@@ -1,52 +1,27 @@
-import {
- Tooltip,
- TooltipTrigger,
- TooltipContent,
-} from "../ui/tooltip";
+import { ProportionBar } from "../shared/proportion-bar";
interface CommitCategorySparklineProps {
categories: Record<string, number>;
}
-const CATEGORY_CONFIG: Record<string, { color: string; label: string }> = {
- feature: { color: "var(--color-info)", label: "Feature" },
- fix: { color: "var(--color-error)", label: "Fix" },
- refactor: { color: "var(--color-accent-secondary)", label: "Refactor" },
- dependency: { color: "var(--color-accent-fill)", label: "Dependency" },
+const CATEGORY_LABEL: Record<string, string> = {
+ feature: "Feature",
+ fix: "Fix",
+ refactor: "Refactor",
+ dependency: "Dependency",
};
-const CATEGORY_ORDER = ["feature", "fix", "refactor", "dependency"];
-
+/** A file's commits by type, on the shared share bar. */
export function CommitCategorySparkline({ categories }: CommitCategorySparklineProps) {
- const total = CATEGORY_ORDER.reduce((sum, k) => sum + (categories[k] || 0), 0);
- if (total === 0) return null;
-
return (
- <div className="flex h-2 w-full rounded-full overflow-hidden bg-[var(--color-bg-elevated)]">
- {CATEGORY_ORDER.map((key) => {
- const count = categories[key] || 0;
- if (count === 0) return null;
- const config = CATEGORY_CONFIG[key];
- if (!config) return null;
- return (
- <Tooltip key={key}>
- <TooltipTrigger asChild>
- <div
- className="h-full transition-all"
- style={{
- flex: count,
- backgroundColor: config.color,
- }}
- />
- </TooltipTrigger>
- <TooltipContent>
- <span className="text-xs">
- {config.label}: {count} ({Math.round((count / total) * 100)}%)
- </span>
- </TooltipContent>
- </Tooltip>
- );
- })}
- </div>
+ <ProportionBar
+ label="Commits by type"
+ size="sm"
+ segments={Object.entries(CATEGORY_LABEL).map(([key, label]) => ({
+ key,
+ label,
+ value: categories[key] || 0,
+ }))}
+ />
);
}
diff --git a/packages/ui/src/git/contributors-strip.tsx b/packages/ui/src/git/contributors-strip.tsx
index 01cc26ae0..576dd35c0 100644
--- a/packages/ui/src/git/contributors-strip.tsx
+++ b/packages/ui/src/git/contributors-strip.tsx
@@ -2,6 +2,7 @@ import { Users, Bot, ArrowRight } from "lucide-react";
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { InfoTip } from "../shared/info-tip";
import { AGENT_PCT_HINT } from "../stats/stat-callout";
+import { ProportionBar } from "../shared/proportion-bar";
export interface StripOwner {
name: string;
@@ -29,17 +30,6 @@ interface ContributorsStripProps {
commitsHref: string;
}
-/* Categorical hues that read in both themes (community ramp is built for
- exactly this — distinguishable, brand-anchored). */
-const SEG_COLORS = [
- "var(--color-community-1)",
- "var(--color-community-2)",
- "var(--color-community-3)",
- "var(--color-community-6)",
- "var(--color-community-7)",
-];
-const OTHER_COLOR = "var(--color-text-tertiary)";
-
function firstName(name: string): string {
return name.split(/\s+/)[0] ?? name;
}
@@ -87,42 +77,18 @@ export function ContributorsStrip({
</CardTitle>
</CardHeader>
<CardContent className="pt-0 space-y-2.5">
- {/* Ownership share */}
- <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {top.map((o, i) => (
- <div
- key={o.email ?? o.name}
- className="h-full"
- style={{ width: `${o.pct}%`, background: SEG_COLORS[i % SEG_COLORS.length] }}
- title={`${o.name} — ${Math.round(o.pct)}% of files`}
- />
- ))}
- {otherPct > 1 && (
- <div className="h-full" style={{ width: `${otherPct}%`, background: OTHER_COLOR }} />
- )}
- </div>
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
- {top.slice(0, 4).map((o, i) => (
- <span
- key={o.email ?? o.name}
- className="flex items-center gap-1.5 text-xs text-[var(--color-text-secondary)] min-w-0"
- >
- <span
- className="h-2 w-2 rounded-full shrink-0"
- style={{ background: SEG_COLORS[i % SEG_COLORS.length] }}
- />
- <span className="truncate max-w-[120px]">{firstName(o.name)}</span>
- <span className="tabular-nums text-[var(--color-text-tertiary)]">
- {Math.round(o.pct)}%
- </span>
- </span>
- ))}
- {owners.length > 4 && (
- <span className="text-xs text-[var(--color-text-tertiary)]">
- +{owners.length - 4} more
- </span>
- )}
- </div>
+ <ProportionBar
+ label="Files by contributor"
+ size="sm"
+ segments={[
+ ...top.map((o) => ({
+ key: o.email ?? o.name,
+ label: firstName(o.name),
+ value: o.pct,
+ })),
+ { key: "__rest", label: "Others", value: otherPct > 1 ? otherPct : 0, tail: true },
+ ]}
+ />
{/* Agent provenance — only when there's something to report */}
{hasProvenance && (
<div className="mt-1 border-t border-[var(--color-border-default)] pt-2.5 space-y-2">
@@ -144,37 +110,20 @@ export function ContributorsStrip({
<InfoTip content={AGENT_PCT_HINT} label="How agent authorship is measured" />
</span>
</div>
- <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- <div
- className="h-full"
- style={{ width: `${100 - provenance!.agentPct}%`, background: "var(--color-text-tertiary)" }}
- title={`Human — ${Math.round(100 - provenance!.agentPct)}%`}
- />
- <div
- className="h-full"
- style={{ width: `${provenance!.agentPct}%`, background: "var(--color-accent-fill)" }}
- title={`Agents — ${Math.round(provenance!.agentPct)}%`}
- />
- </div>
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--color-text-secondary)]">
- <span className="flex items-center gap-1.5">
- <span className="h-2 w-2 rounded-full bg-[var(--color-text-tertiary)]" />
- Human
- <span className="tabular-nums text-[var(--color-text-tertiary)]">
- {Math.round(100 - provenance!.agentPct)}%
- </span>
- </span>
- {provenance!.agentNames.slice(0, 2).map((a) => {
- const pct = Math.round((a.count / provenance!.totalCommits) * 100);
- return (
- <span key={a.name} className="flex items-center gap-1.5 min-w-0">
- <span className="h-2 w-2 rounded-full bg-[var(--color-accent-fill)]" />
- <span className="truncate max-w-[120px]">{a.name}</span>
- <span className="tabular-nums text-[var(--color-text-tertiary)]">{pct}%</span>
- </span>
- );
- })}
- </div>
+ <ProportionBar
+ label="Commits by author"
+ size="sm"
+ segments={[
+ { key: "human", label: "Human", value: 100 - provenance!.agentPct },
+ ...provenance!.agentNames.map((a) => ({
+ key: a.name,
+ label: a.name,
+ value: (a.count / provenance!.totalCommits) * 100,
+ })),
+ ]}
+ maxSegments={3}
+ othersLabel={() => "Other agents"}
+ />
</div>
)}
</CardContent>
diff --git a/packages/ui/src/git/index.ts b/packages/ui/src/git/index.ts
index cfb4dc978..4daff6157 100644
--- a/packages/ui/src/git/index.ts
+++ b/packages/ui/src/git/index.ts
@@ -11,7 +11,6 @@ export * from "./contributors-strip";
export * from "./contributor-network";
export * from "./fix-history-badge";
export * from "./hotspot-table";
-export * from "./ownership-donut";
export * from "./ownership-table";
export * from "./ownership-treemap";
export * from "./risk-distribution-chart";
diff --git a/packages/ui/src/git/ownership-donut.tsx b/packages/ui/src/git/ownership-donut.tsx
deleted file mode 100644
index 37878e137..000000000
--- a/packages/ui/src/git/ownership-donut.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-"use client";
-
-import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from "recharts";
-import { EmptyState } from "../shared/empty-state";
-
-export interface OwnershipDonutSlice {
- name: string;
- value: number;
-}
-
-interface OwnershipDonutProps {
- /** Contributors (or any ownership shares) — largest first is not required. */
- slices: OwnershipDonutSlice[];
- /** Max slices before the remainder collapses into an "Others" wedge. */
- maxSlices?: number;
-}
-
-const SLICE_COLORS = [
- "var(--color-accent-primary)",
- "var(--color-info)",
- "var(--color-accent-secondary)",
- "var(--color-success)",
- "var(--color-warning)",
- "var(--color-accent-fill)",
-];
-const OTHERS_COLOR = "var(--color-text-tertiary)";
-
-/**
- * Ownership concentration as a donut — shows at a glance whether a file is
- * owned by one person (bus-factor risk) or shared. Replaces the plain
- * "Top authors" count list.
- */
-export function OwnershipDonut({ slices, maxSlices = 5 }: OwnershipDonutProps) {
- const sorted = [...slices].filter((s) => s.value > 0).sort((a, b) => b.value - a.value);
- const total = sorted.reduce((s, d) => s + d.value, 0);
-
- if (total === 0) {
- return (
- <EmptyState title="No author data" description="Author attribution appears after the next git sync." />
- );
- }
-
- const head = sorted.slice(0, maxSlices);
- const restTotal = sorted.slice(maxSlices).reduce((s, d) => s + d.value, 0);
- const data = restTotal > 0 ? [...head, { name: "Others", value: restTotal }] : head;
- const top = sorted[0]!;
-
- return (
- <div className="flex items-center gap-4">
- <div className="relative flex shrink-0 items-center justify-center">
- <ResponsiveContainer width={140} height={140}>
- <PieChart>
- <Pie
- data={data}
- cx="50%"
- cy="50%"
- innerRadius={40}
- outerRadius={62}
- paddingAngle={2}
- dataKey="value"
- startAngle={90}
- endAngle={-270}
- >
- {data.map((entry, i) => (
- <Cell
- key={entry.name}
- fill={
- entry.name === "Others"
- ? OTHERS_COLOR
- : SLICE_COLORS[i % SLICE_COLORS.length] ?? OTHERS_COLOR
- }
- strokeWidth={0}
- />
- ))}
- </Pie>
- <Tooltip
- contentStyle={{
- background: "var(--color-bg-overlay)",
- border: "1px solid var(--color-border-default)",
- borderRadius: "6px",
- fontSize: "12px",
- color: "var(--color-text-primary)",
- }}
- formatter={(value, name) => {
- const n = typeof value === "number" ? value : 0;
- return [`${n} commits (${Math.round((n / total) * 100)}%)`, name];
- }}
- />
- </PieChart>
- </ResponsiveContainer>
- <div className="pointer-events-none absolute flex flex-col items-center">
- <span className="text-lg font-bold tabular-nums text-[var(--color-text-primary)]">
- {Math.round((top.value / total) * 100)}%
- </span>
- <span className="text-[10px] text-[var(--color-text-tertiary)]">top owner</span>
- </div>
- </div>
- <ul className="min-w-0 flex-1 space-y-1 text-xs">
- {data.map((entry, i) => (
- <li key={entry.name} className="flex items-center gap-2">
- <span
- className="h-2 w-2 shrink-0 rounded-full"
- style={{
- backgroundColor:
- entry.name === "Others"
- ? OTHERS_COLOR
- : SLICE_COLORS[i % SLICE_COLORS.length] ?? OTHERS_COLOR,
- }}
- />
- <span className="truncate text-[var(--color-text-primary)]">{entry.name}</span>
- <span className="ml-auto shrink-0 tabular-nums text-[var(--color-text-tertiary)]">
- {Math.round((entry.value / total) * 100)}%
- </span>
- </li>
- ))}
- </ul>
- </div>
- );
-}
diff --git a/packages/ui/src/health/coverage-lede.tsx b/packages/ui/src/health/coverage-lede.tsx
index fc36ae8c2..001708c55 100644
--- a/packages/ui/src/health/coverage-lede.tsx
+++ b/packages/ui/src/health/coverage-lede.tsx
@@ -21,6 +21,7 @@ import type {
} from "@repowise-dev/types/health";
import { PageLede } from "../shared/page-lede";
+import { ProportionBar } from "../shared/proportion-bar";
import { Sparkline } from "./sparkline";
import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
import { formatDate, formatDateTime, formatNumber } from "../lib/format";
@@ -42,10 +43,10 @@ const MIN_TREND_POINTS = 3;
/** Band order for the split bar: worst first, matching how the tables list. */
const BANDS = [
- { key: "thin", label: "Thin", max: 30, bar: "bg-[var(--color-error)]" },
- { key: "partial", label: "Partial", max: 60, bar: "bg-[var(--color-warning)]" },
- { key: "solid", label: "Solid", max: 80, bar: "bg-[var(--color-caution)]" },
- { key: "strong", label: "Strong", max: 101, bar: "bg-[var(--color-success)]" },
+ { key: "thin", label: "Thin", max: 30, color: "var(--color-error)" },
+ { key: "partial", label: "Partial", max: 60, color: "var(--color-warning)" },
+ { key: "solid", label: "Solid", max: 80, color: "var(--color-caution)" },
+ { key: "strong", label: "Strong", max: 101, color: "var(--color-success)" },
] as const;
export function CoverageLede({
@@ -255,28 +256,20 @@ function CoverageTrend({ values }: { values: number[] }) {
function BandSplit({
split,
}: {
- split: { key: string; label: string; bar: string; pct: number }[];
+ split: { key: string; label: string; color: string; pct: number }[];
}) {
return (
- <div className="space-y-1.5">
- <div className="flex h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {split.map((b) => (
- <div
- key={b.key}
- className={b.bar}
- style={{ width: `${b.pct}%` }}
- aria-label={`${b.label} ${b.pct}%`}
- />
- ))}
- </div>
- <div className="flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[var(--color-text-tertiary)]">
- {split.map((b) => (
- <span key={b.key} className="inline-flex items-center gap-1 tabular-nums">
- <span className={`inline-block h-1.5 w-1.5 rounded-full ${b.bar}`} />
- {b.pct}% {b.label.toLowerCase()}
- </span>
- ))}
- </div>
- </div>
+ <ProportionBar
+ label="Coverable lines by coverage band"
+ size="sm"
+ sort={false}
+ segments={split.map((b) => ({
+ key: b.key,
+ label: b.label,
+ value: b.pct,
+ detail: `${b.pct}%`,
+ color: b.color,
+ }))}
+ />
);
}
diff --git a/packages/ui/src/health/health-distribution-bar.tsx b/packages/ui/src/health/health-distribution-bar.tsx
index c64c5b6d3..26c35b608 100644
--- a/packages/ui/src/health/health-distribution-bar.tsx
+++ b/packages/ui/src/health/health-distribution-bar.tsx
@@ -5,7 +5,8 @@ import {
type HealthDistribution,
} from "@repowise-dev/types/health";
-import { HEALTH_BAND_BAR } from "./tokens";
+import { ProportionBar } from "../shared/proportion-bar";
+import { HEALTH_BAND_SEGMENT } from "./tokens";
export interface HealthDistributionBarProps {
distribution: HealthDistribution;
@@ -39,41 +40,19 @@ export function HealthDistributionBar({
<p className="text-xs text-[var(--color-text-tertiary)]">No files analyzed.</p>
);
}
- const h = height === "sm" ? "h-1.5" : "h-2";
return (
- <div className="space-y-1.5">
- <div
- className={`flex w-full ${h} overflow-hidden rounded-full bg-[var(--color-bg-inset)]`}
- title={HEALTH_BAND_ORDER.map(
- (b) => `${HEALTH_BAND_LABEL[b]} ${share(b)}%`,
- ).join(" · ")}
- >
- {HEALTH_BAND_ORDER.map((b) => {
- const pct = share(b);
- if (pct === 0) return null;
- return (
- <div
- key={b}
- className={HEALTH_BAND_BAR[b]}
- style={{ width: `${pct}%` }}
- aria-label={`${HEALTH_BAND_LABEL[b]} ${pct}%`}
- />
- );
- })}
- </div>
- {showCounts && (
- <div className="flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[var(--color-text-tertiary)]">
- {HEALTH_BAND_ORDER.map((b) => (
- <span key={b} className="inline-flex items-center gap-1 tabular-nums">
- <span className={`inline-block h-1.5 w-1.5 rounded-full ${HEALTH_BAND_BAR[b]}`} />
- {share(b)}% {HEALTH_BAND_LABEL[b].toLowerCase()}
- <span className="text-[var(--color-text-tertiary)]/70">
- ({files(b)})
- </span>
- </span>
- ))}
- </div>
- )}
- </div>
+ <ProportionBar
+ label="Code volume by health band"
+ size={height}
+ sort={false}
+ legend={showCounts}
+ segments={HEALTH_BAND_ORDER.map((b) => ({
+ key: b,
+ label: HEALTH_BAND_LABEL[b],
+ value: share(b),
+ detail: `${share(b)}% · ${files(b).toLocaleString()} ${files(b) === 1 ? "file" : "files"}`,
+ color: HEALTH_BAND_SEGMENT[b],
+ }))}
+ />
);
}
diff --git a/packages/ui/src/health/severity-distribution.tsx b/packages/ui/src/health/severity-distribution.tsx
index 303bb590f..9dd156a16 100644
--- a/packages/ui/src/health/severity-distribution.tsx
+++ b/packages/ui/src/health/severity-distribution.tsx
@@ -1,4 +1,5 @@
-import { SEVERITY_BAR, SEVERITY_LABEL, type Severity } from "./tokens";
+import { ProportionBar } from "../shared/proportion-bar";
+import { SEVERITY_LABEL, SEVERITY_SEGMENT, type Severity } from "./tokens";
export interface SeverityBreakdown {
critical: number;
@@ -28,36 +29,19 @@ export function SeverityDistribution({
<p className="text-xs text-[var(--color-text-tertiary)]">No findings.</p>
);
}
- const h = height === "sm" ? "h-1.5" : "h-2";
return (
- <div className="space-y-1.5">
- <div
- className={`flex w-full ${h} overflow-hidden rounded-full bg-[var(--color-bg-inset)]`}
- title={ORDER.map((s) => `${SEVERITY_LABEL[s]} ${breakdown[s]}`).join(" · ")}
- >
- {ORDER.map((s) => {
- const pct = (breakdown[s] / total) * 100;
- if (pct === 0) return null;
- return (
- <div
- key={s}
- className={SEVERITY_BAR[s]}
- style={{ width: `${pct}%` }}
- aria-label={`${SEVERITY_LABEL[s]} ${breakdown[s]}`}
- />
- );
- })}
- </div>
- {showCounts && (
- <div className="flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[var(--color-text-tertiary)]">
- {ORDER.map((s) => (
- <span key={s} className="inline-flex items-center gap-1 tabular-nums">
- <span className={`inline-block h-1.5 w-1.5 rounded-full ${SEVERITY_BAR[s]}`} />
- {breakdown[s]} {SEVERITY_LABEL[s].toLowerCase()}
- </span>
- ))}
- </div>
- )}
- </div>
+ <ProportionBar
+ label="Findings by severity"
+ size={height}
+ sort={false}
+ legend={showCounts}
+ segments={ORDER.map((sev) => ({
+ key: sev,
+ label: SEVERITY_LABEL[sev],
+ value: breakdown[sev],
+ detail: breakdown[sev].toLocaleString(),
+ color: SEVERITY_SEGMENT[sev],
+ }))}
+ />
);
}
diff --git a/packages/ui/src/health/tokens.ts b/packages/ui/src/health/tokens.ts
index 6aedddec6..7ca645179 100644
--- a/packages/ui/src/health/tokens.ts
+++ b/packages/ui/src/health/tokens.ts
@@ -45,11 +45,12 @@ export const SEVERITY_CHIP: Record<Severity, string> = {
low: "bg-[var(--color-text-tertiary)]/15 text-[var(--color-text-tertiary)] border border-[var(--color-text-tertiary)]/30",
};
-export const SEVERITY_BAR: Record<Severity, string> = {
- critical: "bg-[var(--color-error)]",
- high: "bg-[var(--color-warning)]",
- medium: "bg-[var(--color-caution)]",
- low: "bg-[var(--color-text-tertiary)]",
+/** Segment fills for a severity split (ProportionBar `color`). */
+export const SEVERITY_SEGMENT: Record<Severity, string> = {
+ critical: "var(--color-error)",
+ high: "var(--color-warning)",
+ medium: "var(--color-caution)",
+ low: "var(--color-text-tertiary)",
};
/**
@@ -114,8 +115,8 @@ export const HEALTH_BAND_FILL: Record<HealthBand, string> = {
};
/**
- * Bar fills for the distribution. Good is the same green stepped down in
- * opacity, so it stays legible where it sits next to Excellent.
+ * Band fills. Good is the same green stepped down in opacity, so it stays
+ * legible where it sits next to Excellent.
*/
export const HEALTH_BAND_BAR: Record<HealthBand, string> = {
excellent: "bg-[var(--color-success)]",
@@ -125,6 +126,15 @@ export const HEALTH_BAND_BAR: Record<HealthBand, string> = {
at_risk: "bg-[var(--color-error)]",
};
+/** The same fills as CSS values, for a ProportionBar `color`. */
+export const HEALTH_BAND_SEGMENT: Record<HealthBand, string> = {
+ excellent: "var(--color-success)",
+ good: "color-mix(in srgb, var(--color-success) 55%, transparent)",
+ fair: "var(--color-caution)",
+ needs_work: "var(--color-warning)",
+ at_risk: "var(--color-error)",
+};
+
/**
* The canvas ramp. Dense filled shapes carry no band word, so Excellent and
* Good separate by value here rather than sharing the one green.
diff --git a/packages/ui/src/lib/ramp.ts b/packages/ui/src/lib/ramp.ts
deleted file mode 100644
index a6a85b34d..000000000
--- a/packages/ui/src/lib/ramp.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * The accent ramp, as CSS var references.
- *
- * One place so a stacked bar, a histogram and an area chart all step through
- * the same five values. The values themselves live in `styles/globals.css`,
- * per theme — see the comment there for why the light and dark ramps are not
- * the same mix percentages.
- *
- * Use `RAMP` for ordered shares of a whole, where position means magnitude.
- * For unrelated categories reach for `CATEGORICAL` instead: two hues the
- * token system already sanctions together, then neutrals. A qualitative
- * palette of five unrelated hues is what this exists to avoid.
- */
-
-export const RAMP = [
- "var(--color-ramp-1)",
- "var(--color-ramp-2)",
- "var(--color-ramp-3)",
- "var(--color-ramp-4)",
- "var(--color-ramp-5)",
-] as const;
-
-export const NEUTRALS = [
- "var(--color-neutral-1)",
- "var(--color-neutral-2)",
- "var(--color-neutral-3)",
-] as const;
-
-/** The long tail past the end of the ramp: present, but not a step. */
-export const RAMP_TAIL = "var(--color-bg-inset)";
-
-/**
- * Ramp step for position `i`. Anything past the last step returns the tail,
- * so a caller can map an arbitrarily long sorted list without bounds checks
- * and without inventing colours it does not have.
- */
-export function rampStep(i: number): string {
- return RAMP[i] ?? RAMP_TAIL;
-}
-
-/**
- * Two hues then neutrals, for a small set of unrelated categories.
- *
- * The pairing is not invented here: `--color-savings-distill` and
- * `--color-savings-mcp` are already accent-fill and accent-secondary, so the
- * token system has settled that these two read as distinct without either
- * standing in for a health band. Everything after position 2 recedes, which
- * is the honest encoding when the trailing categories are context rather
- * than subject.
- */
-export const CATEGORICAL = [
- "var(--color-ramp-1)",
- "var(--color-accent-secondary)",
- ...NEUTRALS,
-] as const;
diff --git a/packages/ui/src/overview/language-bar.tsx b/packages/ui/src/overview/language-bar.tsx
index fb0f7c7ea..1ccf8af8e 100644
--- a/packages/ui/src/overview/language-bar.tsx
+++ b/packages/ui/src/overview/language-bar.tsx
@@ -1,51 +1,12 @@
import * as React from "react";
+import { ProportionBar } from "../shared/proportion-bar";
/**
- * Two hues then neutrals, in the order the rule allows. The accent leads
- * because the first segment is the repository's primary language; plum is the
- * pairing `globals.css` already sanctions beside it; the rest recede, which is
- * also the honest encoding, since a 2% slice is not as interesting as a 60%
- * one.
- */
-const SEGMENTS: { bg: string; ink: string }[] = [
- // `ink` is a fixed value per fill rather than a theme token. Both fills hold
- // their own lightness in either theme — the orange is light, the plum is
- // dark — so a token that flips with the theme is guaranteed to be wrong on
- // one of them half the time.
- { bg: "var(--color-accent-fill)", ink: "#1a1205" },
- { bg: "var(--color-accent-secondary)", ink: "#f5f1ea" },
- { bg: "var(--color-neutral-1)", ink: "var(--color-text-secondary)" },
- { bg: "var(--color-neutral-2)", ink: "var(--color-text-secondary)" },
- { bg: "var(--color-neutral-3)", ink: "var(--color-text-secondary)" },
-];
-
-const OTHER_SEGMENT = {
- bg: "var(--color-bg-inset)",
- ink: "var(--color-text-secondary)",
-};
-
-/** Below this share a segment is too narrow to hold its own name legibly. */
-const INLINE_LABEL_MIN_PCT = 12;
-
-/**
- * Language mix as a stacked bar plus a key.
+ * Language mix as a share bar plus a key.
*
- * Replaces a donut that spent roughly 200px of height rendering four numbers
- * you can read faster as text, and did it in four unrelated hues that fought
- * every other colour on the page.
- *
- * Two problems with what replaced it, both fixed here.
- *
- * It painted the segments with `--color-ramp-*`, whose own definition says
- * "ramp means magnitude; NOT for unrelated categories, which want either the
- * accent/secondary pair or plain neutrals". Languages are unrelated
- * categories, and five steps of one hue in a 6px bar are not separable — you
- * cannot match a swatch in the key back to a segment. It now uses the pairing
- * the rule sanctions: the accent, the plum secondary, then neutrals.
- *
- * More importantly, the widest segments carry their own name. That removes the
- * matching problem outright rather than making it slightly easier, and the key
- * is left to do the job only the small segments still need.
+ * Languages are named in the key, so they take the share steps like every
+ * other proportion rather than a hue each: a colour per language is only worth
+ * its cost with a fixed legend the reader learns once, and there is none.
*/
export function LanguageBar({
distribution,
@@ -55,71 +16,16 @@ export function LanguageBar({
distribution: Record<string, number>;
maxShown?: number;
}) {
- const entries = Object.entries(distribution)
- .filter(([, n]) => n > 0)
- .sort((a, b) => b[1] - a[1]);
- const total = entries.reduce((s, [, n]) => s + n, 0);
- if (total === 0) return null;
-
- const shown = entries.slice(0, maxShown);
- const restCount = entries.slice(maxShown).reduce((s, [, n]) => s + n, 0);
- const segments = shown.map(([name, count], i) => ({
- name,
- count,
- ...(SEGMENTS[i] ?? OTHER_SEGMENT),
- pct: (count / total) * 100,
- }));
- if (restCount > 0) {
- segments.push({
- name: "Other",
- count: restCount,
- ...OTHER_SEGMENT,
- pct: (restCount / total) * 100,
- });
- }
-
return (
- <div className="flex flex-col gap-2.5">
- {/* Tall enough to hold type. The 6px bar it replaces could only ever be
- decoded through the key. */}
- <div className="flex h-6 w-full overflow-hidden rounded-md bg-[var(--color-bg-inset)]">
- {segments.map((s) => (
- <span
- key={s.name}
- title={`${s.name}: ${s.count.toLocaleString()} files`}
- className="flex h-full min-w-0 items-center justify-center overflow-hidden px-1.5"
- style={{ width: `${s.pct}%`, background: s.bg }}
- >
- {s.pct >= INLINE_LABEL_MIN_PCT && (
- <span
- className="truncate font-mono text-[10px] font-medium"
- style={{ color: s.ink }}
- >
- {s.name} {Math.round(s.pct)}%
- </span>
- )}
- </span>
- ))}
- </div>
- {/* Only what the bar could not label itself. A key that repeats every
- segment makes the inline labels redundant rather than helpful. */}
- <div className="flex flex-wrap gap-x-4 gap-y-1 font-mono text-[10px] text-[var(--color-text-tertiary)]">
- {segments
- .filter((s) => s.pct < INLINE_LABEL_MIN_PCT)
- .map((s) => (
- <span key={s.name} className="inline-flex items-center">
- <span
- aria-hidden
- className="mr-1.5 inline-block h-1.5 w-1.5 rounded-sm"
- style={{ background: s.bg }}
- />
- {s.name}{" "}
- <span className="ml-1 tabular-nums text-[var(--color-text-secondary)]">
- {Math.round(s.pct)}%
- </span>
- </span>
- ))}
- </div>
- </div>
+ <ProportionBar
+ label="Files by language"
+ maxSegments={maxShown}
+ othersLabel={() => "Other"}
+ segments={Object.entries(distribution).map(([name, count]) => ({
+ key: name,
+ label: name,
+ value: count,
+ }))}
+ />
);
}
diff --git a/packages/ui/src/overview/overview-model.ts b/packages/ui/src/overview/overview-model.ts
index 179247b35..3e1b38ae2 100644
--- a/packages/ui/src/overview/overview-model.ts
+++ b/packages/ui/src/overview/overview-model.ts
@@ -169,14 +169,16 @@ export function buildReads(summary: OverviewSummaryResponse, routes: OverviewRou
? {
bar: [
{
- fraction: prosePages / docPages,
- color: "var(--color-accent-fill)",
- title: `${formatNumber(prosePages)} pages with model-written prose`,
+ key: "prose",
+ label: "Pages with model-written prose",
+ value: prosePages,
+ detail: formatNumber(prosePages),
},
{
- fraction: withoutProse / docPages,
- color: "color-mix(in srgb, var(--color-accent-fill) 30%, var(--color-bg-inset))",
- title: `${formatNumber(withoutProse)} pages built from the index alone`,
+ key: "index",
+ label: "Pages built from the index alone",
+ value: withoutProse,
+ detail: formatNumber(withoutProse),
},
],
}
diff --git a/packages/ui/src/overview/reads-column.tsx b/packages/ui/src/overview/reads-column.tsx
index 8649f2e86..da8e344cc 100644
--- a/packages/ui/src/overview/reads-column.tsx
+++ b/packages/ui/src/overview/reads-column.tsx
@@ -1,14 +1,8 @@
import * as React from "react";
+import { ProportionBar, type ProportionSegment } from "../shared/proportion-bar";
-export interface ReadBarSegment {
- /** Share of the whole, 0–1. */
- fraction: number;
- /** CSS colour. Keep to accent tints so the bar stays inside the one-accent
- * rule; semantic red/amber/green belong to health, not to proportions. */
- color: string;
- /** Tooltip text for this segment. */
- title: string;
-}
+/** One segment of a row's split; drawn on the shared share bar. */
+export type ReadBarSegment = ProportionSegment;
export interface ReadItem {
key: string;
@@ -84,19 +78,13 @@ export function ReadsColumn({
</span>
{item.bar && item.bar.length > 0 && (
- <span className="mt-2 flex h-1 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {item.bar.map((seg, si) => (
- <span
- key={si}
- title={seg.title}
- className="h-full"
- style={{
- width: `${Math.max(0, Math.min(1, seg.fraction)) * 100}%`,
- background: seg.color,
- }}
- />
- ))}
- </span>
+ <ProportionBar
+ className="mt-2"
+ label={item.label}
+ size="sm"
+ legend={false}
+ segments={item.bar}
+ />
)}
<span className="mt-1.5 block text-[11px] leading-relaxed text-[var(--color-text-tertiary)] [text-wrap:pretty]">
diff --git a/packages/ui/src/owners/owner-profile.tsx b/packages/ui/src/owners/owner-profile.tsx
index b40ea9798..827b87352 100644
--- a/packages/ui/src/owners/owner-profile.tsx
+++ b/packages/ui/src/owners/owner-profile.tsx
@@ -10,7 +10,7 @@ import { OverviewSection, SectionLink } from "../overview/section";
import { ReadsColumn, type ReadItem } from "../overview/reads-column";
import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
import { EmptyState } from "../shared/empty-state";
-import { rampStep } from "../lib/ramp";
+import { ProportionBar } from "../shared/proportion-bar";
import { formatCompact, formatRelativeTimeOrNull } from "../lib/format";
import { OwnerAvatar } from "./owner-avatar";
@@ -264,9 +264,8 @@ export function OwnerProfileView({
* reader to compare bars that are all measuring different denominators. One
* bar shows the split, and the key carries the share.
*
- * The ramp, not a hue per directory: these are ordered shares of one whole, so
- * position is the encoding. Five unrelated colours for five directories is the
- * language-donut anti-pattern.
+ * The share steps, not a hue per directory: these are ordered shares of one
+ * whole, so position is the encoding.
*/
function OwnershipFootprint({
modules,
@@ -279,7 +278,6 @@ function OwnershipFootprint({
hrefForModule?: ((modulePath: string) => string) | undefined;
LinkComponent?: React.ElementType | undefined;
}) {
- const A = LinkComponent ?? "a";
const ordered = [...modules].sort((a, b) => b.file_count - a.file_count);
const total = ordered.reduce((sum, m) => sum + m.file_count, 0);
@@ -300,54 +298,19 @@ function OwnershipFootprint({
description="Ownership by directory appears after the next git sync."
/>
) : (
- <>
- <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- {ordered.map((m, i) => (
- <span
- key={m.module_path}
- title={`${m.module_path}: ${m.file_count.toLocaleString()} owned files`}
- className="h-full"
- style={{
- width: `${(m.file_count / total) * 100}%`,
- background: rampStep(i),
- }}
- />
- ))}
- </div>
- <ul className="flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:gap-x-6 sm:gap-y-2">
- {ordered.map((m, i) => {
- const href = hrefForModule?.(m.module_path);
- const label = (
- <>
- <span
- aria-hidden
- className="h-2 w-2 shrink-0 rounded-[2px]"
- style={{ background: rampStep(i) }}
- />
- <span className="font-mono text-xs text-[var(--color-text-primary)] transition-colors group-hover:text-[var(--color-accent-primary)] [overflow-wrap:anywhere]">
- {m.module_path}
- </span>
- <span className="text-xs tabular-nums text-[var(--color-text-tertiary)]">
- {m.file_count.toLocaleString()}{" "}
- {m.file_count === 1 ? "file" : "files"} ·{" "}
- {Math.round(m.dominant_pct * 100)}% theirs
- </span>
- </>
- );
- return (
- <li key={m.module_path} className="min-w-0">
- {href ? (
- <A href={href} className="group flex items-center gap-2 no-underline">
- {label}
- </A>
- ) : (
- <span className="flex items-center gap-2">{label}</span>
- )}
- </li>
- );
- })}
- </ul>
- </>
+ <ProportionBar
+ label="Owned files by directory"
+ // Every directory keeps its own link; past the fifth they share the tail step.
+ maxSegments={Infinity}
+ segments={ordered.map((m) => ({
+ key: m.module_path,
+ label: m.module_path,
+ value: m.file_count,
+ detail: `${m.file_count.toLocaleString()} ${m.file_count === 1 ? "file" : "files"} · ${Math.round(m.dominant_pct * 100)}% theirs`,
+ ...(hrefForModule ? { href: hrefForModule(m.module_path) } : {}),
+ }))}
+ LinkComponent={LinkComponent}
+ />
)}
</OverviewSection>
);
@@ -584,14 +547,14 @@ function LeadPartner({
/* -------------------------------------------------------------------------- */
/**
- * Commit mix, down the accent ramp.
+ * Commit mix, as one share bar.
*
* The colour map this replaced keyed on `feat`, `docs`, `test`, `chore` and
* `perf`. The endpoint returns `feature`, `fix`, `refactor` and `dependency`,
* so four of the five colours were unreachable and the largest category fell
* through to the default — a palette that had never once rendered as designed.
- * Ordered shares of one whole want the ramp, where position is the magnitude,
- * not a hue per category.
+ * Ordered shares of one whole want the share steps, where position is the
+ * magnitude, not a hue per category.
*
* Zero-count categories are dropped rather than rendered as an empty track:
* the endpoint returns the full key set, so a contributor who has never
@@ -619,24 +582,16 @@ function CommitMix({ categories }: { categories: Record<string, number> }) {
description="Commit classification runs during indexing and fills this in on the next sync."
/>
) : (
- <dl className="flex max-w-[420px] flex-col gap-3">
- {entries.map(([category, n], i) => (
- <div key={category}>
- <div className="flex items-baseline justify-between gap-3 text-xs">
- <dt className="capitalize text-[var(--color-text-secondary)]">{category}</dt>
- <dd className="tabular-nums text-[var(--color-text-tertiary)]">
- {n.toLocaleString()} · {pct(n, total)}%
- </dd>
- </div>
- <div className="mt-1.5 h-1 overflow-hidden rounded-full bg-[var(--color-bg-inset)]">
- <span
- className="block h-full"
- style={{ width: `${(n / total) * 100}%`, background: rampStep(i) }}
- />
- </div>
- </div>
- ))}
- </dl>
+ <ProportionBar
+ className="max-w-[420px]"
+ label="Commits by type"
+ segments={entries.map(([category, n]) => ({
+ key: category,
+ label: category.charAt(0).toUpperCase() + category.slice(1),
+ value: n,
+ detail: `${n.toLocaleString()} · ${pct(n, total)}%`,
+ }))}
+ />
)}
</OverviewSection>
);
diff --git a/packages/ui/src/owners/ownership-distribution-bar.tsx b/packages/ui/src/owners/ownership-distribution-bar.tsx
index 0a7bc66b4..12f3c1625 100644
--- a/packages/ui/src/owners/ownership-distribution-bar.tsx
+++ b/packages/ui/src/owners/ownership-distribution-bar.tsx
@@ -1,6 +1,6 @@
import * as React from "react";
import type { OwnerListEntry } from "@repowise-dev/types/owners";
-import { RAMP_TAIL, rampStep } from "../lib/ramp";
+import { ProportionBar, SHARE_STEPS } from "../shared/proportion-bar";
interface OwnershipDistributionBarProps {
owners: OwnerListEntry[];
@@ -12,32 +12,16 @@ interface OwnershipDistributionBarProps {
LinkComponent?: React.ElementType | undefined;
}
-// Five ramp steps, then the tail. The old version drew ten segments in ten
-// unrelated hues, which spent the page's entire colour budget on a
-// distinction that carries no information: two contributors being rose and
-// teal tells you nothing about either. Position in the ramp means share, so
-// the bar now reads left to right as "most owned to least".
-const TOP_N = 5;
-
-interface Segment {
- owner: OwnerListEntry | null;
- label: string;
- files: number;
- pct: number;
- fill: string;
-}
-
/**
* How owned files spread across contributors, as one proportional bar.
*
* The point is the shape: a bar dominated by one or two segments is a
- * concentration risk, an even spread is healthy. Segments and legend entries
- * drill into the owner profile.
+ * concentration risk, an even spread is healthy. Legend entries drill into
+ * the owner profile.
*
- * A server component. It had no state, and the previous `onSelect`-only API
- * forced every parent to be a client component just to route a click. It now
- * takes `hrefFor` as well, so a server-rendered page links and only a page
- * that genuinely needs the callback pays for hydration.
+ * A server component. It takes `hrefFor` as well as `onSelect`, so a
+ * server-rendered page links and only a page that genuinely needs the
+ * callback pays for hydration.
*/
export function OwnershipDistributionBar({
owners,
@@ -46,105 +30,24 @@ export function OwnershipDistributionBar({
hrefFor,
LinkComponent,
}: OwnershipDistributionBarProps) {
- const sorted = [...owners].sort((a, b) => b.files_owned - a.files_owned);
- const totalFiles = sorted.reduce((s, o) => s + o.files_owned, 0);
- if (sorted.length === 0 || totalFiles === 0) return null;
-
- const top = sorted.slice(0, TOP_N);
- const restFiles = totalFiles - top.reduce((s, o) => s + o.files_owned, 0);
- const restCount = Math.max(0, totalContributors - top.length);
-
- const segments: Segment[] = top.map((o, i) => ({
- owner: o,
- label: o.name || o.email || "unknown",
- files: o.files_owned,
- pct: (o.files_owned / totalFiles) * 100,
- fill: rampStep(i),
- }));
- if (restFiles > 0 && restCount > 0) {
- segments.push({
- owner: null,
- label: `${restCount.toLocaleString()} others`,
- files: restFiles,
- pct: (restFiles / totalFiles) * 100,
- fill: RAMP_TAIL,
- });
- }
-
- const A = LinkComponent ?? "a";
-
+ // The fold names every contributor past the shown ones, not only the
+ // loaded page of them.
+ const others = Math.max(0, totalContributors - SHARE_STEPS.length);
return (
- <div className="flex flex-col gap-3">
- <div className="flex h-2.5 w-full overflow-hidden rounded-[3px]">
- {segments.map((s) => (
- <span
- key={s.owner?.key ?? "__rest"}
- className="h-full min-w-[3px] border-r border-[var(--color-bg-root)] last:border-r-0"
- style={{ width: `${s.pct}%`, background: s.fill }}
- title={`${s.label}: ${s.files.toLocaleString()} files (${s.pct.toFixed(1)}%)`}
- />
- ))}
- </div>
-
- {/* Legend. Names wrap rather than truncate — the old one capped each
- entry at 140px, so a long name was reported to the reader as a
- shorter name. */}
- <div className="flex flex-wrap gap-x-5 gap-y-1.5 text-xs">
- {segments.map((s) => {
- const body = (
- <>
- <span
- aria-hidden
- className="mt-[5px] h-2 w-2 shrink-0 rounded-[2px]"
- style={{ background: s.fill }}
- />
- <span className="text-[var(--color-text-secondary)] [text-wrap:pretty]">
- {s.label}
- </span>
- <span className="shrink-0 font-mono tabular-nums text-[var(--color-text-tertiary)]">
- {Math.round(s.pct)}%
- </span>
- </>
- );
- const cls = "flex items-start gap-1.5 text-left";
- if (!s.owner) {
- return (
- <span key="__rest" className={cls}>
- {body}
- </span>
- );
- }
- if (hrefFor) {
- return (
- <A
- key={s.owner.key}
- href={hrefFor(s.owner)}
- className={`${cls} no-underline hover:text-[var(--color-text-primary)]`}
- >
- {body}
- </A>
- );
- }
- if (onSelect) {
- const owner = s.owner;
- return (
- <button
- key={owner.key}
- type="button"
- onClick={() => onSelect(owner)}
- className={`${cls} hover:text-[var(--color-text-primary)]`}
- >
- {body}
- </button>
- );
- }
- return (
- <span key={s.owner.key} className={cls}>
- {body}
- </span>
- );
- })}
- </div>
- </div>
+ <ProportionBar
+ label="Owned files by contributor"
+ segments={owners.map((o) => ({
+ key: o.key,
+ label: o.name || o.email || "unknown",
+ value: o.files_owned,
+ ...(hrefFor
+ ? { href: hrefFor(o) }
+ : onSelect
+ ? { onSelect: () => onSelect(o) }
+ : {}),
+ }))}
+ othersLabel={(n) => `${Math.max(n, others).toLocaleString()} others`}
+ LinkComponent={LinkComponent}
+ />
);
}
diff --git a/packages/ui/src/refactoring/opportunity.ts b/packages/ui/src/refactoring/opportunity.ts
index 739b70ccf..3e37bbd63 100644
--- a/packages/ui/src/refactoring/opportunity.ts
+++ b/packages/ui/src/refactoring/opportunity.ts
@@ -164,12 +164,12 @@ export function salienceOrder(marks: StructuralMark[]): string[] {
}
/**
- * Two hues, then neutrals - the pattern the commits area chart already uses.
+ * Two hues, then neutrals.
*
- * The accent/secondary pair, and deliberately not the sequential
- * `--color-ramp-*` steps: globals.css reserves the ramp for magnitude, so
- * spending it on unrelated categories would claim an order the types do not
- * have, and it would add orange rather than reduce it. Type is carried in full
+ * The accent/secondary pair, and deliberately not the `--color-share-*`
+ * steps: those are for shares of a whole, where position means magnitude, so
+ * spending them on unrelated categories would claim an order the types do not
+ * have. Type is carried in full
* by the mark's shape, and named in the legend and the hover card, so hue here
* only ranks attention - which is why the tail can recede into neutrals without
* anything becoming unreadable.
diff --git a/packages/ui/src/refactoring/structural-map.tsx b/packages/ui/src/refactoring/structural-map.tsx
index 15422933e..dfceb7b84 100644
--- a/packages/ui/src/refactoring/structural-map.tsx
+++ b/packages/ui/src/refactoring/structural-map.tsx
@@ -34,9 +34,8 @@
* six `--color-refactor-*` accents separating categories where two types were
* 96% of the data, one of them the same green as the health badge beside it -
* was against six hues over the whole plan list, and does not reach a two-hue
- * pair over the four structural types. The sequential `--color-ramp-*` steps
- * stay out of it: globals.css reserves them for magnitude, and they would add
- * orange rather than reduce it.
+ * pair over the four structural types. The `--color-share-*` steps
+ * stay out of it: globals.css reserves them for shares of a whole.
*
* Every mark also carries a separating stroke, which is what actually makes
* it visible: the neutral tiers sit under 2.5:1 against the page in both
diff --git a/packages/ui/src/shared/index.ts b/packages/ui/src/shared/index.ts
index ce9cb6cc1..31a005166 100644
--- a/packages/ui/src/shared/index.ts
+++ b/packages/ui/src/shared/index.ts
@@ -88,3 +88,11 @@ export { RowActions, type RowAction } from "./row-actions";
export * from "./entity";
export { ThemeToggle, type ThemeToggleProps } from "./theme-toggle";
export { resolveToken, resolveTokens, useThemeVersion } from "./use-theme-tokens";
+export {
+ ProportionBar,
+ SHARE_STEPS,
+ SHARE_TAIL,
+ shareColor,
+ type ProportionBarProps,
+ type ProportionSegment,
+} from "./proportion-bar";
diff --git a/packages/ui/src/shared/proportion-bar.tsx b/packages/ui/src/shared/proportion-bar.tsx
new file mode 100644
index 000000000..e158d1258
--- /dev/null
+++ b/packages/ui/src/shared/proportion-bar.tsx
@@ -0,0 +1,217 @@
+import * as React from "react";
+import { cn } from "../lib/cn";
+
+/**
+ * The share steps, largest share first. Literal strings so Tailwind's scan
+ * keeps the tokens; see `--color-share-*` in globals.css.
+ */
+export const SHARE_STEPS = [
+ "var(--color-share-1)",
+ "var(--color-share-2)",
+ "var(--color-share-3)",
+ "var(--color-share-4)",
+ "var(--color-share-5)",
+] as const;
+
+/** The collapsed remainder: present, but not a step. */
+export const SHARE_TAIL = "var(--color-share-tail)";
+
+/** Fill for the segment at `rank` (0 = largest). Past the last step, the tail. */
+export function shareColor(rank: number): string {
+ return SHARE_STEPS[rank] ?? SHARE_TAIL;
+}
+
+export interface ProportionSegment {
+ key: string;
+ label: string;
+ value: number;
+ /** Legend figure. Defaults to the rounded share ("42%"). */
+ detail?: string | undefined;
+ /**
+ * Semantic fill, only for segments that are a verdict (health band,
+ * severity, freshness). Everything else takes the share steps.
+ */
+ color?: string | undefined;
+ /** An unitemised remainder ("others"): drawn last, in the tail step. */
+ tail?: boolean | undefined;
+ href?: string | undefined;
+ onSelect?: (() => void) | undefined;
+}
+
+export interface ProportionBarProps {
+ segments: ProportionSegment[];
+ /** What the bar splits, for assistive tech: "Owned files by contributor". */
+ label: string;
+ /**
+ * Largest first (default). Turn off for an ordered scale (health bands,
+ * severity, confidence) whose order is the point; steps then follow it.
+ */
+ sort?: boolean;
+ /** Named segments before the rest fold into one tail. Default 5, one per step. */
+ maxSegments?: number;
+ /** Label for the folded tail. */
+ othersLabel?: (count: number) => string;
+ /** Default true. Off where the figure beside the bar already names the split. */
+ legend?: boolean;
+ /** `sm` for a bar inside a line of text, `md` (default) standing alone. */
+ size?: "sm" | "md";
+ LinkComponent?: React.ElementType | undefined;
+ className?: string | undefined;
+}
+
+interface Row {
+ key: string;
+ label: string;
+ value: number;
+ detail: string;
+ fill: string;
+ href?: string | undefined;
+ onSelect?: (() => void) | undefined;
+}
+
+function pctText(value: number, total: number): string {
+ const pct = (value / total) * 100;
+ return pct > 0 && pct < 1 ? "<1%" : `${Math.round(pct)}%`;
+}
+
+function buildRows(
+ segments: ProportionSegment[],
+ sort: boolean,
+ maxSegments: number,
+ othersLabel: (count: number) => string,
+): { rows: Row[]; total: number } {
+ const live = segments.filter((s) => Number.isFinite(s.value) && s.value > 0);
+ const named = live.filter((s) => !s.tail);
+ const tails = live.filter((s) => s.tail);
+ if (sort) named.sort((a, b) => b.value - a.value);
+
+ const shown = named.slice(0, maxSegments);
+ const folded = named.slice(maxSegments);
+ const tailSegments: ProportionSegment[] = [...tails];
+ if (folded.length > 0) {
+ tailSegments.push({
+ key: "__others",
+ label: othersLabel(folded.length),
+ value: folded.reduce((s, x) => s + x.value, 0),
+ });
+ }
+
+ const total = live.reduce((s, x) => s + x.value, 0);
+ const toRow = (s: ProportionSegment, fill: string): Row => ({
+ key: s.key,
+ label: s.label,
+ value: s.value,
+ detail: s.detail ?? pctText(s.value, total),
+ fill,
+ href: s.href,
+ onSelect: s.onSelect,
+ });
+ return {
+ rows: [
+ ...shown.map((s, i) => toRow(s, s.color ?? shareColor(i))),
+ ...tailSegments.map((s) => toRow(s, s.color ?? SHARE_TAIL)),
+ ],
+ total,
+ };
+}
+
+/**
+ * A share of a whole, as one bar and a legend.
+ *
+ * Every proportion in the product goes through this, so they all read the
+ * same: ink steps from strongest to faintest, largest share first, hairline
+ * gaps between segments, the long tail folded into "N others". Hue is kept
+ * for bars whose segments are a verdict, which pass `color`.
+ *
+ * With the legend on, the legend is the accessible reading (a labelled list)
+ * and the bar is decoration; with it off, the bar carries the summary itself.
+ */
+export function ProportionBar({
+ segments,
+ label,
+ sort = true,
+ maxSegments = SHARE_STEPS.length,
+ othersLabel = (n) => `${n.toLocaleString()} others`,
+ legend = true,
+ size = "md",
+ LinkComponent,
+ className,
+}: ProportionBarProps) {
+ const { rows, total } = buildRows(segments, sort, maxSegments, othersLabel);
+ if (total === 0) return null;
+
+ const summary = `${label}: ${rows.map((r) => `${r.label} ${r.detail}`).join(", ")}`;
+
+ return (
+ <div className={cn("flex min-w-0 flex-col gap-2", className)}>
+ <div
+ {...(legend ? { "aria-hidden": true } : { role: "img", "aria-label": summary })}
+ className={cn(
+ "flex w-full gap-px overflow-hidden rounded-full",
+ size === "sm" ? "h-1.5" : "h-2.5",
+ )}
+ >
+ {rows.map((r) => (
+ <span
+ key={r.key}
+ title={`${r.label}: ${r.detail}`}
+ className="h-full min-w-[2px]"
+ style={{ flex: `${r.value} 1 0%`, background: r.fill }}
+ />
+ ))}
+ </div>
+ {legend && <ProportionLegend rows={rows} label={label} LinkComponent={LinkComponent} />}
+ </div>
+ );
+}
+
+function ProportionLegend({
+ rows,
+ label,
+ LinkComponent,
+}: {
+ rows: Row[];
+ label: string;
+ LinkComponent?: React.ElementType | undefined;
+}) {
+ const A = LinkComponent ?? "a";
+ return (
+ <ul aria-label={label} className="flex flex-wrap gap-x-4 gap-y-1 text-xs">
+ {rows.map((r) => {
+ const body = (
+ <>
+ <span
+ aria-hidden
+ className="h-2 w-2 shrink-0 rounded-[2px]"
+ style={{ background: r.fill }}
+ />
+ <span className="min-w-0 text-[var(--color-text-secondary)] [overflow-wrap:anywhere]">
+ {r.label}
+ </span>
+ <span className="shrink-0 tabular-nums text-[var(--color-text-tertiary)]">
+ {r.detail}
+ </span>
+ </>
+ );
+ const item = "flex min-w-0 items-center gap-1.5";
+ // Interactive entries keep a 32px target on touch; desktop rows stay tight.
+ const hit = `${item} min-h-8 text-left no-underline sm:min-h-0 [&:hover>span:nth-child(2)]:text-[var(--color-text-primary)]`;
+ return (
+ <li key={r.key} className="min-w-0">
+ {r.href ? (
+ <A href={r.href} className={hit}>
+ {body}
+ </A>
+ ) : r.onSelect ? (
+ <button type="button" onClick={r.onSelect} className={hit}>
+ {body}
+ </button>
+ ) : (
+ <span className={item}>{body}</span>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ );
+}
diff --git a/packages/ui/src/wiki/git-history-panel.tsx b/packages/ui/src/wiki/git-history-panel.tsx
index 71123baa8..fbb186200 100644
--- a/packages/ui/src/wiki/git-history-panel.tsx
+++ b/packages/ui/src/wiki/git-history-panel.tsx
@@ -17,12 +17,6 @@ const AUTHOR_COLORS = [
];
const AUTHOR_COLOR_FALLBACK = "bg-gray-500";
-const AUTHOR_BAR_COLORS = [
- "#3b82f6", "#a855f7", "#22c55e", "#eab308",
- "#ec4899", "#6366f1", "#14b8a6", "#f97316",
-];
-const AUTHOR_BAR_FALLBACK = "#6b7280";
-
function authorColorIndex(name: string): number {
let hash = 0;
for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
@@ -195,11 +189,8 @@ export function GitHistoryPanel({ git }: GitHistoryPanelProps) {
<div className="h-1 w-full rounded-full bg-[var(--color-bg-elevated)] ml-7">
<div
className="h-1 rounded-full transition-all"
- style={{
- width: `${share * 100}%`,
- backgroundColor:
- AUTHOR_BAR_COLORS[authorColorIndex(author.name)] ?? AUTHOR_BAR_FALLBACK,
- }}
+ // One share step for every row: the length is the reading.
+ style={{ width: `${share * 100}%`, backgroundColor: "var(--color-share-1)" }}
/>
</div>
)}
diff --git a/packages/ui/styles/globals.css b/packages/ui/styles/globals.css
index 9a072838e..6cb6cf0a0 100644
--- a/packages/ui/styles/globals.css
+++ b/packages/ui/styles/globals.css
@@ -119,21 +119,21 @@
--color-model-hover: var(--color-plum-600);
--color-model-muted: color-mix(in srgb, var(--color-accent-secondary) 14%, transparent);
- /* Accent ramp — the one sanctioned way to colour a proportion: ordered
- shares of a whole (a stacked bar, a histogram, an area chart), stepped
- from the accent toward the page ground. Sequential, so position in the
- ramp means magnitude; NOT for unrelated categories, which want either the
- accent/secondary pair or plain neutrals.
-
- Defined per theme rather than as one set of color-mix percentages,
- because the mix that recedes gracefully into near-black disappears
- entirely into cream. Light also starts a step down from full #f59520,
- which is louder than it needs to be on a warm paper ground. */
- --color-ramp-1: #e08a12;
- --color-ramp-2: color-mix(in srgb, var(--color-accent-fill) 76%, var(--color-bg-inset));
- --color-ramp-3: color-mix(in srgb, var(--color-accent-fill) 56%, var(--color-bg-inset));
- --color-ramp-4: color-mix(in srgb, var(--color-accent-fill) 40%, var(--color-bg-inset));
- --color-ramp-5: color-mix(in srgb, var(--color-accent-fill) 26%, var(--color-bg-inset));
+ /* Share steps — the one palette for a share-of-whole bar (ProportionBar):
+ ink stepped toward the well, largest share first, `tail` for the
+ collapsed rest. No hue, so a proportion never reads as navigation (orange),
+ model work (plum) or a health verdict (green/amber/red). Steps 1-5 clear
+ 3:1 against the page and a card in both themes; the tail does not and is
+ always named in the legend.
+
+ Per theme because the same mix that holds on cream fades out on
+ near-black. */
+ --color-share-1: color-mix(in srgb, var(--color-text-primary) 86%, var(--color-bg-inset));
+ --color-share-2: color-mix(in srgb, var(--color-text-primary) 74%, var(--color-bg-inset));
+ --color-share-3: color-mix(in srgb, var(--color-text-primary) 63%, var(--color-bg-inset));
+ --color-share-4: color-mix(in srgb, var(--color-text-primary) 54%, var(--color-bg-inset));
+ --color-share-5: color-mix(in srgb, var(--color-text-primary) 47%, var(--color-bg-inset));
+ --color-share-tail: color-mix(in srgb, var(--color-text-primary) 20%, var(--color-bg-inset));
/* Supporting cast beside an accent series. Same idea, no hue. */
--color-neutral-1: color-mix(in srgb, var(--color-text-tertiary) 62%, var(--color-bg-inset));
--color-neutral-2: color-mix(in srgb, var(--color-text-tertiary) 40%, var(--color-bg-inset));
@@ -501,13 +501,14 @@
and need no override; see the light block for the family. */
--color-model-hover: var(--color-plum-200);
- /* Accent ramp — see the light block. Steeper here: mixing toward #0a0a0b
- loses luminance fast, so the same percentages would bottom out invisible. */
- --color-ramp-1: #f59520;
- --color-ramp-2: color-mix(in srgb, var(--color-accent-fill) 64%, var(--color-bg-inset));
- --color-ramp-3: color-mix(in srgb, var(--color-accent-fill) 42%, var(--color-bg-inset));
- --color-ramp-4: color-mix(in srgb, var(--color-accent-fill) 27%, var(--color-bg-inset));
- --color-ramp-5: color-mix(in srgb, var(--color-accent-fill) 16%, var(--color-bg-inset));
+ /* Share steps — see the light block. Light ink on near-black stays visible
+ lower down, so the steps spread wider before the 3:1 floor. */
+ --color-share-1: color-mix(in srgb, var(--color-text-primary) 86%, var(--color-bg-inset));
+ --color-share-2: color-mix(in srgb, var(--color-text-primary) 71%, var(--color-bg-inset));
+ --color-share-3: color-mix(in srgb, var(--color-text-primary) 58%, var(--color-bg-inset));
+ --color-share-4: color-mix(in srgb, var(--color-text-primary) 48%, var(--color-bg-inset));
+ --color-share-5: color-mix(in srgb, var(--color-text-primary) 40%, var(--color-bg-inset));
+ --color-share-tail: color-mix(in srgb, var(--color-text-primary) 18%, var(--color-bg-inset));
--color-neutral-1: color-mix(in srgb, var(--color-text-tertiary) 70%, var(--color-bg-inset));
--color-neutral-2: color-mix(in srgb, var(--color-text-tertiary) 45%, var(--color-bg-inset));
--color-neutral-3: color-mix(in srgb, var(--color-text-tertiary) 26%, var(--color-bg-inset));
diff --git a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx b/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
index ba7c381cc..7ef14cbb6 100644
--- a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
+++ b/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
@@ -6,6 +6,7 @@ import { ConfidenceVsFreshnessMatrix } from "@repowise-dev/ui/coverage/confidenc
import { FreshnessTableWithRegenerate } from "@/components/coverage/freshness-table-wrapper";
import type { DocPage } from "@repowise-dev/types/docs";
import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
+import { ProportionBar } from "@repowise-dev/ui/shared/proportion-bar";
import { listAllPages } from "@/lib/api/pages";
import { formatNumber } from "@repowise-dev/ui/lib/format";
import { getTranslations } from "next-intl/server";
@@ -96,22 +97,15 @@ export default async function CoveragePage({
<p className="text-xs text-[var(--color-text-tertiary)] mb-1.5">
{t("distribution")}
</p>
- <div className="h-3 rounded-full overflow-hidden flex">
- <div className="bg-[var(--color-fresh)]" style={{ width: `${(fresh / pages.length) * 100}%` }} />
- <div className="bg-[var(--color-stale)]" style={{ width: `${(stale / pages.length) * 100}%` }} />
- <div className="bg-[var(--color-outdated)]" style={{ width: `${(outdated / pages.length) * 100}%` }} />
- </div>
- <div className="flex gap-4 mt-1.5 text-xs text-[var(--color-text-tertiary)]">
- <span className="flex items-center gap-1">
- <span className="h-2 w-2 rounded-full bg-[var(--color-fresh)]" /> {t("fresh")}
- </span>
- <span className="flex items-center gap-1">
- <span className="h-2 w-2 rounded-full bg-[var(--color-stale)]" /> {t("stale")}
- </span>
- <span className="flex items-center gap-1">
- <span className="h-2 w-2 rounded-full bg-[var(--color-outdated)]" /> {t("outdated")}
- </span>
- </div>
+ <ProportionBar
+ label={t("distribution")}
+ sort={false}
+ segments={[
+ { key: "fresh", label: t("fresh"), value: fresh, color: "var(--color-fresh)" },
+ { key: "stale", label: t("stale"), value: stale, color: "var(--color-stale)" },
+ { key: "outdated", label: t("outdated"), value: outdated, color: "var(--color-outdated)" },
+ ]}
+ />
</div>
)}