make lightmode default
This commit is contained in:
@@ -199,13 +199,13 @@ const body = document.body;
|
||||
|
||||
// Apply saved theme on load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const savedTheme = localStorage.getItem('theme') || 'light'; // Default is light mode
|
||||
const savedTheme = localStorage.getItem('theme') || 'dark'; // Default is dark mode
|
||||
|
||||
if (savedTheme === 'light') {
|
||||
body.classList.add('light-mode');
|
||||
if (savedTheme === 'dark') {
|
||||
body.classList.add('dark-mode');
|
||||
toggleSwitch.checked = true;
|
||||
} else {
|
||||
body.classList.remove('light-mode');
|
||||
body.classList.remove('dark-mode');
|
||||
toggleSwitch.checked = false;
|
||||
}
|
||||
});
|
||||
@@ -213,12 +213,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Toggle between light and dark mode
|
||||
toggleSwitch.addEventListener('change', () => {
|
||||
if (toggleSwitch.checked) {
|
||||
body.classList.add('light-mode');
|
||||
localStorage.setItem('theme', 'light');
|
||||
} else {
|
||||
body.classList.remove('light-mode');
|
||||
body.classList.add('dark-mode');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
} else {
|
||||
body.classList.remove('dark-mode');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user