init 🚀

This commit is contained in:
moklick
2019-07-15 16:48:04 +02:00
commit cf4441ce6d
24 changed files with 8924 additions and 0 deletions

58
example/SimpleGraph.js Normal file
View File

@@ -0,0 +1,58 @@
import React, { PureComponent } from 'react';
import Graph from '../src';
class App extends PureComponent {
onLoad(graphInstance) {
this.graphInstance = graphInstance;
console.log('graph loaded:', graphInstance);
}
onMove() {
if (!this.graphInstance) {
return false;
}
console.log('graph moved');
}
onFitView() {
if (!this.graphInstance) {
return false;
}
this.graphInstance.fitView();
}
render() {
const elements = [
{ data: { id: '1', label: 'Tests', type: 'input' }, position: { x: 0, y: 0 } },
{ data: { id: '2', label: 'This is a node This is a node This is a node This is a node' }, position: { x: 100, y: 100 } },
{ data: { id: '3', label: 'This is a node' }, position: { x: 100, y: 200 }, style: { background: '#222', color: '#fff' } },
{ data: { id: '4', label: 'nody nodes', type: 'output' }, position: { x: 50, y: 300 } },
{ data: { id: '5', label: 'Another node', type: 'output' }, position: { x: 400, y: 300 } },
{ data: { source: '1', target: '2' } },
{ data: { source: '2', target: '3' } },
{ data: { source: '3', target: '4' } },
{ data: { source: '3', target: '5' } }
];
return (
<Graph
elements={elements}
onNodeClick={node => console.log(node)}
style={{ width: '100%', height: '100%' }}
onLoad={graphInstance => this.onLoad(graphInstance)}
onMove={() => this.onMove()}
>
<button
type="button"
style={{ position: 'absolute', right: '10px', bottom: '10px' }}
onClick={() => this.onFitView()}
>
fit
</button>
</Graph>
);
}
}
export default App;

18
example/index.html Normal file
View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html, body, #root {
height: 100%;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>

9
example/index.js Normal file
View File

@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import SimpleGraph from './SimpleGraph';
ReactDOM.render(
<SimpleGraph />,
document.getElementById('root')
);