feat(svelte): custom nodes

This commit is contained in:
moklick
2023-02-21 14:36:07 +01:00
parent 6b192d90d5
commit aea43103af
12 changed files with 199 additions and 90 deletions
+8 -1
View File
@@ -2,12 +2,18 @@
import type { Node, Edge } from '@reactflow/system';
import SvelteFlow, { Controls, Background, BackgroundVariant, Minimap } from '../lib/index';
import CustomNode from '../customnodes/Custom.svelte';
const yNodes = 10;
const xNodes = 10;
const nodes: Node[] = [];
const edges: Edge[] = [];
const nodeTypes = {
custom: CustomNode,
};
let source = null;
for (let y = 0; y < yNodes; y++) {
@@ -19,6 +25,7 @@
id,
data,
position,
type: x === 0 ? 'custom' : 'default',
};
nodes.push(node);
@@ -57,7 +64,7 @@
// }]
</script>
<SvelteFlow {nodes} {edges} fitView >
<SvelteFlow {nodes} {edges} {nodeTypes} fitView>
<Controls />
<Background variant={BackgroundVariant.Dots} />
<Minimap />