class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
// Initialize mobile menu
this.initMobileMenu();
}
initMobileMenu() {
const menuBtn = this.shadowRoot.querySelector('.mobile-menu-btn');
const navLinks = this.shadowRoot.querySelector('.nav-links');
menuBtn.addEventListener('click', () => {
navLinks.classList.toggle('open');
const icon = menuBtn.querySelector('i');
if (navLinks.classList.contains('open')) {
feather.icons.x.toSvg().then(svg => icon.outerHTML = svg);
} else {
feather.icons.menu.toSvg().then(svg => icon.outerHTML = svg);
}
});
}
}
customElements.define('custom-navbar', CustomNavbar);