-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (25 loc) · 916 Bytes
/
script.js
File metadata and controls
31 lines (25 loc) · 916 Bytes
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
let header = document.getElementById('header');
window.addEventListener('scroll', () => {
if(window.scrollY>= 200){
header.style.background= 'var(--color-darkgolden)';
}else{
header.style.background= 'transparent';
}
})
// Get a reference to the button
const themeToggleBtn = document.getElementById('theme-toggle');
// Function to toggle the color theme
function toggleColorTheme() {
const root = document.documentElement; // Get the :root element
if (root.classList.contains('dark-theme')) {
// Switch to Light Mode
root.classList.remove('dark-theme');
themeToggleBtn.textContent = "Modo Escuro";
} else {
// Switch to Dark Mode
root.classList.add('dark-theme');
themeToggleBtn.textContent = "Modo Claro";
}
}
// Event listener for the theme toggle button
themeToggleBtn.addEventListener('click', toggleColorTheme);