docs-theme: dark mode support

This commit is contained in:
Josh Tynjala
2022-07-18 09:54:51 -07:00
parent fd0fc3da48
commit 795b2fcace
2 changed files with 21 additions and 3 deletions

View File

@@ -6,6 +6,22 @@ function readCookie(name) {
return localStorage.getItem(name);
}
function isDarkTheme() {
return document.querySelector("html").classList.contains("dark-theme");
}
function toggleTheme() {
const htmlTag = document.querySelector("html");
let isDark = isDarkTheme();
if (isDark) {
htmlTag.classList.remove("dark-theme");
} else {
htmlTag.classList.add("dark-theme");
}
isDark = isDarkTheme();
localStorage.theme = isDark ? "dark" : "light";
}
function toggleInherited(el) {
var toggle = $(el).closest(".toggle");
toggle.toggleClass("toggle-on");
@@ -131,7 +147,7 @@ $(document).ready(function(){
}
return true;
});
$("#select-platform").selectpicker().on("change", function(e){
var value = $(":selected", this).val();
setPlatform(value);