Skip to content

Commit

Permalink
Merge pull request #235 from bhouston/move-registry-out-of-flow
Browse files Browse the repository at this point in the history
registry is a flow prop now.
  • Loading branch information
bhouston authored Jul 26, 2023
2 parents 59b6e70 + 3d45a48 commit b7b3e61
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 196 deletions.
1 change: 1 addition & 0 deletions apps/graph-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"@behave-graph/core": "*",
"@behave-graph/scene": "*",
"@behave-graph/flow": "*",
"three": "0.152.2",
"three-stdlib": "^2.22.4"
Expand Down
28 changes: 28 additions & 0 deletions apps/graph-editor/src/components/MyFlow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import Branch from '../../../../graphs/core/flow/Branch.json';
import HelloWorld from '../../../../graphs/core/HelloWorld.json';
import Polynomial from '../../../../graphs/core/logic/Polynomial.json';
import Delay from '../../../../graphs/core/time/Delay.json';
import SetGet from '../../../../graphs/core/variables/SetGet.json';
import rawGraph from '../graph.json';
import { GraphJSON } from '@behave-graph/core';
import { Examples, Flow } from '@behave-graph/flow';
import { useRegistry } from '../hooks/useRegistry.js';

const graph = rawGraph as unknown as GraphJSON;

// TODO remove when json types fixed in behave-graph
const examples: Examples = {
branch: Branch as unknown as GraphJSON,
delay: Delay as unknown as GraphJSON,
helloWorld: HelloWorld as unknown as GraphJSON,
polynomial: Polynomial as unknown as GraphJSON,
setGet: SetGet as unknown as GraphJSON
} as Record<string, GraphJSON>;

const MyFlow: React.FC = () => {
const registry = useRegistry();
return <Flow registry={registry} initialGraph={graph} examples={examples} />;
};

export default MyFlow;
File renamed without changes.
23 changes: 2 additions & 21 deletions apps/graph-editor/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import 'reactflow/dist/style.css';
import './styles.css';

import { GraphJSON } from '@behave-graph/core';
import { Examples, Flow } from '@behave-graph/flow';
import React from 'react';
import ReactDOM from 'react-dom/client';

import Branch from '../../../graphs/core/flow/Branch.json';
import HelloWorld from '../../../graphs/core/HelloWorld.json';
import Polynomial from '../../../graphs/core/logic/Polynomial.json';
import Delay from '../../../graphs/core/time/Delay.json';
import SetGet from '../../../graphs/core/variables/SetGet.json';
import rawGraph from './graph.json';

const graph = rawGraph as unknown as GraphJSON;
import MyFlow from './components/MyFlow.js';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);

// TODO remove when json types fixed in behave-graph
const examples: Examples = {
branch: Branch as unknown as GraphJSON,
delay: Delay as unknown as GraphJSON,
helloWorld: HelloWorld as unknown as GraphJSON,
polynomial: Polynomial as unknown as GraphJSON,
setGet: SetGet as unknown as GraphJSON
} as Record<string, GraphJSON>;

root.render(
<React.StrictMode>
<Flow initialGraph={graph} examples={examples} />
<MyFlow />
</React.StrictMode>
);
Loading

0 comments on commit b7b3e61

Please sign in to comment.