Skip to content

Commit 811595c

Browse files
committed
docs(guide): cleanup
1 parent 372c374 commit 811595c

File tree

2 files changed

+149
-11
lines changed

2 files changed

+149
-11
lines changed

docs/src/guide/getting-started.md

Lines changed: 148 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<script setup>
2+
import LogosJavascript from '~icons/logos/javascript';
3+
import LogosTypescript from '~icons/logos/typescript-icon';
4+
</script>
5+
16
# Kickstart Your Journey with Vue Flow!
27

38
This guide covers the basics of setting up and using Vue Flow. You'll learn how to install Vue Flow, configure it, and
@@ -50,33 +55,164 @@ Refer to the [Theming](/guide/theming) section for additional information.
5055

5156
Here's a simple Vue Flow example to get you started:
5257

53-
```vue
58+
::: code-group
59+
60+
```vue [<LogosJavascript />]
5461
<script setup>
5562
import { VueFlow } from '@vue-flow/core'
5663
64+
import SpecialNode from './components/SpecialNode.vue'
65+
import SpecialEdge from './components/SpecialEdge.vue'
66+
5767
const elements = ref([
58-
// Nodes
59-
// An input node, specified by using `type: 'input'`
68+
// nodes
69+
70+
// an input node, specified by using `type: 'input'`
6071
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
6172
62-
// Default nodes, you can omit `type: 'default'`
73+
// default node, you can omit `type: 'default'` as it's the fallback type
6374
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
64-
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
6575
6676
// An output node, specified by using `type: 'output'`
67-
{ id: '4', type: 'output', label: 'Node 4', position: { x: 400, y: 200 } },
77+
{ id: '3', type: 'output', label: 'Node 3', position: { x: 400, y: 200 } },
78+
79+
// A custom node, specified by using a custom type name
80+
// we choose `type: 'special'` for this example
81+
{
82+
id: '4',
83+
type: 'special',
84+
label: 'Node 4',
85+
position: { x: 400, y: 200 },
86+
87+
// pass custom data to the node
88+
data: {
89+
// you can pass any data you want to the node
90+
hello: 'world',
91+
},
92+
},
93+
94+
// edges
95+
96+
// simple default bezier edge
97+
// consists of an id, source-id and target-id
98+
{ id: 'e1-3', source: '1', target: '3' },
99+
100+
// an animated edge, specified by using `animated: true`
101+
{ id: 'e1-2', source: '1', target: '2', animated: true },
68102
69-
// Edges
70-
// Most basic edge, only consists of an id, source-id and target-id
103+
// a custom edge, specified by using a custom type name
104+
// we choose `type: 'special'` for this example
105+
{
106+
id: 'e1-4',
107+
type: 'special',
108+
source: '1',
109+
target: '4',
110+
111+
// pass custom data to the edge
112+
data: {
113+
// You can pass any data you want to the edge
114+
hello: 'world',
115+
}
116+
},
117+
])
118+
</script>
119+
120+
<template>
121+
<VueFlow v-model="elements">
122+
<!-- bind your custom node type to a component by using slots, slot names are always `node-<type>` -->
123+
<template #node-special="specialNodeProps">
124+
<SpecialNode v-bind="specialNodeProps" />
125+
</template>
126+
127+
<!-- bind your custom edge type to a component by using slots, slot names are always `edge-<type>` -->
128+
<template #edge-special="specialEdgeProps">
129+
<SpecialEdge v-bind="specialEdgeProps" />
130+
</template>
131+
</VueFlow>
132+
</template>
133+
134+
<style>
135+
/* import the necessary styles for Vue Flow to work */
136+
@import '@vue-flow/core/dist/style.css';
137+
138+
/* import the default theme, this is optional but generally recommended */
139+
@import '@vue-flow/core/dist/theme-default.css';
140+
</style>
141+
```
142+
143+
```vue [<LogosTypescript />]
144+
<script setup lang="ts">
145+
import type { Elements } from '@vue-flow/core'
146+
import { VueFlow } from '@vue-flow/core'
147+
148+
import SpecialNode from './components/SpecialNode.vue'
149+
import SpecialEdge from './components/SpecialEdge.vue'
150+
151+
const elements = ref<Elements>([
152+
// nodes
153+
154+
// an input node, specified by using `type: 'input'`
155+
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
156+
157+
// default node, you can omit `type: 'default'` as it's the fallback type
158+
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
159+
160+
// An output node, specified by using `type: 'output'`
161+
{ id: '3', type: 'output', label: 'Node 3', position: { x: 400, y: 200 } },
162+
163+
// A custom node, specified by using a custom type name
164+
// we choose `type: 'special'` for this example
165+
{
166+
id: '4',
167+
type: 'special',
168+
label: 'Node 4',
169+
position: { x: 400, y: 200 },
170+
171+
// pass custom data to the node
172+
data: {
173+
// you can pass any data you want to the node
174+
hello: 'world',
175+
},
176+
},
177+
178+
// edges
179+
180+
// simple default bezier edge
181+
// consists of an id, source-id and target-id
71182
{ id: 'e1-3', source: '1', target: '3' },
72183
73-
// An animated edge
184+
// an animated edge, specified by using `animated: true`
74185
{ id: 'e1-2', source: '1', target: '2', animated: true },
186+
187+
// a custom edge, specified by using a custom type name
188+
// we choose `type: 'special'` for this example
189+
{
190+
id: 'e1-4',
191+
type: 'special',
192+
source: '1',
193+
target: '4',
194+
195+
// pass custom data to the edge
196+
data: {
197+
// You can pass any data you want to the edge
198+
hello: 'world',
199+
}
200+
},
75201
])
76202
</script>
77203
78204
<template>
79-
<VueFlow v-model="elements"/>
205+
<VueFlow v-model="elements">
206+
<!-- bind your custom node type to a component by using slots, slot names are always `node-<type>` -->
207+
<template #node-special="specialNodeProps">
208+
<SpecialNode v-bind="specialNodeProps" />
209+
</template>
210+
211+
<!-- bind your custom edge type to a component by using slots, slot names are always `edge-<type>` -->
212+
<template #edge-special="specialEdgeProps">
213+
<SpecialEdge v-bind="specialEdgeProps" />
214+
</template>
215+
</VueFlow>
80216
</template>
81217
82218
<style>
@@ -88,6 +224,8 @@ const elements = ref([
88224
</style>
89225
```
90226

227+
:::
228+
91229
## TypeScript
92230

93231
As Vue Flow is entirely written in TypeScript, we highly recommend utilizing TypeScript for improved developer

docs/src/guide/theming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Here's how you can use CSS classes to add a pop of color or alter the font style
7777
padding: 8px;
7878
}
7979
</style>
80-
s
80+
8181
### Using CSS Properties
8282

8383
You can also directly pass a style or class attribute to Vue Flow components and nodes/edges.

0 commit comments

Comments
 (0)