Skip to content

Commit f98e635

Browse files
committed
chore: update workflow demo
1 parent 7b52216 commit f98e635

File tree

2 files changed

+89
-33
lines changed

2 files changed

+89
-33
lines changed

packages/examples/src/custom-node.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script setup lang="ts">
22
import type { NodeProps } from '@vue-flow/core'
33
import { Node, NodeContent, NodeDescription, NodeFooter, NodeHeader, NodeTitle } from '@repo/elements/node'
4-
import { Toolbar } from '@repo/elements/toolbar'
5-
import { Button } from '@repo/shadcn-vue/components/ui/button'
64
75
const props = defineProps<NodeProps>()
86
</script>
@@ -25,14 +23,5 @@ const props = defineProps<NodeProps>()
2523
{{ props.data?.footer }}
2624
</p>
2725
</NodeFooter>
28-
29-
<Toolbar>
30-
<Button size="sm" variant="ghost">
31-
Edit
32-
</Button>
33-
<Button size="sm" variant="ghost">
34-
Delete
35-
</Button>
36-
</Toolbar>
3726
</Node>
3827
</template>

packages/examples/src/workflow.vue

Lines changed: 89 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<script setup lang="ts">
22
import type { EdgeTypesObject, NodeTypesObject } from '@vue-flow/core'
33
import { Canvas } from '@repo/elements/canvas'
4-
import { Connection } from '@repo/elements/connection'
5-
import { Controls } from '@repo/elements/controls'
64
import { Animated, Temporary } from '@repo/elements/edge'
7-
import { Panel } from '@repo/elements/panel'
8-
import { Button } from '@repo/shadcn-vue/components/ui/button'
95
import { nanoid } from 'nanoid'
106
import { markRaw, ref } from 'vue'
117
import CustomNode from './custom-node.vue'
128
139
const nodeIds = {
1410
start: nanoid(),
1511
process1: nanoid(),
12+
process2: nanoid(),
13+
decision: nanoid(),
14+
output1: nanoid(),
15+
output2: nanoid(),
1616
}
1717
1818
const nodes = ref([
1919
{
2020
id: nodeIds.start,
2121
type: 'custom',
22-
position: { x: 80, y: 80 },
22+
position: { x: 0, y: 0 },
2323
data: {
24-
label: 'start',
25-
description: 'test',
24+
label: 'Start',
25+
description: 'Initialize workflow',
2626
content: 'test',
2727
footer: 'test',
2828
handles: { target: false, source: true },
@@ -31,15 +31,63 @@ const nodes = ref([
3131
{
3232
id: nodeIds.process1,
3333
type: 'custom',
34-
position: { x: 320, y: 260 },
34+
position: { x: 500, y: 0 },
3535
data: {
36-
label: 'process1',
37-
description: 'test',
36+
label: 'Process Data',
37+
description: 'Transform input',
3838
content: 'test',
3939
footer: 'test',
4040
handles: { target: true, source: true },
4141
},
4242
},
43+
{
44+
id: nodeIds.decision,
45+
type: 'custom',
46+
position: { x: 1000, y: 0 },
47+
data: {
48+
label: 'Decision Point',
49+
description: 'Route based on conditions',
50+
content: 'test',
51+
footer: 'test',
52+
handles: { target: true, source: true },
53+
},
54+
},
55+
{
56+
id: nodeIds.output1,
57+
type: 'custom',
58+
position: { x: 1500, y: -100 },
59+
data: {
60+
label: 'Success Path',
61+
description: 'Handle success case',
62+
content: 'test',
63+
footer: 'test',
64+
handles: { target: true, source: true },
65+
},
66+
},
67+
{
68+
id: nodeIds.output2,
69+
type: 'custom',
70+
position: { x: 1500, y: 100 },
71+
data: {
72+
label: 'Error Path',
73+
description: 'Handle error case',
74+
content: 'test',
75+
footer: 'test',
76+
handles: { target: true, source: true },
77+
},
78+
},
79+
{
80+
id: nodeIds.process2,
81+
type: 'custom',
82+
position: { x: 2000, y: 0 },
83+
data: {
84+
label: 'Complete',
85+
description: 'Finalize workflow',
86+
content: 'test',
87+
footer: 'test',
88+
handles: { target: true, source: false },
89+
},
90+
},
4391
])
4492
4593
const edges = ref([
@@ -49,6 +97,36 @@ const edges = ref([
4997
target: nodeIds.process1,
5098
type: 'animated',
5199
},
100+
{
101+
id: nanoid(),
102+
source: nodeIds.process1,
103+
target: nodeIds.decision,
104+
type: 'animated',
105+
},
106+
{
107+
id: nanoid(),
108+
source: nodeIds.decision,
109+
target: nodeIds.output1,
110+
type: 'animated',
111+
},
112+
{
113+
id: nanoid(),
114+
source: nodeIds.decision,
115+
target: nodeIds.output2,
116+
type: 'temporary',
117+
},
118+
{
119+
id: nanoid(),
120+
source: nodeIds.output1,
121+
target: nodeIds.process2,
122+
type: 'animated',
123+
},
124+
{
125+
id: nanoid(),
126+
source: nodeIds.output2,
127+
target: nodeIds.process2,
128+
type: 'temporary',
129+
},
52130
])
53131
54132
const nodeTypes: NodeTypesObject = {
@@ -68,17 +146,6 @@ const edgeTypes: EdgeTypesObject = {
68146
:edges="edges"
69147
:node-types="nodeTypes"
70148
:edge-types="edgeTypes"
71-
>
72-
<template #connection-line="connectionLineProps">
73-
<Connection v-bind="connectionLineProps" />
74-
</template>
75-
76-
<Controls />
77-
<Panel position="top-right">
78-
<Button size="sm" variant="secondary">
79-
Export
80-
</Button>
81-
</Panel>
82-
</Canvas>
149+
/>
83150
</div>
84151
</template>

0 commit comments

Comments
 (0)