UNPKG

@e280/authlocal

Version:

User-sovereign login system for everybody

46 lines 1.66 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { sub } from "@e280/stz"; import { attributes, html, mixin } from "@benev/slate"; import stylesCss from "./styles.css.js"; import { AuthElement } from "../framework.js"; let AuthButton = class AuthButton extends AuthElement { attrs = attributes(this, { "src": String, }); on = sub(); #clickLogout = async () => this.on.pub(await this.auth.logout()); #clickLogin = async () => this.on.pub(await this.auth.popup(this.attrs.src)); render() { const { auth } = this; const { login } = auth; return login ? html ` <button class=logout theme-button=logout part="button button-logout" @click="${this.#clickLogout}"> <slot name=logout>Logout</slot> </button> ` : html ` <button class=login theme-button=login part="button button-login" @click="${this.#clickLogin}"> <slot>Login</slot> </button> `; } }; AuthButton = __decorate([ mixin.css(stylesCss) ], AuthButton); export { AuthButton }; //# sourceMappingURL=element.js.map