const Navbar = () => { const [scrolled, setScrolled] = React.useState(false); const [menuOpen, setMenuOpen] = React.useState(false); const t = (key, fallback) => { return (window.VILLA_TRANSLATIONS && window.VILLA_TRANSLATIONS[key]) ? window.VILLA_TRANSLATIONS[key] : fallback; }; const currentLang = window.VILLA_LANG || 'en'; React.useEffect(() => { const handleScroll = () => { setScrolled(window.scrollY > 50); }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); const navLinks = [ { name: t('nav_home', 'HOME'), href: 'index.php' }, { name: t('nav_experience', 'THE EXPERIENCE'), href: 'experience.php' }, { name: t('nav_amenities', 'AMENITIES'), href: 'amenities.php' }, { name: t('nav_gallery', 'GALLERY'), href: 'gallery.php' }, { name: t('nav_book', 'BOOK NOW'), href: 'book-now.php' } ]; const toggleLanguage = () => { const newLang = currentLang === 'en' ? 'el' : 'en'; window.location.href = `?lang=${newLang}`; }; // Simulating active path, in a real single-page app this would use a router hook. // For now we will just make "HOME" active by default or base it on pathname. const currentPath = window.location.pathname.split('/').pop() || 'index.php'; return ( {/* Desktop Floating Island Menu */} Villa Nevas {currentLang} {navLinks.map((link) => { const isActive = currentPath === link.href || (currentPath === '' && link.href === 'index.php'); return ( {link.name} ); })} setMenuOpen(!menuOpen)} className={`bg-black text-white px-8 py-3 rounded-full font-serif text-xl font-bold tracking-wider shadow-lg border border-white/10 transition-all duration-300 pointer-events-auto ${menuOpen ? 'border-b-0 opacity-0 pointer-events-none' : 'opacity-100'} `} > Villa Nevas {currentLang} {/* Mobile Menu Overlay */} {/* Mobile Open Header */} Villa Nevas setMenuOpen(false)} className="absolute right-6 top-2 text-white/50 hover:text-white text-3xl"> {/* Mobile Links */} {navLinks.map((link) => { const isActive = currentPath === link.href || (currentPath === '' && link.href === 'index.php'); return ( {link.name} ); })} {currentLang === 'en' ? 'ΕΛΛΗΝΙΚΑ (EL)' : 'ENGLISH (EN)'} ); }; const root = ReactDOM.createRoot(document.getElementById('nav-root')); root.render();