class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
// Mobile menu toggle
this.shadowRoot.addEventListener('click', (e) => {
if (e.target.closest('#mobileMenuButton')) {
const navLinks = this.shadowRoot.getElementById('navLinks');
navLinks.classList.toggle('active');
// Update icon
const menuIcon = this.shadowRoot.querySelector('[data-feather="menu"]');
if (navLinks.classList.contains('active')) {
menuIcon.setAttribute('data-feather', 'x');
} else {
menuIcon.setAttribute('data-feather', 'menu');
}
feather.replace();
}
});
}
}
customElements.define('custom-header', CustomHeader);