mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
Add prefers-color-scheme query for theme fallback
This commit is contained in:
@@ -30,10 +30,11 @@ function loadCodeFont(): CodeFont {
|
||||
}
|
||||
|
||||
function loadTheme(): Theme {
|
||||
const { matches } = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const storedTheme = window.localStorage.getItem("theme");
|
||||
|
||||
if (storedTheme === null) {
|
||||
return "dark";
|
||||
return matches ? "dark" : "light";
|
||||
} else {
|
||||
return storedTheme as Theme;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user