Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 11 additions & 7 deletions docs/_includes/header_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

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

const setHtmlThemeAttr = (theme) => {
document.documentElement.setAttribute("data-theme", theme);
};

jtd.addEvent(toggleDarkMode, "click", function () {
if (jtd.getTheme() === "light") {
jtd.setTheme("dark");
setHtmlThemeAttr("dark");
toggleDarkMode.textContent = "☼";
toggleDarkMode.ariaLabel = "Switch to light mode";
localStorage.setItem("theme", "dark");
} else {
jtd.setTheme("light");
setHtmlThemeAttr("light");
toggleDarkMode.textContent = "☾";
toggleDarkMode.ariaLabel = "Switch to dark mode";
localStorage.setItem("theme", "light");
Expand All @@ -22,12 +29,9 @@
* 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 = "☾";
}
const theme = localStorage.getItem("theme") === "dark" ? "dark" : "light";
jtd.setTheme(theme);
setHtmlThemeAttr(theme);
toggleDarkMode.textContent = theme === "dark" ? "☼" : "☾";
Comment on lines +32 to +35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so clean

});
</script>
38 changes: 38 additions & 0 deletions docs/_sass/custom/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,41 @@ div.site-logo {
width: 100%;
color: $body-text-color;
}

//Dark mode link styles
html[data-theme="dark"] {
.main-header a,
.main-header button,
.side-bar a {
color: $link-color-dark;
}

main a,
footer a {
color: $link-color-dark;
text-decoration: underline;
text-decoration-color: $link-color-dark;
text-decoration-thickness: 1px;
transition:
text-decoration-thickness 0.2s ease-in-out,
text-underline-offset 0.2s ease-in-out;
}

main a:hover,
footer a:hover {
text-decoration-color: $link-color-dark;
text-decoration-thickness: 2px;
text-underline-offset: 3px;
}
}

//Label colors
main {
.label-green {
background-color: $label-success-bg;
}

.label-red {
background-color: $label-error-bg;
}
}
9 changes: 9 additions & 0 deletions docs/_sass/custom/setup.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Color palette
$blue-400: #4da6ff;
$green-700: #00755c;
$red-600: #d13c3c;
Comment on lines +2 to +4
Copy link
Member

@samcunliffe samcunliffe Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Contrast ratios confirmed.

Dark-mode links are 5.87:1.
Traffic lights are now 5:61:1 and 4:74:1.

Screenshot 2025-06-10 at 07 18 39 Screenshot 2025-06-10 at 07 18 35


// Semantic mappings
$link-color-dark: $blue-400;
$label-success-bg: $green-700;
$label-error-bg: $red-600;