Skip to content

Commit 5e953bd

Browse files
committed
chore(docs): update save and restore example
1 parent 6ee3170 commit 5e953bd

File tree

8 files changed

+77
-27
lines changed

8 files changed

+77
-27
lines changed

docs/examples/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { StressApp, StressCSS, StressUtils } from './stress'
77
import { UpdateEdgeApp } from './update-edge'
88
import { UpdateNodeApp, UpdateNodeCSS } from './update-node'
99
import { ValidationApp, ValidationCSS, ValidationCustomInput, ValidationCustomNode } from './validation'
10-
import { SaveRestoreApp, SaveRestoreCSS, SaveRestoreControls } from './save-restore'
10+
import { SaveRestoreApp, SaveRestoreCSS, SaveRestoreControls, SaveRestoreIcon } from './save-restore'
1111
import { DndApp, DndBackground, DndCSS, DndScript, DndSidebar } from './dnd'
1212
import { HiddenApp } from './hidden'
1313
import { InteractionApp, InteractionCSS, InteractionControls } from './interaction'
@@ -71,6 +71,7 @@ export const exampleImports = {
7171
saveRestore: {
7272
'App.vue': SaveRestoreApp,
7373
'Controls.vue': SaveRestoreControls,
74+
'Icon.vue': SaveRestoreIcon,
7475
'style.css': SaveRestoreCSS,
7576
},
7677
dnd: {

docs/examples/math/Icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defineProps(['name'])
44

55
<template>
66
<svg v-if="name === '+'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
7-
<path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z" />
7+
<path fill="currentColor" d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2z" />
88
</svg>
99

1010
<svg v-else-if="name === '-'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">

docs/examples/math/style.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
}
5858

5959
.vue-flow__node-operator.selected {
60-
box-shadow: 0 0 0 2px #0EA5E9;
60+
box-shadow: 0 0 0 2px #2563eb;
6161
}
6262

6363
.vue-flow__node-operator .buttons {
@@ -86,12 +86,12 @@
8686
}
8787

8888
.vue-flow__node-operator button:hover {
89-
background-color: #0EA5E9;
89+
background-color: #2563eb;
9090
transition: background-color 0.2s;
9191
}
9292

9393
.vue-flow__node-operator button.selected {
94-
background-color: #0EA5E9;
94+
background-color: #2563eb;
9595
}
9696

9797
.vue-flow__node-operator .vue-flow__handle[data-handleid="target-a"] {
@@ -103,7 +103,7 @@
103103
}
104104

105105
.vue-flow__node-operator .vue-flow__handle {
106-
background-color: #0EA5E9;
106+
background-color: #2563eb;
107107
}
108108

109109
.vue-flow__node-result {

docs/examples/save-restore/App.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
<script lang="ts" setup>
1+
<script setup>
22
import { ref } from 'vue'
33
import { VueFlow } from '@vue-flow/core'
4+
import { Background } from '@vue-flow/background'
45
import SaveRestoreControls from './Controls.vue'
56
67
const nodes = ref([{ id: '1', label: 'Node 1', position: { x: 100, y: 100 } }])
8+
9+
const edges = ref([])
710
</script>
811

912
<template>
10-
<VueFlow :nodes="nodes">
13+
<VueFlow :nodes="nodes" :edges="edges">
1114
<SaveRestoreControls />
15+
16+
<Background />
1217
</VueFlow>
1318
</template>

docs/examples/save-restore/Controls.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup>
22
import { Panel, useVueFlow } from '@vue-flow/core'
3+
import Icon from './Icon.vue'
34
4-
const flowKey = 'example-flow'
5+
const flowKey = 'vue-flow--save-restore'
56
67
const { nodes, addNodes, dimensions, toObject, fromObject } = useVueFlow()
78
@@ -31,9 +32,17 @@ function onAdd() {
3132
</script>
3233

3334
<template>
34-
<Panel position="top-right" class="save-restore-controls">
35-
<button style="background-color: #33a6b8" @click="onSave">save</button>
36-
<button style="background-color: #113285" @click="onRestore">restore</button>
37-
<button style="background-color: #6f3381" @click="onAdd">add node</button>
35+
<Panel position="top-right">
36+
<div class="buttons">
37+
<button title="save graph" @click="onSave">
38+
<Icon name="save" />
39+
</button>
40+
<button title="restore graph" @click="onRestore">
41+
<Icon name="restore" />
42+
</button>
43+
<button title="add random node" @click="onAdd">
44+
<Icon name="add" />
45+
</button>
46+
</div>
3847
</Panel>
3948
</template>

docs/examples/save-restore/Icon.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script setup>
2+
defineProps(['name'])
3+
</script>
4+
5+
<template>
6+
<svg v-if="name === 'save'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
7+
<path
8+
fill="currentColor"
9+
d="M21 7v12q0 .825-.587 1.413T19 21H5q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h12zm-9 11q1.25 0 2.125-.875T15 15t-.875-2.125T12 12t-2.125.875T9 15t.875 2.125T12 18m-6-8h9V6H6z"
10+
/>
11+
</svg>
12+
13+
<svg v-else-if="name === 'restore'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
14+
<path
15+
fill="currentColor"
16+
d="m12 17l4-4l-1.4-1.4l-1.6 1.55V9h-2v4.15L9.4 11.6L8 13zm-6 5q-.825 0-1.412-.587T4 20V8l6-6h8q.825 0 1.413.588T20 4v16q0 .825-.587 1.413T18 22zm0-2h12V4h-7.15L6 8.85zm0 0h12z"
17+
/>
18+
</svg>
19+
20+
<svg v-else-if="name === 'add'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
21+
<path fill="currentColor" d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2z" />
22+
</svg>
23+
</template>

docs/examples/save-restore/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { default as SaveRestoreApp } from './App.vue?raw'
22
export { default as SaveRestoreControls } from './Controls.vue?raw'
3+
export { default as SaveRestoreIcon } from './Icon.vue?raw'
34
export { default as SaveRestoreCSS } from './style.css?inline'

docs/examples/save-restore/style.css

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
.save-restore-controls {
2-
font-size: 12px;
1+
.vue-flow__panel {
2+
background-color: #2d3748;
3+
padding: 10px;
4+
border-radius: 8px;
5+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
36
}
47

5-
.save-restore-controls button {
6-
margin-left: 5px;
7-
padding: 5px;
8-
border-radius: 5px;
9-
font-weight: 700;
10-
text-transform: uppercase;
11-
color: white;
12-
-webkit-box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
13-
box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
8+
.vue-flow__panel .buttons {
9+
display: flex;
10+
gap: 8px;
11+
}
12+
13+
.vue-flow__panel button {
14+
border: none;
1415
cursor: pointer;
16+
background-color: #4a5568;
17+
border-radius: 8px;
18+
color: white;
19+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
20+
width: 40px;
21+
height: 40px;
22+
font-size: 16px;
23+
display: flex;
24+
align-items: center;
25+
justify-content: center;
1526
}
1627

17-
.save-restore-controls button:hover {
18-
transform: scale(105%);
19-
transition: 250ms all ease-in-out;
28+
.vue-flow__panel button:hover {
29+
background-color: #2563eb;
30+
transition: background-color 0.2s;
2031
}

0 commit comments

Comments
 (0)