Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/_includes/header_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

<script>
const toggleDarkMode = document.querySelector(".js-toggle-dark-mode");

jtd.addEvent(toggleDarkMode, "click", function () {
if (jtd.getTheme() === "light") {
jtd.setTheme("dark");
toggleDarkMode.textContent = "☼";
localStorage.setItem("theme", "dark");
} else {
jtd.setTheme("light");
toggleDarkMode.textContent = "☾";
localStorage.setItem("theme", "light");
}
});

// TODO: we can probably delete this (hacky workaround) if/when just-the-docs/#1223 is fixed.
// Meanwhile, we check each time if there is a theme written to local storage and obey it.
window.addEventListener("DOMContentLoaded", function () {
if (localStorage.getItem("theme") === "dark") {
jtd.setTheme("dark");
toggleDarkMode.textContent = "☼";
} else {
jtd.setTheme("light");
toggleDarkMode.textContent = "☾";
Expand Down