From f2f48c9eae78d82e5d0f063ce526b69446b4adc4 Mon Sep 17 00:00:00 2001 From: Kosztyk <36381705+Kosztyk@users.noreply.github.com> Date: Thu, 4 Dec 2025 14:10:09 +0200 Subject: [PATCH] Add files via upload --- public/theme-init.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 public/theme-init.js diff --git a/public/theme-init.js b/public/theme-init.js new file mode 100644 index 0000000..0924375 --- /dev/null +++ b/public/theme-init.js @@ -0,0 +1,21 @@ +// public/theme-init.js +// Runs on every page and applies the saved theme *before* the page renders. + +(function () { + var STORAGE_KEY = "convertx-theme"; + + try { + var theme = localStorage.getItem(STORAGE_KEY); + + // default to light if nothing stored or value is invalid + if (theme === "dark") { + document.documentElement.setAttribute("data-theme", "dark"); + } else { + document.documentElement.removeAttribute("data-theme"); + } + } catch (e) { + // If localStorage is blocked, just fall back to light theme + document.documentElement.removeAttribute("data-theme"); + } +})(); +