import clsx from "clsx"; import { fmt } from "@/lib/data"; import type { DatasetInfo } from "@/lib/types"; type Splits = NonNullable; export interface SplitMiniBarProps { splits: Splits; className?: string; } /* Segment palette mirrors HourBar tones: Test carries the phosphor note, Hard a softer echo, Train/Valid stay quiet teal-greys. */ const SEGMENTS: ReadonlyArray<{ key: keyof Splits; label: string; fill: string; }> = [ { key: "train", label: "Train", fill: "bg-[color-mix(in_srgb,var(--accent)_16%,var(--muted)_46%)]", }, { key: "valid", label: "Valid", fill: "bg-[color-mix(in_srgb,var(--accent)_10%,var(--muted)_30%)]", }, { key: "test", label: "Test", fill: "bg-accent/75" }, { key: "hard", label: "Hard", fill: "bg-accent/40" }, ]; /** * Compact split-distribution readout for dataset cards: one segmented * hour bar plus a mono legend. The bar is decorative; the legend carries * the numbers. */ export default function SplitMiniBar({ splits, className }: SplitMiniBarProps) { const total = SEGMENTS.reduce((sum, s) => sum + splits[s.key].hours, 0); return (
{SEGMENTS.map((s) => (
))}
{/* 2×2 legend — four columns crowd the card's narrow readout column and wrap the unit onto its own line */}
{SEGMENTS.map((s) => (
{s.label}
{fmt(splits[s.key].hours)} h
))}
); }