// Logout button — drop anywhere in the DOM. // // full button with label // icon only (for tight spaces) // // Delegates to .logout(). Works regardless of where it sits // (header, members panel, dropdown…) since it resolves the gate from the document. // // Phase 2: if login-gate is swapped for oidc-gate, this still works as long as // the auth component exposes a logout() method (see #gate()). const ICON = `` class LogoutButton extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }) const compact = this.hasAttribute('compact') this.shadowRoot.innerHTML = ` ` this.shadowRoot.querySelector('button') .addEventListener('click', () => this.#logout()) } // Resolves the auth component. Today: login-gate. Tomorrow: any element // exposing logout() (oidc-gate, oauth-gate…). #gate() { return document.querySelector('login-gate, [data-auth-gate]') } #logout() { const gate = this.#gate() if (gate?.logout) { gate.logout() } else { console.warn('logout-button: no auth gate with logout() found in document') } } } customElements.define('logout-button', LogoutButton)