import * as React from 'react'; import { cn } from '../../shared/utils'; export type BlockColor = | 'primary' | 'chart-1' | 'chart-2' | 'chart-3' | 'chart-4' | 'chart-5' | 'success' | 'info' | 'warning' | 'destructive'; const colorTokens: Record = { primary: { bg: 'bg-primary/10', icon: 'text-primary' }, 'chart-1': { bg: 'bg-[var(--chart-1)]/15', icon: 'text-[var(--chart-1)]' }, 'chart-2': { bg: 'bg-[var(--chart-2)]/15', icon: 'text-[var(--chart-2)]' }, 'chart-3': { bg: 'bg-[var(--chart-3)]/15', icon: 'text-[var(--chart-3)]' }, 'chart-4': { bg: 'bg-[var(--chart-4)]/15', icon: 'text-[var(--chart-4)]' }, 'chart-5': { bg: 'bg-[var(--chart-5)]/15', icon: 'text-[var(--chart-5)]' }, success: { bg: 'bg-success/10', icon: 'text-success' }, info: { bg: 'bg-info/10', icon: 'text-info' }, warning: { bg: 'bg-warning/10', icon: 'text-warning' }, destructive: { bg: 'bg-destructive/10', icon: 'text-destructive' }, }; export interface StatBandStat { value: string; label: string; color?: BlockColor; } export interface StatBandProps extends React.HTMLAttributes { stats: StatBandStat[]; columns?: 2 | 3 | 4; } const columnClasses: Record<2 | 3 | 4, string> = { 2: 'md:grid-cols-2', 3: 'md:grid-cols-3', 4: 'md:grid-cols-4', }; /** * Row of large highlighted stats with labels, no card chrome. * * @description * Displays a set of headline numbers (e.g. "$5.5T", "3x", "9M+") side by side, * each paired with a small muted label. Useful for social-proof or impact * sections on marketing pages. * * @ai-rules * 1. Pass 2-4 `stats`; `columns` defaults to `stats.length` capped at 4. * 2. Each stat's `color` maps to a token from `colorTokens` — never hardcode colors. * 3. This block has no background/border of its own; wrap it in a `` or section if chrome is needed. */ export function StatBand({ stats, columns, className, ...props }: StatBandProps) { const resolvedColumns = (columns ?? Math.min(stats.length, 4)) as 2 | 3 | 4; return (
{stats.map((stat, index) => { const { icon: valueColor } = colorTokens[stat.color ?? 'primary']; const isNewRow = index % resolvedColumns === 0; return (
{stat.value} {stat.label}
); })}
); }