Skip to content

Commit 69e05cf

Browse files
committed
feat: add toolbar component
1 parent f28324a commit 69e05cf

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed

packages/elements/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@vue-flow/background": "^1.3.2",
1212
"@vue-flow/controls": "^1.1.3",
1313
"@vue-flow/core": "^1.47.0",
14+
"@vue-flow/node-toolbar": "^1.1.1",
1415
"@vueuse/core": "^13.9.0",
1516
"ai": "^5.0.60",
1617
"lucide-vue-next": "^0.544.0",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { cn } from '@repo/shadcn-vue/lib/utils'
4+
import { Position } from '@vue-flow/core'
5+
import { NodeToolbar } from '@vue-flow/node-toolbar'
6+
import { reactiveOmit } from '@vueuse/core'
7+
8+
const props = withDefaults(
9+
defineProps<{
10+
class?: HTMLAttributes['class']
11+
position?: Position
12+
}>(),
13+
{
14+
position: Position.Bottom,
15+
},
16+
)
17+
18+
const delegatedProps = reactiveOmit(props, 'class')
19+
</script>
20+
21+
<template>
22+
<NodeToolbar
23+
data-slot="toolbar"
24+
v-bind="delegatedProps"
25+
:class="cn(
26+
'flex items-center gap-1 rounded-sm border bg-background p-1.5',
27+
props.class,
28+
)"
29+
>
30+
<slot />
31+
</NodeToolbar>
32+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Toolbar } from './Toolbar.vue'

packages/examples/src/custom-node.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import type { NodeProps } from '@vue-flow/core'
33
import { Node, NodeContent, NodeDescription, NodeFooter, NodeHeader, NodeTitle } from '@repo/elements/node'
4+
import { Toolbar } from '@repo/elements/toolbar'
5+
import { Button } from '@repo/shadcn-vue/components/ui/button'
46
57
const props = defineProps<NodeProps>()
68
</script>
@@ -23,5 +25,14 @@ const props = defineProps<NodeProps>()
2325
{{ props.data?.footer }}
2426
</p>
2527
</NodeFooter>
28+
29+
<Toolbar>
30+
<Button size="sm" variant="ghost">
31+
Edit
32+
</Button>
33+
<Button size="sm" variant="ghost">
34+
Delete
35+
</Button>
36+
</Toolbar>
2637
</Node>
2738
</template>

pnpm-lock.yaml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)