Spaces:
Running
Running
Download web/src/components/theme-script.tsx from li2895/chatgpt2api: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/spaces/li2895/chatgpt2api/resolve/main/web/src/components/theme-script.tsx
- Command line
-
hf download hf://spaces/li2895/chatgpt2api/web/src/components/theme-script.tsx
-
curl -L -o theme-script.tsx https://huggingface.co/spaces/li2895/chatgpt2api/resolve/main/web/src/components/theme-script.tsx
658 Bytes
| const themeScript = ` | |
| (() => { | |
| try { | |
| const stored = localStorage.getItem("chatgpt2api-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 }} />; | |
| } | |