From 5359e3a26a93a0a458981358eb921c5b4b205923 Mon Sep 17 00:00:00 2001
From: Braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Sat, 11 Dec 2021 12:16:52 +0100
Subject: [PATCH] refactor(edges): use plugin to import prop interface
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
---
src/components/Edges/BezierEdge.vue | 44 +++-------------------
src/components/Edges/SmoothStepEdge.vue | 50 ++++---------------------
src/components/Edges/StepEdge.vue | 37 +++---------------
src/components/Edges/StraightEdge.vue | 49 ++++--------------------
4 files changed, 26 insertions(+), 154 deletions(-)
diff --git a/src/components/Edges/BezierEdge.vue b/src/components/Edges/BezierEdge.vue
index 29f4c585..1bb2ace4 100644
--- a/src/components/Edges/BezierEdge.vue
+++ b/src/components/Edges/BezierEdge.vue
@@ -1,37 +1,14 @@
-
+
-import { CSSProperties } from 'vue'
-import { ArrowHeadType, EdgeProps, EdgeTextProps, Position } from '../../types'
-import EdgeText from './EdgeText.vue'
+import { Position } from '../../types'
+import type { SmoothStepEdgeProps } from '../../types/edge'
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils'
-
-interface SmoothStepEdgeProps extends EdgeProps {
- id: string
- source: string
- target: string
- sourceX: number
- sourceY: number
- targetX: number
- targetY: number
- selected?: boolean
- animated?: boolean
- sourcePosition: Position
- targetPosition: Position
- label?: string
- labelStyle?: CSSProperties
- labelShowBg?: boolean
- labelBgStyle?: CSSProperties
- labelBgPadding?: [number, number]
- labelBgBorderRadius?: number
- arrowHeadType?: ArrowHeadType
- markerEndId?: string
- borderRadius?: number
- sourceHandleId?: string
- targetHandleId?: string
-}
+import EdgeText from './EdgeText.vue'
const props = withDefaults(defineProps(), {
selected: false,
- sourcePosition: Position.Bottom,
- targetPosition: Position.Top,
+ sourcePosition: 'bottom' as Position,
+ targetPosition: 'top' as Position,
label: '',
labelStyle: () => ({}),
labelShowBg: true,
@@ -54,8 +29,6 @@ const path = computed(() => {
})
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
-
-const attrs = useAttrs() as Record<'style', CSSProperties>
-
-
+
+
-import { CSSProperties } from 'vue'
-import { ArrowHeadType, EdgeProps, Position } from '../../types'
+import { Position } from '../../types'
+import type { EdgeProps } from '../../types/edge'
import SmoothStepEdge from './SmoothStepEdge.vue'
-interface StepEdgeProps extends EdgeProps {
- id: string
- source: string
- target: string
- sourceX: number
- sourceY: number
- targetX: number
- targetY: number
- selected?: boolean
- animated?: boolean
- sourcePosition: Position
- targetPosition: Position
- label?: string
- labelStyle?: CSSProperties
- labelShowBg?: boolean
- labelBgStyle?: CSSProperties
- labelBgPadding?: [number, number]
- labelBgBorderRadius?: number
- arrowHeadType?: ArrowHeadType
- markerEndId?: string
- sourceHandleId?: string
- targetHandleId?: string
-}
-
-const props = withDefaults(defineProps(), {
+const props = withDefaults(defineProps(), {
selected: false,
- sourcePosition: Position.Bottom,
- targetPosition: Position.Top,
+ sourcePosition: 'bottom' as Position,
+ targetPosition: 'top' as Position,
label: '',
labelStyle: () => ({}),
labelShowBg: true,
labelBgStyle: () => ({}),
})
-const attrs = useAttrs() as Record<'style', CSSProperties>
-
+
diff --git a/src/components/Edges/StraightEdge.vue b/src/components/Edges/StraightEdge.vue
index c13748ea..80eb8ba1 100644
--- a/src/components/Edges/StraightEdge.vue
+++ b/src/components/Edges/StraightEdge.vue
@@ -1,37 +1,13 @@
-
-
+
+