From d470ce1f92eb2a1b242542fa86b28b40573bb77b Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Thu, 11 May 2023 15:23:07 +0200
Subject: [PATCH] chore(examples): update RGB examples
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
---
docs/components/home/edges/Custom.vue | 13 +++++--
docs/components/home/nodes/Input.vue | 2 +-
examples/vite/src/RGBFlow/RGBEdge.vue | 56 +++++++++++++++++++++++++++
examples/vite/src/RGBFlow/RGBFlow.vue | 28 +++++++-------
examples/vite/src/RGBFlow/RGBNode.vue | 56 ++++++++++++---------------
examples/vite/src/RGBFlow/utils.ts | 1 +
6 files changed, 105 insertions(+), 51 deletions(-)
create mode 100644 examples/vite/src/RGBFlow/RGBEdge.vue
create mode 100644 examples/vite/src/RGBFlow/utils.ts
diff --git a/docs/components/home/edges/Custom.vue b/docs/components/home/edges/Custom.vue
index 94a8ce81..1cc839b3 100644
--- a/docs/components/home/edges/Custom.vue
+++ b/docs/components/home/edges/Custom.vue
@@ -41,15 +41,20 @@ export default {
-
- {{ data?.text }}
+
+ {{ data.text }}
diff --git a/docs/components/home/nodes/Input.vue b/docs/components/home/nodes/Input.vue
index 6c8ad20d..511a15dc 100644
--- a/docs/components/home/nodes/Input.vue
+++ b/docs/components/home/nodes/Input.vue
@@ -26,7 +26,7 @@ function onChange(e: InputEvent) {
{{ `${currentColor}`.toUpperCase() }}
+import { computed } from 'vue'
+import type { EdgeProps, Position } from '@vue-flow/core'
+import { getBezierPath } from '@vue-flow/core'
+import type { Colors } from './utils'
+
+interface EdgeData {
+ text?: string
+ color?: Colors
+}
+
+interface CustomEdgeProps extends EdgeProps {
+ source: string
+ target: string
+ sourceHandleId?: string
+ targetHandleId?: string
+ id: string
+ sourceX: number
+ sourceY: number
+ targetX: number
+ targetY: number
+ sourcePosition: Position
+ targetPosition: Position
+ markerEnd: string
+ data: {
+ text?: string
+ color?: Colors
+ }
+}
+
+const props = defineProps()
+
+const edgePath = computed(() => getBezierPath(props))
+
+
+
+
+
+
+
+
+
+ {{ data?.text }}
+
+
+
diff --git a/examples/vite/src/RGBFlow/RGBFlow.vue b/examples/vite/src/RGBFlow/RGBFlow.vue
index acc27268..2f7ab25d 100644
--- a/examples/vite/src/RGBFlow/RGBFlow.vue
+++ b/examples/vite/src/RGBFlow/RGBFlow.vue
@@ -3,30 +3,26 @@ import type { Elements } from '@vue-flow/core'
import { VueFlow } from '@vue-flow/core'
import RGBNode from './RGBNode.vue'
import RGBOutputNode from './RGBOutputNode.vue'
-
-interface Colors {
- red: number
- green: number
- blue: number
-}
+import type { Colors } from './utils'
+import RGBEdge from './RGBEdge.vue'
const elements = ref([
- { id: '1', type: 'rgb', data: { color: 'r' }, position: { x: -25, y: 50 } },
- { id: '2', type: 'rgb', data: { color: 'g' }, position: { x: 50, y: -100 } },
- { id: '3', type: 'rgb', data: { color: 'b' }, position: { x: 0, y: 200 } },
+ { id: '1', type: 'rgb', data: { color: 'red' }, position: { x: -25, y: 50 } },
+ { id: '2', type: 'rgb', data: { color: 'green' }, position: { x: 50, y: -100 } },
+ { id: '3', type: 'rgb', data: { color: 'blue' }, position: { x: 0, y: 200 } },
{ id: '4', type: 'rgb-output', data: { label: 'RGB' }, position: { x: 400, y: 50 } },
- { id: 'e1-4', data: { color: 'red' }, source: '1', target: '4', animated: true },
- { id: 'e2-4', data: { color: 'green' }, source: '2', target: '4', animated: true },
- { id: 'e3-4', data: { color: 'blue' }, source: '3', target: '4', animated: true },
+ { id: 'e1-4', type: 'rgb-edge', data: { color: 'red' }, source: '1', target: '4', animated: true },
+ { id: 'e2-4', type: 'rgb-edge', data: { color: 'green' }, source: '2', target: '4', animated: true },
+ { id: 'e3-4', type: 'rgb-edge', data: { color: 'blue' }, source: '3', target: '4', animated: true },
])
-const color = ref({
+const color = ref>({
red: 100,
green: 150,
blue: 100,
})
-function onChange({ color: c, val }: { color: keyof Colors; val: number }) {
+function onChange({ color: c, val }: { color: Colors; val: number }) {
return (color.value[c] = Number(val))
}
@@ -41,6 +37,10 @@ function onChange({ color: c, val }: { color: keyof Colors; val: number }) {
+
+
+
+
diff --git a/examples/vite/src/RGBFlow/RGBNode.vue b/examples/vite/src/RGBFlow/RGBNode.vue
index 61ddc8ed..ad703de4 100644
--- a/examples/vite/src/RGBFlow/RGBNode.vue
+++ b/examples/vite/src/RGBFlow/RGBNode.vue
@@ -1,49 +1,41 @@
-
{{ `${color} Amount`.toUpperCase() }}
-
-
+
{{ `${currentColor}`.toUpperCase() }}
+
+
+
+
diff --git a/examples/vite/src/RGBFlow/utils.ts b/examples/vite/src/RGBFlow/utils.ts
new file mode 100644
index 00000000..625c38d3
--- /dev/null
+++ b/examples/vite/src/RGBFlow/utils.ts
@@ -0,0 +1 @@
+export type Colors = 'red' | 'blue' | 'green'