docs: add toolbar example
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import { TeleportApp, TeleportCSS, TeleportSidebar, TeleportableNode, Teleportab
|
||||
import { TransitionApp, TransitionCSS, TransitionEdge } from './transition'
|
||||
import { IntersectionApp, IntersectionCSS, IntersectionElements } from './intersection'
|
||||
import { SnapToHandleApp, SnappableConnectionLine } from './snap-to-handle'
|
||||
import { ToolbarApp, ToolbarNode } from './node-toolbar'
|
||||
|
||||
export const exampleImports = {
|
||||
basic: {
|
||||
@@ -119,4 +120,8 @@ export const exampleImports = {
|
||||
'App.vue': SnapToHandleApp,
|
||||
'SnappableConnectionLine.vue': SnappableConnectionLine,
|
||||
},
|
||||
toolbar: {
|
||||
'App.vue': ToolbarApp,
|
||||
'ToolbarNode.vue': ToolbarNode,
|
||||
},
|
||||
}
|
||||
|
||||
62
docs/components/examples/node-toolbar/App.vue
Normal file
62
docs/components/examples/node-toolbar/App.vue
Normal file
@@ -0,0 +1,62 @@
|
||||
<script setup>
|
||||
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 elements = ref([
|
||||
{
|
||||
id: '1',
|
||||
type: 'toolbar',
|
||||
label: 'toolbar top',
|
||||
data: { toolbarPosition: Position.Top },
|
||||
position: { x: 200, y: 0 },
|
||||
style: defaultNodeStyle,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
type: 'toolbar',
|
||||
label: 'toolbar right',
|
||||
data: { toolbarPosition: Position.Right },
|
||||
position: { x: -50, y: 100 },
|
||||
style: defaultNodeStyle,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
type: 'toolbar',
|
||||
label: 'toolbar bottom',
|
||||
data: { toolbarPosition: Position.Bottom },
|
||||
position: { x: 0, y: 200 },
|
||||
style: defaultNodeStyle,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
type: 'toolbar',
|
||||
label: 'toolbar left',
|
||||
data: { toolbarPosition: Position.Left },
|
||||
position: { x: 200, y: 300 },
|
||||
style: defaultNodeStyle,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
type: 'toolbar',
|
||||
label: 'toolbar always open',
|
||||
data: { toolbarPosition: Position.Top, toolbarVisible: true },
|
||||
position: { x: 0, y: -100 },
|
||||
style: defaultNodeStyle,
|
||||
},
|
||||
])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VueFlow v-model="elements" fit-view-on-init class="vue-flow-basic-example">
|
||||
<template #node-toolbar="nodeProps">
|
||||
<ToolbarNode :data="nodeProps.data" :label="nodeProps.label" />
|
||||
</template>
|
||||
</VueFlow>
|
||||
</template>
|
||||
25
docs/components/examples/node-toolbar/ToolbarNode.vue
Normal file
25
docs/components/examples/node-toolbar/ToolbarNode.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<script setup>
|
||||
import { Handle, Position } from '@vue-flow/core'
|
||||
import { NodeToolbar } from '@vue-flow/node-toolbar'
|
||||
|
||||
defineProps(['data', 'label'])
|
||||
</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>
|
||||
|
||||
<div :style="{ padding: '10px 20px' }">
|
||||
{{ label }}
|
||||
</div>
|
||||
|
||||
<Handle type="target" :position="Position.Left" />
|
||||
<Handle type="source" :position="Position.Right" />
|
||||
</template>
|
||||
2
docs/components/examples/node-toolbar/index.ts
Normal file
2
docs/components/examples/node-toolbar/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as ToolbarApp } from './App.vue?raw'
|
||||
export { default as ToolbarNode } from './ToolbarNode.vue?raw'
|
||||
@@ -211,6 +211,7 @@ export default defineConfigWithTheme<DefaultTheme.Config>({
|
||||
{ text: 'Custom Node', link: '/examples/nodes/' },
|
||||
{ text: 'Update Node', link: '/examples/nodes/update-node' },
|
||||
{ text: 'Nested Nodes', link: '/examples/nodes/nesting' },
|
||||
{ text: 'Node Toolbar', link: '/examples/nodes/node-toolbar' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -12,6 +12,10 @@ export function copyVueFlowPlugin(): Plugin {
|
||||
path: '../../../node_modules/@vue-flow/additional-components/dist/',
|
||||
pkgName: 'vue-flow-additional-components.mjs',
|
||||
},
|
||||
{
|
||||
path: '../../../node_modules/@vue-flow/node-toolbar/dist/',
|
||||
pkgName: 'vue-flow-node-toolbar.mjs',
|
||||
},
|
||||
].forEach(({ path, pkgName }) => {
|
||||
const filePath = resolve(__dirname, `${path}/${pkgName}`)
|
||||
if (!existsSync(filePath)) {
|
||||
|
||||
10
docs/src/examples/nodes/node-toolbar.md
Normal file
10
docs/src/examples/nodes/node-toolbar.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Node Toolbar
|
||||
|
||||
This is a toolbar component for Vue Flow.
|
||||
It can be used to create a floating Toolbar next to your nodes.
|
||||
You can either display the Toolbar by setting the visibility prop or automatically showing the Toolbar
|
||||
on selected nodes.
|
||||
|
||||
<div class="mt-6">
|
||||
<Repl example="toolbar"></Repl>
|
||||
</div>
|
||||
Reference in New Issue
Block a user