feat(lib): add gridColor param

This commit is contained in:
moklick
2019-10-07 21:55:35 +02:00
parent 5cd3dc6125
commit 2eda8134a8
4 changed files with 20 additions and 11 deletions
+13 -7
View File
@@ -6530,7 +6530,7 @@
strokeColor = _ref$strokeColor === void 0 ? '#999' : _ref$strokeColor, strokeColor = _ref$strokeColor === void 0 ? '#999' : _ref$strokeColor,
_ref$strokeWidth = _ref.strokeWidth, _ref$strokeWidth = _ref.strokeWidth,
strokeWidth = _ref$strokeWidth === void 0 ? 0.1 : _ref$strokeWidth, strokeWidth = _ref$strokeWidth === void 0 ? 0.1 : _ref$strokeWidth,
styles = _ref.styles, style = _ref.style,
className = _ref.className; className = _ref.className;
var _useStoreState = useStoreState(function (s) { var _useStoreState = useStoreState(function (s) {
@@ -6563,7 +6563,7 @@
return React__default.createElement("svg", { return React__default.createElement("svg", {
width: width, width: width,
height: height, height: height,
style: _objectSpread2$1({}, baseStyles, {}, styles), style: _objectSpread2$1({}, baseStyles, {}, style),
className: gridClasses className: gridClasses
}, React__default.createElement("path", { }, React__default.createElement("path", {
fill: "none", fill: "none",
@@ -9168,7 +9168,8 @@
onElementsRemove = _ref.onElementsRemove, onElementsRemove = _ref.onElementsRemove,
deleteKeyCode = _ref.deleteKeyCode, deleteKeyCode = _ref.deleteKeyCode,
elements = _ref.elements, elements = _ref.elements,
onConnect = _ref.onConnect; onConnect = _ref.onConnect,
gridColor = _ref.gridColor;
var zoomPane = React.useRef(); var zoomPane = React.useRef();
var rendererNode = React.useRef(); var rendererNode = React.useRef();
var state = useStoreState(function (s) { var state = useStoreState(function (s) {
@@ -9231,7 +9232,9 @@
return React__default.createElement("div", { return React__default.createElement("div", {
className: "react-flow__renderer", className: "react-flow__renderer",
ref: rendererNode ref: rendererNode
}, React__default.createElement(GridRenderer, null), React__default.createElement(NodeRenderer, { }, React__default.createElement(GridRenderer, {
strokeColor: gridColor
}), React__default.createElement(NodeRenderer, {
nodeTypes: nodeTypes, nodeTypes: nodeTypes,
onElementClick: onElementClick, onElementClick: onElementClick,
onNodeDragStop: onNodeDragStop onNodeDragStop: onNodeDragStop
@@ -9925,7 +9928,8 @@
connectionLineType = _ref.connectionLineType, connectionLineType = _ref.connectionLineType,
connectionLineStyle = _ref.connectionLineStyle, connectionLineStyle = _ref.connectionLineStyle,
deleteKeyCode = _ref.deleteKeyCode, deleteKeyCode = _ref.deleteKeyCode,
selectionKeyCode = _ref.selectionKeyCode; selectionKeyCode = _ref.selectionKeyCode,
gridColor = _ref.gridColor;
var nodeTypesParsed = React.useMemo(function () { var nodeTypesParsed = React.useMemo(function () {
return createNodeTypes(nodeTypes); return createNodeTypes(nodeTypes);
}, []); }, []);
@@ -9950,7 +9954,8 @@
onElementsRemove: onElementsRemove, onElementsRemove: onElementsRemove,
deleteKeyCode: deleteKeyCode, deleteKeyCode: deleteKeyCode,
elements: elements, elements: elements,
onConnect: onConnect onConnect: onConnect,
gridColor: gridColor
}), children)); }), children));
}; };
@@ -9975,7 +9980,8 @@
connectionLineType: 'bezier', connectionLineType: 'bezier',
connectionLineStyle: {}, connectionLineStyle: {},
deleteKeyCode: 8, deleteKeyCode: 8,
selectionKeyCode: 16 selectionKeyCode: 16,
gridColor: '#999'
}; };
var baseStyle = { var baseStyle = {
@@ -145,6 +145,7 @@ class App extends PureComponent {
}} }}
connectionLineStyle={{ stroke: '#ddd', strokeWidth: 2 }} connectionLineStyle={{ stroke: '#ddd', strokeWidth: 2 }}
connectionLineType="bezier" connectionLineType="bezier"
gridColor="#aaa"
> >
<MiniMap <MiniMap
style={{ position: 'absolute', right: 10, bottom: 10 }} style={{ position: 'absolute', right: 10, bottom: 10 }}
+2 -2
View File
@@ -17,7 +17,7 @@ const GraphView = memo(({
nodeTypes, edgeTypes, onMove, onLoad, nodeTypes, edgeTypes, onMove, onLoad,
onElementClick, onNodeDragStop, connectionLineType, connectionLineStyle, onElementClick, onNodeDragStop, connectionLineType, connectionLineStyle,
selectionKeyCode, onElementsRemove, deleteKeyCode, elements, selectionKeyCode, onElementsRemove, deleteKeyCode, elements,
onConnect onConnect, gridColor
}) => { }) => {
const zoomPane = useRef(); const zoomPane = useRef();
const rendererNode = useRef(); const rendererNode = useRef();
@@ -68,7 +68,7 @@ const GraphView = memo(({
return ( return (
<div className="react-flow__renderer" ref={rendererNode}> <div className="react-flow__renderer" ref={rendererNode}>
<GridRenderer /> <GridRenderer strokeColor={gridColor} />
<NodeRenderer <NodeRenderer
nodeTypes={nodeTypes} nodeTypes={nodeTypes}
onElementClick={onElementClick} onElementClick={onElementClick}
+4 -2
View File
@@ -25,7 +25,7 @@ const ReactFlow = ({
style, onElementClick, elements, children, style, onElementClick, elements, children,
nodeTypes, edgeTypes, onLoad, onMove, nodeTypes, edgeTypes, onLoad, onMove,
onElementsRemove, onConnect, onNodeDragStop, connectionLineType, onElementsRemove, onConnect, onNodeDragStop, connectionLineType,
connectionLineStyle, deleteKeyCode, selectionKeyCode connectionLineStyle, deleteKeyCode, selectionKeyCode, gridColor
}) => { }) => {
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []); const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []); const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
@@ -47,6 +47,7 @@ const ReactFlow = ({
deleteKeyCode={deleteKeyCode} deleteKeyCode={deleteKeyCode}
elements={elements} elements={elements}
onConnect={onConnect} onConnect={onConnect}
gridColor={gridColor}
/> />
{children} {children}
</StoreProvider> </StoreProvider>
@@ -76,7 +77,8 @@ ReactFlow.defaultProps = {
connectionLineType: 'bezier', connectionLineType: 'bezier',
connectionLineStyle: {}, connectionLineStyle: {},
deleteKeyCode: 8, deleteKeyCode: 8,
selectionKeyCode: 16 selectionKeyCode: 16,
gridColor: '#999'
}; };
export default ReactFlow; export default ReactFlow;