import {OOElement} from '../../oo-element' import {repeat} from 'lit-html/lib/repeat' import {html} from '../../../lib/html' import signIn from '../../oo-sign-in' import signInWithRedirect from '../../oo-sign-in-with-redirect' import define from '../../../lib/define' import weakMap from '../../../lib/weak-map' import {asSignInFlow} from '../../../lib/as' import {SignInFlow} from '../../../type/sign-in-flow' define('oo-sign-in', signIn) define('oo-sign-in-with-redirect', signInWithRedirect) const ATTR = { DATA_FLOW: 'data-flow' } const stateSignInFlow = weakMap() export default class extends OOElement { static get observedAttributes() { return [ATTR.DATA_FLOW] } constructor() { super() stateSignInFlow.set(this, asSignInFlow(this.getAttribute(ATTR.DATA_FLOW))) } attributeChangedCallback(attr, prev, next) { if (prev === next || !next) { return } stateSignInFlow.set(this, asSignInFlow(next)) if (this.connected) { this.update() } } render() { const flow = stateSignInFlow.get(this) const buttons = f => { const provs = ['google', 'facebook', 'github'] const popup = prov => html`` const redirect = prov => html`` if (f === 'popup') { return repeat(provs, prov => popup(prov)) } if (f === 'redirect') { return repeat(provs, prov => redirect(prov)) } } return html`
${buttons(flow)}

By clicking the 'Sign in with [Google, Facebook or GitHub]' button, you are agreeing to the Terms of service.

` } }