-
Notifications
You must be signed in to change notification settings - Fork 1
/
to-do.js
52 lines (46 loc) · 975 Bytes
/
to-do.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 { LitElement, html, css } from 'lit-element';
import { eventCompleteToDo } from './to-do-events';
import { toDoButton } from './shared-styles';
import { iconMinus } from './icons';
class ToDo extends LitElement {
static get properties() {
return {
todo: {
type: Object,
},
};
}
constructor() {
super();
this.todo = {};
}
completeToDo() {
this.dispatchEvent(eventCompleteToDo(this.todo.id));
}
static get styles() {
return [
css`
:host {
display: block;
}
div {
border-top: 1px solid;
padding-left: 5px;
white-space: pre-wrap;
}
`,
toDoButton,
];
}
render() {
return html`
<div>
${this.todo.todo}
</div>
<button @click="${this.completeToDo}" aria-label="Complete ${this.todo.todo} To Do">
${iconMinus}
</button>
`;
}
}
customElements.define('to-do', ToDo);