import React, { useState } from 'react'; import { motion, AnimatePresence, useReducedMotion } from 'framer-motion'; import { ArrowRight, Clock } from 'lucide-react'; import { assetUrl } from '../lib/assetUrl'; export default function FeaturedGallery({ gallery }) { const galleryData = gallery?.items || []; const header = gallery || { eyebrow: 'Featured Gallery', title: '', subtitle: '' }; const [activeGalleryIndex, setActiveGalleryIndex] = useState(0); const [isMobile, setIsMobile] = useState(false); React.useEffect(() => { const check = () => setIsMobile(window.innerWidth < 1024); check(); window.addEventListener('resize', check); return () => window.removeEventListener('resize', check); }, []); // Auto-advance card every 4 seconds React.useEffect(() => { if (!galleryData.length) return; const timer = setInterval(() => { setActiveGalleryIndex((prev) => (prev + 1) % galleryData.length); }, 4000); return () => clearInterval(timer); }, [activeGalleryIndex, galleryData.length]); return ( ); } function ResponsiveGalleryWrapper({ galleryData, activeIdx, setActiveIdx }) { const [isMobileSize, setIsMobileSize] = React.useState(false); const shouldReduceMotion = useReducedMotion(); React.useEffect(() => { const handleResize = () => { setIsMobileSize(window.innerWidth < 1024); }; handleResize(); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); const getRevealProps = (index) => { if (shouldReduceMotion) return {}; return { initial: { opacity: 0, y: 40 }, whileInView: { opacity: 1, y: 0 }, viewport: { once: true, amount: 0.15 } }; }; if (isMobileSize) { return (
{galleryData.map((item, index) => { const isFirst = index === 0; const revealProps = getRevealProps(index); return ( {item.category}

{item.title}

{item.excerpt}

{item.readTime} Read More
); })}
); } // Desktop horizontal layout return (
{galleryData.map((item, index) => { const isActive = activeIdx === index; const revealProps = getRevealProps(index); return ( setActiveIdx(index)} className="glass-card" {...revealProps} transition={shouldReduceMotion ? { type: 'spring', stiffness: 350, damping: 32 } : { layout: { type: 'spring', stiffness: 350, damping: 32 }, y: { duration: 0.8, ease: [0.22, 1, 0.36, 1], delay: index * 0.1 }, opacity: { duration: 0.8, ease: 'easeOut', delay: index * 0.1 } }} style={{ flex: isActive ? 2.8 : 1, borderRadius: '24px', overflow: 'hidden', border: '1px solid rgba(255, 255, 255, 0.06)', position: 'relative', cursor: 'pointer', display: 'flex', flexDirection: 'column', justifyContent: 'space-between', boxShadow: isActive ? '0 15px 35px -12px rgba(255, 170, 0, 0.2)' : '0 4px 20px rgba(0, 0, 0, 0.3)', borderColor: isActive ? 'rgba(255, 170, 0, 0.3)' : 'rgba(255, 255, 255, 0.06)', }} > {/* Background image container for smooth scale transform */} {/* Dark Overlay */} {/* Top Tag */}
{item.category}
{/* Bottom Content Area */}

{item.title}

{/* Excerpt - Animate visibility based on active state */}

{item.excerpt}

{/* Progress Line and Footer Area */}
{isActive ? ( ) : (
)}
{item.readTime} {isActive && ( Read More )}
); })}
); }