@docusaurus/theme-classic 0.0.0-4734 → 0.0.0-4735
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/theme-classic.d.ts +7 -3
- package/lib-next/theme/ColorModeToggle/index.js +36 -59
- package/lib-next/theme/ColorModeToggle/styles.module.css +8 -24
- package/lib-next/theme/Navbar/index.js +7 -11
- package/lib-next/theme/ThemedImage/index.js +2 -2
- package/package.json +13 -13
- package/src/theme/ColorModeToggle/index.tsx +36 -63
- package/src/theme/ColorModeToggle/styles.module.css +8 -24
- package/src/theme/Navbar/index.tsx +10 -10
- package/src/theme/ThemedImage/index.tsx +3 -2
- package/src/theme-classic.d.ts +7 -3
package/lib/theme-classic.d.ts
CHANGED
|
@@ -746,12 +746,16 @@ declare module '@theme/TOCCollapsible' {
|
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
declare module '@theme/ColorModeToggle' {
|
|
749
|
-
import type {
|
|
749
|
+
import type {ColorMode} from '@docusaurus/theme-common';
|
|
750
750
|
|
|
751
751
|
export interface Props {
|
|
752
752
|
readonly className?: string;
|
|
753
|
-
readonly
|
|
754
|
-
|
|
753
|
+
readonly value: ColorMode;
|
|
754
|
+
/**
|
|
755
|
+
* The parameter represents the "to-be" value. For example, if currently in
|
|
756
|
+
* dark mode, clicking the button should call `onChange("light")`
|
|
757
|
+
*/
|
|
758
|
+
readonly onChange: (colorMode: ColorMode) => void;
|
|
755
759
|
}
|
|
756
760
|
|
|
757
761
|
export default function Toggle(props: Props): JSX.Element;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import IconLightMode from '@theme/IconLightMode';
|
|
@@ -12,72 +12,49 @@ import IconDarkMode from '@theme/IconDarkMode';
|
|
|
12
12
|
import clsx from 'clsx';
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
|
|
15
|
-
function ColorModeToggle({className,
|
|
15
|
+
function ColorModeToggle({className, value, onChange}) {
|
|
16
16
|
const isBrowser = useIsBrowser();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const title = translate(
|
|
18
|
+
{
|
|
19
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
20
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
21
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
mode:
|
|
25
|
+
value === 'dark'
|
|
26
|
+
? translate({
|
|
27
|
+
message: 'dark mode',
|
|
28
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
29
|
+
description: 'The name for the dark color mode',
|
|
30
|
+
})
|
|
31
|
+
: translate({
|
|
32
|
+
message: 'light mode',
|
|
33
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
34
|
+
description: 'The name for the light color mode',
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
);
|
|
23
38
|
return (
|
|
24
|
-
<div
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
tabIndex={-1}
|
|
37
|
-
onClick={() => inputRef.current?.click()}>
|
|
39
|
+
<div className={clsx(styles.toggle, className)}>
|
|
40
|
+
<button
|
|
41
|
+
className={clsx(
|
|
42
|
+
'clean-btn',
|
|
43
|
+
styles.toggleButton,
|
|
44
|
+
!isBrowser && styles.toggleButtonDisabled,
|
|
45
|
+
)}
|
|
46
|
+
type="button"
|
|
47
|
+
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
|
|
48
|
+
disabled={!isBrowser}
|
|
49
|
+
title={title}
|
|
50
|
+
aria-label={title}>
|
|
38
51
|
<IconLightMode
|
|
39
52
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
40
53
|
/>
|
|
41
54
|
<IconDarkMode
|
|
42
55
|
className={clsx(styles.toggleIcon, styles.darkToggleIcon)}
|
|
43
56
|
/>
|
|
44
|
-
</
|
|
45
|
-
|
|
46
|
-
<input
|
|
47
|
-
ref={inputRef}
|
|
48
|
-
checked={checked}
|
|
49
|
-
type="checkbox"
|
|
50
|
-
className={styles.toggleScreenReader}
|
|
51
|
-
aria-label={translate(
|
|
52
|
-
{
|
|
53
|
-
message: 'Switch between dark and light mode (currently {mode})',
|
|
54
|
-
id: 'theme.colorToggle.ariaLabel',
|
|
55
|
-
description: 'The ARIA label for the navbar color mode toggle',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
mode: checked
|
|
59
|
-
? translate({
|
|
60
|
-
message: 'dark mode',
|
|
61
|
-
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
62
|
-
description: 'The name for the dark color mode',
|
|
63
|
-
})
|
|
64
|
-
: translate({
|
|
65
|
-
message: 'light mode',
|
|
66
|
-
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
67
|
-
description: 'The name for the light color mode',
|
|
68
|
-
}),
|
|
69
|
-
},
|
|
70
|
-
)}
|
|
71
|
-
onChange={onChange}
|
|
72
|
-
onClick={() => setChecked(!checked)}
|
|
73
|
-
onFocus={() => setFocused(true)}
|
|
74
|
-
onBlur={() => setFocused(false)}
|
|
75
|
-
onKeyDown={(e) => {
|
|
76
|
-
if (e.key === 'Enter') {
|
|
77
|
-
inputRef.current?.click();
|
|
78
|
-
}
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
57
|
+
</button>
|
|
81
58
|
</div>
|
|
82
59
|
);
|
|
83
60
|
}
|
|
@@ -6,28 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
.toggle {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
height: 32px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.toggleScreenReader {
|
|
15
|
-
border: 0;
|
|
16
|
-
clip: rect(0 0 0 0);
|
|
17
|
-
height: 1px;
|
|
18
|
-
margin: -1px;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
position: absolute;
|
|
21
|
-
width: 1px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.toggleDisabled {
|
|
25
|
-
cursor: not-allowed;
|
|
9
|
+
width: 2rem;
|
|
10
|
+
height: 2rem;
|
|
26
11
|
}
|
|
27
12
|
|
|
28
13
|
.toggleButton {
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
user-select: none;
|
|
31
14
|
-webkit-tap-highlight-color: transparent;
|
|
32
15
|
align-items: center;
|
|
33
16
|
display: flex;
|
|
@@ -35,17 +18,18 @@
|
|
|
35
18
|
width: 100%;
|
|
36
19
|
height: 100%;
|
|
37
20
|
border-radius: 50%;
|
|
21
|
+
transition: background var(--ifm-transition-fast);
|
|
38
22
|
}
|
|
39
23
|
|
|
40
24
|
.toggleButton:hover {
|
|
41
|
-
background-color
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[data-theme='dark'] .toggleButton:hover {
|
|
45
|
-
background-color: #ffffff20;
|
|
25
|
+
background: var(--ifm-color-emphasis-200);
|
|
46
26
|
}
|
|
47
27
|
|
|
48
28
|
[data-theme='light'] .darkToggleIcon,
|
|
49
29
|
[data-theme='dark'] .lightToggleIcon {
|
|
50
30
|
display: none;
|
|
51
31
|
}
|
|
32
|
+
|
|
33
|
+
.toggleButtonDisabled {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
@@ -84,14 +84,10 @@ function useColorModeToggle() {
|
|
|
84
84
|
const {
|
|
85
85
|
colorMode: {disableSwitch},
|
|
86
86
|
} = useThemeConfig();
|
|
87
|
-
const {
|
|
88
|
-
const toggle = useCallback(
|
|
89
|
-
(e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
|
|
90
|
-
[setLightTheme, setDarkTheme],
|
|
91
|
-
);
|
|
87
|
+
const {colorMode, setColorMode} = useColorMode();
|
|
92
88
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
value: colorMode,
|
|
90
|
+
onChange: setColorMode,
|
|
95
91
|
disabled: disableSwitch,
|
|
96
92
|
};
|
|
97
93
|
}
|
|
@@ -159,8 +155,8 @@ function NavbarMobileSidebar({sidebarShown, toggleSidebar}) {
|
|
|
159
155
|
{!colorModeToggle.disabled && (
|
|
160
156
|
<ColorModeToggle
|
|
161
157
|
className={styles.navbarSidebarToggle}
|
|
162
|
-
|
|
163
|
-
onChange={colorModeToggle.
|
|
158
|
+
value={colorModeToggle.value}
|
|
159
|
+
onChange={colorModeToggle.onChange}
|
|
164
160
|
/>
|
|
165
161
|
)}
|
|
166
162
|
<button
|
|
@@ -262,8 +258,8 @@ export default function Navbar() {
|
|
|
262
258
|
{!colorModeToggle.disabled && (
|
|
263
259
|
<ColorModeToggle
|
|
264
260
|
className={styles.toggle}
|
|
265
|
-
|
|
266
|
-
onChange={colorModeToggle.
|
|
261
|
+
value={colorModeToggle.value}
|
|
262
|
+
onChange={colorModeToggle.onChange}
|
|
267
263
|
/>
|
|
268
264
|
)}
|
|
269
265
|
{!hasSearchNavbarItem && <SearchBar />}
|
|
@@ -11,9 +11,9 @@ import {useColorMode} from '@docusaurus/theme-common';
|
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
export default function ThemedImage(props) {
|
|
13
13
|
const isBrowser = useIsBrowser();
|
|
14
|
-
const {
|
|
14
|
+
const {colorMode} = useColorMode();
|
|
15
15
|
const {sources, className, alt, ...propsRest} = props;
|
|
16
|
-
const clientThemes =
|
|
16
|
+
const clientThemes = colorMode === 'dark' ? ['dark'] : ['light'];
|
|
17
17
|
const renderedSourceNames = isBrowser
|
|
18
18
|
? clientThemes // We need to render both images on the server to avoid flash
|
|
19
19
|
: // See https://github.com/facebook/docusaurus/pull/3730
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4735",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4735",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4735",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4735",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4735",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4735",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4735",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4735",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4735",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4735",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"rtlcss": "^3.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
46
|
-
"@docusaurus/types": "0.0.0-
|
|
45
|
+
"@docusaurus/module-type-aliases": "0.0.0-4735",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4735",
|
|
47
47
|
"@types/mdx-js__react": "^1.5.5",
|
|
48
48
|
"@types/prismjs": "^1.26.0",
|
|
49
49
|
"@types/rtlcss": "^3.1.2",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=14"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "0f869a8574293be34dcba878680b8adb519887dd"
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
9
9
|
import type {Props} from '@theme/ColorModeToggle';
|
|
10
10
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
11
11
|
import {translate} from '@docusaurus/Translate';
|
|
@@ -15,78 +15,51 @@ import IconDarkMode from '@theme/IconDarkMode';
|
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import styles from './styles.module.css';
|
|
17
17
|
|
|
18
|
-
function ColorModeToggle({
|
|
19
|
-
className,
|
|
20
|
-
checked: defaultChecked,
|
|
21
|
-
onChange,
|
|
22
|
-
}: Props): JSX.Element {
|
|
18
|
+
function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
|
|
23
19
|
const isBrowser = useIsBrowser();
|
|
24
|
-
const [checked, setChecked] = useState(defaultChecked);
|
|
25
|
-
const [focused, setFocused] = useState(false);
|
|
26
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const title = translate(
|
|
22
|
+
{
|
|
23
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
24
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
25
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
mode:
|
|
29
|
+
value === 'dark'
|
|
30
|
+
? translate({
|
|
31
|
+
message: 'dark mode',
|
|
32
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
33
|
+
description: 'The name for the dark color mode',
|
|
34
|
+
})
|
|
35
|
+
: translate({
|
|
36
|
+
message: 'light mode',
|
|
37
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
38
|
+
description: 'The name for the light color mode',
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
);
|
|
31
42
|
|
|
32
43
|
return (
|
|
33
|
-
<div
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
tabIndex={-1}
|
|
46
|
-
onClick={() => inputRef.current?.click()}>
|
|
44
|
+
<div className={clsx(styles.toggle, className)}>
|
|
45
|
+
<button
|
|
46
|
+
className={clsx(
|
|
47
|
+
'clean-btn',
|
|
48
|
+
styles.toggleButton,
|
|
49
|
+
!isBrowser && styles.toggleButtonDisabled,
|
|
50
|
+
)}
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
|
|
53
|
+
disabled={!isBrowser}
|
|
54
|
+
title={title}
|
|
55
|
+
aria-label={title}>
|
|
47
56
|
<IconLightMode
|
|
48
57
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
49
58
|
/>
|
|
50
59
|
<IconDarkMode
|
|
51
60
|
className={clsx(styles.toggleIcon, styles.darkToggleIcon)}
|
|
52
61
|
/>
|
|
53
|
-
</
|
|
54
|
-
|
|
55
|
-
<input
|
|
56
|
-
ref={inputRef}
|
|
57
|
-
checked={checked}
|
|
58
|
-
type="checkbox"
|
|
59
|
-
className={styles.toggleScreenReader}
|
|
60
|
-
aria-label={translate(
|
|
61
|
-
{
|
|
62
|
-
message: 'Switch between dark and light mode (currently {mode})',
|
|
63
|
-
id: 'theme.colorToggle.ariaLabel',
|
|
64
|
-
description: 'The ARIA label for the navbar color mode toggle',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
mode: checked
|
|
68
|
-
? translate({
|
|
69
|
-
message: 'dark mode',
|
|
70
|
-
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
71
|
-
description: 'The name for the dark color mode',
|
|
72
|
-
})
|
|
73
|
-
: translate({
|
|
74
|
-
message: 'light mode',
|
|
75
|
-
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
76
|
-
description: 'The name for the light color mode',
|
|
77
|
-
}),
|
|
78
|
-
},
|
|
79
|
-
)}
|
|
80
|
-
onChange={onChange}
|
|
81
|
-
onClick={() => setChecked(!checked)}
|
|
82
|
-
onFocus={() => setFocused(true)}
|
|
83
|
-
onBlur={() => setFocused(false)}
|
|
84
|
-
onKeyDown={(e) => {
|
|
85
|
-
if (e.key === 'Enter') {
|
|
86
|
-
inputRef.current?.click();
|
|
87
|
-
}
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
62
|
+
</button>
|
|
90
63
|
</div>
|
|
91
64
|
);
|
|
92
65
|
}
|
|
@@ -6,28 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
.toggle {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
height: 32px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.toggleScreenReader {
|
|
15
|
-
border: 0;
|
|
16
|
-
clip: rect(0 0 0 0);
|
|
17
|
-
height: 1px;
|
|
18
|
-
margin: -1px;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
position: absolute;
|
|
21
|
-
width: 1px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.toggleDisabled {
|
|
25
|
-
cursor: not-allowed;
|
|
9
|
+
width: 2rem;
|
|
10
|
+
height: 2rem;
|
|
26
11
|
}
|
|
27
12
|
|
|
28
13
|
.toggleButton {
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
user-select: none;
|
|
31
14
|
-webkit-tap-highlight-color: transparent;
|
|
32
15
|
align-items: center;
|
|
33
16
|
display: flex;
|
|
@@ -35,17 +18,18 @@
|
|
|
35
18
|
width: 100%;
|
|
36
19
|
height: 100%;
|
|
37
20
|
border-radius: 50%;
|
|
21
|
+
transition: background var(--ifm-transition-fast);
|
|
38
22
|
}
|
|
39
23
|
|
|
40
24
|
.toggleButton:hover {
|
|
41
|
-
background-color
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[data-theme='dark'] .toggleButton:hover {
|
|
45
|
-
background-color: #ffffff20;
|
|
25
|
+
background: var(--ifm-color-emphasis-200);
|
|
46
26
|
}
|
|
47
27
|
|
|
48
28
|
[data-theme='light'] .darkToggleIcon,
|
|
49
29
|
[data-theme='dark'] .lightToggleIcon {
|
|
50
30
|
display: none;
|
|
51
31
|
}
|
|
32
|
+
|
|
33
|
+
.toggleButtonDisabled {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
@@ -88,12 +88,12 @@ function useColorModeToggle() {
|
|
|
88
88
|
const {
|
|
89
89
|
colorMode: {disableSwitch},
|
|
90
90
|
} = useThemeConfig();
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
const {colorMode, setColorMode} = useColorMode();
|
|
92
|
+
return {
|
|
93
|
+
value: colorMode,
|
|
94
|
+
onChange: setColorMode,
|
|
95
|
+
disabled: disableSwitch,
|
|
96
|
+
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function useSecondaryMenu({
|
|
@@ -173,8 +173,8 @@ function NavbarMobileSidebar({
|
|
|
173
173
|
{!colorModeToggle.disabled && (
|
|
174
174
|
<ColorModeToggle
|
|
175
175
|
className={styles.navbarSidebarToggle}
|
|
176
|
-
|
|
177
|
-
onChange={colorModeToggle.
|
|
176
|
+
value={colorModeToggle.value}
|
|
177
|
+
onChange={colorModeToggle.onChange}
|
|
178
178
|
/>
|
|
179
179
|
)}
|
|
180
180
|
<button
|
|
@@ -279,8 +279,8 @@ export default function Navbar(): JSX.Element {
|
|
|
279
279
|
{!colorModeToggle.disabled && (
|
|
280
280
|
<ColorModeToggle
|
|
281
281
|
className={styles.toggle}
|
|
282
|
-
|
|
283
|
-
onChange={colorModeToggle.
|
|
282
|
+
value={colorModeToggle.value}
|
|
283
|
+
onChange={colorModeToggle.onChange}
|
|
284
284
|
/>
|
|
285
285
|
)}
|
|
286
286
|
{!hasSearchNavbarItem && <SearchBar />}
|
|
@@ -16,12 +16,13 @@ import styles from './styles.module.css';
|
|
|
16
16
|
|
|
17
17
|
export default function ThemedImage(props: Props): JSX.Element {
|
|
18
18
|
const isBrowser = useIsBrowser();
|
|
19
|
-
const {
|
|
19
|
+
const {colorMode} = useColorMode();
|
|
20
20
|
const {sources, className, alt, ...propsRest} = props;
|
|
21
21
|
|
|
22
22
|
type SourceName = keyof Props['sources'];
|
|
23
23
|
|
|
24
|
-
const clientThemes: SourceName[] =
|
|
24
|
+
const clientThemes: SourceName[] =
|
|
25
|
+
colorMode === 'dark' ? ['dark'] : ['light'];
|
|
25
26
|
|
|
26
27
|
const renderedSourceNames: SourceName[] = isBrowser
|
|
27
28
|
? clientThemes
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -746,12 +746,16 @@ declare module '@theme/TOCCollapsible' {
|
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
declare module '@theme/ColorModeToggle' {
|
|
749
|
-
import type {
|
|
749
|
+
import type {ColorMode} from '@docusaurus/theme-common';
|
|
750
750
|
|
|
751
751
|
export interface Props {
|
|
752
752
|
readonly className?: string;
|
|
753
|
-
readonly
|
|
754
|
-
|
|
753
|
+
readonly value: ColorMode;
|
|
754
|
+
/**
|
|
755
|
+
* The parameter represents the "to-be" value. For example, if currently in
|
|
756
|
+
* dark mode, clicking the button should call `onChange("light")`
|
|
757
|
+
*/
|
|
758
|
+
readonly onChange: (colorMode: ColorMode) => void;
|
|
755
759
|
}
|
|
756
760
|
|
|
757
761
|
export default function Toggle(props: Props): JSX.Element;
|