-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (42 loc) · 1.47 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8">
<title>My New Project!</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Styles -->
<link rel="stylesheet" href="index.css">
</head>
<body>
<h1>Quantity Selector</h1>
<div class="qty-selector" data-id="a">
<button class="dec">-</button>
<input class="qty" type="number" min="1" max="8"/>
<button class="inc">+</button>
</div>
<div class="qty-selector" data-id="a">
<button class="dec">-</button>
<input class="qty" type="number" min="1" max="8"/>
<button class="inc">+</button>
</div>
<div class="qty-selector" data-id="b">
<button class="dec">-</button>
<input class="qty" type="number" min="1" max="8"/>
<button class="inc">+</button>
</div>
<div class="qty-selector" data-id="b">
<button class="dec">-</button>
<input class="qty" type="number" min="1" max="8"/>
<button class="inc">+</button>
</div>
<!-- Scripts -->
<script type="module">
import { init, SelectorComponent, Store, syncAllSelectors } from './index.js';
const quantitySelectors = document.querySelectorAll('.qty-selector');
const myStore = new Store({ a: 2, b: 4 }, syncAllSelectors);
const selectorComponents = [...quantitySelectors].map((el) => new SelectorComponent(el));
init(selectorComponents, myStore);
</script>
</body>
</html>