"use client"; import { useEffect, useState } from "react"; const TYPE_STYLES: Record = { Function: { color: "var(--accent)", bg: "var(--accent-glow)" }, Class: { color: "var(--green)", bg: "var(--green-dim)" }, Method: { color: "var(--yellow)", bg: "var(--yellow-dim)" }, }; interface Props { onSelectSymbol: (uid: string) => void; } export function ClusterPanel({ onSelectSymbol }: Props) { const [clusters, setClusters] = useState([]); const [loading, setLoading] = useState(true); const [expanded, setExpanded] = useState(null); useEffect(() => { fetch("/api/clusters") .then((r) => r.json()) .then((data) => { setClusters(data.clusters || []); setLoading(false); }) .catch(() => setLoading(false)); }, []); if (loading) { return (
{[1, 2, 3, 4].map((i) => (
))}
); } return (

Functional Clusters

{clusters.length}
{clusters.map((cluster, i) => { const members = cluster.members || []; const isOpen = expanded === cluster.uid; return (
{isOpen && (
{members.map((m: any, j: number) => { const style = TYPE_STYLES[m.type] || TYPE_STYLES.Function; return ( ); })}
)}
); })}
); } function CohesionBadge({ value }: { value: number }) { const pct = (value * 100).toFixed(0); const color = value >= 0.7 ? "var(--green)" : value >= 0.3 ? "var(--yellow)" : "var(--red)"; const bg = value >= 0.7 ? "var(--green-dim)" : value >= 0.3 ? "var(--yellow-dim)" : "var(--red-dim)"; return ( {pct}% ); }