-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathblank-template.html
More file actions
95 lines (77 loc) · 1.75 KB
/
blank-template.html
File metadata and controls
95 lines (77 loc) · 1.75 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="module">
// https://github.com/WebReflection/lighterhtml/issues/92
// ucdn --debug
import {render, html} from '../esm/index.js';
let state = 0;
const next = (ev) => {
ev.preventDefault();
if(state >= views.length - 1) {
return;
}
state++;
update();
}
const back = (ev) => {
ev.preventDefault();
if (state <= 0) {
return;
}
state --;
update();
}
const refresh = (ev) => {
ev.preventDefault();
update();
};
const box = f => f();
const one = (name = 'one') => html`${box(() => html`one`)}`;
const two = (name = 'two', value = 'opt') => html`${box(() => html`
<label class="block px-3 mb-3">
<input type="radio" class="form-radio" name=${name} value=${value}>
<span>two</span>
</label>`)}`;
const three = (value = 'three') => html`
<label class="block px-3 mb-3">
<div>
${value}
</div>
</label>
`;
const four = (name = 'four') => html`
<div>
Four. All good?
</div>
`;
const views = [one, two, three, four];
const view = () => (views[state] || four)();
const button = (click, text) => html`<button onclick=${click}>${text}</button>`;
const nav = () => html`
<nav>
${button(back, 'back')}
${button(next, 'next')}
${button(refresh, 'refresh')}
</nav>
`
const main = () => html`
<form>
${box(() => view())}
</form>
${nav()}
`;
const app = () => html`
<div>
<main>
${main()}
</main>
</div>
`;
const update = () => render(document.body, app);
update();
</script>
</head>
</html>