Skip to content

Commit

Permalink
fix(v2): dynamic dark mode detection without toggle widget (#3877)
Browse files Browse the repository at this point in the history
* fix(v2): dynamic dark mode detection without toggle widget

* Update packages/docusaurus-theme-classic/src/theme/hooks/useTheme.ts

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
  • Loading branch information
hmil and slorber authored Dec 4, 2020
1 parent 415a797 commit c4aeb19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-classic/src/theme/hooks/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const storeTheme = (newTheme) => {

const useTheme = (): useThemeReturns => {
const {
colorMode: {disableSwitch = false},
colorMode: {disableSwitch, respectPrefersColorScheme},
} = useThemeConfig();
const [theme, setTheme] = useState(getInitialTheme);

Expand Down Expand Up @@ -71,7 +71,7 @@ const useTheme = (): useThemeReturns => {
}, [setTheme]);

useEffect(() => {
if (disableSwitch) {
if (disableSwitch && !respectPrefersColorScheme) {
return;
}

Expand Down

0 comments on commit c4aeb19

Please sign in to comment.