refactor(theme-{classic,common}): refactor ColorModeToggle + useColorMode() hook (#6930)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
Alexey Pyltsyn 2022-03-18 17:28:35 +03:00 committed by GitHub
parent 8a1421a938
commit ecbe0b26c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 156 additions and 165 deletions

View file

@ -901,9 +901,9 @@ import {useColorMode} from '@docusaurus/theme-common';
const Example = () => {
// highlight-next-line
const {isDarkTheme, setLightTheme, setDarkTheme} = useColorMode();
const {colorMode, setColorMode} = useColorMode();
return <h1>Dark mode is now {isDarkTheme ? 'on' : 'off'}</h1>;
return <h1>Dark mode is now {colorMode === 'dark' ? 'on' : 'off'}</h1>;
};
```