Skip to content

Commit e094426

Browse files
committed
examples: cleanup basic example
Signed-off-by: braks <[email protected]>
1 parent 2b2c9a9 commit e094426

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

examples/vite/src/Basic/Basic.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<script lang="ts" setup>
2-
import type { Elements } from '@vue-flow/core'
3-
import { Panel, VueFlow, isNode, useVueFlow } from '@vue-flow/core'
2+
import type { Edge, Node, ValidConnectionFunc } from '@vue-flow/core'
3+
import { ConnectionMode, Panel, VueFlow, isNode, useVueFlow } from '@vue-flow/core'
44
55
import { Background } from '@vue-flow/background'
66
import { Controls } from '@vue-flow/controls'
77
import { MiniMap } from '@vue-flow/minimap'
88
9-
const nodes = ref<Elements>([
9+
const nodes = ref<Node[]>([
1010
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
1111
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
1212
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' },
1313
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 }, class: 'light' },
1414
])
1515
16-
const edges = ref<Elements>([
16+
const edges = ref<Edge[]>([
1717
{ id: 'e1-2', source: '1', target: '2', animated: true },
1818
{ id: 'e1-3', source: '1', target: '3' },
1919
])
@@ -45,32 +45,30 @@ function resetViewport() {
4545
function toggleclass() {
4646
return nodes.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
4747
}
48+
49+
const isValidConnection: ValidConnectionFunc = (...args) => {
50+
console.log(args)
51+
return true
52+
}
4853
</script>
4954

5055
<template>
5156
<VueFlow
5257
:nodes="nodes"
5358
:edges="edges"
54-
:delete-key-code="['Backspace', 'Delete']"
59+
:connection-mode="ConnectionMode.Strict"
60+
:is-valid-connection="isValidConnection"
5561
fit-view-on-init
5662
class="vue-flow-basic-example"
5763
>
5864
<Background />
59-
<MiniMap node-color="red" :nodes="nodes" :edges="edges" />
65+
<MiniMap />
6066
<Controls />
6167
<Panel position="top-right" style="display: flex; gap: 5px">
62-
<input />
6368
<button @click="resetViewport">reset viewport</button>
6469
<button @click="updatePos">change pos</button>
6570
<button @click="toggleclass">toggle class</button>
6671
<button @click="logToObject">toObject</button>
6772
</Panel>
6873
</VueFlow>
6974
</template>
70-
71-
<style>
72-
.vue-flow__minimap {
73-
transform: scale(75%);
74-
transform-origin: bottom right;
75-
}
76-
</style>

0 commit comments

Comments
 (0)