const CSS = new URL('./logout-button.css', import.meta.url).href
const ICON = ``
class LogoutButton extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' })
this.shadowRoot.innerHTML = `
`
this.shadowRoot.querySelector('button')
.addEventListener('click', () => this.#logout())
}
#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)