Line data Source code
1 : <script setup lang="ts">
2 : import { remove } from 'es-toolkit'
3 : import { computed } from 'vue'
4 :
5 : import { useAppModeStore } from '@/stores/appModeStore'
6 : import { parseNodeId } from '@comfyorg/graph-model/nodeId'
7 : import type { NodeId, SerializedNodeId } from '@comfyorg/graph-model/nodeId'
8 : import { cn } from '@comfyorg/tailwind-utils'
9 :
10 : const { id } = defineProps<{ id: SerializedNodeId }>()
11 :
12 2355 : const appModeStore = useAppModeStore()
13 40 : const parsedId = computed(() => parseNodeId(id))
14 40 : const isPromoted = computed(() =>
15 : parsedId.value ? appModeStore.selectedOutputs.some(matchesThis) : false
16 : )
17 :
18 40 : function matchesThis(nodeId: NodeId) {
19 40 : return parsedId.value === nodeId
20 : }
21 34 : function togglePromotion() {
22 34 : if (!parsedId.value) return
23 34 : if (isPromoted.value) remove(appModeStore.selectedOutputs, matchesThis)
24 34 : else appModeStore.selectedOutputs.push(parsedId.value)
25 : }
26 40 : </script>
27 : <template>
28 74 : <div
29 : :class="
30 : cn(
31 : 'pointer-events-auto absolute z-1 size-full rounded-2xl ring-5 ring-warning/50',
32 : isPromoted && 'ring-warning'
33 : )
34 : "
35 : @click.capture.stop.prevent
36 : @pointerup.capture.stop.prevent
37 : @pointermove.capture.stop.prevent
38 : @pointerdown.capture.stop="togglePromotion"
39 : @contextmenu.capture.stop.prevent
40 : >
41 : <div class="absolute top-0 right-0 size-8">
42 : <div
43 : v-if="isPromoted"
44 : class="absolute -top-1/2 -right-1/2 size-full rounded-lg bg-warning p-2"
45 : >
46 : <i class="icon-[lucide--check] size-full bg-foreground" />
47 : </div>
48 : <div
49 : v-else
50 : class="absolute -top-1/2 -right-1/2 size-full rounded-lg bg-card ring-4 ring-warning/50 ring-inset"
51 : />
52 : </div>
53 : </div>
54 : </template>
|