UNPKG

radh-ui

Version:

Stencil Component Starter

56 lines (55 loc) 1.57 kB
import { Component, Event, h, State } from "@stencil/core"; import { authState } from "rxfire/auth"; export class RadhAuth { componentWillLoad() { authState(firebase.auth()).subscribe(u => { this.user = u; this.userInfo.emit(u); }); } login() { const provider = new firebase.auth.GoogleAuthProvider(); firebase.auth().signInWithPopup(provider); } logout() { firebase.auth().signOut(); } render() { if (this.user) { return (h("div", null, "You are logged is as ", this.user.displayName, h("button", { onClick: this.logout }, "Logout"))); } else { return (h("div", null, h("radh-button", { onClick: this.login }, "Login with Google"))); } } static get is() { return "radh-auth"; } static get originalStyleUrls() { return { "$": ["radh-auth.css"] }; } static get styleUrls() { return { "$": ["radh-auth.css"] }; } static get states() { return { "user": {} }; } static get events() { return [{ "method": "userInfo", "name": "userInfo", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } }