'use client'; import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, ChevronLeft, ChevronRight, Maximize2 } from 'lucide-react'; import Image from 'next/image'; interface VillaGalleryProps { images: string[]; name: string; } export default function VillaGallery({ images, name }: VillaGalleryProps) { const [isOpen, setIsOpen] = useState(false); const [currentIndex, setCurrentIndex] = useState(0); const openLightbox = (index: number) => { setCurrentIndex(index); setIsOpen(true); document.body.style.overflow = 'hidden'; }; const closeLightbox = () => { setIsOpen(false); document.body.style.overflow = 'auto'; }; const nextImage = () => { setCurrentIndex((prev) => (prev + 1) % images.length); }; const prevImage = () => { setCurrentIndex((prev) => (prev - 1 + images.length) % images.length); }; return ( <>
{/* Main large image */}
openLightbox(0)} > {`${name}
{/* Second image */}
openLightbox(1)} > {images[1] ? ( {`${name} ) : (
)}
{/* Third image */}
openLightbox(2)} > {images[2] ? ( {`${name} ) : (
)}
{/* Fourth image with overlay if more exists */}
openLightbox(3)} > {images[3] ? ( {`${name} ) : (
)} {images.length > 4 && (
+{images.length - 4} Daha Fazla Fotoğraf
)}
{! (images.length > 4) && }
{/* Lightbox Overlay */} {isOpen && ( {images[currentIndex] ? ( {`${name} ) : (
Görsel Yüklenemedi
)}
{currentIndex + 1} / {images.length} — {name}
)}
); }