Add files via upload
This commit is contained in:
parent
48d1ce57e0
commit
f2f48c9eae
1 changed files with 21 additions and 0 deletions
21
public/theme-init.js
Normal file
21
public/theme-init.js
Normal file
|
|
@ -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");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue