From 2c97ec727287ad50d3a6bddfc940e6fbe9c7be6d Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 6 Mar 2024 23:38:38 -0800 Subject: [PATCH] hopefully this adds dynamic theming lol --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.html b/index.html index 46a6a25..23249c1 100644 --- a/index.html +++ b/index.html @@ -74,6 +74,16 @@ }); document.querySelector(".last-updated").innerHTML = document.lastModified; + + window.addEventListener("DOMContentLoaded", () => { + const selector = document.querySelector(".theme-selector"); + selector.value = localStorage.getItem("theme") || window.matchMedia('(prefers-color-scheme: light)').matches ? "latte" : "frappe"; + document.documentElement.setAttribute("theme", selector.value); + selector.addEventListener("change", function () { + localStorage.setItem("theme", this.value); + document.documentElement.setAttribute("theme", this.value); + }); +});