// ======================================== // Graph Sidebar Component // ======================================== // Sidebar with legend and node details for Graph Explorer import { useIntl } from 'react-intl'; import { X, Info, Network, FileText, GitBranch, Zap } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/Button'; import { Badge } from '@/components/ui/Badge'; import type { GraphNode, NodeType, EdgeType } from '@/types/graph-explorer'; export interface GraphSidebarProps { /** Selected node */ selectedNode: GraphNode | null; /** Legend visibility */ showLegend?: boolean; /** On close callback */ onClose: () => void; } /** * Node type legend item */ interface LegendItem { type: NodeType; label: string; color: string; icon: React.ElementType; } /** * Graph sidebar component */ export function GraphSidebar({ selectedNode, showLegend = true, onClose }: GraphSidebarProps) { const { formatMessage } = useIntl(); const legendItems: LegendItem[] = [ { type: 'component', label: formatMessage({ id: 'graph.legend.component' }), color: 'bg-blue-500', icon: Network, }, { type: 'module', label: formatMessage({ id: 'graph.legend.module' }), color: 'bg-blue-500', icon: FileText, }, { type: 'class', label: formatMessage({ id: 'graph.legend.class' }), color: 'bg-green-500', icon: GitBranch, }, { type: 'function', label: formatMessage({ id: 'graph.legend.function' }), color: 'bg-orange-500', icon: Zap, }, { type: 'variable', label: formatMessage({ id: 'graph.legend.variable' }), color: 'bg-cyan-500', icon: Info, }, ]; const edgeLegendItems = [ { type: 'imports' as EdgeType, label: formatMessage({ id: 'graph.legend.imports' }), color: 'stroke-gray-500', dashArray: '', }, { type: 'calls' as EdgeType, label: formatMessage({ id: 'graph.legend.calls' }), color: 'stroke-green-500', dashArray: '', }, { type: 'extends' as EdgeType, label: formatMessage({ id: 'graph.legend.extends' }), color: 'stroke-purple-500', dashArray: 'stroke-dasharray', }, ]; return (
{selectedNode.data.filePath}
{selectedNode.data.lineNumber}
{selectedNode.data.category}
{selectedNode.data.lineCount} lines
{selectedNode.data.documentation}
{formatMessage({ id: 'graph.sidebar.instructions' })}