import React from 'react'; import { cn } from '@/lib/utils'; import type { GovernanceState, SeverityLevel } from '@/data/fabric/types'; export function FabricHeader({ eyebrow, title, blurb, trailing, }: { eyebrow: string; title: string; blurb: string; trailing?: React.ReactNode; }) { return (
{eyebrow}

{title}

{blurb}

{trailing}
); } export function FabricStat({ label, value, sub, tone = 'neutral', }: { label: string; value: React.ReactNode; sub?: string; tone?: 'neutral' | 'good' | 'warn' | 'bad' | 'gold'; }) { const toneClass = tone === 'good' ? 'text-[#5a8a6e]' : tone === 'warn' ? 'text-[#d4a853]' : tone === 'bad' ? 'text-[#b85450]' : tone === 'gold' ? 'text-[#c9b787]' : 'text-[#f5f5f5]'; return (
{label}
{value}
{sub &&
{sub}
}
); } export function GovernanceDot({ state }: { state: GovernanceState }) { const color = state === 'green' ? '#5a8a6e' : state === 'amber' ? '#d4a853' : '#b85450'; return ( ); } export function SeverityChip({ level }: { level: SeverityLevel }) { const map: Record = { critical: { bg: 'rgba(184,84,80,0.18)', fg: '#b85450', bd: 'rgba(184,84,80,0.3)', label: 'CRITICAL' }, high: { bg: 'rgba(212,168,83,0.16)', fg: '#d4a853', bd: 'rgba(212,168,83,0.3)', label: 'HIGH' }, medium: { bg: 'rgba(201,183,135,0.12)', fg: '#c9b787', bd: 'rgba(201,183,135,0.22)', label: 'MED' }, low: { bg: 'rgba(138,138,138,0.12)', fg: '#8a8a8a', bd: 'rgba(138,138,138,0.18)', label: 'LOW' }, info: { bg: 'rgba(120,170,200,0.12)', fg: '#78aac8', bd: 'rgba(120,170,200,0.2)', label: 'INFO' }, }; const t = map[level]; return ( {t.label} ); } export function FabricCard({ children, className, title, trailing, }: { children: React.ReactNode; className?: string; title?: string; trailing?: React.ReactNode; }) { return (
{(title || trailing) && (
{title &&
{title}
} {trailing}
)} {children}
); } export function FabricToolbar({ children }: { children: React.ReactNode }) { return (
{children}
); } export function FabricDrawer({ open, onClose, title, subtitle, children, }: { open: boolean; onClose: () => void; title: string; subtitle?: string; children: React.ReactNode; }) { if (!open) return null; return (
{children}
); } export function MicroBar({ value, max, tone = 'gold' }: { value: number; max: number; tone?: 'gold' | 'good' | 'warn' | 'bad' }) { const pct = Math.max(0, Math.min(100, (value / Math.max(1, max)) * 100)); const color = tone === 'good' ? '#5a8a6e' : tone === 'warn' ? '#d4a853' : tone === 'bad' ? '#b85450' : '#c9b787'; return (
); } export function Sparkline({ values, width = 120, height = 28, tone = 'gold' }: { values: readonly number[]; width?: number; height?: number; tone?: 'gold' | 'good' | 'warn' | 'bad' }) { if (values.length === 0) return ; const min = Math.min(...values); const max = Math.max(...values); const range = max - min || 1; const stepX = width / Math.max(1, values.length - 1); const path = values .map((v, i) => { const x = i * stepX; const y = height - ((v - min) / range) * height; return `${i === 0 ? 'M' : 'L'}${x.toFixed(1)},${y.toFixed(1)}`; }) .join(' '); const color = tone === 'good' ? '#5a8a6e' : tone === 'warn' ? '#d4a853' : tone === 'bad' ? '#b85450' : '#c9b787'; return ( ); } export function HeatCell({ value, max }: { value: number; max: number }) { const intensity = Math.max(0, Math.min(1, value / Math.max(1, max))); const bg = `rgba(184,84,80,${0.08 + intensity * 0.5})`; return (
{value > 0 ? value : ''}
); }