import { memo, useState } from "react" import type { GraphEdge, GraphNode, GraphThemeColors } from "../types" interface LegendProps { nodes?: GraphNode[] edges?: GraphEdge[] isLoading?: boolean colors: GraphThemeColors } function HexagonIcon({ fill, stroke, size = 12, }: { fill: string stroke: string size?: number }) { return ( ) } function LineIcon({ color, dashed = false, }: { color: string dashed?: boolean }) { return (
) } function ChevronDownIcon({ color }: { color: string }) { return ( ) } function ChevronRightIcon({ color }: { color: string }) { return ( ) } function StatRow({ icon, label, count, expandable = false, expanded = false, onToggle, children, colors, }: { icon: React.ReactNode label: string count: number expandable?: boolean expanded?: boolean onToggle?: () => void children?: React.ReactNode colors: GraphThemeColors }) { const buttonStyle: React.CSSProperties = { display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center", width: "100%", padding: 0, outline: "none", background: "none", border: "none", cursor: expandable ? "pointer" : "default", } const leftStyle: React.CSSProperties = { display: "flex", flexDirection: "row", alignItems: "center", gap: 8, } const labelStyle: React.CSSProperties = { fontSize: 12, color: colors.textPrimary, fontWeight: 400, } const countStyle: React.CSSProperties = { fontSize: 12, color: colors.textMuted, } const childrenContainerStyle: React.CSSProperties = { paddingLeft: 10, paddingTop: 6, display: "flex", flexDirection: "column", gap: 6, } return (
{expandable && expanded && children && (
{children}
)}
) } export const Legend = memo(function Legend({ nodes = [], edges = [], isLoading: _isLoading = false, colors, }: LegendProps) { const [isExpanded, setIsExpanded] = useState(false) const [connectionsExpanded, setConnectionsExpanded] = useState(true) const memoryCount = nodes.filter((n) => n.type === "memory").length const documentCount = nodes.filter((n) => n.type === "document").length const connectionCount = edges.length const outerStyle: React.CSSProperties = { position: "absolute", zIndex: 20, overflow: "hidden", bottom: 16, left: 16, width: 214, } const cardStyle: React.CSSProperties = { borderRadius: 12, backgroundColor: colors.controlBg, border: `1px solid ${colors.controlBorder}`, boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)", } const headerBtnStyle: React.CSSProperties = { display: "flex", flexDirection: "row", alignItems: "center", gap: 6, width: "100%", cursor: "pointer", outline: "none", background: "none", border: "none", padding: 0, } const headerTextStyle: React.CSSProperties = { fontSize: 14, color: colors.textPrimary, fontWeight: 400, } const sectionLabelStyle: React.CSSProperties = { fontSize: 12, color: colors.textMuted, fontWeight: 400, textTransform: "uppercase", letterSpacing: "0.05em", } const rowStyle: React.CSSProperties = { display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center", } const rowLeftStyle: React.CSSProperties = { display: "flex", alignItems: "center", gap: 8, } const edgeLabelStyle: React.CSSProperties = { fontSize: 12, color: colors.textPrimary, } const statusRowStyle: React.CSSProperties = { display: "flex", flexDirection: "row", alignItems: "center", gap: 8, } return (
{isExpanded && (
{/* Statistics section */}
Statistics
} label="Memories" colors={colors} /> } label="Documents" colors={colors} />
{/* Memory Status section */}
Memory Status
Recent (< 24h)
Expiring soon
Forgotten
)}
) }) Legend.displayName = "Legend"