update(examples): Add multi flows example

This commit is contained in:
Braks
2021-10-21 14:55:19 +02:00
parent 712cf3ef66
commit 0a9c1b0717
4 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<script lang="ts" setup>
import Flow, { Background, Connection, Elements, Edge, removeElements, addEdge } from '~/index'
const initialElements: Elements = [
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 }, className: 'light' },
{ id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 }, className: 'light' },
{ id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 }, className: 'light' },
{ id: '4', data: { label: 'Node 4' }, position: { x: 400, y: 200 }, className: 'light' },
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e1-3', source: '1', target: '3' },
] as Elements
const elements = ref<Elements>(initialElements)
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value))
</script>
<template>
<Flow :elements="elements" @elements-remove="onElementsRemove" @connect="onConnect">
<Background />
</Flow>
</template>

View File

@@ -0,0 +1,10 @@
<script lang="ts" setup>
import Flow from './Flow.vue'
import './multiflows.css'
</script>
<template>
<div class="vue-flow__example-multiflows">
<Flow />
<Flow />
</div>
</template>

View File

@@ -0,0 +1,13 @@
.vue-flow__example-multiflows {
display: flex;
height: 100%;
}
.vue-flow__example-multiflows .vue-flow {
width: 100%;
height: 100%;
}
.vue-flow__example-multiflows .vue-flow:first-child {
border-right: 2px solid #333;
}

View File

@@ -49,6 +49,10 @@ export const routes: RouterOptions['routes'] = [
path: '/layouting',
component: () => import('./Layouting/LayoutingExample.vue'),
},
{
path: '/multi-flows',
component: () => import('./MultiFlows/MultiFlowsExample.vue'),
},
]
export const router = createRouter({