whois/static/js/util/setThemeBeforeRender.js

12 lines
392 B
JavaScript
Raw Permalink Normal View History

2025-01-05 16:39:13 -08:00
const preferredMode = window.matchMedia("(prefers-color-scheme: dark)").matches
? "DARK"
: "LIGHT";
// sets theme before rendering & jquery loaded to prevent flashing of uninitialized theme
// (ugly white background)
localStorage.setItem("theme", localStorage.getItem("theme") || preferredMode);
document.documentElement.setAttribute(
"data-theme",
localStorage.getItem("theme"),
);