feat: add lazy loading to product images across market components

- Implemented lazy loading for product images in CartItem, CartSummary, ProductCard, ProductDetailDialog, CheckoutPage, and StallView components.
- This enhancement improves performance by deferring the loading of off-screen images, resulting in faster initial page load times and a smoother user experience.

These changes optimize image handling across the market module, contributing to better resource management and user interaction.
This commit is contained in:
padreug 2025-09-27 18:48:57 +02:00
parent b3428c2905
commit 43c368e4e4
6 changed files with 11 additions and 3 deletions

View file

@ -8,6 +8,7 @@
:src="item.product.images?.[0] || '/placeholder-product.png'" :src="item.product.images?.[0] || '/placeholder-product.png'"
:alt="item.product.name" :alt="item.product.name"
class="w-16 h-16 object-cover rounded-md" class="w-16 h-16 object-cover rounded-md"
loading="lazy"
@error="handleImageError" @error="handleImageError"
/> />
</div> </div>
@ -106,6 +107,7 @@
:src="item.product.images?.[0] || '/placeholder-product.png'" :src="item.product.images?.[0] || '/placeholder-product.png'"
:alt="item.product.name" :alt="item.product.name"
class="w-16 h-16 object-cover rounded-md" class="w-16 h-16 object-cover rounded-md"
loading="lazy"
@error="handleImageError" @error="handleImageError"
/> />
</div> </div>

View file

@ -20,6 +20,7 @@
:src="item.product.images?.[0] || '/placeholder-product.png'" :src="item.product.images?.[0] || '/placeholder-product.png'"
:alt="item.product.name" :alt="item.product.name"
class="w-8 h-8 object-cover rounded" class="w-8 h-8 object-cover rounded"
loading="lazy"
/> />
<div> <div>
<p class="font-medium text-foreground">{{ item.product.name }}</p> <p class="font-medium text-foreground">{{ item.product.name }}</p>

View file

@ -6,6 +6,7 @@
:src="product.images?.[0] || '/placeholder-product.png'" :src="product.images?.[0] || '/placeholder-product.png'"
:alt="product.name" :alt="product.name"
class="w-full h-48 object-cover" class="w-full h-48 object-cover"
loading="lazy"
@error="handleImageError" @error="handleImageError"
/> />

View file

@ -17,6 +17,7 @@
:src="currentImage" :src="currentImage"
:alt="product.name" :alt="product.name"
class="w-full h-full object-cover" class="w-full h-full object-cover"
loading="lazy"
@error="handleImageError" @error="handleImageError"
/> />
<div v-else class="w-full h-full flex items-center justify-center"> <div v-else class="w-full h-full flex items-center justify-center">
@ -37,6 +38,7 @@
:src="image" :src="image"
:alt="`${product.name} - Image ${index + 1}`" :alt="`${product.name} - Image ${index + 1}`"
class="w-full h-full object-cover" class="w-full h-full object-cover"
loading="lazy"
/> />
</button> </button>
</div> </div>

View file

@ -54,11 +54,12 @@
<div class="flex items-center space-x-4"> <div class="flex items-center space-x-4">
<!-- Product Image --> <!-- Product Image -->
<div class="w-16 h-16 bg-muted rounded-lg flex items-center justify-center"> <div class="w-16 h-16 bg-muted rounded-lg flex items-center justify-center">
<img <img
v-if="item.product.images?.[0]" v-if="item.product.images?.[0]"
:src="item.product.images[0]" :src="item.product.images[0]"
:alt="item.product.name" :alt="item.product.name"
class="w-full h-full object-cover rounded-lg" class="w-full h-full object-cover rounded-lg"
loading="lazy"
/> />
<Package v-else class="w-8 h-8 text-muted-foreground" /> <Package v-else class="w-8 h-8 text-muted-foreground" />
</div> </div>

View file

@ -24,6 +24,7 @@
:src="stall.logo" :src="stall.logo"
:alt="stall.name" :alt="stall.name"
class="w-full h-full object-cover" class="w-full h-full object-cover"
loading="lazy"
@error="handleLogoError" @error="handleLogoError"
/> />
</div> </div>