class CustomNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; // Add scroll effect const navbar = this.shadowRoot.getElementById('navbar'); window.addEventListener('scroll', () => { if (window.scrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } }); // Mobile menu functionality const mobileMenuBtn = this.shadowRoot.getElementById('mobileMenuBtn'); mobileMenuBtn.addEventListener('click', () => { this.dispatchEvent(new CustomEvent('openmobilemenu', { bubbles: true, composed: true })); }); } } customElements.define('custom-navbar', CustomNavbar);