import Link from 'next/link'; import type { ReactNode } from 'react'; import { cn } from '@/lib/cn'; import { fmtInt } from '@/lib/format'; export type BarRow = { key: string; label: ReactNode; value: number; href?: string; color?: string; hint?: ReactNode }; /** Horizontal bars (server-renderable): label · bar · value. Sorted by the caller. */ export function Bars({ rows, className, format = fmtInt, max: maxOverride, dense = false }: { rows: BarRow[]; className?: string; format?: (v: number) => string; max?: number; dense?: boolean }) { const max = maxOverride ?? Math.max(1, ...rows.map((r) => Math.abs(r.value))); if (!rows.length) return null; return ( ); } /** Tiny vertical column strip (e.g. events per day) — SVG, server-renderable. */ export function Columns({ values, width = 120, height = 28, className, color = 'var(--accent)', ariaLabel }: { values: number[]; width?: number; height?: number; className?: string; color?: string; ariaLabel?: string }) { const max = Math.max(1, ...values); const n = values.length || 1; const gap = 1; const bw = Math.max(1, (width - gap * (n - 1)) / n); return ( {values.map((v, i) => { const h = Math.max(v > 0 ? 1.5 : 0, (v / max) * (height - 1)); return 0 ? 0.85 : 0.2} rx={0.5} />; })} ); }