Skip to content

Commit

Permalink
fix: 🐛 fixed issue with dark mode when refreshing the page
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Feb 21, 2025
1 parent c689ace commit 4f8091a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
5 changes: 4 additions & 1 deletion templates/assets/js/darkmode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var darkMode = "darkmode";

function applyDarkMode() {
document.getElementById("features-table").classList.toggle("table-striped");
applyFontStyle();
document
.querySelector("html")
.setAttribute("data-bs-theme", isDarkModeOn() ? "dark" : "light");
document.getElementById("features-table").classList.toggle("table-striped");
}

function saveState() {
Expand All @@ -29,5 +29,8 @@ window.onload = function () {
if (window.localStorage["darkmode"] === "on") {
applyDarkMode();
document.getElementById("darkCheck").checked = true;
document
.querySelector("html")
.setAttribute("data-bs-theme", isDarkModeOn() ? "dark" : "light");
}
};
22 changes: 6 additions & 16 deletions templates/feature-overview.index.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../assets/js/darkmode.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
Expand Down Expand Up @@ -40,10 +41,6 @@

<link href="../assets/css/font-awesome.min.css" rel="stylesheet">
<% } %>
<!-- Darkmode -->
<script>
<%= darkmodeScript %>
</script>

<!-- Custom Theme Style -->
<style type="text/css">
Expand All @@ -52,13 +49,6 @@
</style>
</head>
<body>
<script type="text/javascript">
window.onload = function() {
if(window.localStorage['darkmode'] === 'on') {
applyFontStyle();
}
}
</script>
<nav class="navbar">
<div class="container-fluid">

Expand Down Expand Up @@ -156,11 +146,11 @@

<% if (!pageFooter) { %>
<div class="created-by">
<p>Created by wswebcreation. Find me on:</p>
<a href="http://www.wswebcreation.nl/" target="_blank"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="https://github.com/wswebcreation/" target="_blank"><i class="fa fa-github-square fa-2x"></i></a>
<a href="http://nl.linkedin.com/in/wimselles" target="_blank"><i class="fa fa-linkedin-square fa-2x"></i></a>
<a href="http://stackoverflow.com/users/5911978/wswebcreation" target="_blank"><i class="fa fa-stack-overflow fa-2x"></i></a>
<p>Maintained by Wasiq Bhamla. Find me on:</p>
<a href="https://www.youtube.com/@WasiqBhamla" target="_blank"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="https://github.com/WasiqB/" target="_blank"><i class="fa fa-github-square fa-2x"></i></a>
<a href="https://www.linkedin.com/in/wasiqbhamla/" target="_blank"><i class="fa fa-linkedin-square fa-2x"></i></a>
<a href="https://stackoverflow.com/users/5320558/wasiq-bhamla" target="_blank"><i class="fa fa-stack-overflow fa-2x"></i></a>
</div>
<% } else { %>
<%= pageFooter %>
Expand Down
16 changes: 6 additions & 10 deletions templates/features-overview.index.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="assets/js/darkmode.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
Expand Down Expand Up @@ -89,11 +90,11 @@
</div>
<% if (!pageFooter) { %>
<div class="created-by">
<p>Created by wswebcreation. Find me on:</p>
<a href="http://www.wswebcreation.nl/" target="_blank"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="https://github.com/wswebcreation/" target="_blank"><i class="fa fa-github-square fa-2x"></i></a>
<a href="http://nl.linkedin.com/in/wimselles" target="_blank"><i class="fa fa-linkedin-square fa-2x"></i></a>
<a href="http://stackoverflow.com/users/5911978/wswebcreation" target="_blank"><i class="fa fa-stack-overflow fa-2x"></i></a>
<p>Maintained by Wasiq Bhamla. Find me on:</p>
<a href="https://www.youtube.com/@WasiqBhamla" target="_blank"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="https://github.com/WasiqB/" target="_blank"><i class="fa fa-github-square fa-2x"></i></a>
<a href="https://www.linkedin.com/in/wasiqbhamla/" target="_blank"><i class="fa fa-linkedin-square fa-2x"></i></a>
<a href="https://stackoverflow.com/users/5320558/wasiq-bhamla" target="_blank"><i class="fa fa-stack-overflow fa-2x"></i></a>
</div>
<% } else { %>
<%= pageFooter %>
Expand Down Expand Up @@ -122,11 +123,6 @@
<script src="assets/js/responsive.bootstrap5.js"></script>
<% } %>

<!-- Darkmode -->
<script>
<%= darkmodeScript %>
</script>

<!-- Custom -->
<script>
$(document).ready(function () {
Expand Down

0 comments on commit 4f8091a

Please sign in to comment.