Skip to content

Commit 69d3335

Browse files
committed
fix: vue nodes image preview widget, better multi image gallery support
1 parent 3c8def7 commit 69d3335

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

src/renderer/extensions/vueNodes/components/ImagePreview.vue

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
v-if="imageUrls.length > 0"
4-
class="image-preview group relative flex size-full min-h-16 min-w-16 flex-col px-2 justify-center"
4+
class="image-preview outline-none group relative flex size-full min-h-16 min-w-16 flex-col px-2 justify-center"
55
tabindex="0"
66
role="region"
77
:aria-label="$t('g.imagePreview')"
@@ -11,7 +11,7 @@
1111
>
1212
<!-- Image Wrapper -->
1313
<div
14-
class="h-full w-full overflow-hidden rounded-[5px] bg-node-component-surface"
14+
class="h-full w-full overflow-hidden rounded-[5px] bg-node-component-surface relative"
1515
>
1616
<!-- Error State -->
1717
<div
@@ -24,16 +24,13 @@
2424
{{ getImageFilename(currentImageUrl) }}
2525
</p>
2626
</div>
27-
2827
<!-- Loading State -->
2928
<Skeleton
3029
v-if="isLoading && !imageError"
31-
class="absolute inset-0 size-full"
3230
border-radius="5px"
33-
width="16rem"
34-
height="16rem"
31+
width="100%"
32+
height="100%"
3533
/>
36-
3734
<!-- Main Image -->
3835
<img
3936
v-if="!imageError"
@@ -83,29 +80,10 @@
8380
<i class="icon-[lucide--x] h-4 w-4" />
8481
</button>
8582
</div>
86-
87-
<!-- Multiple Images Navigation -->
88-
<div
89-
v-if="hasMultipleImages"
90-
class="absolute right-2 bottom-2 left-2 flex justify-center gap-1"
91-
>
92-
<button
93-
v-for="(_, index) in imageUrls"
94-
:key="index"
95-
:class="getNavigationDotClass(index)"
96-
:aria-label="
97-
$t('g.viewImageOfTotal', {
98-
index: index + 1,
99-
total: imageUrls.length
100-
})
101-
"
102-
@click="setCurrentIndex(index)"
103-
/>
104-
</div>
10583
</div>
10684

10785
<!-- Image Dimensions -->
108-
<div class="mt-2 text-center text-xs text-white">
86+
<div class="pt-2 text-center text-xs text-white">
10987
<span v-if="imageError" class="text-red-400">
11088
{{ $t('g.errorLoadingImage') }}
11189
</span>
@@ -116,6 +94,21 @@
11694
{{ actualDimensions || $t('g.calculatingDimensions') }}
11795
</span>
11896
</div>
97+
<!-- Multiple Images Navigation -->
98+
<div v-if="hasMultipleImages" class="flex justify-center gap-1 pt-4">
99+
<button
100+
v-for="(_, index) in imageUrls"
101+
:key="index"
102+
:class="getNavigationDotClass(index)"
103+
:aria-label="
104+
$t('g.viewImageOfTotal', {
105+
index: index + 1,
106+
total: imageUrls.length
107+
})
108+
"
109+
@click="setCurrentIndex(index)"
110+
/>
111+
</div>
119112
</div>
120113
</template>
121114

@@ -230,6 +223,7 @@ const handleRemove = () => {
230223
}
231224
232225
const setCurrentIndex = (index: number) => {
226+
if (currentIndex.value === index) return
233227
if (index >= 0 && index < props.imageUrls.length) {
234228
currentIndex.value = index
235229
actualDimensions.value = null
@@ -248,8 +242,8 @@ const handleMouseLeave = () => {
248242
249243
const getNavigationDotClass = (index: number) => {
250244
return [
251-
'w-2 h-2 rounded-full transition-all duration-200 border-0 cursor-pointer',
252-
index === currentIndex.value ? 'bg-white' : 'bg-white/50 hover:bg-white/80'
245+
'size-2 rounded-full transition-all duration-200 border-0 cursor-pointer p-0',
246+
index === currentIndex.value ? 'bg-white' : 'bg-white/75 hover:bg-white/80'
253247
]
254248
}
255249

0 commit comments

Comments
 (0)