fix(docs): move node from edges array

This commit is contained in:
braks
2024-02-06 00:53:17 +01:00
parent 96b93e30e3
commit 6dd95145b1
2 changed files with 55 additions and 21 deletions

View File

@@ -2,6 +2,7 @@
import dagre from 'dagre'
import { nextTick, ref } from 'vue'
import { Panel, Position, VueFlow, useVueFlow } from '@vue-flow/core'
import { Background } from '@vue-flow/background'
import { initialEdges, initialNodes } from './initial-elements.js'
@@ -54,6 +55,8 @@ function handleLayout(direction) {
<template>
<div class="layoutflow">
<VueFlow :nodes="nodes" :edges="edges" @nodes-initialized="handleLayout('TB')">
<Background />
<Panel style="display: flex; gap: 1rem" position="top-right">
<button @click="handleLayout('TB')">vertical layout</button>
<button @click="handleLayout('LR')">horizontal layout</button>
@@ -67,4 +70,34 @@ function handleLayout(direction) {
height: 100%;
width: 100%;
}
.layoutflow .vue-flow .vue-flow__node-input {
background-color: #10b981;
color: white;
border: 1px solid #10b981;
border-radius: 99px;
}
.layoutflow .vue-flow .vue-flow__node-output {
background-color: #ef467e;
color: white;
border: 1px solid #ef467e;
border-radius: 99px;
}
.layoutflow .vue-flow .vue-flow__node-default {
background-color: #1a192b;
color: white;
border: 1px solid #10b981;
border-radius: 99px;
}
.layoutflow .vue-flow .vue-flow__node.selected {
box-shadow: 0 0 0 2px #3b82f6;
}
.layoutflow .vue-flow .vue-flow__edge-path {
stroke: #10b981;
stroke-width: 2px;
}
</style>

View File

@@ -4,67 +4,68 @@ export const initialNodes = [
{
id: '1',
type: 'input',
label: 'input',
label: 'Start',
position,
},
{
id: '2',
label: 'node 2',
label: 'Process 1',
position,
},
{
id: '2a',
label: 'node 2a',
label: 'Process 2a',
position,
},
{
id: '2b',
label: 'node 2b',
type: 'output',
label: 'Process 2b',
position,
},
{
id: '2c',
label: 'node 2c',
label: 'Process 2c',
position,
},
{
id: '2d',
label: 'node 2d',
label: 'Process 2d',
position,
},
{
id: '3',
label: 'node 3',
label: 'Process 3',
position,
},
{
id: '4',
label: 'node 4',
type: 'input',
label: 'Start',
position,
},
{
id: '5',
label: 'node 5',
label: 'Process 5',
position,
},
{
id: '6',
type: 'output',
label: 'output',
label: 'Process 6',
position,
},
{ id: '7', label: 'Process 7', position },
]
export const initialEdges = [
{ id: '7', type: 'output', label: 'output', position: { x: 400, y: 450 } },
{ id: 'e12', source: '1', target: '2', type: 'smoothstep', animated: true },
{ id: 'e13', source: '1', target: '3', type: 'smoothstep', animated: true },
{ id: 'e22a', source: '2', target: '2a', type: 'smoothstep', animated: true },
{ id: 'e22b', source: '2', target: '2b', type: 'smoothstep', animated: true },
{ id: 'e22c', source: '2', target: '2c', type: 'smoothstep', animated: true },
{ id: 'e2c2d', source: '2c', target: '2d', type: 'smoothstep', animated: true },
{ id: 'e45', source: '4', target: '5', type: 'smoothstep', animated: true },
{ id: 'e56', source: '5', target: '6', type: 'smoothstep', animated: true },
{ id: 'e57', source: '5', target: '7', type: 'smoothstep', animated: true },
{ id: 'e1-2', source: '1', target: '2', type: 'smoothstep', animated: true },
{ id: 'e1-3', source: '1', target: '3', type: 'smoothstep', animated: true },
{ id: 'e2-2a', source: '2', target: '2a', type: 'smoothstep', animated: true },
{ id: 'e2-2b', source: '2', target: '2b', type: 'smoothstep', animated: true },
{ id: 'e2-2c', source: '2', target: '2c', type: 'smoothstep', animated: true },
{ id: 'e2c-2d', source: '2c', target: '2d', type: 'smoothstep', animated: true },
{ id: 'e4-5', source: '4', target: '5', type: 'smoothstep', animated: true },
{ id: 'e5-6', source: '5', target: '6', type: 'smoothstep', animated: true },
{ id: 'e5-7', source: '5', target: '7', type: 'smoothstep', animated: true },
]