class LanguageSwitcher extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
Українська
Русский
English
`; const btn = this.shadowRoot.getElementById('language-btn'); const dropdown = this.shadowRoot.getElementById('language-dropdown'); btn.addEventListener('click', () => { dropdown.classList.toggle('show'); feather.replace(); }); this.shadowRoot.querySelectorAll('.language-option').forEach(option => { option.addEventListener('click', () => { const lang = option.getAttribute('data-lang'); // In a real implementation, this would change the language console.log(`Language changed to ${lang}`); dropdown.classList.remove('show'); }); }); // Close dropdown when clicking outside document.addEventListener('click', (e) => { if (!this.contains(e.target)) { dropdown.classList.remove('show'); } }); feather.replace(); } } customElements.define('language-switcher', LanguageSwitcher);