fix(v2): switch a toggle when system theme changed (#2325)

* fix(v2): switch a toggle when system theme changed

* fix: add check on disabled dark mode
This commit is contained in:
Alexey Pyltsyn 2020-02-27 05:14:20 +03:00 committed by GitHub
parent 68a5cd5df1
commit 37dff050ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -61,6 +61,18 @@ const useTheme = () => {
}
}, [setTheme]);
useEffect(() => {
if (disableDarkMode) {
return;
}
window
.matchMedia('(prefers-color-scheme: dark)')
.addListener(({matches}) => {
setTheme(matches ? themes.dark : themes.light);
});
}, []);
return {
isDarkTheme: theme === themes.dark,
setLightTheme,