chore(examples): cleanup
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,7 @@ const elements = ref<Elements>([
|
|||||||
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' },
|
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' },
|
||||||
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 }, class: 'light' },
|
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 }, class: 'light' },
|
||||||
{ id: 'e1-2', source: '1', target: '2', animated: true },
|
{ id: 'e1-2', source: '1', target: '2', animated: true },
|
||||||
{ id: 'e1-3', source: '1', target: '5' },
|
{ id: 'e1-3', source: '1', target: '3' },
|
||||||
])
|
])
|
||||||
const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject } = useVueFlow({
|
const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject } = useVueFlow({
|
||||||
minZoom: 0.2,
|
minZoom: 0.2,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ interface Data {
|
|||||||
interface ColorSelectorNodeProps extends NodeProps<Data, {}, 'selectorNode'> {
|
interface ColorSelectorNodeProps extends NodeProps<Data, {}, 'selectorNode'> {
|
||||||
data: Data
|
data: Data
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<ColorSelectorNodeProps>()
|
const props = defineProps<ColorSelectorNodeProps>()
|
||||||
|
|
||||||
const targetHandleStyle: CSSProperties = { background: '#555' }
|
const targetHandleStyle: CSSProperties = { background: '#555' }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Elements, Node, SnapGrid } from '@vue-flow/core'
|
import type { Elements, Node, SnapGrid } from '@vue-flow/core'
|
||||||
import { ConnectionMode, Position, VueFlow, isEdge, useVueFlow } from '@vue-flow/core'
|
import { Position, VueFlow, isEdge, useVueFlow } from '@vue-flow/core'
|
||||||
|
|
||||||
import { Controls } from '@vue-flow/controls'
|
import { Controls } from '@vue-flow/controls'
|
||||||
import { MiniMap } from '@vue-flow/minimap'
|
import { MiniMap } from '@vue-flow/minimap'
|
||||||
@@ -24,7 +24,6 @@ const elements = ref<Elements>([
|
|||||||
type: 'selectorNode',
|
type: 'selectorNode',
|
||||||
data: { onChange, color: bgColor },
|
data: { onChange, color: bgColor },
|
||||||
style: { border: '1px solid #777', padding: '10px' },
|
style: { border: '1px solid #777', padding: '10px' },
|
||||||
parentNode: '1',
|
|
||||||
position: { x: 250, y: 50 },
|
position: { x: 250, y: 50 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -48,7 +47,6 @@ const elements = ref<Elements>([
|
|||||||
])
|
])
|
||||||
|
|
||||||
useVueFlow({
|
useVueFlow({
|
||||||
connectionMode: ConnectionMode.Loose,
|
|
||||||
connectionLineOptions: {
|
connectionLineOptions: {
|
||||||
style: connectionLineStyle,
|
style: connectionLineStyle,
|
||||||
},
|
},
|
||||||
@@ -57,19 +55,32 @@ useVueFlow({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function nodeStroke(n: Node) {
|
function nodeStroke(n: Node) {
|
||||||
if (n.type === 'input') return '#0041d0'
|
switch (n.type) {
|
||||||
if (n.type === 'selectorNode') return bgColor.value
|
case 'selectorNode':
|
||||||
if (n.type === 'output') return '#ff0072'
|
return bgColor.value
|
||||||
return '#eee'
|
case 'input':
|
||||||
|
return '#0041d0'
|
||||||
|
case 'output':
|
||||||
|
return '#ff0072'
|
||||||
|
default:
|
||||||
|
return '#eee'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nodeColor(n: Node) {
|
function nodeColor(n: Node) {
|
||||||
if (n.type === 'selectorNode') return bgColor.value
|
if (n.type === 'selectorNode') {
|
||||||
|
return bgColor.value
|
||||||
|
}
|
||||||
|
|
||||||
return '#fff'
|
return '#fff'
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(event: InputEvent) {
|
function onChange(event: InputEvent) {
|
||||||
elements.value.forEach((e) => {
|
elements.value.forEach((e) => {
|
||||||
if (isEdge(e) || e.id !== '2') return e
|
if (isEdge(e) || e.id !== '2') {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
bgColor.value = (event.target as HTMLInputElement).value
|
bgColor.value = (event.target as HTMLInputElement).value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user