import { memo } from "react"; import { Handle, Position } from "@xyflow/react"; import type { NodeProps, Node } from "@xyflow/react"; import { getLayerColor } from "./LayerLegend"; const complexityColors: Record = { simple: "text-node-function", moderate: "text-gold-dim", complex: "text-[#c97070]", }; export interface LayerClusterData extends Record { layerId: string; layerName: string; layerDescription: string; fileCount: number; aggregateComplexity: string; layerColorIndex: number; searchMatchCount?: number; onDrillIn: (layerId: string) => void; } export type LayerClusterFlowNode = Node; function LayerClusterNode({ data, }: NodeProps) { const color = getLayerColor(data.layerColorIndex); const complexityColor = complexityColors[data.aggregateComplexity] ?? complexityColors.simple; return (
data.onDrillIn(data.layerId)} > {/* Left color bar */}
{/* Header row */}
Layer
{data.searchMatchCount != null && data.searchMatchCount > 0 && ( {data.searchMatchCount} match{data.searchMatchCount !== 1 ? "es" : ""} )} {data.aggregateComplexity}
{/* Layer name */}
{data.layerName}
{/* Description */}
{data.layerDescription}
{/* Footer */}
{data.fileCount} file{data.fileCount !== 1 ? "s" : ""} Click to explore →
); } export default memo(LayerClusterNode);