class CustomNavigation extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; // Mobile menu toggle const mobileMenuBtn = this.shadowRoot.getElementById('mobileMenuBtn'); const navLinks = this.shadowRoot.getElementById('navLinks'); mobileMenuBtn.addEventListener('click', () => { navLinks.classList.toggle('active'); const icon = mobileMenuBtn.querySelector('i'); if (navLinks.classList.contains('active')) { icon.setAttribute('data-feather', 'x'); } else { icon.setAttribute('data-feather', 'menu'); } if (typeof feather !== 'undefined') { feather.replace(); } }); // Close mobile menu when clicking outside document.addEventListener('click', (e) => { if (!this.contains(e.target) && navLinks.classList.contains('active')) { navLinks.classList.remove('active'); const icon = mobileMenuBtn.querySelector('i'); icon.setAttribute('data-feather', 'menu'); if (typeof feather !== 'undefined') { feather.replace(); } } }); // Feather icons initialization if (typeof feather !== 'undefined') { feather.replace({ 'stroke-width': 2 }); } } } customElements.define('custom-navigation', CustomNavigation);