dark mode only

This commit is contained in:
Joshua Seigler 2025-06-22 08:15:08 -04:00
parent dbb7f59197
commit 0c788a6893
6 changed files with 18 additions and 104 deletions

View file

@ -0,0 +1,23 @@
@font-face {
font-family: FTAurebesh;
font-style: normal;
font-weight: 500;
font-display: block;
src: url("/fonts/ftaurebesh/ftaurebesh-medium.woff2") format("woff2");
size-adjust: 125%;
}
@font-face {
font-family: FTAurebesh;
font-style: normal;
font-weight: 700;
font-display: block;
src: url("/fonts/ftaurebesh/ftaurebesh-bold.woff2") format("woff2");
size-adjust: 125%;
}
[data-language="aurebesh"] {
font-family: FTAurebesh;
line-height: 1.25;
ul:not(.collection) > li {
list-style-type: square;
}
}

View file

@ -1,10 +1,6 @@
"use strict";
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
const defaultPrefs = {
language: "english",
theme: "auto",
};
document.querySelector('script[data-website-id]').addEventListener('load', () => {
try {
@ -12,26 +8,6 @@ document.querySelector('script[data-website-id]').addEventListener('load', () =>
} catch {}
});
function applyPreference(key, value, shouldSave) {
if (umami !== null) {
umami.identify({
[`pref-${key}`]: value,
});
if (shouldSave) {
umami.track(`Set ${key} to ${value}`);
}
}
document.body.setAttribute(`data-${key}`, value);
document.querySelectorAll(`input[name=${key}]`).forEach((input) => {
if (input.value === value) {
input.checked = true;
}
});
if (shouldSave) {
localStorage.setItem(key, value);
}
}
/** @param {Event} evt */
function removeEffect({ target }) {
const effectsLayer = document.querySelector("#effects");
@ -87,15 +63,6 @@ function addEffect({ target }) {
});
}
Object.entries(defaultPrefs).forEach(([key, defaultPref]) => {
const currentPref = localStorage.getItem(key) ?? defaultPref;
applyPreference(key, currentPref, false);
document.querySelectorAll(`input[name=${key}]`).forEach((input) => {
input.addEventListener("change", (e) => {
applyPreference(key, e.currentTarget.value, true);
});
});
});
document.addEventListener("mouseenter", addEffect, true);
document.addEventListener("focus", addEffect, true);