-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview.tsx
More file actions
103 lines (92 loc) · 3.03 KB
/
view.tsx
File metadata and controls
103 lines (92 loc) · 3.03 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
96
97
98
99
100
101
102
103
import { DOMRenderer, JsxChildren } from 'dom-renderer';
import { Polyfill } from './Polyfill';
export interface LayoutProps {
children?: JsxChildren;
}
export const Layout = ({ children }: LayoutProps) => (
<html>
<head>
<meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web polyfill</title>
<link rel="icon" href="https://github.com/EasyWebApp.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link
rel="stylesheet"
href="https://unpkg.com/bootstrap/dist/css/bootstrap-utilities.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/github-markdown-css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/prismjs@1.29.0/themes/prism-okaidia.min.css"
/>
</head>
<body class="p-3 markdown-body">
{children}
<script src="https://unpkg.com/prismjs@1.29.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
</body>
</html>
);
export interface SavedPolyfill
extends Pick<Polyfill, 'packageName' | 'sourceMapURLs'> {
name: string;
}
export interface TableProps {
data: SavedPolyfill[];
}
const { WAN_ICON, WAN_HOST, LAN_ICON, LAN_HOST } = process.env;
export const Table = ({ data }: TableProps) => (
<table>
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>Package</th>
<th>Source Map</th>
<th>Network</th>
</tr>
</thead>
<tbody>
{data.map(({ name, packageName, sourceMapURLs }, index) => (
<tr>
<td>{++index}</td>
<td>{name}</td>
<td>
<a
href={`https://www.npmjs.com/package/${packageName}`}
>
{packageName}
</a>
</td>
<td>{sourceMapURLs[0] ? `✅` : ''}</td>
<td>
<a href={`${WAN_HOST}/feature/${name}.js`}>
{WAN_ICON}
</a>{' '}
<a href={`${LAN_HOST}/feature/${name}.js`}>
{LAN_ICON}
</a>
</td>
</tr>
))}
</tbody>
</table>
);
const renderer = new DOMRenderer();
export const generateHomePage = (
ReadMe: string,
polyfills: TableProps['data']
) =>
renderer.renderToStaticMarkup(
<Layout>
<article innerHTML={ReadMe} />
<h2>All supported polyfills</h2>
<Table data={polyfills} />
</Layout>
);