update(examples): Add multi flows example
This commit is contained in:
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -49,6 +49,10 @@ export const routes: RouterOptions['routes'] = [
|
|||||||
path: '/layouting',
|
path: '/layouting',
|
||||||
component: () => import('./Layouting/LayoutingExample.vue'),
|
component: () => import('./Layouting/LayoutingExample.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/multi-flows',
|
||||||
|
component: () => import('./MultiFlows/MultiFlowsExample.vue'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const router = createRouter({
|
export const router = createRouter({
|
||||||
|
|||||||
Reference in New Issue
Block a user