feat(packages): add svelte version
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user