-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurora.html
113 lines (93 loc) · 3.01 KB
/
aurora.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="assets/images/CheerLights-Icon.png">
<title>CheerLights JavaScript Widget - Aurora</title>
<meta name="description" content="A widget that displays a dynamic aurora inspired by the current CheerLights color using the CheerLights JavaScript library." />
<style>
html, body {
width: 100%;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}
body {
cursor: pointer;
background: linear-gradient(0deg, rgba(0,0,0,1) 0%, var(--aurora-color) 100%);
position: relative;
}
.aurora {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
animation: aurora 20s infinite;
opacity: 0.8;
background: linear-gradient(45deg,
var(--aurora-color) 0%,
transparent 70%
);
filter: blur(60px);
}
.aurora:nth-child(2) {
animation-delay: -5s;
transform: rotate(60deg);
}
.aurora:nth-child(3) {
animation-delay: -10s;
transform: rotate(-60deg);
}
@keyframes aurora {
0% {
transform: translate(0, -50%) rotate(0deg);
}
50% {
transform: translate(0, 50%) rotate(180deg);
}
100% {
transform: translate(0, -50%) rotate(360deg);
}
}
</style>
</head>
<body>
<div class="aurora"></div>
<div class="aurora"></div>
<div class="aurora"></div>
<script src="https://cdn.jsdelivr.net/gh/cheerlights/[email protected]/cheerlights.js"></script>
<script>
const REFRESH_INTERVAL = 5000;
const CHEERLIGHTS_URL = 'https://cheerlights.com/cheerlights-javascript-widgets/';
// get current cheerlights color
CheerLights.getColor(initialColor => {
setBodyBackgroundColor(initialColor);
setAuroraColor(initialColor);
});
// refresh cheerlights color every 5 seconds
setInterval(() => {
CheerLights.getColor(color => {
setBodyBackgroundColor(color);
setAuroraColor(color);
});
}, REFRESH_INTERVAL);
function setBodyBackgroundColor(color) {
if (!color || !color.htmlName) {
console.error('Invalid color data received');
return;
}
document.body.style.backgroundColor = color.htmlName;
document.body.title = `Current CheerLights color: ${color.htmlName}`;
}
function setAuroraColor(color) {
document.documentElement.style.setProperty('--aurora-color', color.htmlName);
}
document.body.addEventListener('click', () => {
window.open(CHEERLIGHTS_URL, '_blank');
});
</script>
</body>
</html>