From a9072370ca1eb9a5cce928b1d487db0f307edea6 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Tue, 20 Sep 2022 15:24:27 +0800 Subject: feat: Move old apps into it's own directory --- apps/kit/static/preload.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 apps/kit/static/preload.js (limited to 'apps/kit/static/preload.js') diff --git a/apps/kit/static/preload.js b/apps/kit/static/preload.js new file mode 100644 index 0000000..379902f --- /dev/null +++ b/apps/kit/static/preload.js @@ -0,0 +1,13 @@ +const value = `; ${document.cookie}`; +const parts = value.split(`; go_theme=`); +let currentTheme = "system"; +if (parts.length === 2) { + currentTheme = parts.pop().split(";").shift(); +} +if (currentTheme === "light") { + document.querySelector("html").dataset.theme = "light"; +} else if (currentTheme === "dark") { + document.querySelector("html").dataset.theme = "dark"; +} else { + document.querySelector("html").dataset.theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; +} \ No newline at end of file -- cgit v1.3