Line data Source code
1 : <script setup lang="ts">
2 : import { ref, useTemplateRef } from 'vue'
3 :
4 : import ZoomPane from '@comfyorg/design-system/media/ZoomPane'
5 : import { useExecutionStatus } from '@/renderer/extensions/linearMode/useExecutionStatus'
6 : import { cn } from '@comfyorg/tailwind-utils'
7 :
8 2355 : const { executionStatusMessage } = useExecutionStatus()
9 :
10 : defineOptions({ inheritAttrs: false })
11 :
12 : const { src, showSize = true } = defineProps<{
13 : src: string
14 : mobile?: boolean
15 : label?: string
16 : showSize?: boolean
17 : }>()
18 :
19 11 : const imageRef = useTemplateRef('imageRef')
20 11 : const width = ref<number | null>(null)
21 11 : const height = ref<number | null>(null)
22 :
23 2 : function onImageLoad() {
24 2 : if (!imageRef.value || !showSize) return
25 0 : width.value = imageRef.value.naturalWidth
26 0 : height.value = imageRef.value.naturalHeight
27 : }
28 11 : </script>
29 : <template>
30 : <ZoomPane
31 : v-if="!mobile"
32 : v-slot="slotProps"
33 : :class="cn('w-full flex-1', $attrs.class as string)"
34 : >
35 : <img
36 : ref="imageRef"
37 : :src
38 : v-bind="slotProps"
39 : class="size-full object-contain"
40 : @load="onImageLoad"
41 : />
42 : </ZoomPane>
43 : <img
44 : v-else
45 : ref="imageRef"
46 : class="grow object-contain contain-size"
47 : :src
48 : @load="onImageLoad"
49 : />
50 : <span
51 : v-if="executionStatusMessage"
52 : class="animate-pulse self-center text-muted-foreground md:z-10"
53 : >
54 : {{ executionStatusMessage }}
55 : </span>
56 : <span v-else-if="width && height" class="self-center md:z-10">
57 : {{ `${width} x ${height}` }}
58 : <template v-if="label"> | {{ label }}</template>
59 : </span>
60 : </template>
|