-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremoteReadmeTemplate.html
101 lines (92 loc) · 2.57 KB
/
remoteReadmeTemplate.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
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
<!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.0" />
<!-- open-graph-protocol metadata -->
<title><!-- readme title --></title>
<style>
body {
font-family: system-ui, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding-bottom: 10rem;
}
main {
max-width: 65ch;
display: flex;
flex-direction: column;
}
img {
justify-self: center;
max-width: 100%;
}
@media (prefers-color-scheme: dark) {
html {
background-color: #242424;
color: #e3e3e3;
}
a {
color: #209df0;
}
}
</style>
<script>
// we create a style tag containing the CSS specific to our component
// cloning content from a <template> tag is faster than using .innerHTML() on the main element
const style = document.createElement("template");
style.innerHTML = `
<style>
:host > a{
color:white;
background:#209df0;
font-size:1rem;
padding: 10px 16px;
line-height:1.2;
border-radius:4px;
border:3px solid transparent;
text-align:center;
text-decoration:none;
user-select:none;
display:inline-block;
}
:host > a:hover{
background: #2facff;
}
</style>
`;
const markup = document.createElement("template");
markup.innerHTML = `
<a href="<!-- zip url -->">
Download the template
<slot></slot>
</a>
`;
class GetZipButton extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(markup.content.cloneNode(true));
this.shadowRoot.appendChild(style.content.cloneNode(true));
}
}
window.customElements.define("an-zip-downloader", GetZipButton);
</script>
</head>
<body>
<main>
<!-- readme content -->
</main>
<script>
const downloadBtn = document.createElement("an-zip-downloader");
const firstH1 = document.querySelector("h1");
if (firstH1) {
firstH1.insertAdjacentElement("afterend", downloadBtn);
} else {
document.body.insertAdjacentElement("afterbegin", downloadBtn);
}
</script>
</body>
</html>