import { Show, type JSX, splitProps } from 'solid-js'; import { cn } from '../utils/cn'; export interface StatProps extends JSX.HTMLAttributes { /** The small muted caption above the value. */ label?: string; /** The big value. A default-slot / `children` override wins over this. */ value?: string; /** A small caption below the value. */ hint?: string; } /** * A single metric / KPI tile: a muted label on top, a large value below, and an * optional hint caption. The consumer arranges tiles in their own CSS grid — this * is ONE cell. `children` (the default slot in the element) override `value` for * rich content. */ export function Stat(props: StatProps) { const [local, rest] = splitProps(props, ['label', 'value', 'hint', 'class', 'children']); return (
{local.label} {local.children ?? local.value} {/* When used directly (no slot), `value` renders; the element facade passes a {value} as `children`, so projected light-DOM content overrides `value` while `value` remains the slot's fallback. */} {local.hint}
); }