class CustomNavbar extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.shadowRoot.innerHTML = ` `; // Gestion de la route active const currentPage = window.location.pathname.split('/').pop() || 'dashboard'; this.shadowRoot.querySelectorAll('.nav-links a').forEach(link => { if (link.dataset.page === currentPage || (currentPage === '' && link.dataset.page === 'dashboard')) { link.classList.add('active'); } }); } } customElements.define('custom-navbar', CustomNavbar);