Dark mode by default.
This commit is contained in:
parent
1282bf2bda
commit
5240aec346
1 changed files with 12 additions and 8 deletions
20
index.html
20
index.html
|
@ -291,14 +291,18 @@
|
||||||
document.getElementById("fumbleButton").addEventListener("click", fumble);
|
document.getElementById("fumbleButton").addEventListener("click", fumble);
|
||||||
|
|
||||||
// Dark mode toggle
|
// Dark mode toggle
|
||||||
const darkModeToggle = document.getElementById("darkModeToggle");
|
const darkModeToggle = document.getElementById('darkModeToggle');
|
||||||
const darkModeToggleArea = document.getElementById("darkModeToggleArea");
|
const darkModeToggleArea = document.getElementById('darkModeToggleArea');
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
|
|
||||||
// Check for saved preference
|
// Check for saved preference, default to dark if not set
|
||||||
if (localStorage.getItem("darkMode") === "true") {
|
if (localStorage.getItem('darkMode') === null) {
|
||||||
body.classList.add("dark-mode");
|
localStorage.setItem('darkMode', 'true');
|
||||||
darkModeToggle.textContent = "☀️";
|
}
|
||||||
|
|
||||||
|
if (localStorage.getItem('darkMode') === 'true') {
|
||||||
|
body.classList.add('dark-mode');
|
||||||
|
darkModeToggle.textContent = '☀️';
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleDarkMode = () => {
|
const toggleDarkMode = () => {
|
||||||
|
|
Loading…
Reference in a new issue