Skip to content

Commit 7b084ea

Browse files
committed
[fix] Added Feature for keeping Dark Mode states whenever a styled-button is pressed.
1 parent 0f46308 commit 7b084ea

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

WebApplication2/Customer/Pages/CustomerComponent.aspx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@
602602
document.getElementById(id).style.display = 'block';
603603
}
604604
605+
// Dark Mode Toggle
605606
// Dark Mode Toggle
606607
function toggleDarkMode() {
607608
const body = document.body;
@@ -612,10 +613,25 @@
612613
const icon = document.getElementById('modeIcon');
613614
if (body.classList.contains('dark-mode')) {
614615
icon.src = "https://img.icons8.com/?size=100&id=83221&format=png&color=FAB005"; // Sun for light mode
616+
localStorage.setItem('darkMode', 'true'); // Save dark mode state
615617
} else {
616618
icon.src = "https://img.icons8.com/?size=100&id=59841&format=png&color=FFFFFF"; // Half Moon for dark mode
619+
localStorage.removeItem('darkMode'); // Remove dark mode state
617620
}
618621
}
622+
623+
document.addEventListener("DOMContentLoaded", function () {
624+
// Check if dark mode is enabled in localStorage
625+
if (localStorage.getItem("darkMode") === "true") {
626+
document.body.classList.add("dark-mode");
627+
document.body.classList.remove("light-mode");
628+
document.getElementById('modeIcon').src = "https://img.icons8.com/?size=100&id=83221&format=png&color=FAB005"; // Sun for light mode
629+
} else {
630+
document.body.classList.add("light-mode");
631+
document.body.classList.remove("dark-mode");
632+
document.getElementById('modeIcon').src = "https://img.icons8.com/?size=100&id=59841&format=png&color=FFFFFF"; // Half Moon for dark mode
633+
}
634+
});
619635
// Sortable Table Functionality
620636
document.addEventListener('DOMContentLoaded', function () {
621637
document.querySelectorAll('.styled-table th').forEach(function (th) {

0 commit comments

Comments
 (0)