mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
refactor: address non-blocking review feedback
- Extract footerWrapperBase constant to eliminate third inline duplicate - Consolidate 3 radius computed into shared getBottomRadius helper - Narrow useVueElementTracking parameter from MaybeRefOrGetter to string (toValue was called eagerly at setup, making reactive updates impossible)
This commit is contained in:
@@ -343,7 +343,7 @@ const { handleNodeCollapse, handleNodeTitleUpdate, handleNodeRightClick } =
|
||||
useNodeEventHandlers()
|
||||
const { bringNodeToFront } = useNodeZIndex()
|
||||
|
||||
useVueElementTracking(() => nodeData.id, 'node')
|
||||
useVueElementTracking(String(nodeData.id), 'node')
|
||||
|
||||
const { selectedNodeIds } = storeToRefs(useCanvasStore())
|
||||
const isSelected = computed(() => {
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
v-else-if="isSubgraph"
|
||||
:class="
|
||||
cn(
|
||||
'isolate -z-1 -mt-5 box-border flex',
|
||||
footerWrapperBase,
|
||||
hasAnyError ? '-mx-1 -mb-2 w-[calc(100%+8px)] pb-1' : 'w-full'
|
||||
)
|
||||
"
|
||||
@@ -156,7 +156,7 @@
|
||||
v-else-if="showAdvancedInputsButton || showAdvancedState"
|
||||
:class="
|
||||
cn(
|
||||
'isolate -z-1 -mt-5 box-border flex',
|
||||
footerWrapperBase,
|
||||
hasAnyError ? '-mx-1 -mb-2 w-[calc(100%+8px)] pb-1' : 'w-full'
|
||||
)
|
||||
"
|
||||
@@ -227,42 +227,33 @@ defineEmits<{
|
||||
(e: 'toggleAdvanced'): void
|
||||
}>()
|
||||
|
||||
const footerRadiusClass = computed(() => {
|
||||
const isError = hasAnyError
|
||||
switch (shape) {
|
||||
case RenderShape.BOX:
|
||||
return ''
|
||||
case RenderShape.CARD:
|
||||
return isError ? 'rounded-br-[20px]' : 'rounded-br-[17px]'
|
||||
default:
|
||||
return isError ? 'rounded-b-[20px]' : 'rounded-b-[17px]'
|
||||
}
|
||||
})
|
||||
function getBottomRadius(
|
||||
nodeShape: RenderShape | undefined,
|
||||
size: string,
|
||||
corners: 'both' | 'right' = 'both'
|
||||
): string {
|
||||
if (nodeShape === RenderShape.BOX) return ''
|
||||
const prefix =
|
||||
nodeShape === RenderShape.CARD || corners === 'right'
|
||||
? 'rounded-br'
|
||||
: 'rounded-b'
|
||||
return `${prefix}-[${size}]`
|
||||
}
|
||||
|
||||
const errorRadiusClass = computed(() => {
|
||||
switch (shape) {
|
||||
case RenderShape.BOX:
|
||||
return ''
|
||||
case RenderShape.CARD:
|
||||
return 'rounded-br-[20px]'
|
||||
default:
|
||||
return 'rounded-b-[20px]'
|
||||
}
|
||||
})
|
||||
const footerRadiusClass = computed(() =>
|
||||
getBottomRadius(shape, hasAnyError ? '20px' : '17px')
|
||||
)
|
||||
|
||||
const enterRadiusClass = computed(() => {
|
||||
switch (shape) {
|
||||
case RenderShape.BOX:
|
||||
return ''
|
||||
case RenderShape.CARD:
|
||||
default:
|
||||
return 'rounded-br-[20px]'
|
||||
}
|
||||
})
|
||||
const errorRadiusClass = computed(() => getBottomRadius(shape, '20px'))
|
||||
|
||||
const enterRadiusClass = computed(() => getBottomRadius(shape, '20px', 'right'))
|
||||
|
||||
const tabStyles = 'pointer-events-auto h-9 text-xs'
|
||||
const errorWrapperStyles =
|
||||
'isolate -z-1 -mx-1 -mt-5 -mb-2 box-border flex w-[calc(100%+8px)] pb-1'
|
||||
const footerWrapperBase = 'isolate -z-1 -mt-5 box-border flex'
|
||||
const errorWrapperStyles = cn(
|
||||
footerWrapperBase,
|
||||
'-mx-1 -mb-2 w-[calc(100%+8px)] pb-1'
|
||||
)
|
||||
|
||||
const headerColorStyle = computed(() =>
|
||||
headerColor ? { backgroundColor: headerColor } : undefined
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
* Supports different element types (nodes, slots, widgets, etc.) with
|
||||
* customizable data attributes and update handlers.
|
||||
*/
|
||||
import { getCurrentInstance, onMounted, onUnmounted, toValue, watch } from 'vue'
|
||||
import type { MaybeRefOrGetter } from 'vue'
|
||||
import { getCurrentInstance, onMounted, onUnmounted, watch } from 'vue'
|
||||
|
||||
import { useDocumentVisibility } from '@vueuse/core'
|
||||
|
||||
@@ -291,10 +290,9 @@ const resizeObserver = new ResizeObserver((entries) => {
|
||||
* ```
|
||||
*/
|
||||
export function useVueElementTracking(
|
||||
appIdentifierMaybe: MaybeRefOrGetter<string>,
|
||||
appIdentifier: string,
|
||||
trackingType: string
|
||||
) {
|
||||
const appIdentifier = toValue(appIdentifierMaybe)
|
||||
onMounted(() => {
|
||||
const element = getCurrentInstance()?.proxy?.$el
|
||||
if (!(element instanceof HTMLElement) || !appIdentifier) return
|
||||
|
||||
Reference in New Issue
Block a user