templates/components/nav_landing.html.twig line 1
<nav class="sticky bg-white w-full fixed z-[9999] top-0 left-0 border-b border-gray-200"><div class="flex items-center justify-between px-4 py-2 container mx-auto"><!-- Logo --><a href="{{ path('home') }}" class="flex items-center"><img src="{{ asset('images/site/logo.png') }}" class="h-12 mr-3 sm:h-16" alt="Roomlers Logo"><span class="self-center text-xl font-semibold uppercase whitespace-nowrap">Roomlers</span></a><!-- Bouton Burger pour mobile/tablette --><button id="mobileMenuButton" class="lg:hidden p-2 rounded-md text-gray-700 hover:text-gray-900 hover:bg-gray-100 focus:outline-none"><svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg></button><!-- Conteneur pour les éléments alignés à droite (version desktop) --><div class="nav-links hidden lg:flex items-center space-x-4"><!-- Onglet "Pré-réservation de logement" --><a href="{{ path('attestation') }}" class="px-4 py-2 text-black rounded-lg font-semibold hover:underline">{{ 'nav_landing.accommodation_prereservation'|trans }}</a><!-- Liste déroulante pour la langue --><div class="relative"><button class="language-dropdown flex items-center px-4 py-2 text-black rounded-lg font-semibold hover:underline"><img src="{{ asset('images/flagfr.png') }}" class="w-6 h-4 mr-2" alt="France Flag"><svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg></button><div class="language-menu hidden absolute right-0 mt-2 w-40 bg-white border border-gray-200 rounded-lg shadow-lg"><a href="#" data-language="fr" class="flex items-center px-4 py-2 hover:bg-gray-100"><img src="{{ asset('images/flagfr.png') }}" class="w-6 h-4 mr-3" alt="France Flag"> French</a><a href="#" data-language="en" class="flex items-center px-4 py-2 hover:bg-gray-100"><img src="{{ asset('images/flagen.png') }}" class="w-6 h-4 mr-3" alt="UK Flag"> English</a></div></div><!-- Icône de coeur --><button id="openModalLink1" class="px-4 py-2 text-black rounded-lg font-semibold hover:underline"><svg class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"fill="white" stroke="black" stroke-width="2"/></svg></button><!-- Dropdown utilisateur --><div class="relative"><button class="user-dropdown px-4 py-2 text-black rounded-lg font-semibold hover:underline" type="button"><i class="fa-solid fa-user"></i></button><div class="user-dropdown-menu hidden absolute right-0 mt-2 w-48 bg-white border border-gray-200 rounded-lg shadow-lg"><a class="block px-4 py-2 hover:bg-gray-100" href="{{ path('app_register') }}">{{ 'nav_landing.register'|trans }}</a><a class="block px-4 py-2 hover:bg-gray-100" href="{{ path('app_login_site') }}">{{ 'nav_landing.login'|trans }}</a><a class="block px-4 py-2 hover:bg-gray-100" href="{{ path('attestation') }}">{{ 'nav_landing.accommodation_prereservation'|trans }}</a><a class="block px-4 py-2 hover:bg-gray-100" href="{{ path('app_login_site') }}">{{ 'nav_landing.add_accommodation'|trans }}</a></div></div></div></div><!-- Menu mobile (caché par défaut) --><div id="mobileMenu" class="hidden lg:hidden bg-white border-t border-gray-200"><div class="px-2 pt-2 pb-3 space-y-1"><a href="{{ path('attestation') }}" class="block px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100">{{ 'nav_landing.accommodation_prereservation'|trans }}</a><!-- Dropdown langue mobile --><div class="relative"><button class="language-dropdown flex items-center px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100"><img src="{{ asset('images/flagfr.png') }}" class="w-6 h-4 mr-2" alt="France Flag"><svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg></button><div class="language-menu hidden pl-4"><a href="#" data-language="fr" class="flex items-center px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100"><img src="{{ asset('images/flagfr.png') }}" class="w-6 h-4 mr-2" alt="France Flag"></a><a href="#" data-language="en" class="flex items-center px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100"><img src="{{ asset('images/flagen.png') }}" class="w-6 h-4 mr-2" alt="UK Flag"></a></div></div><!-- Bouton coeur mobile --><button id="openModalLinkMobile" class="w-full text-left px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100 flex items-center"><svg class="w-6 h-6 mr-2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"fill="white" stroke="black" stroke-width="2"/></svg>{{ 'nav_landing.favorites'|trans }}</button><!-- Dropdown utilisateur mobile --><div class="relative"><button class="user-dropdown w-full text-left px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100 flex items-center"><i class="fa-solid fa-user mr-2"></i>{{ 'nav_landing.my_account'|trans }}</button><div class="user-dropdown-menu hidden pl-4"><a class="block px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100" href="{{ path('app_register') }}">{{ 'nav_landing.register'|trans }}</a><a class="block px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100" href="{{ path('app_login_site') }}">{{ 'nav_landing.login'|trans }}</a><a class="block px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100" href="{{ path('attestation') }}">{{ 'nav_landing.accommodation_prereservation'|trans }}</a><a class="block px-3 py-2 text-black rounded-lg font-semibold hover:bg-gray-100" href="{{ path('userFormOwner') }}">{{ 'nav_landing.add_accommodation'|trans }}</a></div></div></div></div></nav><!-- Modal de connexion/inscription --><div id="connectModal" class="fixed inset-0 bg-gray-500 bg-opacity-50 flex justify-center items-center hidden z-50"><div class="bg-white p-6 rounded-lg shadow-lg max-w-sm w-full text-center"><p class="text-lg font-semibold mb-4">{{ 'nav_landing.choose_option'|trans }}</p><button onclick="window.location.href='{{ path('app_login_site') }}'" class="bg-yellow-400 text-black px-4 py-2 rounded-lg font-semibold hover:bg-yellow-500 transition mb-2 w-full">{{ 'nav_landing.login'|trans }}</button><button onclick="window.location.href='{{ path('app_register') }}'" class="bg-yellow-400 text-black px-4 py-2 rounded-lg font-semibold hover:bg-yellow-500 transition w-full">{{ 'nav_landing.register'|trans }}</button></div></div><script>document.addEventListener('DOMContentLoaded', function () {// Fonction pour afficher le bon drapeau selon l'URLfunction updateCurrentFlag() {const lang = window.location.pathname.startsWith('/en') ? 'en' : 'fr';const flagSrc = lang === 'en' ? "{{ asset('images/flagen.png') }}" : "{{ asset('images/flagfr.png') }}";document.querySelectorAll('.language-dropdown img').forEach(flag => {flag.src = flagSrc;});}updateCurrentFlag();// Gestion du changement de languedocument.querySelectorAll('[data-language]').forEach(link => {link.addEventListener('click', function (event) {event.preventDefault();const language = this.getAttribute('data-language');const currentPath = window.location.pathname;const searchParams = window.location.search;// Supprimer le préfixe de langue actuel s'il existeconst pathWithoutLang = currentPath.replace(/^\/[a-z]{2}\//, '/');// Construire le nouvel URL avec le préfixe de langueconst newPath = language === 'en' ? `/en${pathWithoutLang}` : pathWithoutLang;// Recharger la page avec le nouvel URLwindow.location.href = newPath + searchParams;});});// Gestion des dropdowns (langue & utilisateur)function setupDropdown(triggerSelector, menuSelector) {const triggers = document.querySelectorAll(triggerSelector);const menus = document.querySelectorAll(menuSelector);triggers.forEach((trigger, index) => {trigger.addEventListener('click', function (event) {event.stopPropagation();menus[index].classList.toggle('hidden');});});document.addEventListener('click', function (event) {menus.forEach(menu => {if (!menu.contains(event.target)) {menu.classList.add('hidden');}});});}setupDropdown('.language-dropdown', '.language-menu');setupDropdown('.user-dropdown', '.user-dropdown-menu');// Gestion du menu mobileconst mobileMenuButton = document.getElementById('mobileMenuButton');const mobileMenu = document.getElementById('mobileMenu');let menuOpen = false;if (mobileMenuButton && mobileMenu) {mobileMenuButton.addEventListener('click', function (e) {e.preventDefault();e.stopPropagation();menuOpen = !menuOpen;mobileMenu.classList.toggle('hidden', !menuOpen);});document.addEventListener('click', function (e) {if (menuOpen && !mobileMenu.contains(e.target) && !mobileMenuButton.contains(e.target)) {menuOpen = false;mobileMenu.classList.add('hidden');}});mobileMenu.addEventListener('click', function (e) {e.stopPropagation();});}// Gestion de la modal de connexionconst openModalElements = document.querySelectorAll('#openModalLink1, #openModalLinkMobile');const connectModal = document.getElementById('connectModal');if (openModalElements.length > 0 && connectModal) {openModalElements.forEach(element => {element.addEventListener('click', function (event) {event.preventDefault();connectModal.classList.remove('hidden');});});connectModal.addEventListener('click', function (event) {if (event.target === connectModal) {connectModal.classList.add('hidden');}});connectModal.querySelector('.bg-white').addEventListener('click', function (event) {event.stopPropagation();});}});</script>