From 5240aec3467886351e7e276b8cdbbfeefea30b99 Mon Sep 17 00:00:00 2001 From: Michael Maurakis Date: Mon, 20 Jan 2025 02:17:55 -0600 Subject: [PATCH] Dark mode by default. --- index.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 0cce989..fda48b4 100644 --- a/index.html +++ b/index.html @@ -291,14 +291,18 @@ document.getElementById("fumbleButton").addEventListener("click", fumble); // Dark mode toggle - const darkModeToggle = document.getElementById("darkModeToggle"); - const darkModeToggleArea = document.getElementById("darkModeToggleArea"); - const body = document.body; - - // Check for saved preference - if (localStorage.getItem("darkMode") === "true") { - body.classList.add("dark-mode"); - darkModeToggle.textContent = "☀️"; + const darkModeToggle = document.getElementById('darkModeToggle'); + const darkModeToggleArea = document.getElementById('darkModeToggleArea'); + const body = document.body; + + // Check for saved preference, default to dark if not set + if (localStorage.getItem('darkMode') === null) { + localStorage.setItem('darkMode', 'true'); + } + + if (localStorage.getItem('darkMode') === 'true') { + body.classList.add('dark-mode'); + darkModeToggle.textContent = '☀️'; } const toggleDarkMode = () => {