feat(product-page): add high-res image zoom lightbox with pan/zoom/drag and unoptimized raw rendering
This commit is contained in:
1 parent
0ddc635dfd
commit
a00778ffaa
13 files changed
+5169
-4750
No files matched your search
@@ -76,6 +76,7 @@ import PodcastInlinePlayer from "./PodcastInlinePlayer";
|
||||
|
||||
const VideoModalPlayer = dynamic(() => import("./VideoModalPlayer"), { ssr: false });
|
||||
const ProductReviews = dynamic(() => import("./ProductReviews"), { ssr: false });
|
||||
const ProductImageZoomModal = dynamic(() => import("./ProductImageZoomModal"), { ssr: false });
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
@@ -1206,70 +1207,18 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Fullscreen High-Resolution Image Zoom / Lightbox Modal */}
|
||||
<AnimatePresence>
|
||||
{isImageZoomOpen && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-8 bg-black/85 backdrop-blur-md"
|
||||
onClick={() => setIsImageZoomOpen(false)}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.9 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.9 }}
|
||||
className="relative max-w-4xl max-h-[90vh] w-full flex flex-col items-center justify-center"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Close Button */}
|
||||
<button
|
||||
onClick={() => setIsImageZoomOpen(false)}
|
||||
className="absolute -top-12 left-0 sm:left-auto sm:-right-12 w-10 h-10 rounded-full bg-white/20 hover:bg-white/30 text-white flex items-center justify-center transition-colors cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
|
||||
{/* Main Zoomed Image Container */}
|
||||
<div className="bg-white rounded-3xl p-6 sm:p-10 shadow-2xl border border-white/20 max-h-[75vh] flex items-center justify-center overflow-hidden w-full">
|
||||
<SafeImage
|
||||
src={activeImage || product.image}
|
||||
alt={product.name}
|
||||
className="max-h-[60vh] max-w-full w-full"
|
||||
imgClassName="max-h-[60vh] max-w-full w-auto object-contain drop-shadow-2xl mx-auto"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Lightbox Thumbnails Navigation */}
|
||||
{(() => {
|
||||
const allImgs = [
|
||||
product.image,
|
||||
...(product.images || []).filter(img => img && img !== product.image)
|
||||
].filter(Boolean);
|
||||
|
||||
if (allImgs.length <= 1) return null;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3 mt-4 overflow-x-auto py-2 px-4 max-w-full">
|
||||
{allImgs.map((img, idx) => (
|
||||
<button
|
||||
key={idx}
|
||||
onClick={() => setActiveImage(img)}
|
||||
className={`w-14 h-14 rounded-xl overflow-hidden bg-white/10 border-2 transition-all p-1 shrink-0 ${
|
||||
(activeImage || product.image) === img
|
||||
? 'border-white scale-110 shadow-lg'
|
||||
: 'border-transparent opacity-60 hover:opacity-100'
|
||||
}`}
|
||||
>
|
||||
<SafeImage src={img} alt="Thumbnail" className="w-full h-full" imgClassName="w-full h-full object-contain" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</motion.div>
|
||||
</div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
{/* Fullscreen High-Resolution Image Zoom & Inspection Lightbox Modal */}
|
||||
<ProductImageZoomModal
|
||||
isOpen={isImageZoomOpen}
|
||||
onClose={() => setIsImageZoomOpen(false)}
|
||||
images={[
|
||||
product.image,
|
||||
...(product.images || []).filter(img => img && img !== product.image)
|
||||
].filter(Boolean) as string[]}
|
||||
activeImage={activeImage || product.image || ""}
|
||||
onSelectImage={(img) => setActiveImage(img)}
|
||||
productName={product.nameFa || product.name}
|
||||
/>
|
||||
|
||||
{/* Dedicated Video Modal Player */}
|
||||
<VideoModalPlayer
|
||||
|
||||
Reference in new issue
Block a user