class SidebarNav extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
this.attachEvents();
}
render() {
this.shadowRoot.innerHTML = `
CORE STABLE
Ver 4.2.0-Alpha
`;
}
attachEvents() {
// Listen for route changes from main script to update active class
document.addEventListener('route-change', (e) => {
const hash = e.detail.hash;
const links = this.shadowRoot.querySelectorAll('.nav-item a');
links.forEach(link => {
link.classList.remove('active');
// Check if href matches hash
if(link.getAttribute('href') === hash) {
link.classList.add('active');
}
});
});
// Re-initialize icons inside shadow DOM
if (window.feather) {
window.feather.replace();
}
}
}
customElements.define('nav-sidebar', SidebarNav);