From 1415ed003e2fd4ceb07b88bd3e0303960c03790a Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Thu, 9 Mar 2023 14:25:23 +0000 Subject: [PATCH] :sparkles: Add an optional 'MiniMapNode' field to 'MiniMapProps'. This lets users supply a custom SVG node to render in the minimap instead of the default rectangle. --- packages/minimap/src/MiniMap.tsx | 5 ++++- packages/minimap/src/types.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/minimap/src/MiniMap.tsx b/packages/minimap/src/MiniMap.tsx index bb4a2f89..378ee4f6 100644 --- a/packages/minimap/src/MiniMap.tsx +++ b/packages/minimap/src/MiniMap.tsx @@ -64,6 +64,9 @@ function MiniMap({ pannable = false, zoomable = false, ariaLabel = 'React Flow mini map', + // Rename the field to avoid clashes with the default `MiniMapNode` component. + // Fallback to that component if none is provided. + MiniMapNode: CustomMiniMapNode = MiniMapNode, }: MiniMapProps) { const store = useStoreApi(); const svg = useRef(null); @@ -176,7 +179,7 @@ function MiniMap({ const { x, y } = getNodePositionWithOrigin(node, nodeOrigin).positionAbsolute; return ( - = (node: Node) => string; @@ -19,6 +19,7 @@ export type MiniMapProps = Omit, ' pannable?: boolean; zoomable?: boolean; ariaLabel?: string | null; + MiniMapNode?: ComponentType; }; export interface MiniMapNodeProps {