-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.html
506 lines (450 loc) · 13.7 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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamic Year Progress with 3D Animation</title>
<link href="/styles.css" rel="stylesheet" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
:root {
--light-bg: linear-gradient(
to right,
rgb(109, 190, 190),
rgb(138, 147, 226)
);
--dark-bg: linear-gradient(to right, rgb(15, 15, 49), rgb(2, 54, 56));
--light-color: black;
--dark-color: white;
--button-bg: rgb(213, 184, 238);
--progress-msg-color: #25cc3b;
--random-msg-color-day: #1b4421;
--random-msg-color-night: #25cc3b;
}
body {
transition: background-color 0.5s, color 0.5s;
padding: 20px;
font-family: "Poppins", Arial, Helvetica, sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 100px;
background: linear-gradient(
to right,
rgb(109, 190, 190),
rgb(138, 147, 226)
);
text-align: center;
}
body.dark-mode {
background: linear-gradient(to right, rgb(15, 15, 49), rgb(2, 54, 56));
color: white;
}
h1 {
font-size: 2rem;
font-family: Georgia, "Times New Roman", Times, serif;
}
#theme-toggle {
margin-top: 3rem;
padding: 0.7rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(213, 184, 238);
border: none;
font-size: 1rem;
width: 2rem;
height: 2rem;
border-radius: 50%;
}
#progress-img {
display: block;
margin: 10px auto;
width: 100%;
max-width: 450px;
height: auto;
border-radius: 1rem;
}
#animation-container {
width: 300px;
height: 300px;
margin: 20px auto;
background: transparent;
}
#arrow-down {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #333;
margin: 5px auto;
animation: slideUpDown 2s ease-in-out infinite;
}
#contribution-container {
position: fixed;
right: 30px;
bottom: 30px;
text-align: center;
margin-bottom: 10px;
}
#contribution-container p {
font-size: 16px;
margin: 0;
color: #333;
animation: slideUpDown 2s ease-in-out infinite;
}
.github-icon {
width: 40px;
height: 40px;
animation: pulse 2s infinite;
cursor: pointer;
transition: filter 0.3s ease;
}
.github-icon:hover {
filter: drop-shadow(-0.2rem 0 1rem #f0f0f0);
}
.github-icon.invert {
filter: invert(1);
transition: filter 0.3s ease;
}
.github-icon.invert:hover {
filter: invert(1) brightness(100) drop-shadow(-0.2rem 0 1rem #f0f0f0);
}
.dateBox {
display: flex;
gap: 10px;
margin-bottom: 0.3em;
}
.fromDate,
.toDate,
.submit {
border-radius: 5px;
}
/* Keyframes for the minimal slide animation */
@keyframes slideUpDown {
0% {
transform: translateY(0);
}
50% {
transform: translateY(-5px);
}
100% {
transform: translateY(0);
}
}
/* Pulse animation */
@keyframes pulse {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
}
@media (min-width: 768px) {
#random-msg-container {
margin-top: -70px;
width: 50%;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#random-msg {
font-size: 1rem;
font-weight: 400;
color: var(--progress-msg-color);
}
}
@media (max-width: 768px) {
h1 {
font-size: 1.75rem;
}
#progress-img {
max-width: 350px;
}
#theme-toggle {
font-size: 0.9rem;
padding: 8px;
}
#animation-container {
width: 250px;
height: 250px;
}
#random-msg-container {
margin-top: -50px;
width: 50%;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#random-msg {
font-size: 1rem;
font-weight: 400;
color: #25cc3b;
}
}
@media (max-width: 480px) {
h1 {
font-size: 1.5rem;
}
#progress-img {
max-width: 250px;
}
#theme-toggle {
font-size: 0.8rem;
padding: 6px;
}
#animation-container {
width: 200px;
height: 200px;
}
#random-msg-container {
margin-top: 10px;
width: 50%;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#random-msg {
font-size: 1rem;
font-weight: 400;
color: #25cc3b;
}
}
body #random-msg {
color: var(--random-msg-color-day);
}
body.dark-mode #contribution-container p,
body.dark-mode #contribution-container #arrow-down #random-msg {
color: var(--random-msg-color-night);
}
.footer-link {
transition: color 0.3s;
}
.footer-link:hover {
color: #ffa500;
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Year Progress</h1>
<img
id="progress-img"
src="https://year-in-progress.vercel.app/year-progress"
alt="Year Progress"
/>
<div id="animation-container"></div>
<div class="dateBox">
<input
type="date"
class="fromDate"
name="startDate"
id="startDate"
required
/>
<input type="date" class="toDate" name="endDate" id="endDate" required />
<button class="submit" onclick="changeDate()">Submit</button>
</div>
<div id="random-msg-container">
<h1 id="random-msg"></h1>
</div>
<button id="theme-toggle"><i class="fa-solid fa-moon"></i></button>
<!-- GitHub image with animation -->
<div id="contribution-container">
<p>Contribute here</p>
<div id="arrow-down"></div>
<a
href="https://github.com/DhanushNehru/year-in-progress"
target="_blank"
rel="noopener noreferrer"
>
<img
src="assets/githubmark.svg"
alt="GitHub Logo"
class="github-icon"
/>
</a>
</div>
<footer
style="
margin: 2rem 0 0 0;
padding: 1rem;
background-color: #10111c;
text-align: center;
color: #fff;
"
>
<p>
© <span id="current-year"></span> Year in Progress. All rights
reserved.
</p>
<p>
Made with ❤️ by
<a
href="https://github.com/DhanushNehru"
target="_blank"
style="color: #fff; text-decoration: none"
class="footer-link"
>Dhanush Nehru</a
>
</p>
</footer>
<script>
document.getElementById("current-year").textContent =
new Date().getFullYear();
</script>
<style>
.footer-link {
transition: color 0.3s;
}
.footer-link:hover {
color: #ffa500;
text-decoration: underline;
}
</style>
<script>
document.getElementById("current-year").textContent =
new Date().getFullYear();
</script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"
></script>
<script>
const themeToggleButton = document.getElementById("theme-toggle");
const githubIcon = document.querySelector(".github-icon");
const body = document.body;
var queryString;
function isDayTime() {
const now = new Date();
const hours = now.getHours();
return hours >= 8 && hours < 17;
}
function updateTheme(isAutomatic = false) {
if (isAutomatic) {
const isDay = isDayTime();
body.classList.toggle("dark-mode", !isDay);
themeToggleButton.innerHTML = isDay
? '<i class="fa-solid fa-moon"></i>'
: '<i class="fa-solid fa-sun"></i>';
} else {
body.classList.toggle("dark-mode");
themeToggleButton.innerHTML = body.classList.contains("dark-mode")
? '<i class="fa-solid fa-sun"></i>'
: '<i class="fa-solid fa-moon"></i>';
}
updateProgressImg();
updateGitHubIcon();
}
function updateProgressImg() {
const theme = body.classList.contains("dark-mode") ? "dark" : "light";
if (queryString) {
document.getElementById(
"progress-img"
).src = `https://year-in-progress.vercel.app/year-progress?${queryString}&time=${Date.now()}&theme=${theme}`;
} else {
document.getElementById(
"progress-img"
).src = `https://year-in-progress.vercel.app/year-progress?time=${Date.now()}&theme=${theme}`;
}
}
function updateGitHubIcon() {
if (body.classList.contains("dark-mode")) {
githubIcon.classList.add("invert");
} else {
githubIcon.classList.remove("invert");
}
}
window.addEventListener("load", () => {
updateTheme(true);
});
themeToggleButton.addEventListener("click", () => updateTheme(false));
setInterval(updateProgressImg, 500);
// 3D Animation
let scene, camera, renderer, cube;
function init3D() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(300, 300);
renderer.setClearColor(0x000000, 0); // This makes the background transparent
document
.getElementById("animation-container")
.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry(2, 2, 2); // Increased from default 1,1,1
const material = new THREE.MeshBasicMaterial({
color: 0x00ff00,
wireframe: true,
transparent: true,
opacity: 0.8,
});
cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 7; // Moved the camera back to keep the larger cube in view
animate();
}
function animate() {
requestAnimationFrame(animate);
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render(scene, camera);
}
function updateCubeScale() {
const now = new Date();
const start = new Date(now.getFullYear(), 0, 1);
const end = new Date(now.getFullYear() + 1, 0, 1);
const progress = (now - start) / (end - start);
const baseScale = 0.5; // This sets the minimum size of the cube
cube.scale.set(
baseScale + progress,
baseScale + progress,
baseScale + progress
);
}
window.addEventListener("load", () => {
init3D();
setInterval(updateCubeScale, 1000);
});
function changeDate() {
var startDate = new Date(document.getElementById("startDate").value);
var endDate = new Date(document.getElementById("endDate").value);
if (endDate < startDate) {
alert("Please enter valid Date");
return;
}
if (startDate.toDateString() == endDate.toDateString()) {
endDate.setDate(endDate.getDate() + 1);
}
startDate = startDate.toISOString();
endDate = endDate.toISOString();
queryString = `startDate=${startDate}&endDate=${endDate}`;
document.getElementById(
"progress-img"
).src = `https://year-in-progress.vercel.app/year-progress?${queryString}`;
}
</script>
<script src="js/randomMsg.js"></script>
</body>
</html>