class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
// Initialize feather icons in shadow DOM
const featherScript = document.createElement('script');
featherScript.src = 'https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js';
this.shadowRoot.appendChild(featherScript);
featherScript.onload = () => {
if (window.feather) {
window.feather.replace();
}
};
// Mobile menu toggle functionality
const mobileMenuBtn = this.shadowRoot.querySelector('.mobile-menu-btn');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', () => {
const navLinks = this.shadowRoot.querySelector('.nav-links');
const userActions = this.shadowRoot.querySelector('.user-actions');
if (navLinks.style.display === 'flex' || navLinks.style.display === '') {
navLinks.style.display = 'none';
userActions.style.display = 'none';
} else {
navLinks.style.display = 'flex';
userActions.style.display = 'flex';
}
});
}
}
}
customElements.define('custom-navbar', CustomNavbar);