mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 12:22:45 +02:00
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:
parent
8a1421a938
commit
ecbe0b26c5
12 changed files with 156 additions and 165 deletions
|
@ -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>;
|
||||
};
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue