-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
50 lines (40 loc) · 1.84 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', function() {
const colorToggle = document.getElementById('color-toggle');
const warning = document.getElementById('warning');
// Check for OKLCH support
const supportsOKLCH = CSS.supports('color', 'oklch(0.98 0.05 95)');
if (!supportsOKLCH) {
warning.classList.remove('hidden');
}
colorToggle.addEventListener('click', function() {
if (document.body.classList.contains('hd-colors')) {
document.body.classList.remove('hd-colors');
document.body.classList.add('light-mode');
document.querySelector('header').classList.remove('hd-colors');
document.querySelector('header').classList.add('light-mode');
document.querySelectorAll('a').forEach(el => {
el.classList.remove('hd-colors');
el.classList.add('light-mode');
});
document.querySelectorAll('.color-box').forEach(el => {
el.classList.remove('hd-colors');
el.classList.add('light-mode');
});
colorToggle.textContent = 'Switch to HD Colors';
} else {
document.body.classList.remove('light-mode');
document.body.classList.add('hd-colors');
document.querySelector('header').classList.remove('light-mode');
document.querySelector('header').classList.add('hd-colors');
document.querySelectorAll('a').forEach(el => {
el.classList.remove('light-mode');
el.classList.add('hd-colors');
});
document.querySelectorAll('.color-box').forEach(el => {
el.classList.remove('light-mode');
el.classList.add('hd-colors');
});
colorToggle.textContent = 'Switch to Standard Colors';
}
});
});