refactor(examples): rename Graph to ReactFlow
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import Graph, { removeElements, addEdge } from 'react-flow-renderer';
|
import ReactFlow, { removeElements, addEdge } from 'react-flow-renderer';
|
||||||
|
|
||||||
const onNodeDragStop = node => console.log('drag stop', node);
|
const onNodeDragStop = node => console.log('drag stop', node);
|
||||||
const onLoad = graphInstance => console.log('graph loaded:', graphInstance);
|
const onLoad = graphInstance => console.log('graph loaded:', graphInstance);
|
||||||
@@ -22,7 +22,7 @@ const BasicGraph = () => {
|
|||||||
const onConnect = (params) => setElements(els => addEdge(params, els));
|
const onConnect = (params) => setElements(els => addEdge(params, els));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={elements}
|
elements={elements}
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
onElementClick={onElementClick}
|
onElementClick={onElementClick}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import Graph, { isEdge, removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
import ReactFlow, { isEdge, removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
||||||
|
|
||||||
import ColorSelectorNode from './ColorSelectorNode';
|
import ColorSelectorNode from './ColorSelectorNode';
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ const CustomNodeGraph = () => {
|
|||||||
const onConnect = (params) => setElements(els => addEdge(params, els));
|
const onConnect = (params) => setElements(els => addEdge(params, els));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={elements}
|
elements={elements}
|
||||||
onElementClick={onElementClick}
|
onElementClick={onElementClick}
|
||||||
onElementsRemove={onElementsRemove}
|
onElementsRemove={onElementsRemove}
|
||||||
@@ -79,7 +79,7 @@ const CustomNodeGraph = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Controls />
|
<Controls />
|
||||||
</Graph>
|
</ReactFlow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const initialElements = [
|
|||||||
{ id: '5', data: { label: 'Node 5' }, position: { x: 450, y: 400 } },
|
{ id: '5', data: { label: 'Node 5' }, position: { x: 450, y: 400 } },
|
||||||
{ id: '6', type: 'output', data: { label: 'Output Node 5' }, position: { x: 250, y: 550 } },
|
{ id: '6', type: 'output', data: { label: 'Output Node 5' }, position: { x: 250, y: 550 } },
|
||||||
{ id: '7', type: 'output', data: { label: 'Output Node 6' }, position: { x: 550, y: 550 } },
|
{ id: '7', type: 'output', data: { label: 'Output Node 6' }, position: { x: 550, y: 550 } },
|
||||||
{ id: 'e1-2', source: '1', target: '2', label: 'bezier edge', labelBgStyle: { fillOpacity: 0.75 } },
|
{ id: 'e1-2', source: '1', target: '2', label: 'bezier edge' },
|
||||||
{ id: 'e2-3', source: '2', target: '3', type: 'step', label: 'step edge' },
|
{ id: 'e2-3', source: '2', target: '3', type: 'step', label: 'step edge' },
|
||||||
{ id: 'e3-4', source: '3', target: '4', type: 'straight', label: 'straight edge' },
|
{ id: 'e3-4', source: '3', target: '4', type: 'straight', label: 'straight edge' },
|
||||||
{ id: 'e3-5', source: '4', target: '5', animated: true, label: 'animated styled edge', style: { stroke: 'red' } },
|
{ id: 'e3-5', source: '4', target: '5', animated: true, label: 'animated styled edge', style: { stroke: 'red' } },
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import Graph, { removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
import ReactFlow, { removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
||||||
|
|
||||||
const onNodeDragStop = node => console.log('drag stop', node);
|
const onNodeDragStop = node => console.log('drag stop', node);
|
||||||
const onLoad = graphInstance => console.log('graph loaded:', graphInstance);
|
const onLoad = graphInstance => console.log('graph loaded:', graphInstance);
|
||||||
@@ -22,7 +22,7 @@ const EmptyGraph = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={elements}
|
elements={elements}
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
onElementClick={onElementClick}
|
onElementClick={onElementClick}
|
||||||
@@ -41,7 +41,7 @@ const EmptyGraph = () => {
|
|||||||
>
|
>
|
||||||
add node
|
add node
|
||||||
</button>
|
</button>
|
||||||
</Graph>
|
</ReactFlow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import Graph, { MiniMap, Controls } from 'react-flow-renderer';
|
import ReactFlow, { MiniMap, Controls } from 'react-flow-renderer';
|
||||||
|
|
||||||
const initialElements = [
|
const initialElements = [
|
||||||
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } },
|
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } },
|
||||||
@@ -18,7 +18,7 @@ const EmptyGraph = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={initialElements}
|
elements={initialElements}
|
||||||
style={{ width: '100%', height: '100%' }}
|
style={{ width: '100%', height: '100%' }}
|
||||||
backgroundType="lines"
|
backgroundType="lines"
|
||||||
@@ -39,7 +39,7 @@ const EmptyGraph = () => {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</Graph>
|
</ReactFlow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import Graph, { removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
import ReactFlow, { removeElements, addEdge, MiniMap, Controls } from 'react-flow-renderer';
|
||||||
|
|
||||||
const onNodeDragStop = node => console.log('drag stop', node);
|
const onNodeDragStop = node => console.log('drag stop', node);
|
||||||
const onElementClick = element => console.log('click', element);
|
const onElementClick = element => console.log('click', element);
|
||||||
@@ -41,7 +41,7 @@ const RichGraph = () => {
|
|||||||
const onConnect = (params) => setElements(els => addEdge(params, els));
|
const onConnect = (params) => setElements(els => addEdge(params, els));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={elements}
|
elements={elements}
|
||||||
onElementClick={onElementClick}
|
onElementClick={onElementClick}
|
||||||
onElementsRemove={onElementsRemove}
|
onElementsRemove={onElementsRemove}
|
||||||
@@ -73,7 +73,7 @@ const RichGraph = () => {
|
|||||||
>
|
>
|
||||||
add node
|
add node
|
||||||
</button>
|
</button>
|
||||||
</Graph>
|
</ReactFlow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import Graph, { removeElements, addEdge, MiniMap } from 'react-flow-renderer';
|
import ReactFlow, { removeElements, addEdge, MiniMap } from 'react-flow-renderer';
|
||||||
import { getElements } from './utils';
|
import { getElements } from './utils';
|
||||||
|
|
||||||
const onLoad = graph => {
|
const onLoad = graph => {
|
||||||
@@ -17,7 +17,7 @@ const StressGraph = () => {
|
|||||||
const onConnect = (params) => setElements(els => addEdge(params, els));
|
const onConnect = (params) => setElements(els => addEdge(params, els));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<ReactFlow
|
||||||
elements={elements}
|
elements={elements}
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
onElementsRemove={onElementsRemove}
|
onElementsRemove={onElementsRemove}
|
||||||
@@ -26,7 +26,7 @@ const StressGraph = () => {
|
|||||||
backgroundType="lines"
|
backgroundType="lines"
|
||||||
>
|
>
|
||||||
<MiniMap />
|
<MiniMap />
|
||||||
</Graph>
|
</ReactFlow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ const routes = [{
|
|||||||
path: '/basic',
|
path: '/basic',
|
||||||
component: Basic,
|
component: Basic,
|
||||||
label: 'Basic'
|
label: 'Basic'
|
||||||
},{
|
}, {
|
||||||
|
path: '/edges',
|
||||||
|
component: Edges,
|
||||||
|
label: 'Edges'
|
||||||
|
}, {
|
||||||
path: '/custom-node',
|
path: '/custom-node',
|
||||||
component: CustomNode,
|
component: CustomNode,
|
||||||
label: 'CustomNode'
|
label: 'CustomNode'
|
||||||
@@ -28,10 +32,6 @@ const routes = [{
|
|||||||
path: '/stress',
|
path: '/stress',
|
||||||
component: Stress,
|
component: Stress,
|
||||||
label: 'Stress'
|
label: 'Stress'
|
||||||
}, {
|
|
||||||
path: '/edges',
|
|
||||||
component: Edges,
|
|
||||||
label: 'Edges'
|
|
||||||
}, {
|
}, {
|
||||||
path: '/empty',
|
path: '/empty',
|
||||||
component: Empty
|
component: Empty
|
||||||
|
|||||||
Reference in New Issue
Block a user