-
Notifications
You must be signed in to change notification settings - Fork 0
/
helsinki-js-fav.js
69 lines (58 loc) · 1.38 KB
/
helsinki-js-fav.js
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
import { html, PolymerElement } from "@polymer/polymer/polymer-element.js";
import "@polymer/iron-icon/iron-icon.js";
import "@polymer/iron-icons/iron-icons.js";
/**
* `helsinki-js-fav`
* Web component demo for the Helsinki JS Meetup
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class HelsinkiJsFav extends PolymerElement {
static get template() {
return html`
<style>
:host {
display: flex;
align-items : center;
cursor: pointer;
user-select: none;
}
.title {
font-size: 1.5em;
margin-right: 0.125em;
}
.icon {
fill: rgba(0,0,0,0);
stroke: currentcolor;
transition: fill .6s ease-in-out;
--iron-icon-height: 32px;
--iron-icon-width: 32px;
}
:host([faved]) .icon {
fill: rgba(231,76,60, 1.0);
}
</style>
<span class="title">Helsinki JS!</span>
<iron-icon class="icon" icon="favorite"></iron-icon>
`;
}
static get properties() {
return {
faved: {
type: Boolean,
value: false,
reflectToAttribute: true
}
};
}
constructor() {
super();
this.addEventListener("click", this.toggle.bind(this));
}
toggle() {
this.faved = !this.faved;
}
}
window.customElements.define("helsinki-js-fav", HelsinkiJsFav);