class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
// Add smooth scroll behavior
this.shadowRoot.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const targetId = link.getAttribute('href').substring(1);
const targetElement = document.querySelector(`[id*="${targetId.toLowerCase()}"]`);
if (targetElement) {
// Remove active class from all links
this.shadowRoot.querySelectorAll('.nav-link').forEach(l => l.classList.remove('active'));
// Add active class to clicked link
link.classList.add('active');
// Smooth scroll to element
targetElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
});
});
// Re-initialize feather icons
if (typeof feather !== 'undefined') {
feather.replace();
}
}
}
customElements.define('custom-navbar', CustomNavbar);