Skip to content

Commit

Permalink
Merge pull request #4357 from aslams2020/main
Browse files Browse the repository at this point in the history
Resolved Dark mode issue
  • Loading branch information
kunjgit authored Jun 12, 2024
2 parents 51bbedd + 9d3af60 commit 2c45b24
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,27 @@ for (let i = 0; i < filterBtn.length; i++) {
// Code for enabling Light-Dark THEME


function applyTheme() {
var slider = document.getElementById("themeToggle");
var isDarkTheme = localStorage.getItem("isDarkTheme");

if (isDarkTheme === "true") {
slider.checked = true;
enableDarkTheme();
} else {
slider.checked = false;
disableDarkTheme();
}
}

function toggleTheme() {
var slider = document.getElementById("themeToggle");
if (slider.checked) {
disableDarkTheme();
} else {
localStorage.setItem("isDarkTheme", "true");
enableDarkTheme();
} else {
localStorage.setItem("isDarkTheme", "false");
disableDarkTheme();
}
}

Expand Down Expand Up @@ -245,6 +258,8 @@ function disableDarkTheme() {
}
}

document.addEventListener("DOMContentLoaded", applyTheme);

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
Expand Down

0 comments on commit 2c45b24

Please sign in to comment.