Skip to content

Commit

Permalink
update(examples): Add multi flows example
Browse files Browse the repository at this point in the history
  • Loading branch information
bcakmakoglu committed Oct 21, 2021
1 parent 712cf3e commit 0a9c1b0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/MultiFlows/Flow.vue
Original file line number Diff line number Diff line change
@@ -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>
10 changes: 10 additions & 0 deletions examples/MultiFlows/MultiFlowsExample.vue
Original file line number Diff line number Diff line change
@@ -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>
13 changes: 13 additions & 0 deletions examples/MultiFlows/multiflows.css
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions examples/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

1 comment on commit 0a9c1b0

@vercel
Copy link

@vercel vercel bot commented on 0a9c1b0 Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.