Merge pull request #5 from barrett-ruth/theme

dark theme
This commit is contained in:
Barrett Ruth 2025-11-09 14:46:49 -05:00 committed by GitHub
commit d456ae4cec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 113 additions and 42 deletions

0
ne
View file

View file

@ -25,5 +25,6 @@
"prettier": "^3.6.2", "prettier": "^3.6.2",
"prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro": "^0.14.1",
"typescript": "^5.9.3" "typescript": "^5.9.3"
} },
"packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a"
} }

View file

@ -237,6 +237,30 @@
true, true,
); );
const themeToggle = document.getElementById("theme-toggle");
if (themeToggle) {
function updateBearVisual() {
const currentTheme =
document.documentElement.getAttribute("data-theme");
if (currentTheme === "dark") {
themeToggle.textContent = "☾⊂ʕ•ᴥ•ʔ";
} else {
themeToggle.textContent = "☼⊂ʕ•ᴥ•ʔ";
}
}
updateBearVisual();
themeToggle.addEventListener("click", () => {
const currentTheme =
document.documentElement.getAttribute("data-theme");
const newTheme = currentTheme === "dark" ? "light" : "dark";
document.documentElement.setAttribute("data-theme", newTheme);
localStorage.setItem("theme", newTheme);
updateBearVisual();
});
}
window.addEventListener("beforeunload", () => { window.addEventListener("beforeunload", () => {
const el = promptEl(); const el = promptEl();
if (el) el.textContent = TERMINAL_PROMPT; if (el) el.textContent = TERMINAL_PROMPT;

View file

@ -142,6 +142,40 @@
font-display: swap; font-display: swap;
} }
:root {
--bg: #fff;
--text: #000;
--code-bg: #f4f4f4;
--border: #e1e1e1;
--grid-color: rgba(200, 200, 200, 0.4);
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #000;
--text: #fff;
--code-bg: #0a0a0a;
--border: #1a1a1a;
--grid-color: rgba(55, 55, 55, 0.4);
}
}
[data-theme="light"] {
--bg: #fff;
--text: #000;
--code-bg: #f4f4f4;
--border: #e1e1e1;
--grid-color: rgba(200, 200, 200, 0.4);
}
[data-theme="dark"] {
--bg: #000;
--text: #fff;
--code-bg: #0a0a0a;
--border: #1a1a1a;
--grid-color: rgba(55, 55, 55, 0.4);
}
pre, pre,
code, code,
pre code, pre code,
@ -158,23 +192,27 @@ body {
font-family: "Signifier", serif; font-family: "Signifier", serif;
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 100%; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: var(--bg);
color: var(--text);
} }
header, header,
footer { footer {
padding: 20px; padding: 20px;
}
header {
font-size: 1.5em; font-size: 1.5em;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
#theme-toggle {
cursor: pointer;
user-select: none;
}
.main { .main {
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -191,8 +229,8 @@ li {
.graph-background { .graph-background {
background-image: background-image:
linear-gradient(to right, rgba(200, 200, 200, 0.4) 1px, transparent 1px), linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
linear-gradient(to bottom, rgba(200, 200, 200, 0.4) 1px, transparent 1px); linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
background-size: 3vw 3vw; background-size: 3vw 3vw;
} }
@ -200,8 +238,8 @@ li {
display: inline-block; display: inline-block;
width: 10px; width: 10px;
height: 1em; height: 1em;
background-color: white; background-color: var(--bg);
border: 1px solid black; border: 1px solid var(--text);
vertical-align: text-top; vertical-align: text-top;
animation: blink 1s step-start infinite; animation: blink 1s step-start infinite;
} }

View file

@ -41,7 +41,7 @@ li {
.post-meta { .post-meta {
font-size: 1.3em; font-size: 1.3em;
color: black; color: var(--text);
margin-left: 100px; margin-left: 100px;
} }
@ -118,12 +118,12 @@ article pre {
padding: 1rem; padding: 1rem;
overflow-x: auto; overflow-x: auto;
border-radius: 4px; border-radius: 4px;
background: #f4f4f4 !important; background: var(--code-bg) !important;
border: 1px solid #e1e1e1; border: 1px solid var(--border);
} }
pre * { pre * {
background: #f4f4f4 !important; background: var(--code-bg) !important;
} }
:not(pre) > code { :not(pre) > code {
@ -131,9 +131,9 @@ pre * {
padding: 4px; padding: 4px;
margin: 0 5px; margin: 0 5px;
white-space: nowrap; white-space: nowrap;
border: 1px solid #e1e1e1; border: 1px solid var(--border);
border-radius: 4px; border-radius: 4px;
background: #f4f4f4 !important; background: var(--code-bg) !important;
} }
.astro-code { .astro-code {

View file

@ -1,6 +1,12 @@
<footer> <footer>
<span>ʕ •ᴥ•ʔ</span> <div class="footer-links-left">
<div class="footer-links"> <a href="/resume.pdf" data-topic="resume" target="_blank">resume</a>
<a href="/transcript.pdf" data-topic="transcript" target="_blank"
>transcript</a
>
<a href="/about.html" data-topic="about">about</a>
</div>
<div class="footer-links-right">
<a href="/gist.html" data-topic="gist">gist</a> <a href="/gist.html" data-topic="gist">gist</a>
<a href="/git.html" data-topic="git">git</a> <a href="/git.html" data-topic="git">git</a>
<a <a
@ -13,18 +19,23 @@
</footer> </footer>
<style> <style>
footer { .footer-links-left,
padding: 20px; .footer-links-right {
font-size: 1.5em;
display: flex; display: flex;
align-items: center; gap: 25px;
justify-content: space-between;
} }
.footer-links a { .footer-links-left a,
margin-left: 25px; .footer-links-right a {
text-decoration: none; text-decoration: none;
cursor: pointer; cursor: pointer;
} }
@media (max-width: 768px) {
.footer-links-left,
.footer-links-right {
flex-direction: column;
gap: 5px;
}
}
</style> </style>
<script type="module" src="/scripts/index.js"></script> <script type="module" src="/scripts/index.js"></script>

View file

@ -21,35 +21,21 @@ const promptText = topic ? `barrett@ruth:~$ ${topic}` : "barrett@ruth:~$";
<span class="terminal-cursor"></span> <span class="terminal-cursor"></span>
</div> </div>
</a> </a>
<div class="header-links"> <span id="theme-toggle">☼⊂ʕ•ᴥ•ʔ</span>
<a href="/resume.pdf" data-topic="resume" target="_blank">resume</a>
<a href="/transcript.pdf" data-topic="transcript" target="_blank"
>transcript</a
>
<a href="/about.html" data-topic="about">about</a>
</div>
</header> </header>
<style> <style>
.header-links a { #theme-toggle {
margin-left: 25px;
text-decoration: none;
cursor: pointer; cursor: pointer;
user-select: none;
} }
@media (max-width: 768px) { @media (max-width: 768px) {
header { header {
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
} }
.header-links { #theme-toggle {
align-self: flex-end; align-self: flex-end;
display: flex;
flex-direction: column;
text-align: right;
gap: 5px;
}
.header-links a {
margin-left: 0;
} }
} }
</style> </style>

View file

@ -12,6 +12,17 @@ const {
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<script is:inline>
(function () {
const stored = localStorage.getItem("theme");
const theme =
stored ||
(matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light");
document.documentElement.setAttribute("data-theme", theme);
})();
</script>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />