Add prefers-color-scheme query for theme fallback

This commit is contained in:
Sebastian Martinez
2024-03-19 10:28:06 +01:00
committed by Rūdolfs Ošiņš
parent cee200e629
commit 91866f6292
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -16,6 +16,7 @@ const config: PlaywrightTestConfig = {
reporter: "list",
globalSetup: "./tests/support/globalSetup",
use: {
colorScheme: "dark",
actionTimeout: 5000,
baseURL: "http://localhost:3001",
trace: "retain-on-failure",
+2 -1
View File
@@ -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;
}