Files
ComfyUI_frontend/src/components/graph/modals/ZoomControlsModal.vue
Christian Byrne 24144ebeea Backport PR #6589 (minimap and canvas bg color tokens) to core/1.30 (#6714)
## Summary
Backport of PR #6589 (commit 549ef79e02)
from main to core/1.30 branch.

Updates minimap and canvas background colors to use menu color tokens
(`--comfy-menu-bg`) for consistency across the interface.

## Changes
- Updated minimap container and panel backgrounds to use semantic color
tokens
- Updated canvas menu and zoom controls backgrounds to use consistent
tokens
- Updated user avatar, login button, and other interface elements
- Resolved 20 binary browser test snapshot conflicts using backportee's
copy
- Fixed 8 Vue component conflicts by accepting semantic token changes

## Resolved Conflicts
- **Binary snapshots (20 files)**: Used --theirs (backportee's copy) as
instructed
- **Source files (8 files)**: Accepted cherry-picked semantic token
changes
  - TopMenuSection.vue, UserAvatar.vue, CanvasModeSelector.vue
  - GraphCanvasMenu.vue, ZoomControlsModal.vue, LoginButton.vue  
  - MiniMap.vue, MiniMapPanel.vue

All linting and TypeScript checks passed.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6714-Backport-PR-6589-minimap-and-canvas-bg-color-tokens-to-core-1-30-2ad6d73d3650811d9c82d1e5f3a81a38)
by [Unito](https://www.unito.io)

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alexander Brown <drjkl@comfy.org>
2025-11-18 11:56:00 -07:00

154 lines
4.6 KiB
Vue

<template>
<div
v-if="visible"
class="z-1300 border-0! bg-inherit! absolute bottom-[62px] right-0 flex w-[250px] justify-center"
>
<div
class="w-4/5 rounded-lg border border-interface-stroke bg-interface-panel-surface p-2 text-text-primary shadow-lg select-none"
:style="filteredMinimapStyles"
@click.stop
>
<div class="flex flex-col gap-1">
<div
class="hover:bg-node-component-surface-hovered flex cursor-pointer items-center justify-between rounded px-3 py-2 text-sm"
@mousedown="startRepeat('Comfy.Canvas.ZoomIn')"
@mouseup="stopRepeat"
@mouseleave="stopRepeat"
>
<span class="font-medium">{{ $t('graphCanvasMenu.zoomIn') }}</span>
<span class="text-text-primary text-[9px]">{{
zoomInCommandText
}}</span>
</div>
<div
class="hover:bg-node-component-surface-hovered flex cursor-pointer items-center justify-between rounded px-3 py-2 text-sm"
@mousedown="startRepeat('Comfy.Canvas.ZoomOut')"
@mouseup="stopRepeat"
@mouseleave="stopRepeat"
>
<span class="font-medium">{{ $t('graphCanvasMenu.zoomOut') }}</span>
<span class="text-text-primary text-[9px]">{{
zoomOutCommandText
}}</span>
</div>
<div
class="hover:bg-node-component-surface-hovered flex cursor-pointer items-center justify-between rounded px-3 py-2 text-sm"
@click="executeCommand('Comfy.Canvas.FitView')"
>
<span class="font-medium">{{ $t('zoomControls.zoomToFit') }}</span>
<span class="text-text-primary text-[9px]">{{
zoomToFitCommandText
}}</span>
</div>
<div
ref="zoomInputContainer"
class="zoomInputContainer bg-input-surface flex items-center gap-1 rounded p-2"
>
<InputNumber
ref="zoomInput"
:default-value="canvasStore.appScalePercentage"
:min="1"
:max="1000"
:show-buttons="false"
:use-grouping="false"
:unstyled="true"
input-class="bg-transparent border-none outline-hidden text-sm shadow-none my-0 w-full"
fluid
@input="applyZoom"
@keyup.enter="applyZoom"
/>
<span class="text-text-primary shrink-0 text-sm">%</span>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import type { InputNumberInputEvent } from 'primevue'
import { InputNumber } from 'primevue'
import { computed, nextTick, ref, watch } from 'vue'
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { useMinimap } from '@/renderer/extensions/minimap/composables/useMinimap'
import { useCommandStore } from '@/stores/commandStore'
const minimap = useMinimap()
const commandStore = useCommandStore()
const canvasStore = useCanvasStore()
const { formatKeySequence } = useCommandStore()
interface Props {
visible: boolean
}
const props = defineProps<Props>()
const interval = ref<number | null>(null)
const applyZoom = (val: InputNumberInputEvent) => {
const inputValue = val.value as number
if (isNaN(inputValue) || inputValue < 1 || inputValue > 1000) {
return
}
canvasStore.setAppZoomFromPercentage(inputValue)
}
const executeCommand = (command: string) => {
void commandStore.execute(command)
}
const startRepeat = (command: string) => {
if (interval.value) return
const cmd = () => commandStore.execute(command)
void cmd()
interval.value = window.setInterval(cmd, 100)
}
const stopRepeat = () => {
if (interval.value) {
clearInterval(interval.value)
interval.value = null
}
}
const filteredMinimapStyles = computed(() => {
return {
...minimap.containerStyles.value,
height: undefined,
width: undefined
}
})
const zoomInCommandText = computed(() =>
formatKeySequence(commandStore.getCommand('Comfy.Canvas.ZoomIn'))
)
const zoomOutCommandText = computed(() =>
formatKeySequence(commandStore.getCommand('Comfy.Canvas.ZoomOut'))
)
const zoomToFitCommandText = computed(() =>
formatKeySequence(commandStore.getCommand('Comfy.Canvas.FitView'))
)
const zoomInput = ref<InstanceType<typeof InputNumber> | null>(null)
const zoomInputContainer = ref<HTMLDivElement | null>(null)
watch(
() => props.visible,
async (newVal) => {
if (newVal) {
await nextTick()
const input = zoomInputContainer.value?.querySelector(
'input'
) as HTMLInputElement
input?.focus()
}
}
)
</script>
<style>
.zoomInputContainer:focus-within {
border: 1px solid var(--color-white);
}
</style>