-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathindex.html
More file actions
54 lines (43 loc) · 1.51 KB
/
index.html
File metadata and controls
54 lines (43 loc) · 1.51 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="module">
import { render, html, svg, signal, unsafe } from '../dist/dev/dom.js';
let hello = 'hello';
const comp = () => html`<${Button} text=${hello}>world</>`;
function Button(props) {
return html`<button key=${1}>${props.text} ${props.children}</button>`;
}
function Counter({ count }) {
return html`<button @click=${() => count.value++}>${unsafe('<em>count</em>')} ${count.value}</button>`;
}
function LI(entries) {
return entries.map(key => html`<li key=${key}>Rando ${key}</li>`);
}
function UL(keys) {
return html`<ul>${LI(keys)}</ul>`;
}
document.body.appendChild(
html`<svg><rect fill="red" width=${100} height=${50} /></svg>`
);
document.body.appendChild(comp());
setTimeout(render, 1000, document.body, comp);
setTimeout((...args) => {
hello = 'ahoi';
render(...args);
}, 2000, document.body, comp);
setTimeout((...args) => {
render(document.body, () => UL([1, 2, 3]));
}, 3000, document.body, comp);
setTimeout((...args) => {
render(document.body, () => UL([3, 2, 1]));
}, 4000, document.body, comp);
setTimeout((...args) => {
const count = signal(0);
render(document.body, html`<${Counter} count=${count} />`);
}, 5000);
</script>
</head>
</html>