From 7b29a6f98ebfe65522b8cbcad66a72f050eac3f3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 12 Jul 2026 02:32:02 -0400 Subject: [PATCH] x --- apps/spa/src/components/ProductCard.tsx | 54 ++++++++++++++---- apps/website/src/components/ProductCard.tsx | 63 ++++++++++++++++----- 2 files changed, 91 insertions(+), 26 deletions(-) diff --git a/apps/spa/src/components/ProductCard.tsx b/apps/spa/src/components/ProductCard.tsx index c21dbb1..eaa80de 100644 --- a/apps/spa/src/components/ProductCard.tsx +++ b/apps/spa/src/components/ProductCard.tsx @@ -46,6 +46,11 @@ export default function ProductCard({ product, enableQuickShop = false, category const [selectedVariant, _setSelectedVariant] = useState(product.variants?.[0] || null); const displayName = resolveStr(product.name, i18n.language) || (product.brand ? product.brand.name : ''); const displayCategoryName = categoryNameOverride || resolveStr(product.category.name, i18n.language); + const fallbackImage = getCategoryImage(displayCategoryName); + const images = (product.images?.length ?? 0) > 0 + ? product.images!.slice(0, 3).map(img => img.url) + : [fallbackImage]; + const hasMultipleImages = images.length > 1; const handleWishlistClick = (e: React.MouseEvent) => { e.preventDefault(); @@ -66,27 +71,54 @@ export default function ProductCard({ product, enableQuickShop = false, category onClick={handleCardClick} className="ui-shell-card ui-shell-card-hover group flex cursor-pointer flex-col overflow-hidden p-2" > -
- {displayName} { - (e.target as HTMLImageElement).style.display = 'none'; - }} - /> -
+
+
{displayCategoryName}
+ + {hasMultipleImages ? ( + <> + {/* Desktop Hover Effect */} +
+ {displayName} + {displayName} +
+ + {/* Mobile Native Slider */} +
e.stopPropagation()}> +
+ {images.map((img, idx) => ( +
+ {`${displayName} +
+ ))} +
+
+ {images.map((_, idx) => ( +
+ ))} +
+
+ + ) : ( + {displayName} { + (e.target as HTMLImageElement).style.display = 'none'; + }} + /> + )}
diff --git a/apps/website/src/components/ProductCard.tsx b/apps/website/src/components/ProductCard.tsx index 0409c94..497dba4 100644 --- a/apps/website/src/components/ProductCard.tsx +++ b/apps/website/src/components/ProductCard.tsx @@ -25,6 +25,10 @@ export default function ProductCard({ product }: ProductCardProps) { const productName = resolveLocalized(product.name, lang) || product.brand.name const productSlug = generateProductSlug(productName, product.id) const imageUrl = product.images?.[0]?.url || product.category.imageUrl || getCategoryImage(categoryName) + const images = (product.images?.length ?? 0) > 0 + ? product.images!.slice(0, 3).map(img => img.url) + : [imageUrl]; + const hasMultipleImages = images.length > 1; const displayPrice = selectedVariant?.price ?? product.variants[0]?.price ?? 0 const addToCartLabels: Record = { @@ -59,21 +63,50 @@ export default function ProductCard({ product }: ProductCardProps) { return (
- - - {productName} - {categoryName && ( - - {categoryName} - - )} - +
+ +
+ {categoryName && ( + + {categoryName} + + )} + + {hasMultipleImages ? ( + <> + {/* Desktop Hover Effect */} + + {productName} + {productName} + + + {/* Mobile Native Slider */} +
+
+ {images.map((img, idx) => ( + + {`${productName} + + ))} +
+
+ {images.map((_, idx) => ( +
+ ))} +
+
+ + ) : ( + + {productName} + + )}