class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
// Initialize feather icons in shadow DOM
const featherScript = document.createElement('script');
featherScript.src = 'https://unpkg.com/feather-icons';
this.shadowRoot.appendChild(featherScript);
featherScript.onload = () => {
feather.replace();
// Theme toggle functionality
const themeToggle = this.shadowRoot.getElementById('themeToggle');
themeToggle.addEventListener('click', () => {
themeManager.toggleTheme();
this.updateThemeIcon();
});
};
}
updateThemeIcon() {
const themeIcon = this.shadowRoot.querySelector('#themeToggle i');
if (themeManager.currentTheme === 'dark') {
themeIcon.setAttribute('data-feather', 'sun');
} else {
themeIcon.setAttribute('data-feather', 'moon');
}
feather.replace();
}
}
customElements.define('custom-header', CustomHeader);