class CryptoNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; this.setupMobileMenu(); this.setupSearch(); } setupMobileMenu() { const menuBtn = this.shadowRoot.querySelector('.mobile-menu-btn'); const navLinks = this.shadowRoot.querySelector('.nav-links'); menuBtn.addEventListener('click', () => { navLinks.classList.toggle('active'); const icon = menuBtn.querySelector('i'); if (navLinks.classList.contains('active')) { icon.setAttribute('data-feather', 'x'); } else { icon.setAttribute('data-feather', 'menu'); } feather.replace(); }); } setupSearch() { const searchInput = this.shadowRoot.querySelector('.search-input'); searchInput.addEventListener('input', (e) => { const query = e.target.value; this.searchCryptos(query); }); } searchCryptos(query) { const event = new CustomEvent('crypto-search', { detail: { query } }); this.shadowRoot.dispatchEvent(event); } } customElements.define('crypto-navbar', CryptoNavbar);