chore(examples): update custom edge example

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-14 19:04:13 +01:00
committed by Braks
parent f0f7e7e49a
commit f983549d1c
+13 -12
View File
@@ -1,12 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { EdgeProps, Position } from '@vue-flow/core' import type { EdgeProps, Position } from '@vue-flow/core'
import { EdgeText, getBezierPath, getMarkerId } from '@vue-flow/core' import { BezierEdge } from '@vue-flow/core'
interface CustomData { interface CustomData {
text: string text: string
} }
interface CustomEdgeProps<T = CustomData> extends EdgeProps<T> { interface CustomEdgeProps extends EdgeProps<CustomData> {
source: string source: string
target: string target: string
sourceHandleId?: string sourceHandleId?: string
@@ -18,13 +18,11 @@ interface CustomEdgeProps<T = CustomData> extends EdgeProps<T> {
targetY: number targetY: number
sourcePosition: Position sourcePosition: Position
targetPosition: Position targetPosition: Position
markerEnd?: string markerEnd: string
data: T data: CustomData
} }
const props = defineProps<CustomEdgeProps>() defineProps<CustomEdgeProps>()
const path = $computed(() => getBezierPath(props))
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -34,12 +32,15 @@ export default {
</script> </script>
<template> <template>
<path :id="id" class="vue-flow__edge-path" :d="path[0]" :marker-end="markerEnd" /> <BezierEdge
<EdgeText
:x="path[1]"
:y="path[2]"
:label="data.text" :label="data.text"
:source-x="sourceX"
:source-y="sourceY"
:target-x="targetX"
:target-y="targetY"
:source-position="sourcePosition"
:target-position="targetPosition"
:marker-end="markerEnd"
:label-style="{ fill: 'white' }" :label-style="{ fill: 'white' }"
:label-show-bg="true" :label-show-bg="true"
:label-bg-style="{ fill: 'red' }" :label-bg-style="{ fill: 'red' }"