feat(packages): add svelte version

This commit is contained in:
moklick
2023-02-01 09:41:09 +01:00
parent 079e380a31
commit 2af833aee1
30 changed files with 2279 additions and 21 deletions
+59
View File
@@ -0,0 +1,59 @@
<script lang="ts">
import type { Node, Edge } from '@reactflow/core';
import SvelteFlow from '../lib/index';
const yNodes = 10;
const xNodes = 10;
const nodes: Node[] = [];
const edges: Edge[] = [];
let source = null;
for (let y = 0; y < yNodes; y++) {
for (let x = 0; x < xNodes; x++) {
const position = { x: x * 100, y: y * 50 };
const id = `${x}-${y}`;
const data = { label: `Node ${id}` };
const node = {
id,
data,
position,
};
nodes.push(node);
if (source) {
const edge = {
id: `${source.id}-${id}`,
source: source.id,
target: id,
};
edges.push(edge);
}
source = node;
}
}
// const nodes = [{
// id: '1',
// type: 'input',
// data: { label: 'Input Node' },
// position: { x: 250, y: 5 }
// }, {
// id: '2',
// type: 'input',
// data: { label: 'Input Node 2' },
// position: { x: 150, y: 250 },
// }]
</script>
<SvelteFlow {nodes} {edges} />
<style>
:root {
--node-width: 50;
}
</style>