commit d66b12f585fba304b3cce33a92196988473d7c7f
parent 3ce8e07a4dd13bc0a91234448801d4910d10bed3
Author: Gabriel de Brito <me@gboncoffee.dev.br>
Date: Mon, 30 Nov 2026 20:59:44 -0300
Added light theme (Tomorrow) with a toggle button.
The theme follows the browser's preferred color scheme by default, and
the button overrides it, persisting the choice in localStorage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
| M | head.html | | | 94 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ |
| M | header.html | | | 1 | + |
2 files changed, 88 insertions(+), 7 deletions(-)
diff --git a/head.html b/head.html
@@ -2,30 +2,101 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="/static/profile.png">
+<script>
+ (function () {
+ var theme = null;
+ try {
+ theme = localStorage.getItem("theme");
+ } catch (e) {}
+ if (theme === "light" || theme === "dark")
+ document.documentElement.setAttribute("data-theme", theme);
+
+ function current() {
+ var t = document.documentElement.getAttribute("data-theme");
+ if (t)
+ return t;
+ return window.matchMedia("(prefers-color-scheme: dark)").matches
+ ? "dark" : "light";
+ }
+
+ document.addEventListener("DOMContentLoaded", function () {
+ var button = document.getElementById("themetoggle");
+ if (!button)
+ return;
+ function label() {
+ button.textContent = current() === "dark" ? "Light" : "Dark";
+ }
+ label();
+ button.hidden = false;
+ button.addEventListener("click", function () {
+ var next = current() === "dark" ? "light" : "dark";
+ document.documentElement.setAttribute("data-theme", next);
+ try {
+ localStorage.setItem("theme", next);
+ } catch (e) {}
+ label();
+ });
+ window.matchMedia("(prefers-color-scheme: dark)")
+ .addEventListener("change", label);
+ });
+ })();
+</script>
+
<style>
+ /* Light: Tomorrow. */
:root {
font-family: sans-serif;
+ color-scheme: light;
+ --bg: #ffffff;
+ --fg: #4d4d4c;
+ --link: #4271ae;
+ --visited: #8959a8;
+ --code: #718c00;
+ --quote: #6e6e6d;
+ }
+
+ /* Dark: Tomorrow Night Bright. */
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) {
+ color-scheme: dark;
+ --bg: #000000;
+ --fg: #eaeaea;
+ --link: #7aa6da;
+ --visited: #c397d8;
+ --code: #b9ca4a;
+ --quote: #c4c4c4;
+ }
+ }
+
+ :root[data-theme="dark"] {
+ color-scheme: dark;
+ --bg: #000000;
+ --fg: #eaeaea;
+ --link: #7aa6da;
+ --visited: #c397d8;
+ --code: #b9ca4a;
+ --quote: #c4c4c4;
}
html {
- background-color: #000000;
- color: #eaeaea;
+ background-color: var(--bg);
+ color: var(--fg);
}
a {
- color: #7aa6da;
+ color: var(--link);
text-decoration: none;
}
a:visited {
- color: #c397d8;
+ color: var(--visited);
text-decoration: none;
}
code {
font-family: monospace, monospace;
font-size: small;
- color: #b9ca4a;
+ color: var(--code);
}
#navlist {
@@ -34,6 +105,15 @@
padding: 0;
}
+ #themetoggle {
+ background: none;
+ border: none;
+ padding: 0;
+ font: inherit;
+ color: var(--link);
+ cursor: pointer;
+ }
+
#navlistitem {
display: inline;
padding-right: 2.5rem;
@@ -58,7 +138,7 @@
}
blockquote {
- color: #c4c4c4;
+ color: var(--quote);
}
header {
@@ -66,7 +146,7 @@
}
#bigtitle {
- color: #eaeaea;
+ color: var(--fg);
}
#date {
diff --git a/header.html b/header.html
@@ -7,6 +7,7 @@
<li id="navlistitem"><a href="/projects/">Projects</a></li>
<li id="navlistitem"><a href="/posts/">Posts</a></li>
<li id="navlistitem"><a href="/literature/">Literature</a></li>
+ <li id="navlistitem"><button id="themetoggle" type="button" hidden>Dark</button></li>
</ul>
</nav>
</header>