blob: 87fc2ef598dc7f09ae0c75ddc10f4b0f342920fb [file]
<link rel="import" href="../polymer/polymer.html">
<dom-module id="crdx-login">
<template>
<style>
* {
font-family: 'Roboto', 'Noto', sans-serif;
font-size: .75em;
}
a:link {
text-decoration: none;
}
</style>
<template is="dom-if" if="[[!user]]">
<p><a href="[[loginUrl]]">LOGIN</a></p>
</template>
<template is="dom-if" if="[[user]]">
<p>[[user]] (<a href="[[logoutUrl]]">LOGOUT</a>)</p>
</template>
</template>
<script>
'use strict';
/**
* `crdx-login` shows the login/logout links and current user, if provided.
*
* When the user is logged in provide, at least, the user and logoutURL properties.
* When there is no user logged in provide, at least the loginURL property.
* In either case, bother URLs may be provided but only one will be shown.
*
*
* @customElement
* @polymer
* @demo /demo/crdx-login_demo.html
*/
class CrdxLogin extends Polymer.Element {
static get is() { return 'crdx-login'; }
static get properties() {
return {
/** The login URL must be provided if no user is given. */
loginUrl: {
type: String,
},
/** The logout URL must be provided if a user is given. */
logoutUrl: {
type: String,
},
/** The logged in user. If this isn't given the login URL will be shown.*/
user: {
type: String,
value: "",
},
}
}
}
customElements.define(CrdxLogin.is, CrdxLogin);
</script>
<dom-module>