From 60c39718f9f6feb864a7ef05375189f842b96a16 Mon Sep 17 00:00:00 2001 From: Robin Goupil Date: Tue, 25 Aug 2020 18:42:41 +0200 Subject: [PATCH 1/3] Allow to pass a string of FuncString for Minimap node className --- src/additional-components/MiniMap/MiniMapNode.tsx | 5 +++-- src/additional-components/MiniMap/index.tsx | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/additional-components/MiniMap/MiniMapNode.tsx b/src/additional-components/MiniMap/MiniMapNode.tsx index f6b5b4ab..93d3aa2e 100644 --- a/src/additional-components/MiniMap/MiniMapNode.tsx +++ b/src/additional-components/MiniMap/MiniMapNode.tsx @@ -6,17 +6,18 @@ interface MiniMapNodeProps { width: number; height: number; color: string; + className: string; borderRadius: number; style?: CSSProperties; } -const MiniMapNode = ({ x, y, width, height, style, color, borderRadius }: MiniMapNodeProps) => { +const MiniMapNode = ({ x, y, width, height, style, color, className, borderRadius }: MiniMapNodeProps) => { const { background, backgroundColor } = style || {}; const fill = (color || background || backgroundColor) as string; return ( string; interface MiniMapProps extends React.HTMLAttributes { nodeColor?: string | StringFunc; + nodeClassName?: string | StringFunc; nodeBorderRadius?: number; maskColor?: string; } @@ -23,6 +24,7 @@ const MiniMap = ({ style = { backgroundColor: '#f8f8f8' }, className, nodeColor = '#ddd', + nodeClassName = '', nodeBorderRadius = 5, maskColor = 'rgba(10, 10, 10, .25)', }: MiniMapProps) => { @@ -35,6 +37,7 @@ const MiniMap = ({ const elementWidth = (style.width || defaultWidth)! as number; const elementHeight = (style.height || defaultHeight)! as number; const nodeColorFunc = (nodeColor instanceof Function ? nodeColor : () => nodeColor) as StringFunc; + const nodeClassNameFunc = (nodeClassName instanceof Function ? nodeClassName : () => nodeClassName) as StringFunc; const hasNodes = nodes && nodes.length; const bb = getRectOfNodes(nodes); const viewBB: Rect = { @@ -73,6 +76,7 @@ const MiniMap = ({ width={node.__rf.width} height={node.__rf.height} style={node.style} + className={nodeClassNameFunc(node)} color={nodeColorFunc(node)} borderRadius={nodeBorderRadius} /> From 3b2be2fddb478678cab67e697f317c7a549c74c8 Mon Sep 17 00:00:00 2001 From: Robin Goupil Date: Tue, 25 Aug 2020 18:42:51 +0200 Subject: [PATCH 2/3] Expose getConnectedEdges --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9bce1399..40da9303 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ export { getBezierPath } from './components/Edges/BezierEdge'; export { getSmoothStepPath } from './components/Edges/SmoothStepEdge'; export { getMarkerEnd, getCenter as getEdgeCenter } from './components/Edges/utils'; -export { isNode, isEdge, removeElements, addEdge, getOutgoers } from './utils/graph'; +export { isNode, isEdge, removeElements, addEdge, getOutgoers, getConnectedEdges } from './utils/graph'; export * from './additional-components'; export * from './types'; From 40bb9470844ae2e8fb5bc6eeaba8b981e03394c8 Mon Sep 17 00:00:00 2001 From: Robin Goupil Date: Fri, 28 Aug 2020 13:57:47 +0200 Subject: [PATCH 3/3] use classcat instead of template literal --- src/additional-components/MiniMap/MiniMapNode.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/additional-components/MiniMap/MiniMapNode.tsx b/src/additional-components/MiniMap/MiniMapNode.tsx index 93d3aa2e..a3ab7a43 100644 --- a/src/additional-components/MiniMap/MiniMapNode.tsx +++ b/src/additional-components/MiniMap/MiniMapNode.tsx @@ -1,4 +1,5 @@ import React, { memo, CSSProperties } from 'react'; +import cc from 'classcat'; interface MiniMapNodeProps { x: number; @@ -17,7 +18,7 @@ const MiniMapNode = ({ x, y, width, height, style, color, className, borderRadiu return (