IMAGE / web /src /components /theme-script.tsx
cjovs's picture
Rebrand chatgpt2api to IMAGE
b174937 verified
Raw
History Blame Contribute Delete
652 Bytes
const themeScript = `
(() => {
try {
const stored = localStorage.getItem("image-theme");
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
const theme = stored === "light" || stored === "dark" ? stored : prefersDark ? "dark" : "light";
document.documentElement.classList.toggle("dark", theme === "dark");
document.documentElement.style.colorScheme = theme;
} catch {
document.documentElement.classList.remove("dark");
document.documentElement.style.colorScheme = "light";
}
})();
`;
export function ThemeScript() {
return <script dangerouslySetInnerHTML={{ __html: themeScript }} />;
}