mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
## Summary Applied stylelint auto-fixes and resolved manual CSS issues across 25 files to achieve full compliance with stylelint rules. ## Changes - **What**: Auto-fixed 68 CSS issues (legacy color functions, font-weight keywords, shorthand properties, pseudo-element notation) and manually resolved 6 remaining issues (duplicate selectors, vendor prefix duplicates, font fallbacks, Vue v-bind whitelisting) - **Config**: Disabled `no-descending-specificity` rule (43 warnings require architectural CSS refactor) ## Review Focus Verify no visual regressions from modernized CSS syntax: - Modern [color function notation](https://www.w3.org/TR/css-color-4/#funcdef-rgb): `rgba(0, 0, 0, 0.5)` → `rgb(0 0 0 / 50%)` - Numeric font weights: `bold`/`normal` → `700`/`400` - Pseudo-element double colons: `:before` → `::before ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5940-apply-stylelint-auto-fixes-2846d73d365081ee8031c212a69a4bd4) by [Unito](https://www.unito.io) --------- Co-authored-by: DrJKL <DrJKL0424@gmail.com>
239 lines
7.2 KiB
Vue
239 lines
7.2 KiB
Vue
<template>
|
|
<div
|
|
v-if="visible"
|
|
class="w-[250px] absolute flex justify-center right-2 md:right-11 z-1300 bottom-[66px] bg-inherit! border-0!"
|
|
>
|
|
<div
|
|
class="bg-white dark-theme:bg-[#2b2b2b] border border-gray-200 dark-theme:border-gray-700 rounded-lg shadow-lg p-4 w-4/5"
|
|
:style="filteredMinimapStyles"
|
|
@click.stop
|
|
>
|
|
<div>
|
|
<Button
|
|
severity="secondary"
|
|
text
|
|
:pt="{
|
|
root: {
|
|
class:
|
|
'flex items-center justify-between cursor-pointer p-2 rounded w-full text-left hover:bg-transparent! focus:bg-transparent! active:bg-transparent!'
|
|
},
|
|
label: {
|
|
class: 'flex flex-col items-start w-full'
|
|
}
|
|
}"
|
|
@mousedown="startRepeat('Comfy.Canvas.ZoomIn')"
|
|
@mouseup="stopRepeat"
|
|
@mouseleave="stopRepeat"
|
|
>
|
|
<template #default>
|
|
<span class="text-sm font-medium block">{{
|
|
$t('graphCanvasMenu.zoomIn')
|
|
}}</span>
|
|
<span class="text-sm text-gray-500 block">{{
|
|
zoomInCommandText
|
|
}}</span>
|
|
</template>
|
|
</Button>
|
|
|
|
<Button
|
|
severity="secondary"
|
|
text
|
|
:pt="{
|
|
root: {
|
|
class:
|
|
'flex items-center justify-between cursor-pointer p-2 rounded w-full text-left hover:bg-transparent! focus:bg-transparent! active:bg-transparent!'
|
|
},
|
|
label: {
|
|
class: 'flex flex-col items-start w-full'
|
|
}
|
|
}"
|
|
@mousedown="startRepeat('Comfy.Canvas.ZoomOut')"
|
|
@mouseup="stopRepeat"
|
|
@mouseleave="stopRepeat"
|
|
>
|
|
<template #default>
|
|
<span class="text-sm font-medium block">{{
|
|
$t('graphCanvasMenu.zoomOut')
|
|
}}</span>
|
|
<span class="text-sm text-gray-500 block">{{
|
|
zoomOutCommandText
|
|
}}</span>
|
|
</template>
|
|
</Button>
|
|
|
|
<Button
|
|
severity="secondary"
|
|
text
|
|
:pt="{
|
|
root: {
|
|
class:
|
|
'flex items-center justify-between cursor-pointer p-2 rounded w-full text-left hover:bg-transparent! focus:bg-transparent! active:bg-transparent!'
|
|
},
|
|
label: {
|
|
class: 'flex flex-col items-start w-full'
|
|
}
|
|
}"
|
|
@click="executeCommand('Comfy.Canvas.FitView')"
|
|
>
|
|
<template #default>
|
|
<span class="text-sm font-medium block">{{
|
|
$t('zoomControls.zoomToFit')
|
|
}}</span>
|
|
<span class="text-sm text-gray-500 block">{{
|
|
zoomToFitCommandText
|
|
}}</span>
|
|
</template>
|
|
</Button>
|
|
<hr class="border-[#E1DED5] mb-1 dark-theme:border-[#2E3037]" />
|
|
<Button
|
|
severity="secondary"
|
|
text
|
|
data-testid="toggle-minimap-button"
|
|
:pt="{
|
|
root: {
|
|
class:
|
|
'flex items-center justify-between cursor-pointer p-2 rounded w-full text-left hover:bg-transparent! focus:bg-transparent! active:bg-transparent!'
|
|
},
|
|
label: {
|
|
class: 'flex flex-col items-start w-full'
|
|
}
|
|
}"
|
|
@click="executeCommand('Comfy.Canvas.ToggleMinimap')"
|
|
>
|
|
<template #default>
|
|
<span class="text-sm font-medium block">{{
|
|
minimapToggleText
|
|
}}</span>
|
|
<span class="text-sm text-gray-500 block">{{
|
|
showMinimapCommandText
|
|
}}</span>
|
|
</template>
|
|
</Button>
|
|
<hr class="border-[#E1DED5] mt-1 dark-theme:border-[#2E3037]" />
|
|
<div
|
|
ref="zoomInputContainer"
|
|
class="flex items-center px-2 bg-[#E7E6E6] focus-within:bg-[#F3F3F3] dark-theme:bg-[#8282821A] rounded p-2 zoomInputContainer"
|
|
>
|
|
<InputNumber
|
|
ref="zoomInput"
|
|
:default-value="canvasStore.appScalePercentage"
|
|
:min="1"
|
|
:max="1000"
|
|
:show-buttons="false"
|
|
:use-grouping="false"
|
|
:unstyled="true"
|
|
input-class="flex-1 bg-transparent border-none outline-hidden text-sm shadow-none my-0 "
|
|
fluid
|
|
@input="applyZoom"
|
|
@keyup.enter="applyZoom"
|
|
/>
|
|
<span class="text-sm text-gray-500 -ml-4">%</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import type { InputNumberInputEvent } from 'primevue'
|
|
import { Button, InputNumber } from 'primevue'
|
|
import { computed, nextTick, ref, watch } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
|
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
|
import { useMinimap } from '@/renderer/extensions/minimap/composables/useMinimap'
|
|
import { useCommandStore } from '@/stores/commandStore'
|
|
|
|
const { t } = useI18n()
|
|
const minimap = useMinimap()
|
|
const settingStore = useSettingStore()
|
|
const commandStore = useCommandStore()
|
|
const canvasStore = useCanvasStore()
|
|
const { formatKeySequence } = useCommandStore()
|
|
|
|
interface Props {
|
|
visible: boolean
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
const interval = ref<number | null>(null)
|
|
|
|
// Computed properties for reactive states
|
|
const minimapToggleText = computed(() =>
|
|
settingStore.get('Comfy.Minimap.Visible')
|
|
? t('zoomControls.hideMinimap')
|
|
: t('zoomControls.showMinimap')
|
|
)
|
|
|
|
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 showMinimapCommandText = computed(() =>
|
|
formatKeySequence(commandStore.getCommand('Comfy.Canvas.ToggleMinimap'))
|
|
)
|
|
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 rgb(204 204 204);
|
|
}
|
|
|
|
.dark-theme .zoomInputContainer:focus-within {
|
|
border: 1px solid rgb(204 204 204);
|
|
}
|
|
</style>
|