Deploy
This commit is contained in:
@@ -0,0 +1,112 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useEmDashContent } from '@/hooks/useEmDashContent'
|
||||||
|
import Image from 'next/image'
|
||||||
|
import { ArrowLeft, ArrowRight, X } from 'lucide-react'
|
||||||
|
import { Modal } from '@/components/ui/Modal'
|
||||||
|
import { Card, CardContent } from '@/components/ui/Card'
|
||||||
|
|
||||||
|
export default function SafariGallerySection() {
|
||||||
|
const { items, loading } = useEmDashContent('gallery')
|
||||||
|
const [selectedIndex, setSelectedIndex] = useState<number | null>(null)
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="flex justify-center py-20">
|
||||||
|
<div className="w-8 h-8 rounded-full border-2 border-current border-t-transparent animate-spin text-[#36454F]" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items.length === 0) return null
|
||||||
|
|
||||||
|
const openLightbox = (index: number) => setSelectedIndex(index)
|
||||||
|
const closeLightbox = () => setSelectedIndex(null)
|
||||||
|
const prev = () => setSelectedIndex((prev) => (prev === null ? null : (prev - 1 + items.length) % items.length))
|
||||||
|
const next = () => setSelectedIndex((prev) => (prev === null ? null : (prev + 1) % items.length))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section id="safari-gallery" data-vula-section="safarigallery" data-vula-cms="gallery" className="py-20 bg-white">
|
||||||
|
<div className="container mx-auto px-4 max-w-7xl">
|
||||||
|
<h2 className="text-3xl md:text-4xl font-light text-[#36454F] mb-4 text-center">
|
||||||
|
The <span className="font-semibold text-[#d4af37]">wilderness</span> in frames
|
||||||
|
</h2>
|
||||||
|
<p className="text-[#1f2b33] text-center max-w-xl mx-auto mb-12 text-lg leading-relaxed">
|
||||||
|
A private glimpse into life on the reserve — captured for the discerning eye.
|
||||||
|
</p>
|
||||||
|
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
|
||||||
|
{items.map((item, idx) => {
|
||||||
|
const d = item.data as { title?: string; description?: string; image?: string }
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.id}
|
||||||
|
className="overflow-hidden rounded-[24px] border-0 cursor-pointer shadow-lg hover:shadow-2xl transition-all duration-200 ease-out"
|
||||||
|
onClick={() => openLightbox(idx)}
|
||||||
|
>
|
||||||
|
<CardContent className="p-0 relative aspect-square w-full">
|
||||||
|
{d.image && (
|
||||||
|
<Image
|
||||||
|
src={d.image}
|
||||||
|
alt={d.title || 'Safari image'}
|
||||||
|
fill
|
||||||
|
sizes="(max-width: 768px) 50vw, 25vw"
|
||||||
|
className="object-cover transition-transform duration-500 ease-out hover:scale-105"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-t from-black/10 to-transparent" />
|
||||||
|
<div className="absolute bottom-3 left-3 right-3">
|
||||||
|
<h3 className="text-white text-sm font-medium drop-shadow-lg">{d.title}</h3>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Lightbox modal */}
|
||||||
|
{selectedIndex !== null && items[selectedIndex] && (
|
||||||
|
<Modal isOpen={true} onClose={closeLightbox}>
|
||||||
|
<div className="relative max-w-5xl mx-auto">
|
||||||
|
<button
|
||||||
|
onClick={closeLightbox}
|
||||||
|
className="absolute top-4 right-4 z-10 bg-black/50 text-white rounded-full p-2 hover:bg-black/70 transition-colors"
|
||||||
|
aria-label="Close"
|
||||||
|
>
|
||||||
|
<X className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
<div className="flex items-center justify-between mb-4">
|
||||||
|
<button
|
||||||
|
onClick={prev}
|
||||||
|
className="bg-black/50 text-white rounded-full p-3 hover:bg-black/70 transition-colors"
|
||||||
|
aria-label="Previous"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
<div className="flex-grow h-96 relative mx-4">
|
||||||
|
<Image
|
||||||
|
src={(items[selectedIndex].data as { image?: string }).image || ''}
|
||||||
|
alt={(items[selectedIndex].data as { title?: string }).title || 'Gallery image'}
|
||||||
|
fill
|
||||||
|
className="object-contain"
|
||||||
|
sizes="80vw"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={next}
|
||||||
|
className="bg-black/50 text-white rounded-full p-3 hover:bg-black/70 transition-colors"
|
||||||
|
aria-label="Next"
|
||||||
|
>
|
||||||
|
<ArrowRight className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p className="text-center text-sm text-white mt-2">
|
||||||
|
{(items[selectedIndex].data as { title?: string }).title}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user