class PowerButton extends HTMLElement { static get observedAttributes() { return ['active']; } constructor() { super(); this.attachShadow({ mode: 'open' }); this.active = false; this.render(); } attributeChangedCallback(name, oldValue, newValue) { if (name === 'active') { this.active = newValue === 'true'; this.updateState(); } } render() { this.shadowRoot.innerHTML = `
`; this.button = this.shadowRoot.getElementById('powerBtn'); this.ripples = this.shadowRoot.querySelectorAll('.ripple'); this.button.addEventListener('click', () => { this.dispatchEvent(new CustomEvent('power-toggle', { bubbles: true, composed: true })); }); this.updateState(); } updateState() { if (!this.button) return; if (this.active) { this.button.classList.add('active'); this.ripples.forEach(r => r.classList.add('active')); } else { this.button.classList.remove('active'); this.ripples.forEach(r => r.classList.remove('active')); } } } customElements.define('power-button', PowerButton);