-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
72 lines (64 loc) · 2.27 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kennel Testing</title>
<style>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
}
@media screen and (prefers-color-scheme: dark) {
body {
color: #fff;
background-color: #000;
}
}
</style>
</head>
<body>
<script type="module">
import { render, hydrate } from "/lib/index.ts";
async function renderDepiction([name, depictionImport]) {
const { default: depiction } = await depictionImport();
let [dom, ssr] = await Promise.all([render(depiction), render(depiction, { ssr: true })]);
const details = document.createElement("div");
const content = document.createElement("div");
const summary = document.createElement("h3");
summary.innerHTML = name;
details.appendChild(summary);
// add dom el
const domDetails = document.createElement("details");
const domSummary = document.createElement("summary");
domSummary.innerHTML = "Client Side";
const domContent = document.createElement("div");
domContent.style.maxWidth = "32rem";
domContent.style.margin = "auto";
domContent.appendChild(dom);
domDetails.append(domSummary, domContent);
// add ssr el
const ssrDetails = document.createElement("details");
const ssrSummary = document.createElement("summary");
ssrSummary.innerHTML = "SSR";
const ssrContent = document.createElement("div");
ssrContent.style.maxWidth = "32rem";
ssrContent.style.margin = "auto";
ssrContent.innerHTML = ssr;
ssrDetails.append(ssrSummary, ssrContent);
content.append(domDetails, ssrDetails);
details.appendChild(content);
// add to body
document.body.appendChild(details);
}
// let k = new Kennel(depiction);
// k.render()
// .then((resp) => target.appendChild(resp))
// .then(() => k.mounted());
// k.render(true).then((resp) => (ssrTarget.innerHTML = resp));
let depictions = import.meta.glob("./test/*.json");
Promise.all(Object.entries(depictions).map(renderDepiction)).then(() => hydrate());
</script>
</body>
</html>