class CustomNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; // Initialize mobile menu toggle const mobileMenuBtn = this.shadowRoot.getElementById('mobile-menu-btn'); const mobileMenu = this.shadowRoot.getElementById('mobile-menu'); mobileMenuBtn.addEventListener('click', () => { mobileMenu.classList.toggle('open'); const icon = mobileMenuBtn.querySelector('i'); if (mobileMenu.classList.contains('open')) { feather.replace(); icon.setAttribute('data-feather', 'x'); } else { feather.replace(); icon.setAttribute('data-feather', 'menu'); } feather.replace(); }); // Handle scroll effect window.addEventListener('scroll', () => { const nav = this.shadowRoot.getElementById('main-nav'); if (window.scrollY > 50) { nav.classList.add('scrolled'); } else { nav.classList.remove('scrolled'); } }); // Replace feather icons feather.replace(); } } customElements.define('custom-navbar', CustomNavbar);