Line data Source code
1 : <template>
2 : <div
3 9929 : v-if="visible && initialized"
4 : ref="minimapRef"
5 : :class="
6 : cn(
7 : 'minimap-main-container absolute right-0 bottom-[54px] isolate flex',
8 : isMobile ? 'flex-col' : 'flex-row'
9 : )
10 : "
11 : >
12 : <MiniMapPanel
13 : v-if="showOptionsPanel"
14 : :panel-styles="panelStyles"
15 : :node-colors="nodeColors"
16 : :show-links="showLinks"
17 : :show-groups="showGroups"
18 : :render-bypass="renderBypass"
19 : :render-error="renderError"
20 : :is-mobile="isMobile"
21 : @update-option="updateOption"
22 : />
23 :
24 : <div
25 : ref="containerRef"
26 : class="litegraph-minimap relative border bg-background shadow-md"
27 : data-testid="minimap-container"
28 : :aria-label="`${$t('minimap.label')}. ${$t('minimap.highlightedNodes', { count: decorationCount })}`"
29 : :style="containerStyles"
30 : >
31 : <Button
32 : class="absolute top-0 left-0 z-10"
33 : size="icon"
34 : variant="muted-textonly"
35 : :aria-label="$t('g.settings')"
36 : @click.stop="toggleOptionsPanel"
37 : >
38 : <i class="icon-[lucide--settings-2]" />
39 : </Button>
40 : <Button
41 : class="absolute top-0 right-0 z-10"
42 : size="icon"
43 : variant="muted-textonly"
44 : :aria-label="$t('g.close')"
45 : data-testid="close-minimap-button"
46 : @click.stop="() => commandStore.execute('Comfy.Canvas.ToggleMinimap')"
47 : >
48 : <i class="icon-[lucide--x]" />
49 : </Button>
50 :
51 : <hr
52 : class="absolute top-8 h-px border-0 bg-border"
53 : :style="{
54 : width: containerStyles.width
55 : }"
56 : />
57 :
58 : <canvas
59 : ref="canvasRef"
60 : :width="width"
61 : :height="height"
62 : class="minimap-canvas"
63 : data-testid="minimap-canvas"
64 : />
65 :
66 : <div
67 : class="minimap-viewport"
68 : :style="viewportStyles"
69 : data-testid="minimap-viewport"
70 : />
71 :
72 : <div
73 : class="absolute inset-0 touch-none"
74 : data-testid="minimap-interaction-overlay"
75 : @pointerdown="handlePointerDown"
76 : @pointermove="handlePointerMove"
77 : @pointerup="handlePointerUp"
78 : @pointerleave="handlePointerUp"
79 : @pointercancel="handlePointerCancel"
80 : @wheel="handleWheel"
81 : />
82 : </div>
83 : </div>
84 : </template>
85 :
86 : <script setup lang="ts">
87 : import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
88 : import { onMounted, onUnmounted, ref, useTemplateRef } from 'vue'
89 :
90 : import Button from '@comfyorg/design-system/button/Button'
91 : import { useMinimap } from '@/renderer/extensions/minimap/composables/useMinimap'
92 : import { useCommandStore } from '@/platform/keybindings/commandStore'
93 : import { cn } from '@comfyorg/tailwind-utils'
94 :
95 : import MiniMapPanel from './MiniMapPanel.vue'
96 :
97 1966 : const isMobile = useBreakpoints(breakpointsTailwind).smaller('md')
98 :
99 1966 : const commandStore = useCommandStore()
100 1966 : const minimapRef = ref<HTMLDivElement>()
101 1966 : const containerRef = useTemplateRef<HTMLDivElement>('containerRef')
102 1966 : const canvasRef = useTemplateRef<HTMLCanvasElement>('canvasRef')
103 :
104 1966 : const {
105 : initialized,
106 : visible,
107 : decorationCount,
108 : containerStyles,
109 : viewportStyles,
110 : width,
111 : height,
112 : panelStyles,
113 : nodeColors,
114 : showLinks,
115 : showGroups,
116 : renderBypass,
117 : renderError,
118 : updateOption,
119 : destroy,
120 : handlePointerDown,
121 : handlePointerMove,
122 : handlePointerUp,
123 : handlePointerCancel,
124 : handleWheel,
125 : setMinimapRef
126 : } = useMinimap({
127 : containerRefMaybe: containerRef,
128 : canvasRefMaybe: canvasRef
129 : })
130 :
131 1966 : const showOptionsPanel = ref(false)
132 :
133 1966 : const toggleOptionsPanel = () => {
134 0 : showOptionsPanel.value = !showOptionsPanel.value
135 : }
136 :
137 1966 : onMounted(() => {
138 1966 : if (minimapRef.value) {
139 1966 : setMinimapRef(minimapRef.value)
140 : }
141 : })
142 :
143 1966 : onUnmounted(() => {
144 68 : destroy()
145 : })
146 : </script>
147 :
148 : <style scoped>
149 : .litegraph-minimap {
150 : overflow: hidden;
151 : }
152 :
153 : .minimap-canvas {
154 : display: block;
155 : width: 100%;
156 : height: 100%;
157 : pointer-events: none;
158 : }
159 :
160 : .minimap-viewport {
161 : position: absolute;
162 : top: 0;
163 : left: 0;
164 : pointer-events: none;
165 : }
166 : </style>
|