chore(docs): update example styles (#1469)

* chore(docs): update basic example styles

* chore(docs): update confirm delete example styles

* chore(docs): update dnd example styles

* chore(docs): update hidden example

* chore(docs): update update node example

* chore(docs): update node toolbar example styles

* chore(docs): update transition example styles

* chore(docs): cleanup basic example els

* chore(docs): cleanup examples
This commit is contained in:
Braks
2024-06-10 23:51:47 +02:00
committed by braks
parent 5dc8711a6b
commit d71de0a92d
34 changed files with 528 additions and 244 deletions
+52 -30
View File
@@ -3,61 +3,83 @@ import { ref } from 'vue'
import { Position, VueFlow } from '@vue-flow/core'
import ToolbarNode from './ToolbarNode.vue'
const defaultNodeStyle = {
border: '1px solid #10b981',
background: '#ef467e',
color: 'white',
borderRadius: '99px',
}
const nodes = ref([
{
id: '1',
type: 'toolbar',
label: 'toolbar top',
data: { toolbarPosition: Position.Top },
type: 'menu',
data: { label: 'toolbar top', toolbarPosition: Position.Top },
position: { x: 200, y: 0 },
style: defaultNodeStyle,
},
{
id: '2',
type: 'toolbar',
label: 'toolbar right',
data: { toolbarPosition: Position.Right },
type: 'menu',
data: { label: 'toolbar right', toolbarPosition: Position.Right },
position: { x: -50, y: 100 },
style: defaultNodeStyle,
},
{
id: '3',
type: 'toolbar',
label: 'toolbar bottom',
data: { toolbarPosition: Position.Bottom },
type: 'menu',
data: { label: 'toolbar bottom', toolbarPosition: Position.Bottom },
position: { x: 0, y: 200 },
style: defaultNodeStyle,
},
{
id: '4',
type: 'toolbar',
label: 'toolbar left',
data: { toolbarPosition: Position.Left },
type: 'menu',
data: { label: 'toolbar left', toolbarPosition: Position.Left },
position: { x: 200, y: 300 },
style: defaultNodeStyle,
},
{
id: '5',
type: 'toolbar',
label: 'toolbar always open',
data: { toolbarPosition: Position.Top, toolbarVisible: true },
type: 'menu',
data: { label: 'toolbar always open', toolbarPosition: Position.Top, toolbarVisible: true },
position: { x: 0, y: -100 },
style: defaultNodeStyle,
},
])
</script>
<template>
<VueFlow :nodes="nodes" fit-view-on-init class="vue-flow-basic-example">
<template #node-toolbar="nodeProps">
<ToolbarNode :data="nodeProps.data" :label="nodeProps.label" />
<VueFlow :nodes="nodes" fit-view-on-init>
<template #node-menu="props">
<ToolbarNode :id="props.id" :data="props.data" />
</template>
</VueFlow>
</template>
<style>
.vue-flow__node-toolbar {
display: flex;
gap: 0.5rem;
align-items: center;
background-color: #2d3748;
padding: 8px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.vue-flow__node-toolbar button {
background: #4a5568;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 8px;
cursor: pointer;
}
.vue-flow__node-toolbar button.selected {
background: #2563eb;
}
.vue-flow__node-toolbar button:hover {
background: #2563eb;
}
.vue-flow__node-menu {
padding: 16px 24px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
.vue-flow__node-menu.selected {
box-shadow: 0 0 0 2px #2563eb;
}
</style>
+18 -12
View File
@@ -1,23 +1,29 @@
<script setup>
import { Handle, Position } from '@vue-flow/core'
import { Handle, Position, useVueFlow } from '@vue-flow/core'
import { NodeToolbar } from '@vue-flow/node-toolbar'
defineProps(['data', 'label'])
const props = defineProps(['id', 'data'])
const actions = ['👎', '✋', '👍']
const { updateNodeData } = useVueFlow()
</script>
<template>
<NodeToolbar
style="display: flex; gap: 0.5rem; align-items: center"
:is-visible="data.toolbarVisible"
:position="data.toolbarPosition"
>
<button>Action1</button>
<button>Action2</button>
<button>Action3</button>
<NodeToolbar :is-visible="data.toolbarVisible" :position="data.toolbarPosition">
<button
v-for="action of actions"
:key="action"
type="button"
:class="{ selected: action === data.action }"
@click="updateNodeData(props.id, { action })"
>
{{ action }}
</button>
</NodeToolbar>
<div :style="{ padding: '10px 20px' }">
{{ label }}
<div>
{{ data.label }}
</div>
<Handle type="target" :position="Position.Left" />