Skip to content

Commit

Permalink
feat(editor): add gridSize and showGrid params
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 7, 2019
1 parent 2eda813 commit e146a63
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
19 changes: 14 additions & 5 deletions dist/ReactGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9169,7 +9169,9 @@
deleteKeyCode = _ref.deleteKeyCode,
elements = _ref.elements,
onConnect = _ref.onConnect,
gridColor = _ref.gridColor;
gridColor = _ref.gridColor,
showGrid = _ref.showGrid,
gridGap = _ref.gridGap;
var zoomPane = React.useRef();
var rendererNode = React.useRef();
var state = useStoreState(function (s) {
Expand Down Expand Up @@ -9232,7 +9234,8 @@
return React__default.createElement("div", {
className: "react-flow__renderer",
ref: rendererNode
}, React__default.createElement(GridRenderer, {
}, showGrid && React__default.createElement(GridRenderer, {
gap: gridGap,
strokeColor: gridColor
}), React__default.createElement(NodeRenderer, {
nodeTypes: nodeTypes,
Expand Down Expand Up @@ -9929,7 +9932,9 @@
connectionLineStyle = _ref.connectionLineStyle,
deleteKeyCode = _ref.deleteKeyCode,
selectionKeyCode = _ref.selectionKeyCode,
gridColor = _ref.gridColor;
gridColor = _ref.gridColor,
showGrid = _ref.showGrid,
gridGap = _ref.gridGap;
var nodeTypesParsed = React.useMemo(function () {
return createNodeTypes(nodeTypes);
}, []);
Expand All @@ -9955,7 +9960,9 @@
deleteKeyCode: deleteKeyCode,
elements: elements,
onConnect: onConnect,
gridColor: gridColor
gridColor: gridColor,
gridGap: gridGap,
showGrid: showGrid
}), children));
};

Expand All @@ -9981,7 +9988,9 @@
connectionLineStyle: {},
deleteKeyCode: 8,
selectionKeyCode: 16,
gridColor: '#999'
gridColor: '#999',
gridGap: 24,
showGrid: true
};

var baseStyle = {
Expand Down
1 change: 1 addition & 0 deletions examples/advanced/scripts/ExampleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class App extends PureComponent {
connectionLineStyle={{ stroke: '#ddd', strokeWidth: 2 }}
connectionLineType="bezier"
gridColor="#aaa"
gridGap={16}
>
<MiniMap
style={{ position: 'absolute', right: 10, bottom: 10 }}
Expand Down
1 change: 1 addition & 0 deletions examples/basic/scripts/ExampleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class App extends PureComponent {
onConnect={this.onConnect}
onNodeDragStop={onNodeDragStop}
style={{ width: '100%', height: '100%' }}
showGrid={false}
/>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/container/GraphView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const GraphView = memo(({
nodeTypes, edgeTypes, onMove, onLoad,
onElementClick, onNodeDragStop, connectionLineType, connectionLineStyle,
selectionKeyCode, onElementsRemove, deleteKeyCode, elements,
onConnect, gridColor
onConnect, gridColor, showGrid, gridGap
}) => {
const zoomPane = useRef();
const rendererNode = useRef();
Expand Down Expand Up @@ -68,7 +68,7 @@ const GraphView = memo(({

return (
<div className="react-flow__renderer" ref={rendererNode}>
<GridRenderer strokeColor={gridColor} />
{showGrid && <GridRenderer gap={gridGap} strokeColor={gridColor} />}
<NodeRenderer
nodeTypes={nodeTypes}
onElementClick={onElementClick}
Expand Down
9 changes: 7 additions & 2 deletions src/container/ReactFlow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const ReactFlow = ({
style, onElementClick, elements, children,
nodeTypes, edgeTypes, onLoad, onMove,
onElementsRemove, onConnect, onNodeDragStop, connectionLineType,
connectionLineStyle, deleteKeyCode, selectionKeyCode, gridColor
connectionLineStyle, deleteKeyCode, selectionKeyCode, gridColor,
showGrid, gridGap
}) => {
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
Expand All @@ -48,6 +49,8 @@ const ReactFlow = ({
elements={elements}
onConnect={onConnect}
gridColor={gridColor}
gridGap={gridGap}
showGrid={showGrid}
/>
{children}
</StoreProvider>
Expand Down Expand Up @@ -78,7 +81,9 @@ ReactFlow.defaultProps = {
connectionLineStyle: {},
deleteKeyCode: 8,
selectionKeyCode: 16,
gridColor: '#999'
gridColor: '#999',
gridGap: 24,
showGrid: true
};

export default ReactFlow;

0 comments on commit e146a63

Please sign in to comment.