Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registry is a flow prop now. #235

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
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>
);