File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -192,15 +192,12 @@ export function startClientSideIsDarkLogic(params: {
192
192
193
193
const isDarkFromOsPreference = getSystemColorScheme ( ) === "dark" ;
194
194
195
- const isDarkFallback = false ;
196
-
197
195
return {
198
- "ssrWasPerformedWithIsDark" : isDarkExplicitlyProvidedAsParameter ?? isDarkFallback ,
196
+ "ssrWasPerformedWithIsDark" : isDarkExplicitlyProvidedAsParameter ?? false ,
199
197
"clientSideIsDark" :
200
198
isDarkFromLocalStorage ??
201
199
isDarkExplicitlyProvidedAsParameter ??
202
- isDarkFromOsPreference ??
203
- isDarkFallback
200
+ isDarkFromOsPreference
204
201
} ;
205
202
} ) ( ) ;
206
203
Original file line number Diff line number Diff line change @@ -27,6 +27,20 @@ export const getScriptToRunAsap: GetScriptToRunAsap = ({
27
27
const sanitizer = typeof trustedTypes !== "undefined" ? trustedTypes.createPolicy("${ trustedTypesPolicyName } -asap", { createHTML: s => s }) : {
28
28
createHTML: s => s,
29
29
};
30
+
31
+ reset_persisted_value_if_website_config_changed: {
32
+ const localStorageKey = "scheme-website-config-default";
33
+
34
+ const localStorageValue = localStorage.getItem(localStorageKey);
35
+
36
+ if (localStorageValue === "${ defaultColorScheme } ") {
37
+ break reset_persisted_value_if_website_config_changed;
38
+ }
39
+
40
+ localStorage.removeItem("scheme");
41
+
42
+ localStorage.setItem(localStorageKey, "${ defaultColorScheme } ");
43
+ }
30
44
31
45
const isDark = (() => {
32
46
@@ -62,19 +76,16 @@ export const getScriptToRunAsap: GetScriptToRunAsap = ({
62
76
63
77
const isDarkFromOsPreference = (() => {
64
78
if (!window.matchMedia) {
65
- return undefined ;
79
+ return false ;
66
80
}
67
81
68
82
return window.matchMedia("(prefers-color-scheme: dark)").matches;
69
83
})();
70
84
71
- const isDarkFallback = false;
72
-
73
85
return (
74
86
isDarkFromLocalStorage ??
75
87
isDarkExplicitlyProvidedAsParameter ??
76
- isDarkFromOsPreference ??
77
- isDarkFallback
88
+ isDarkFromOsPreference
78
89
);
79
90
80
91
})();
You can’t perform that action at this time.
0 commit comments