We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2adf927 + a565c90 commit 2d43fb1Copy full SHA for 2d43fb1
apps/website/src/root.tsx
@@ -39,8 +39,14 @@ export default component$(() => {
39
useContextProvider(ROOT_STORE_CONTEXT_ID, rootStore);
40
41
useVisibleTask$(() => {
42
- rootStore.mode =
43
- localStorage.getItem(THEME_STORAGE_KEY) === 'dark' ? 'dark' : 'light';
+ const userStoredTheme = localStorage.getItem(THEME_STORAGE_KEY);
+ if (userStoredTheme) {
44
+ rootStore.mode = userStoredTheme === 'dark' ? 'dark' : 'light';
45
+ } else {
46
+ rootStore.mode = window.matchMedia('(prefers-color-scheme: dark)').matches
47
+ ? 'dark'
48
+ : 'light';
49
+ }
50
});
51
52
// TODO: remove this old state once refactored
0 commit comments