@docusaurus/theme-classic 0.0.0-5492 → 0.0.0-5494

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.
@@ -6,6 +6,6 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import type { Props } from '@theme/ColorModeToggle';
9
- declare function ColorModeToggle({ className, value, onChange }: Props): JSX.Element;
9
+ declare function ColorModeToggle({ className, buttonClassName, value, onChange, }: Props): JSX.Element;
10
10
  declare const _default: React.MemoExoticComponent<typeof ColorModeToggle>;
11
11
  export default _default;
@@ -11,7 +11,7 @@ import {translate} from '@docusaurus/Translate';
11
11
  import IconLightMode from '@theme/Icon/LightMode';
12
12
  import IconDarkMode from '@theme/Icon/DarkMode';
13
13
  import styles from './styles.module.css';
14
- function ColorModeToggle({className, value, onChange}) {
14
+ function ColorModeToggle({className, buttonClassName, value, onChange}) {
15
15
  const isBrowser = useIsBrowser();
16
16
  const title = translate(
17
17
  {
@@ -41,6 +41,7 @@ function ColorModeToggle({className, value, onChange}) {
41
41
  'clean-btn',
42
42
  styles.toggleButton,
43
43
  !isBrowser && styles.toggleButtonDisabled,
44
+ buttonClassName,
44
45
  )}
45
46
  type="button"
46
47
  onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
@@ -7,7 +7,9 @@
7
7
  import React from 'react';
8
8
  import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
9
9
  import ColorModeToggle from '@theme/ColorModeToggle';
10
+ import styles from './styles.module.css';
10
11
  export default function NavbarColorModeToggle({className}) {
12
+ const navbarStyle = useThemeConfig().navbar.style;
11
13
  const disabled = useThemeConfig().colorMode.disableSwitch;
12
14
  const {colorMode, setColorMode} = useColorMode();
13
15
  if (disabled) {
@@ -16,6 +18,9 @@ export default function NavbarColorModeToggle({className}) {
16
18
  return (
17
19
  <ColorModeToggle
18
20
  className={className}
21
+ buttonClassName={
22
+ navbarStyle === 'dark' ? styles.darkNavbarColorModeToggle : undefined
23
+ }
19
24
  value={colorMode}
20
25
  onChange={setColorMode}
21
26
  />
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .darkNavbarColorModeToggle:hover {
9
+ background: var(--ifm-color-gray-800);
10
+ }
@@ -47,9 +47,11 @@ function DropdownNavbarItemDesktop({
47
47
  };
48
48
  document.addEventListener('mousedown', handleClickOutside);
49
49
  document.addEventListener('touchstart', handleClickOutside);
50
+ document.addEventListener('focusin', handleClickOutside);
50
51
  return () => {
51
52
  document.removeEventListener('mousedown', handleClickOutside);
52
53
  document.removeEventListener('touchstart', handleClickOutside);
54
+ document.removeEventListener('focusin', handleClickOutside);
53
55
  };
54
56
  }, [dropdownRef]);
55
57
  return (
@@ -79,22 +81,6 @@ function DropdownNavbarItemDesktop({
79
81
  {items.map((childItemProps, i) => (
80
82
  <NavbarItem
81
83
  isDropdownItem
82
- onKeyDown={(e) => {
83
- if (i === items.length - 1 && e.key === 'Tab') {
84
- e.preventDefault();
85
- setShowDropdown(false);
86
- const nextNavbarItem = dropdownRef.current.nextElementSibling;
87
- if (nextNavbarItem) {
88
- const targetItem =
89
- nextNavbarItem instanceof HTMLAnchorElement
90
- ? nextNavbarItem
91
- : // Next item is another dropdown; focus on the inner
92
- // anchor element instead so there's outline
93
- nextNavbarItem.querySelector('a');
94
- targetItem.focus();
95
- }
96
- }
97
- }}
98
84
  activeClassName="dropdown__link--active"
99
85
  {...childItemProps}
100
86
  key={i}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5492",
3
+ "version": "0.0.0-5494",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,18 +20,18 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "0.0.0-5492",
24
- "@docusaurus/mdx-loader": "0.0.0-5492",
25
- "@docusaurus/module-type-aliases": "0.0.0-5492",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5492",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5492",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5492",
29
- "@docusaurus/theme-common": "0.0.0-5492",
30
- "@docusaurus/theme-translations": "0.0.0-5492",
31
- "@docusaurus/types": "0.0.0-5492",
32
- "@docusaurus/utils": "0.0.0-5492",
33
- "@docusaurus/utils-common": "0.0.0-5492",
34
- "@docusaurus/utils-validation": "0.0.0-5492",
23
+ "@docusaurus/core": "0.0.0-5494",
24
+ "@docusaurus/mdx-loader": "0.0.0-5494",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5494",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5494",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5494",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5494",
29
+ "@docusaurus/theme-common": "0.0.0-5494",
30
+ "@docusaurus/theme-translations": "0.0.0-5494",
31
+ "@docusaurus/types": "0.0.0-5494",
32
+ "@docusaurus/utils": "0.0.0-5494",
33
+ "@docusaurus/utils-common": "0.0.0-5494",
34
+ "@docusaurus/utils-validation": "0.0.0-5494",
35
35
  "@mdx-js/react": "^1.6.22",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=16.14"
64
64
  },
65
- "gitHead": "65900ea8e44b160f0c4663f7bc02c5d3d3c366b6"
65
+ "gitHead": "9b9f5f1d54df064dc515aee91dfc1af0e843df60"
66
66
  }
@@ -15,7 +15,12 @@ import type {Props} from '@theme/ColorModeToggle';
15
15
 
16
16
  import styles from './styles.module.css';
17
17
 
18
- function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
18
+ function ColorModeToggle({
19
+ className,
20
+ buttonClassName,
21
+ value,
22
+ onChange,
23
+ }: Props): JSX.Element {
19
24
  const isBrowser = useIsBrowser();
20
25
 
21
26
  const title = translate(
@@ -47,6 +52,7 @@ function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
47
52
  'clean-btn',
48
53
  styles.toggleButton,
49
54
  !isBrowser && styles.toggleButtonDisabled,
55
+ buttonClassName,
50
56
  )}
51
57
  type="button"
52
58
  onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
@@ -9,10 +9,12 @@ import React from 'react';
9
9
  import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
10
10
  import ColorModeToggle from '@theme/ColorModeToggle';
11
11
  import type {Props} from '@theme/Navbar/ColorModeToggle';
12
+ import styles from './styles.module.css';
12
13
 
13
14
  export default function NavbarColorModeToggle({
14
15
  className,
15
16
  }: Props): JSX.Element | null {
17
+ const navbarStyle = useThemeConfig().navbar.style;
16
18
  const disabled = useThemeConfig().colorMode.disableSwitch;
17
19
  const {colorMode, setColorMode} = useColorMode();
18
20
 
@@ -23,6 +25,9 @@ export default function NavbarColorModeToggle({
23
25
  return (
24
26
  <ColorModeToggle
25
27
  className={className}
28
+ buttonClassName={
29
+ navbarStyle === 'dark' ? styles.darkNavbarColorModeToggle : undefined
30
+ }
26
31
  value={colorMode}
27
32
  onChange={setColorMode}
28
33
  />
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ .darkNavbarColorModeToggle:hover {
9
+ background: var(--ifm-color-gray-800);
10
+ }
@@ -54,7 +54,9 @@ function DropdownNavbarItemDesktop({
54
54
  const [showDropdown, setShowDropdown] = useState(false);
55
55
 
56
56
  useEffect(() => {
57
- const handleClickOutside = (event: MouseEvent | TouchEvent) => {
57
+ const handleClickOutside = (
58
+ event: MouseEvent | TouchEvent | FocusEvent,
59
+ ) => {
58
60
  if (
59
61
  !dropdownRef.current ||
60
62
  dropdownRef.current.contains(event.target as Node)
@@ -66,10 +68,12 @@ function DropdownNavbarItemDesktop({
66
68
 
67
69
  document.addEventListener('mousedown', handleClickOutside);
68
70
  document.addEventListener('touchstart', handleClickOutside);
71
+ document.addEventListener('focusin', handleClickOutside);
69
72
 
70
73
  return () => {
71
74
  document.removeEventListener('mousedown', handleClickOutside);
72
75
  document.removeEventListener('touchstart', handleClickOutside);
76
+ document.removeEventListener('focusin', handleClickOutside);
73
77
  };
74
78
  }, [dropdownRef]);
75
79
 
@@ -100,22 +104,6 @@ function DropdownNavbarItemDesktop({
100
104
  {items.map((childItemProps, i) => (
101
105
  <NavbarItem
102
106
  isDropdownItem
103
- onKeyDown={(e) => {
104
- if (i === items.length - 1 && e.key === 'Tab') {
105
- e.preventDefault();
106
- setShowDropdown(false);
107
- const nextNavbarItem = dropdownRef.current!.nextElementSibling;
108
- if (nextNavbarItem) {
109
- const targetItem =
110
- nextNavbarItem instanceof HTMLAnchorElement
111
- ? nextNavbarItem
112
- : // Next item is another dropdown; focus on the inner
113
- // anchor element instead so there's outline
114
- nextNavbarItem.querySelector('a')!;
115
- targetItem.focus();
116
- }
117
- }
118
- }}
119
107
  activeClassName="dropdown__link--active"
120
108
  {...childItemProps}
121
109
  key={i}
@@ -1352,6 +1352,7 @@ declare module '@theme/ColorModeToggle' {
1352
1352
 
1353
1353
  export interface Props {
1354
1354
  readonly className?: string;
1355
+ readonly buttonClassName?: string;
1355
1356
  readonly value: ColorMode;
1356
1357
  /**
1357
1358
  * The parameter represents the "to-be" value. For example, if currently in