class CustomHeader extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; // Initialize feather icons const initFeatherIcons = () => { if (typeof feather !== 'undefined') { this.shadowRoot.querySelectorAll('[data-feather]').forEach(icon => { const iconName = icon.getAttribute('data-feather'); icon.outerHTML = ``; }); feather.replace(); } }; // Check if feather is already loaded if (typeof feather !== 'undefined') { initFeatherIcons(); } else { // Load feather icons script const featherScript = document.createElement('script'); featherScript.src = 'https://unpkg.com/feather-icons'; featherScript.onload = initFeatherIcons; this.shadowRoot.appendChild(featherScript); } // Mobile menu toggle const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button'); const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); if (mobileMenuButton && mobileMenu) { mobileMenuButton.addEventListener('click', () => { mobileMenu.classList.toggle('open'); // Change icon const icon = mobileMenuButton.querySelector('i'); if (mobileMenu.classList.contains('open')) { icon.setAttribute('data-feather', 'x'); } else { icon.setAttribute('data-feather', 'menu'); } if (typeof feather !== 'undefined') { feather.replace(); } }); } } } customElements.define('custom-header', CustomHeader);