docs: update examples

This commit is contained in:
braks
2022-11-13 19:13:43 +01:00
committed by Braks
parent f6a97c504b
commit cd03034bdb
35 changed files with 222 additions and 161 deletions
@@ -1,13 +1,13 @@
<script lang="ts" setup>
import { VueFlow } from '@vue-flow/core'
import { ref } from 'vue'
import Controls from './Controls.vue'
import SaveRestoreControls from './Controls.vue'
const elements = ref([{ id: '1', label: 'Node 1', position: { x: 100, y: 100 } }])
</script>
<template>
<VueFlow v-model="elements">
<Controls />
<SaveRestoreControls />
</VueFlow>
</template>
@@ -1,4 +1,5 @@
<script setup>
import { Panel, PanelPosition } from '@vue-flow/additional-components'
import { useVueFlow } from '@vue-flow/core'
const flowKey = 'example-flow'
@@ -22,19 +23,21 @@ const onRestore = () => {
const onAdd = () => {
const id = nodes.value.length + 1
const newNode = {
id: `random_node-${id}`,
label: `Node ${id}`,
position: { x: Math.random() * dimensions.value.width, y: Math.random() * dimensions.value.height },
}
addNodes([newNode])
}
</script>
<template>
<div class="save__controls">
<Panel :position="PanelPosition.TopRight" class="save-restore-controls">
<button style="background-color: #33a6b8" @click="onSave">save</button>
<button style="background-color: #113285" @click="onRestore">restore</button>
<button style="background-color: #6f3381" @click="onAdd">add node</button>
</div>
</Panel>
</template>
@@ -1,12 +1,8 @@
.save__controls {
position: absolute;
left: 10px;
top: 10px;
z-index: 4;
.save-restore-controls {
font-size: 12px;
}
.save__controls button {
.save-restore-controls button {
margin-left: 5px;
padding: 5px;
border-radius: 5px;
@@ -18,8 +14,7 @@
cursor: pointer;
}
.save__controls button:hover {
opacity: 0.8;
.save-restore-controls button:hover {
transform: scale(105%);
transition: 250ms all ease-in-out;
}