feat: set dark-mode default

This commit is contained in:
Matthew McKinnon 2024-09-15 13:51:30 +10:00
parent fc56fecdb5
commit 4183f254d2

View File

@ -1,7 +1,7 @@
// script.js
document.addEventListener('DOMContentLoaded', () => {
const switcher = document.getElementById('modeSwitcher');
const currentMode = localStorage.getItem('theme') || 'light';
const currentMode = localStorage.getItem('theme') || 'dark';
if (currentMode === 'dark') {
document.body.classList.add('dark-mode');
@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
switcher.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
const mode = document.body.classList.contains('dark-mode') ? 'dark' : 'light';
const mode = document.body.classList.contains('dark-mode') ? 'light' : 'dark';
// switcher.textContent = mode === 'dark' ? 'Switch to Light Mode' : 'Switch to Dark Mode';
localStorage.setItem('theme', mode);
});