-
Notifications
You must be signed in to change notification settings - Fork 0
/
brewery-detail.js
52 lines (51 loc) · 1.18 KB
/
brewery-detail.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
import {html, css, LitElement} from 'lit';
import '@material/mwc-button';
class BreweryDetail extends LitElement {
static get styles() {
return css`p { color: coral }`;
}
static get properties() {
return {
id: String,
name: String,
type: String,
city: String,
visited: {type: Boolean},
url: String
};
}
constructor() {
super();
this.id = '';
this.name = '';
this.type = '';
this.city = '';
this.visited = false;
this.url = '';
}
render() {
console.log('brewery-detail rendered');
return html`
<h3>Name: ${this.name} - ${this.visitedStatus(this.visited)} - <mwc-button @click=${this.visit}>${this.visitButtonText()} This!</mwc-button></h3>
<p>Type: ${this.type}</p>
<p>City: ${this.city}</p>
`;
}
visitedStatus(visited) {
if (visited) {
return 'Visited';
}
return 'Not Visited';
}
visit() {
console.log('brewery-detail visit');
this.dispatchEvent(new CustomEvent('toggle-visited-status'));
}
visitButtonText() {
if (this.visited) {
return 'Un-Visit';
}
return 'Visit';
}
}
customElements.define('brewery-detail', BreweryDetail);