import { cn } from '@/lib/utils'; import { Sparkline } from '@/components/ui/sparkline'; export type SignalTone = 'value' | 'warn' | 'error' | 'subtitle'; export interface SignalTile { kicker: string; value: string; tone?: SignalTone; /** Optional series for a 64x20 sparkline stroked in brand cyan. */ spark?: number[]; /** When set, the tile renders as a button that navigates on click. */ onClick?: () => void; } interface SignalRailProps { tiles: SignalTile[]; className?: string; } const toneClass: Record = { value: 'text-stat-value', warn: 'text-warning', error: 'text-destructive', subtitle: 'text-stat-subtitle', }; export function SignalRail({ tiles, className }: SignalRailProps) { if (tiles.length === 0) return null; return (
{tiles.map((tile, idx) => { const inner = ( <>
{tile.kicker} {tile.value}
{tile.spark && tile.spark.length > 1 ? (
) : null} ); const cellClass = cn( 'flex items-center justify-between gap-4 px-5 py-[var(--density-tile-y)] text-left', idx > 0 && 'border-l border-card-border', tile.onClick && 'cursor-pointer transition-colors hover:bg-accent/5', ); return tile.onClick ? ( ) : (
{inner}
); })}
); }