-
Notifications
You must be signed in to change notification settings - Fork 36
/
github.html
258 lines (234 loc) · 6.07 KB
/
github.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="theme-color" content="#FFF" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
<title>Easter egg for GitHub</title>
<link rel="shortcut icon" type="image/x-icon" href="https://gw.alipayobjects.com/zos/k/vx/favicon.svg" />
<style>
@font-face {
font-family: 'JetBrains Mono';
src: url('https://gw.alipayobjects.com/os/k/app/JetBrainsMono-Regular.ttf') format('truetype');
}
* {
font-family: JetBrains Mono, SF Mono, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif;
}
body {
height: 100vh;
color: #fff;
background: #15141a;
margin: 0;
font-size: 14px;
line-height: 1.4;
}
</style>
</head>
<body>
<script>
let styles = `\
/*
* Open source is a fascinating endeavor.
* It's a treasure trove of learning and intriguing ideas.
* Let's draw a Github Octocat to honor open source contributors.
*/
/* Starting with a 'pre' tag for coding */
pre {
color: #61ffca;
width: 100%;
height: 100%;
position: absolute;
top: 0;
box-sizing: border-box;
padding: 24px 16px;
margin-top: 0;
overflow-y: auto;
transition: all 500ms;
}
/* Not a fan of italics, let's straighten them out. */
pre em {
font-style: normal;
}
/* Time to highlight our code. */
.selector,
.selector .key {
color: #f694ff;
}
.key,
.comment {
color: #edecee;
}
.value {
color: #ffca85;
}
/* To better draw the Octocat, let's move the code down. */
pre {
top: 42%;
height: 58%;
}
/* Having set up the container, let's get started. */
.github-box {
width: 100%;
height: 42%;
background: #fff;
position: absolute;
top: 0;
display: flex;
align-items: center;
justify-content: center;
}
/* Phew, drawing isn't easy, maybe start with a circle. */
.github {
width: 200px;
height: 200px;
background: #15141a;
border-radius: 50%;
margin: auto;
display: block;
position: relative;
}
/* Ha, because I fiddled with the styles, it might look a bit long~ */
.github::before,
.github::after,
.github > i::before,
.github > i::after,
.github > i > i::before,
.github > i > i::after {
content: '';
display: block;
position: absolute;
background-color: #fff;
}
/* he face seems to go like this. */
.github::before {
width: 120px;
height: 108px;
top: 41px;
left: 40px;
border-radius: 50%;
box-shadow: 16px 0px 0 -6px #fff, -16px 0px 0 -6px #fff;
}
/* Let's sketch a simple neck. */
.github::after {
width: 46px;
height: 62px;
border-radius: 14px 14px 0 0;
top: 140px;
left: 77px;
}
/* Ears seem to work like this. */
.github > i::before {
width: 40px;
height: 40px;
border-radius: 15% 70% 15% 70%;
top: 35px;
left: 40px;
transform: rotate(11deg);
}
/* Another ear coming up. */
.github > i::after {
width: 40px;
height: 40px;
border-radius: 15% 70% 15% 70%;
top: 35px;
right: 40px;
transform: rotate(79deg);
}
/* Ha ha, the tail is a bit tricky, isn't it? */
.github > i > i::before {
width: 40px;
height: 40px;
border-radius: 50% 50%;
top: 121px;
left: 40px;
background: transparent;
border-bottom: 14px solid #fff;
border-left: 6px solid transparent;
border-right: 12px solid transparent;
transform: rotate(15deg);
}
/* Let's try another one and see how it goes. */
.github > i > i::after {
width: 28px;
height: 28px;
border-radius: 50% 50%;
top: 140px;
left: 12px;
background: transparent;
border-top: 9px solid #fff;
border-left: 1px solid transparent;
border-right: 12px solid transparent;
transform: rotate(39deg);
}
/* All right, that's it, we've got it!*/
/*
* You never win by quantity, creativity is your lifeblood.
* With just a computer, you're ready to create.
* Reigning far and wide, you slay from afar.
* Hidden in the bustle, you wander among the many.
* Not just a coder, you are an engineer with limitless potential.
* May you always write the code you love~
*/
`;
const getStyleHtml = function () {
return document.getElementById('style-text').innerHTML;
};
let openComment = false;
const writeStyleChar = function (which) {
if (which === '/' && !openComment) {
openComment = true;
styles = getStyleHtml() + which;
} else if (which === '/' && openComment) {
openComment = false;
styles = getStyleHtml().replace(
/(\/[^\/]*\*)$/,
'<em class="comment">$1/</em>',
);
} else if (which === ':') {
styles = getStyleHtml().replace(
/([a-zA-Z- ^\n]*)$/,
'<em class="key">$1</em>:',
);
} else if (which === ';') {
styles = getStyleHtml().replace(
/([^:]*)$/,
'<em class="value">$1</em>;',
);
} else if (which === '{') {
styles = getStyleHtml().replace(
/(.*)$/,
'<em class="selector">$1</em>{',
);
} else {
styles = getStyleHtml() + which;
}
document.getElementById('style-text').innerHTML = styles;
return document
.getElementById('style-tag')
.insertAdjacentHTML('beforeend', which);
};
const writeStyles = function (message, index, interval) {
if (index < message.length) {
const pre = document.getElementById('style-text');
pre.scrollTop = pre.scrollHeight;
writeStyleChar(message[index++]);
return setTimeout(
() => writeStyles(message, index, interval),
interval,
);
}
};
document.body.insertAdjacentHTML(
'beforeend',
`\<style id="style-tag"></style>
<div class="github-box">
<span class="github"><i><i></i></i></span>
</div>
<pre id="style-text"></pre>\
`,
);
writeStyles(styles, 0, 20);
</script>
</body>
</html>