class CustomHeader extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; // Mobile menu toggle const menuBtn = this.shadowRoot.querySelector('.mobile-menu-btn'); const navLinks = this.shadowRoot.querySelector('.nav-links'); menuBtn.addEventListener('click', () => { navLinks.classList.toggle('active'); const menuIcon = menuBtn.querySelector('i'); if (navLinks.classList.contains('active')) { menuIcon.setAttribute('data-feather', 'x'); } else { menuIcon.setAttribute('data-feather', 'menu'); } feather.replace(); }); // Close menu when clicking a link this.shadowRoot.querySelectorAll('.nav-links a').forEach(link => { link.addEventListener('click', () => { navLinks.classList.remove('active'); const menuIcon = menuBtn.querySelector('i'); menuIcon.setAttribute('data-feather', 'menu'); feather.replace(); }); }); } } customElements.define('custom-header', CustomHeader);