/
fs-signin.html
86 lines (69 loc) · 2.13 KB
/
fs-signin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../fs-client/fs-client.html">
<link rel="import" href="../fs-api-aware/fs-api-aware.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-styles/color.html">
<!--
A FamilySearch sign in button.
Example:
<fs-signin></fs-signin>
### Styling
The following custom properties are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--fs-signin-signout` | Mixin applied when the button is in the signed out state | {}
`--fs-signin-signin` | Mixin applied when the button is in the signed in state | {}
@group FamilySearch Elements
@customElement
@polymer
@demo demo/index.html
-->
<dom-module id="fs-signin">
<template>
<style>
:host {
font-family: arial;
}
paper-button {
background-color: var(--paper-grey-200);
color: #333;
@apply --fs-signin-signout;
}
paper-button.recommended {
background-color: var(--paper-blue-500);
color: #fff;
@apply --fs-signin-signin;
}
</style>
<fs-client id="client" name="[[clientName]]" authenticated="{{signedIn}}"></fs-client>
<paper-button id="button" class$="{{_computeClass(signedIn)}}" on-click="_clickAction">{{_computeText(signedIn)}}</paper-button>
</template>
<script>
class FSSignin extends FSApiAwareMixin(Polymer.Element) {
static get is() { return 'fs-signin'; }
static get properties() {
return {
signedIn: {
type: Boolean,
notify: true,
value: false
}
};
}
_clickAction() {
if(this.signedIn){
this.$.client.signOut();
} else {
this.$.client.signIn();
}
}
_computeText(signedIn) {
return signedIn ? 'Sign Out' : 'Sign In';
}
_computeClass(signedIn) {
return signedIn ? '' : 'recommended';
}
}
customElements.define(FSSignin.is, FSSignin);
</script>
</dom-module>