-
Notifications
You must be signed in to change notification settings - Fork 0
/
grocery.js
34 lines (32 loc) · 960 Bytes
/
grocery.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
class Grocery extends HTMLElement {
constructor() {
super();
this.root = this.attachShadow({ mode: 'closed' });
}
set detail(item) {
this.root.innerHTML = `
<style>
li {
list-style: none;
border-bottom: 1px solid #ececec;
height: 40px;
line-height: 22px;
padding: 16px 10px 0 10px;
}
li:last-child { border-bottom: none; }
li:hover { background-color: #6fb98f; cursor: pointer; }
span { display: inline-block; padding-bottom: 10px; }
.name { width: 250px; }
.isfood { width: 230px; }
.checkbox { height: 20px; width: 20px; }
</style>
<li>
<span class="name">${item.name}</span>
<span class="isfood">
<input class="checkbox" type="checkbox" onclick="return false;" ${item.isFood && 'checked'}>
</span>
</li>
`;
}
}
customElements.define('grocery-item', Grocery);