-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
476 lines (401 loc) · 15.4 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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width">
<!-- HTML Meta Tags -->
<title>Mobject Gallery</title>
<meta name="description" content="">
<!-- OpenGraph Meta Tags -->
<meta property="og:url" content="https://github.com/kolibril13/mobject-gallery">
<meta property="og:type" content="website">
<meta property="og:title" content="Mobject Gallery">
<meta property="og:description" content="">
<meta property="og:image" content="https://kolibril13.github.io/mobject-gallery/preview_image.png">
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="kolibril13.github.io">
<meta property="twitter:url" content="https://github.com/kolibril13/mobject-gallery">
<meta name="twitter:title" content="Mobject Gallery">
<meta name="twitter:description" content="">
<meta name="twitter:image" content="https://kolibril13.github.io/mobject-gallery/preview_image.png">
<!-- Meta Tags Generated via https://www.opengraph.xyz -->
<link rel="icon" type="image/x-icon" href="icon.png">
<!-- the original plywood icon is dedicated to the Marble Machine X by Wintergatan https://youtu.be/JgM2ruB8M34?t=614 -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/default.min.css">
<!-- <link rel="stylesheet" href="styles.css"> comming soon!! -->
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/highlight.min.js"></script>
<script src="https://kit.fontawesome.com/fd8b485006.js" crossorigin="anonymous"></script>
<!-- <script src="script.js" defer></script> comming soon!! -->
<style>
h1,
h2 {
font-family: monospace;
margin-bottom: 0;
margin-top: 0
}
.whole_page {
margin: auto;
width: 840px;
border-left: 3px solid #d6c6bb;
border-right: 3px solid #d6c6bb;
padding: 10px;
}
.container_code {
position: relative;
width: 600px;
height: 1px;
/* there is probably a better way to do this */
border: 0;
z-index: 2;
font-size: 10px;
position: sticky;
top: 0;
}
/* .python can not be renamed because of highlight.js */
.container_code .python {
border-radius: 8px;
position: relative;
z-index: 2;
width: 600px;
}
.container_code .close_button {
position: absolute;
top: 17px;
right: -14px;
z-index: 3;
}
.container_code .close_button button {
border-radius: 4px;
background-color: lightgrey;
height: 18px;
width: 18px;
padding: 0px;
z-index: 3;
border-width: 0;
}
.container_code .close_button button:hover {
opacity: 0.6;
}
/* .gallery_container{
} */
.gallery_entry {
opacity: 1;
display: inline-block;
width: 80px;
height: auto;
margin: 3px;
vertical-align: middle;
transition: .1s ease;
backface-visibility: hidden;
border-radius: 8px;
}
.gallery_entry:hover {
opacity: 0.7;
}
/* container_info is the top right info section */
.container_info {
position: fixed;
top: 0px;
right: 0px;
width: max-content;
width: 300px;
height: 200px;
/* border: 2px solid; */
border-color: grey;
}
.container_info table {
border-spacing: 10px 20px;
font-family: monospace
}
.container_info .info_github_icon {
font-size: 36px
}
.container_info .info_search_icon {
font-size: 36px
}
.container_info .info_version p {
margin-bottom: 2.5px;
margin-top: 2.5px;
}
.container_info .info_version a {
color: black;
text-decoration: none;
}
.container_info .info_version a:hover {
color: blue;
opacity: 0.8;
}
.container_info .info_info_icon {
font-size: 36px
}
.container_info .githublink a:link {
color: black;
background-color: transparent;
text-decoration: none;
}
.container_info .githublink a:visited {
color: black;
background-color: transparent;
text-decoration: none;
}
.container_info .githublink a:hover {
color: grey;
background-color: transparent;
text-decoration: underline;
}
.container_info .githublink a:active {
color: blue;
background-color: transparent;
text-decoration: underline;
}
.container_info .info_legend ul {
margin: 0;
padding: 0;
float: left;
list-style: none;
}
.container_info .info_legend ul li {
margin-left: 0;
line-height: 18px;
}
.container_info .info_legend .legend-labels span {
float: left;
height: 10px;
width: 30px;
/* IMPORTANT spacing on the right */
margin-right: 5px;
margin-left: 3px;
border-radius: 4px;
/* margin-top must be (info_legend ul li line-height - .info_legend .legend-labels span height) /2 */
margin-top: 4px;
}
.container_info .tooltip {
position: relative;
display: inline-block;
}
.container_info .tooltip .tooltiptext {
visibility: hidden;
font-size: small;
width: 500px;
background-color: white;
color: black;
text-align: left;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 100%;
margin-left: -350px;
border: 2px solid;
}
/* TODO: The Tooltip has to be refectored*/
/* this is the arrow */
.container_info .tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
/* TODO: calculate left: 66%; from margin-lef at tooltiptextt*/
left: 66%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.container_info .tooltip:hover .tooltiptext {
visibility: visible;
}
@media (max-width: 1200px) {
.container_info {
position: static;
}
}
/* TODO: This should be done with a smooth transition. */
@media (max-width: 750px) {
.whole_page {
width: 95%;
}
}
/* TODO: This should be done with a smooth transition. */
@media (max-width: 680px) {
.container_code {
width: 97%;
}
.container_code .python {
width: 100%;
;
}
}
</style>
</head>
<body style="background-color:#ece6e2;">
<div class="whole_page">
<div style="text-align:center">
<h2>Mobject Gallery</h2>
</div>
<div class="container_code">
<!-- maybe better html indention possible for this pre block? -->
<pre>
<b>Code:</b>
<code class="python" id="code_snippet"> <br> </code>
</pre> <!-- better naming of these divs here-->
<div class='close_button'>
<button type="button" onclick="reset_content(this)">X</button>
</div>
</div>
<div>
<br><br><br><br><br><br><br><br>
<!-- TODO This can be done better with a fixed length -->
</div>
<div id="gallery_container">
<template gallery-item-template>
<img class='gallery_entry' src='' data-code='' style='width: auto;'
onclick='display_code_from_gallery_cell(this);'>
</template>
<template heading-template>
<span><br>
<h2></h2>
</span>
</template>
</div>
<div class="container_info">
<table>
<tr>
<td class="info_github_icon">
<div class="tooltip">
<div class="githublink">
<i class="fa fa-github"></i>
</div>
<!-- TODO: This tooltip needs to be adjusted in a better way, should not be hard-coded! -->
<div class="tooltiptext" style="padding:5px; width: 160px; margin-left:-130px">
Links to GitHub repos on the right.
</div>
</div>
</td>
<td class="info_version">
<p style="opacity: 0.8;"> <a title="Plywood Core at GitHub"
href="https://github.com/kolibril13/mobject-gallery"><span
class="tooltip">user content v0.17.1 (Manim) </span></a><br></p>
<p style="opacity: 0.4;"> <a title="Plywood Core at GitHub"
href="https://github.com/kolibril13/plywood-gallery"><span class="tooltip">
plywood core v0.0.11</span></a></p>
</td>
</tr>
<tr>
<td class="info_search_icon">
<div class="tooltip">
<div class="githublink">
<i class="fa fa-search"></i>
</div>
<!-- TODO: This tooltip needs to be adjusted in a better way, should not be hard-coded! -->
<div class="tooltiptext" style="padding:5px; width: 160px; margin-left:-130px">
Search for keywords in gallery.
</div>
</div>
</td>
<td>
<div>
<input type="search" id="search" autocomplete="off" data-search>
</div>
</td>
</tr>
<tr>
<td class="info_info_icon">
<div class="tooltip">
<div class="infologo">
<i class="fa-solid fa-circle-info"></i>
</div>
<div class="tooltiptext">
<ul>
<li> <strong>Header</strong> cells contain imports and definitions.</li>
<li> <strong>Normal</strong> cells are independent of each other, and can run
togehter
with the <strong>Header</strong> cell.
</li>
<li> A <strong>Dependent</strong> cell depends on the <strong>Normal</strong> cell
left
to it.
</li>
<li> A <strong>Dependent</strong> cell depends on another <strong>Dependent</strong>
cell left to it.
</li>
</ul>
</div>
</div>
</td>
<td>
<div class="info_legend">
<ul class='legend-labels'>
<li><span style='background:#ED6A5A;'></span>Header</li>
<li><span style='background:#007AB8;'></span>Normal</li>
<li><span style='background:#A8DCF0;'></span>Dependent</li>
</ul>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
<script>
hljs.highlightAll();
function display_code_from_gallery_cell(imgs) {
var name = imgs.dataset.code;
document.getElementById("code_snippet").innerHTML = name
hljs.highlightAll();
}
// rest the code content block to an empty paragraph
function reset_content(imgs) {
document.getElementById("code_snippet").innerHTML = "<p> <br></p>" //maybe better solution possible?
hljs.highlightAll();
}
let request = new XMLHttpRequest();
request.open("GET", "gallery_assets/gallery_parameters.json", false);
request.send(null);
let json_content_all = JSON.parse(request.responseText);
jsonData = json_content_all["plywood_content"]
const gallery_area = document.getElementById("gallery_container");
plywood_entries = []
for (let key of Object.keys(jsonData)) {
let chapter_of_html = key
var template_heading = document.querySelector("[heading-template]");
var my_heading = template_heading.content.cloneNode(true);
my_heading.querySelector("h2").innerHTML = chapter_of_html;
gallery_area.appendChild(my_heading);
let chapter_content = jsonData[key]
for (const chap_element of chapter_content) {
let path_of_example = chap_element["image_path"]
let codeblock_of_example = chap_element["code"]
let c = codeblock_of_example
if (c.startsWith(" ")) {
c = c.replaceAll(" ", ""); // a bit hacky, but it works
}
let css_of_example = chap_element["css"]
var template_entry = document.querySelector("[gallery-item-template]");
var my_entry = template_entry.content.cloneNode(true);
let my_img = my_entry.querySelector(".gallery_entry")
my_img.style = css_of_example;
my_img.ref_style = css_of_example;
my_img.src = path_of_example;
my_img.dataset.code = c;
gallery_area.appendChild(my_img);
plywood_entries.push({ codesnip: codeblock_of_example, img: my_img })
}
}
const searchInput = document.querySelector("[data-search]")
searchInput.addEventListener("input", e => {
const value = e.target.value.toLowerCase()
plywood_entries.forEach(pw_entry => {
const isVisible = pw_entry.codesnip.toLowerCase().includes(value)
console.log(isVisible)
if (!isVisible) {
pw_entry.img.style = "opacity:0.1";
}
if (isVisible) {
pw_entry.img.style = pw_entry.img.ref_style;
// pw_entry.img.style ="height:200px" // this line would have a nice folding effect
}
})
})
</script>
</html>