-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (77 loc) · 2.09 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>winkblue playground</title>
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
<style>
ul.flex-list {
display: flex;
flex-wrap: wrap;
padding: 20px;
margin: 0 auto;
}
ul.flex-list > li {
width: 100px;
height: 100px;
list-style: none;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid white;
margin: 4px;
}
[hidden] { display: none; }
/* cspell:ignore fizzbuzz */
</style>
</head>
<body>
<h1>Observe <code>li[hidden]</code></h1>
<p><a href="https://github.com/FlandreDaisuki/winkblue/blob/master/docs/play/hidden/index.html">view source code</a></p>
<div>
<button type="button" id="btn">Append a list item</button>
</div>
<main>
<h2>winkblue list</h2>
<ul id="winkblue-list" class="flex-list"></ul>
<h2>sentinel-js list</h2>
<ul id="sentinel-list" class="flex-list"></ul>
</main>
<script>
(() => {
const btnEl = document.getElementById('btn');
const flexListEls = Array.from(document.querySelectorAll('ul.flex-list'));
if(!btnEl || flexListEls.length === 0) { return; }
let i = 0;
btnEl.onclick = () => {
i += 1;
const hiddenStr = (i % 3) === 0 ? 'hidden' : '';
for (const flexListEl of flexListEls) {
flexListEl.insertAdjacentHTML('beforeend', `<li ${hiddenStr}>${String(i).padStart(3, '0')}</li>`)
}
}
})();
</script>
<script type="importmap">
{
"imports": {
"winkblue": "https://esm.sh/winkblue",
"sentinel": "https://esm.sh/sentinel-js"
}
}
</script>
<script type="module">
import sentinel from 'sentinel';
sentinel.on('ul#sentinel-list > li[hidden]', (el) => {
el.removeAttribute('hidden');
});
</script>
<script type="module">
import { winkblue } from 'winkblue';
winkblue.on('ul#winkblue-list > li[hidden]', (el) => {
el.removeAttribute('hidden');
});
</script>
</body>
</html>