"use client"; import { motion, AnimatePresence } from "framer-motion"; import { useState } from "react"; import { ChevronDown } from "lucide-react"; interface MetricBarsProps { metrics: { label: string; score: number; status: 'pass' | 'warning' | 'fail'; category?: 'page' | 'domain' | 'ai'; details?: string; recommendation?: string; actionItems?: string[]; }[]; } export default function MetricBars({ metrics }: MetricBarsProps) { const [expandedItems, setExpandedItems] = useState>(new Set()); const getBarColor = (score: number) => { // Use brand orange colors with opacity for gradient effect if (score >= 80) return 'bg-heat-100'; if (score >= 60) return 'bg-heat-90'; if (score >= 40) return 'bg-heat-40 opacity-80'; return 'bg-heat-20'; }; const getBulletColor = (_score: number) => { // Always use heat-100 for all bullets for consistency return 'bg-heat-100'; }; const toggleExpanded = (label: string) => { const newExpanded = new Set(expandedItems); if (newExpanded.has(label)) { newExpanded.delete(label); } else { newExpanded.add(label); } setExpandedItems(newExpanded); }; // Sort metrics by score descending const sortedMetrics = [...metrics].sort((a, b) => b.score - a.score); return (
{sortedMetrics.map((metric, index) => { const isExpanded = expandedItems.has(metric.label); return (
toggleExpanded(metric.label)} > {/* Bullet and Label - fixed width */}
{metric.label}
{/* Bar container - flexible width */}
{/* Animated bar */} {/* Subtle inner glow */}
{/* Score indicator lines at key thresholds */} {[40, 60, 80].map(threshold => (
))}
{/* Score value - fixed width */}
{metric.score}%
{/* Expanded Details */} {isExpanded && metric.details && (
Status
{metric.details}
{metric.recommendation && (
Recommendation
{metric.recommendation}
)} {metric.actionItems && metric.actionItems.length > 0 && (
Action Items
    {metric.actionItems.map((item: string, i: number) => (
  • {item}
  • ))}
)}
)}
); })} {/* Summary stats */}
{metrics.filter(m => m.status === 'pass').length}
Passing
{metrics.filter(m => m.status === 'warning').length}
Warning
{metrics.filter(m => m.status === 'fail').length}
Failing
); }