-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.ts
146 lines (141 loc) · 4.03 KB
/
template.ts
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { html } from "./deps.ts";
export interface TemplateHeaders {
[key: string]: {
version: string;
};
}
export interface TemplateTtesters {
[key: string]: {
[key: string]: {
[key: string]: {
path: string;
code: string;
};
};
};
}
export interface TemplateData {
headers: TemplateHeaders;
testers: TemplateTtesters;
result: (nodeVersion: string, path: string) => string;
percent: (nodeVersion: string) => number;
}
function renderHeaders(
headers: TemplateHeaders,
percent: (nodeVersion: string) => number,
): string {
return Object.entries(headers)
.map(([nodeVersion, details]) => {
return html`
<th class="version">${details.version}<sub>${percent(
nodeVersion,
)}%</sub></th>
`;
})
.join("");
}
export function render({
headers,
testers,
result,
percent,
}: TemplateData): string {
return html`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Web-Platform-Tests for Deno</title>
<link href="favico.ico" rel="shortcut icon" />
<link rel="stylesheet" href="style.css" />
</head>
</html>
<body>
<a
class="github-fork"
href="https://github.com/denodev/wpt"
target="_blank"
data-ribbon="Edit on GitHub"
>Edit on GitHub</a
>
<header>
<h1><a href="#top">Web-Platform-Tests for Deno</a></h1>
<table class="headings">
<tr>${renderHeaders(headers, percent)}</tr>
</table>
</header>
<article id="top">
${Object.entries(testers)
.map(([category, obj1]) => {
const category2 = category.replace(/\W/g, "-");
return html`
<table class="results">
<caption>
<h2 class="category">
<div class="hash" id="${category2}"></div>
<a href="#${category2}">${category2}</a>
</h2>
</caption>
${Object.entries(obj1)
.map(([subcategory, obj2]) => {
const subcategory2 = [
category2,
subcategory.replace(/\W/g, "-"),
].join("-");
return html`
<tr>
<td
class="feature sub"
colspan="${Object.keys(headers).length + 1}"
>
<h3>
<div class="hash" id="${subcategory2}"></div>
<a href="#${subcategory2}">${subcategory}</a>
</h3>
</td>
</tr>
${Object.entries(obj2)
.map(([subsubcategory, obj3]) => {
const subsubcategory2 = [
subcategory2,
subsubcategory.replace(/\W/g, "-"),
].join("-");
return html`
<tr>
<td class="feature subsub">
<div class="hash" id="${subsubcategory2}"></div>
<a href="#${subsubcategory2}"
>${subsubcategory}</a
>
<div class="info">
?
<div class="fn">
<div class="code">${obj3.code}</div>
</div>
</div>
</td>
${Object.keys(headers)
.map(
(nodeVersion) =>
html`
<td class="result">
${result(nodeVersion, obj3.path)}
</td>
`,
)
.join("")}
</tr>
`;
})
.join("")}
`;
})
.join("")}
</table>
`;
})
.join("")}
</article>
</body>`;
}