@docusaurus/theme-classic 0.0.0-5050 → 0.0.0-5053

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.
Files changed (32) hide show
  1. package/lib/getSwizzleConfig.js +0 -7
  2. package/lib/theme/Navbar/Content/index.js +2 -2
  3. package/lib/theme/Navbar/Search/index.d.ts +1 -1
  4. package/lib/theme/Navbar/Search/index.js +3 -2
  5. package/lib/theme/NavbarItem/DefaultNavbarItem.js +3 -2
  6. package/lib/theme/NavbarItem/DocNavbarItem.js +4 -11
  7. package/lib/theme/NavbarItem/DocSidebarNavbarItem.js +1 -7
  8. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -1
  9. package/lib/theme/NavbarItem/DropdownNavbarItem.js +10 -4
  10. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +10 -2
  11. package/lib/theme/NavbarItem/NavbarNavLink.d.ts +1 -1
  12. package/lib/theme/NavbarItem/NavbarNavLink.js +1 -6
  13. package/lib/theme/NavbarItem/SearchNavbarItem.d.ts +1 -1
  14. package/lib/theme/NavbarItem/SearchNavbarItem.js +2 -2
  15. package/lib/validateThemeConfig.js +1 -0
  16. package/package.json +13 -13
  17. package/src/getSwizzleConfig.ts +0 -7
  18. package/src/theme/Navbar/Content/index.tsx +2 -2
  19. package/src/theme/Navbar/Search/index.tsx +6 -2
  20. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +3 -2
  21. package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -12
  22. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +1 -8
  23. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +0 -1
  24. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +6 -6
  25. package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +10 -2
  26. package/src/theme/NavbarItem/NavbarNavLink.tsx +1 -7
  27. package/src/theme/NavbarItem/SearchNavbarItem.tsx +5 -2
  28. package/src/theme-classic.d.ts +4 -12
  29. package/src/validateThemeConfig.ts +1 -0
  30. package/lib/theme/NavbarItem/utils.d.ts +0 -7
  31. package/lib/theme/NavbarItem/utils.js +0 -9
  32. package/src/theme/NavbarItem/utils.ts +0 -13
@@ -199,13 +199,6 @@ function getSwizzleConfig() {
199
199
  },
200
200
  description: 'The Navbar item components mapping. Can be ejected to add custom navbar item types. See https://github.com/facebook/docusaurus/issues/7227.',
201
201
  },
202
- // TODO should probably not even appear here
203
- 'NavbarItem/utils': {
204
- actions: {
205
- eject: 'forbidden',
206
- wrap: 'forbidden',
207
- },
208
- },
209
202
  NotFound: {
210
203
  actions: {
211
204
  eject: 'safe',
@@ -42,7 +42,7 @@ export default function NavbarContent() {
42
42
  const mobileSidebar = useNavbarMobileSidebar();
43
43
  const items = useNavbarItems();
44
44
  const [leftItems, rightItems] = splitNavbarItems(items);
45
- const autoAddSearchBar = !items.some((item) => item.type === 'search');
45
+ const searchBarItem = items.find((item) => item.type === 'search');
46
46
  return (
47
47
  <NavbarContentLayout
48
48
  left={
@@ -59,7 +59,7 @@ export default function NavbarContent() {
59
59
  <>
60
60
  <NavbarItems items={rightItems} />
61
61
  <NavbarColorModeToggle className={styles.colorModeToggle} />
62
- {autoAddSearchBar && (
62
+ {!searchBarItem && (
63
63
  <NavbarSearch>
64
64
  <SearchBar />
65
65
  </NavbarSearch>
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/Navbar/Search';
9
- export default function NavbarSearch({ children }: Props): JSX.Element;
9
+ export default function NavbarSearch({ children, className, }: Props): JSX.Element;
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
+ import clsx from 'clsx';
8
9
  import styles from './styles.module.css';
9
- export default function NavbarSearch({children}) {
10
- return <div className={styles.searchBox}>{children}</div>;
10
+ export default function NavbarSearch({children, className}) {
11
+ return <div className={clsx(className, styles.searchBox)}>{children}</div>;
11
12
  }
@@ -7,7 +7,6 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
10
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
11
10
  function DefaultNavbarItemDesktop({
12
11
  className,
13
12
  isDropdownItem = false,
@@ -19,6 +18,7 @@ function DefaultNavbarItemDesktop({
19
18
  isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
20
19
  className,
21
20
  )}
21
+ isDropdownLink={isDropdownItem}
22
22
  {...props}
23
23
  />
24
24
  );
@@ -44,7 +44,8 @@ export default function DefaultNavbarItem({
44
44
  <Comp
45
45
  {...props}
46
46
  activeClassName={
47
- props.activeClassName ?? getInfimaActiveClassName(mobile)
47
+ props.activeClassName ??
48
+ (mobile ? 'menu__link--active' : 'navbar__link--active')
48
49
  }
49
50
  />
50
51
  );
@@ -5,11 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
8
  import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
10
9
  import {useLayoutDoc} from '@docusaurus/theme-common';
11
10
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
12
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
13
11
  export default function DocNavbarItem({
14
12
  docId,
15
13
  label: staticLabel,
@@ -22,19 +20,14 @@ export default function DocNavbarItem({
22
20
  if (doc === null) {
23
21
  return null;
24
22
  }
25
- const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
26
23
  return (
27
24
  <DefaultNavbarItem
28
25
  exact
29
26
  {...props}
30
- className={clsx(props.className, {
31
- [activeDocInfimaClassName]:
32
- // Do not make the item active if the active doc doesn't have sidebar.
33
- // If `activeDoc === doc` react-router will make it active anyways,
34
- // regardless of the existence of a sidebar
35
- activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
36
- })}
37
- activeClassName={activeDocInfimaClassName}
27
+ isActive={() =>
28
+ activeDoc?.path === doc.path ||
29
+ (!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
30
+ }
38
31
  label={staticLabel ?? doc.id}
39
32
  to={doc.path}
40
33
  />
@@ -5,11 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import clsx from 'clsx';
9
8
  import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
10
9
  import {useLayoutDocsSidebar} from '@docusaurus/theme-common';
11
10
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
12
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
13
11
  export default function DocSidebarNavbarItem({
14
12
  sidebarId,
15
13
  label,
@@ -23,15 +21,11 @@ export default function DocSidebarNavbarItem({
23
21
  `DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
24
22
  );
25
23
  }
26
- const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
27
24
  return (
28
25
  <DefaultNavbarItem
29
26
  exact
30
27
  {...props}
31
- className={clsx(props.className, {
32
- [activeDocInfimaClassName]: activeDoc?.sidebar === sidebarId,
33
- })}
34
- activeClassName={activeDocInfimaClassName}
28
+ isActive={() => activeDoc?.sidebar === sidebarId}
35
29
  label={label ?? sidebarLink.label}
36
30
  to={sidebarLink.path}
37
31
  />
@@ -36,7 +36,6 @@ export default function DocsVersionDropdownNavbarItem({
36
36
  activeDocContext.alternateDocVersions[version.name] ??
37
37
  getVersionMainDoc(version);
38
38
  return {
39
- isNavLink: true,
40
39
  label: version.label,
41
40
  to: versionDoc.path,
42
41
  isActive: () => version === activeDocContext.activeVersion,
@@ -15,7 +15,6 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
17
17
  import NavbarItem from '@theme/NavbarItem';
18
- const dropdownLinkActiveClass = 'dropdown__link--active';
19
18
  function isItemActive(item, localPathname) {
20
19
  if (isSamePath(item.to, localPathname)) {
21
20
  return true;
@@ -31,7 +30,13 @@ function isItemActive(item, localPathname) {
31
30
  function containsActiveItems(items, localPathname) {
32
31
  return items.some((item) => isItemActive(item, localPathname));
33
32
  }
34
- function DropdownNavbarItemDesktop({items, position, className, ...props}) {
33
+ function DropdownNavbarItemDesktop({
34
+ items,
35
+ position,
36
+ className,
37
+ onClick,
38
+ ...props
39
+ }) {
35
40
  const dropdownRef = useRef(null);
36
41
  const [showDropdown, setShowDropdown] = useState(false);
37
42
  useEffect(() => {
@@ -91,7 +96,7 @@ function DropdownNavbarItemDesktop({items, position, className, ...props}) {
91
96
  }
92
97
  }
93
98
  }}
94
- activeClassName={dropdownLinkActiveClass}
99
+ activeClassName="dropdown__link--active"
95
100
  {...childItemProps}
96
101
  key={i}
97
102
  />
@@ -104,6 +109,7 @@ function DropdownNavbarItemMobile({
104
109
  items,
105
110
  className,
106
111
  position, // Need to destructure position from props so that it doesn't get passed on.
112
+ onClick,
107
113
  ...props
108
114
  }) {
109
115
  const localPathname = useLocalPathname();
@@ -140,7 +146,7 @@ function DropdownNavbarItemMobile({
140
146
  <NavbarItem
141
147
  mobile
142
148
  isDropdownItem
143
- onClick={props.onClick}
149
+ onClick={onClick}
144
150
  activeClassName="menu__link--active"
145
151
  {...childItemProps}
146
152
  key={i}
@@ -27,12 +27,20 @@ export default function LocaleDropdownNavbarItem({
27
27
  fullyQualified: false,
28
28
  })}`;
29
29
  return {
30
- isNavLink: true,
31
30
  label: localeConfigs[locale].label,
32
31
  to,
33
32
  target: '_self',
34
33
  autoAddBaseUrl: false,
35
- className: locale === currentLocale ? 'dropdown__link--active' : '',
34
+ className:
35
+ // eslint-disable-next-line no-nested-ternary
36
+ locale === currentLocale
37
+ ? // Similar idea as DefaultNavbarItem: select the right Infima active
38
+ // class name. This cannot be substituted with isActive, because the
39
+ // target URLs contain `pathname://` and therefore are not NavLinks!
40
+ mobile
41
+ ? 'menu__link--active'
42
+ : 'dropdown__link--active'
43
+ : '',
36
44
  };
37
45
  });
38
46
  const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter];
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/NavbarItem/NavbarNavLink';
9
- export default function NavbarNavLink({ activeBasePath, activeBaseRegex, to, href, label, html, activeClassName, prependBaseUrlToHref, ...props }: Props): JSX.Element;
9
+ export default function NavbarNavLink({ activeBasePath, activeBaseRegex, to, href, label, html, isDropdownLink, prependBaseUrlToHref, ...props }: Props): JSX.Element;
@@ -10,7 +10,6 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
10
10
  import isInternalUrl from '@docusaurus/isInternalUrl';
11
11
  import {isRegexpStringMatch} from '@docusaurus/theme-common';
12
12
  import IconExternalLink from '@theme/IconExternalLink';
13
- const dropdownLinkActiveClass = 'dropdown__link--active';
14
13
  export default function NavbarNavLink({
15
14
  activeBasePath,
16
15
  activeBaseRegex,
@@ -18,7 +17,7 @@ export default function NavbarNavLink({
18
17
  href,
19
18
  label,
20
19
  html,
21
- activeClassName = '',
20
+ isDropdownLink,
22
21
  prependBaseUrlToHref,
23
22
  ...props
24
23
  }) {
@@ -28,7 +27,6 @@ export default function NavbarNavLink({
28
27
  const activeBaseUrl = useBaseUrl(activeBasePath);
29
28
  const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
30
29
  const isExternalLink = label && href && !isInternalUrl(href);
31
- const isDropdownLink = activeClassName === dropdownLinkActiveClass;
32
30
  // Link content is set through html XOR label
33
31
  const linkContentProps = html
34
32
  ? {dangerouslySetInnerHTML: {__html: html}}
@@ -57,9 +55,6 @@ export default function NavbarNavLink({
57
55
  <Link
58
56
  to={toUrl}
59
57
  isNavLink
60
- activeClassName={
61
- !props.className?.includes(activeClassName) ? activeClassName : ''
62
- }
63
58
  {...((activeBasePath || activeBaseRegex) && {
64
59
  isActive: (_match, location) =>
65
60
  activeBaseRegex
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/NavbarItem/SearchNavbarItem';
9
- export default function SearchNavbarItem({ mobile }: Props): JSX.Element | null;
9
+ export default function SearchNavbarItem({ mobile, className, }: Props): JSX.Element | null;
@@ -7,12 +7,12 @@
7
7
  import React from 'react';
8
8
  import SearchBar from '@theme/SearchBar';
9
9
  import NavbarSearch from '@theme/Navbar/Search';
10
- export default function SearchNavbarItem({mobile}) {
10
+ export default function SearchNavbarItem({mobile, className}) {
11
11
  if (mobile) {
12
12
  return null;
13
13
  }
14
14
  return (
15
- <NavbarSearch>
15
+ <NavbarSearch className={className}>
16
16
  <SearchBar />
17
17
  </NavbarSearch>
18
18
  );
@@ -177,6 +177,7 @@ const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
177
177
  });
178
178
  const SearchItemSchema = utils_validation_1.Joi.object({
179
179
  type: utils_validation_1.Joi.string().equal('search').required(),
180
+ className: utils_validation_1.Joi.string(),
180
181
  });
181
182
  const NavbarItemSchema = utils_validation_1.Joi.object({
182
183
  position: NavbarItemPosition,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5050",
3
+ "version": "0.0.0-5053",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,15 +20,15 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "0.0.0-5050",
24
- "@docusaurus/plugin-content-blog": "0.0.0-5050",
25
- "@docusaurus/plugin-content-docs": "0.0.0-5050",
26
- "@docusaurus/plugin-content-pages": "0.0.0-5050",
27
- "@docusaurus/theme-common": "0.0.0-5050",
28
- "@docusaurus/theme-translations": "0.0.0-5050",
29
- "@docusaurus/utils": "0.0.0-5050",
30
- "@docusaurus/utils-common": "0.0.0-5050",
31
- "@docusaurus/utils-validation": "0.0.0-5050",
23
+ "@docusaurus/core": "0.0.0-5053",
24
+ "@docusaurus/plugin-content-blog": "0.0.0-5053",
25
+ "@docusaurus/plugin-content-docs": "0.0.0-5053",
26
+ "@docusaurus/plugin-content-pages": "0.0.0-5053",
27
+ "@docusaurus/theme-common": "0.0.0-5053",
28
+ "@docusaurus/theme-translations": "0.0.0-5053",
29
+ "@docusaurus/utils": "0.0.0-5053",
30
+ "@docusaurus/utils-common": "0.0.0-5053",
31
+ "@docusaurus/utils-validation": "0.0.0-5053",
32
32
  "@mdx-js/react": "^1.6.22",
33
33
  "clsx": "^1.1.1",
34
34
  "copy-text-to-clipboard": "^3.0.1",
@@ -43,8 +43,8 @@
43
43
  "tslib": "^2.4.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@docusaurus/module-type-aliases": "0.0.0-5050",
47
- "@docusaurus/types": "0.0.0-5050",
46
+ "@docusaurus/module-type-aliases": "0.0.0-5053",
47
+ "@docusaurus/types": "0.0.0-5053",
48
48
  "@types/mdx-js__react": "^1.5.5",
49
49
  "@types/nprogress": "^0.2.0",
50
50
  "@types/prismjs": "^1.26.0",
@@ -60,5 +60,5 @@
60
60
  "engines": {
61
61
  "node": ">=14"
62
62
  },
63
- "gitHead": "1e14a127a30082891b24582362a69bca2f8d4b0d"
63
+ "gitHead": "5aaad8c6db7c7c72a1e9514cf31749ae7e2de0a8"
64
64
  }
@@ -214,13 +214,6 @@ export default function getSwizzleConfig(): SwizzleConfig {
214
214
  description:
215
215
  'The Navbar item components mapping. Can be ejected to add custom navbar item types. See https://github.com/facebook/docusaurus/issues/7227.',
216
216
  },
217
- // TODO should probably not even appear here
218
- 'NavbarItem/utils': {
219
- actions: {
220
- eject: 'forbidden',
221
- wrap: 'forbidden',
222
- },
223
- },
224
217
  NotFound: {
225
218
  actions: {
226
219
  eject: 'safe',
@@ -56,7 +56,7 @@ export default function NavbarContent(): JSX.Element {
56
56
  const items = useNavbarItems();
57
57
  const [leftItems, rightItems] = splitNavbarItems(items);
58
58
 
59
- const autoAddSearchBar = !items.some((item) => item.type === 'search');
59
+ const searchBarItem = items.find((item) => item.type === 'search');
60
60
 
61
61
  return (
62
62
  <NavbarContentLayout
@@ -74,7 +74,7 @@ export default function NavbarContent(): JSX.Element {
74
74
  <>
75
75
  <NavbarItems items={rightItems} />
76
76
  <NavbarColorModeToggle className={styles.colorModeToggle} />
77
- {autoAddSearchBar && (
77
+ {!searchBarItem && (
78
78
  <NavbarSearch>
79
79
  <SearchBar />
80
80
  </NavbarSearch>
@@ -6,10 +6,14 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import clsx from 'clsx';
9
10
  import type {Props} from '@theme/Navbar/Search';
10
11
 
11
12
  import styles from './styles.module.css';
12
13
 
13
- export default function NavbarSearch({children}: Props): JSX.Element {
14
- return <div className={styles.searchBox}>{children}</div>;
14
+ export default function NavbarSearch({
15
+ children,
16
+ className,
17
+ }: Props): JSX.Element {
18
+ return <div className={clsx(className, styles.searchBox)}>{children}</div>;
15
19
  }
@@ -8,7 +8,6 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
11
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
12
11
  import type {
13
12
  DesktopOrMobileNavBarItemProps,
14
13
  Props,
@@ -25,6 +24,7 @@ function DefaultNavbarItemDesktop({
25
24
  isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
26
25
  className,
27
26
  )}
27
+ isDropdownLink={isDropdownItem}
28
28
  {...props}
29
29
  />
30
30
  );
@@ -58,7 +58,8 @@ export default function DefaultNavbarItem({
58
58
  <Comp
59
59
  {...props}
60
60
  activeClassName={
61
- props.activeClassName ?? getInfimaActiveClassName(mobile)
61
+ props.activeClassName ??
62
+ (mobile ? 'menu__link--active' : 'navbar__link--active')
62
63
  }
63
64
  />
64
65
  );
@@ -6,11 +6,9 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
9
  import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
11
10
  import {useLayoutDoc} from '@docusaurus/theme-common';
12
11
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
13
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
14
12
  import type {Props} from '@theme/NavbarItem/DocNavbarItem';
15
13
 
16
14
  export default function DocNavbarItem({
@@ -27,20 +25,14 @@ export default function DocNavbarItem({
27
25
  return null;
28
26
  }
29
27
 
30
- const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
31
-
32
28
  return (
33
29
  <DefaultNavbarItem
34
30
  exact
35
31
  {...props}
36
- className={clsx(props.className, {
37
- [activeDocInfimaClassName]:
38
- // Do not make the item active if the active doc doesn't have sidebar.
39
- // If `activeDoc === doc` react-router will make it active anyways,
40
- // regardless of the existence of a sidebar
41
- activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
42
- })}
43
- activeClassName={activeDocInfimaClassName}
32
+ isActive={() =>
33
+ activeDoc?.path === doc.path ||
34
+ (!!activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar)
35
+ }
44
36
  label={staticLabel ?? doc.id}
45
37
  to={doc.path}
46
38
  />
@@ -6,11 +6,9 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import clsx from 'clsx';
10
9
  import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
11
10
  import {useLayoutDocsSidebar} from '@docusaurus/theme-common';
12
11
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
13
- import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
14
12
  import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
15
13
 
16
14
  export default function DocSidebarNavbarItem({
@@ -26,16 +24,11 @@ export default function DocSidebarNavbarItem({
26
24
  `DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
27
25
  );
28
26
  }
29
- const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
30
-
31
27
  return (
32
28
  <DefaultNavbarItem
33
29
  exact
34
30
  {...props}
35
- className={clsx(props.className, {
36
- [activeDocInfimaClassName]: activeDoc?.sidebar === sidebarId,
37
- })}
38
- activeClassName={activeDocInfimaClassName}
31
+ isActive={() => activeDoc?.sidebar === sidebarId}
39
32
  label={label ?? sidebarLink.label}
40
33
  to={sidebarLink.path}
41
34
  />
@@ -41,7 +41,6 @@ export default function DocsVersionDropdownNavbarItem({
41
41
  activeDocContext.alternateDocVersions[version.name] ??
42
42
  getVersionMainDoc(version);
43
43
  return {
44
- isNavLink: true,
45
44
  label: version.label,
46
45
  to: versionDoc.path,
47
46
  isActive: () => version === activeDocContext.activeVersion,
@@ -21,8 +21,6 @@ import type {
21
21
  Props,
22
22
  } from '@theme/NavbarItem/DropdownNavbarItem';
23
23
 
24
- const dropdownLinkActiveClass = 'dropdown__link--active';
25
-
26
24
  function isItemActive(
27
25
  item: LinkLikeNavbarItemProps,
28
26
  localPathname: string,
@@ -50,6 +48,7 @@ function DropdownNavbarItemDesktop({
50
48
  items,
51
49
  position,
52
50
  className,
51
+ onClick,
53
52
  ...props
54
53
  }: DesktopOrMobileNavBarItemProps) {
55
54
  const dropdownRef = useRef<HTMLDivElement>(null);
@@ -113,12 +112,12 @@ function DropdownNavbarItemDesktop({
113
112
  ? nextNavbarItem
114
113
  : // Next item is another dropdown; focus on the inner
115
114
  // anchor element instead so there's outline
116
- nextNavbarItem.querySelector('a');
117
- (targetItem as HTMLElement).focus();
115
+ nextNavbarItem.querySelector('a')!;
116
+ targetItem.focus();
118
117
  }
119
118
  }
120
119
  }}
121
- activeClassName={dropdownLinkActiveClass}
120
+ activeClassName="dropdown__link--active"
122
121
  {...childItemProps}
123
122
  key={i}
124
123
  />
@@ -132,6 +131,7 @@ function DropdownNavbarItemMobile({
132
131
  items,
133
132
  className,
134
133
  position, // Need to destructure position from props so that it doesn't get passed on.
134
+ onClick,
135
135
  ...props
136
136
  }: DesktopOrMobileNavBarItemProps) {
137
137
  const localPathname = useLocalPathname();
@@ -171,7 +171,7 @@ function DropdownNavbarItemMobile({
171
171
  <NavbarItem
172
172
  mobile
173
173
  isDropdownItem
174
- onClick={props.onClick}
174
+ onClick={onClick}
175
175
  activeClassName="menu__link--active"
176
176
  {...childItemProps}
177
177
  key={i}
@@ -33,12 +33,20 @@ export default function LocaleDropdownNavbarItem({
33
33
  fullyQualified: false,
34
34
  })}`;
35
35
  return {
36
- isNavLink: true,
37
36
  label: localeConfigs[locale]!.label,
38
37
  to,
39
38
  target: '_self',
40
39
  autoAddBaseUrl: false,
41
- className: locale === currentLocale ? 'dropdown__link--active' : '',
40
+ className:
41
+ // eslint-disable-next-line no-nested-ternary
42
+ locale === currentLocale
43
+ ? // Similar idea as DefaultNavbarItem: select the right Infima active
44
+ // class name. This cannot be substituted with isActive, because the
45
+ // target URLs contain `pathname://` and therefore are not NavLinks!
46
+ mobile
47
+ ? 'menu__link--active'
48
+ : 'dropdown__link--active'
49
+ : '',
42
50
  };
43
51
  });
44
52
 
@@ -13,8 +13,6 @@ import {isRegexpStringMatch} from '@docusaurus/theme-common';
13
13
  import IconExternalLink from '@theme/IconExternalLink';
14
14
  import type {Props} from '@theme/NavbarItem/NavbarNavLink';
15
15
 
16
- const dropdownLinkActiveClass = 'dropdown__link--active';
17
-
18
16
  export default function NavbarNavLink({
19
17
  activeBasePath,
20
18
  activeBaseRegex,
@@ -22,7 +20,7 @@ export default function NavbarNavLink({
22
20
  href,
23
21
  label,
24
22
  html,
25
- activeClassName = '',
23
+ isDropdownLink,
26
24
  prependBaseUrlToHref,
27
25
  ...props
28
26
  }: Props): JSX.Element {
@@ -32,7 +30,6 @@ export default function NavbarNavLink({
32
30
  const activeBaseUrl = useBaseUrl(activeBasePath);
33
31
  const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
34
32
  const isExternalLink = label && href && !isInternalUrl(href);
35
- const isDropdownLink = activeClassName === dropdownLinkActiveClass;
36
33
 
37
34
  // Link content is set through html XOR label
38
35
  const linkContentProps = html
@@ -64,9 +61,6 @@ export default function NavbarNavLink({
64
61
  <Link
65
62
  to={toUrl}
66
63
  isNavLink
67
- activeClassName={
68
- !props.className?.includes(activeClassName) ? activeClassName : ''
69
- }
70
64
  {...((activeBasePath || activeBaseRegex) && {
71
65
  isActive: (_match, location) =>
72
66
  activeBaseRegex
@@ -10,13 +10,16 @@ import SearchBar from '@theme/SearchBar';
10
10
  import NavbarSearch from '@theme/Navbar/Search';
11
11
  import type {Props} from '@theme/NavbarItem/SearchNavbarItem';
12
12
 
13
- export default function SearchNavbarItem({mobile}: Props): JSX.Element | null {
13
+ export default function SearchNavbarItem({
14
+ mobile,
15
+ className,
16
+ }: Props): JSX.Element | null {
14
17
  if (mobile) {
15
18
  return null;
16
19
  }
17
20
 
18
21
  return (
19
- <NavbarSearch>
22
+ <NavbarSearch className={className}>
20
23
  <SearchBar />
21
24
  </NavbarSearch>
22
25
  );
@@ -777,6 +777,7 @@ declare module '@theme/Navbar/Search' {
777
777
 
778
778
  export interface Props {
779
779
  readonly children: ReactNode;
780
+ readonly className?: string;
780
781
  }
781
782
 
782
783
  export default function NavbarSearch(props: Props): JSX.Element;
@@ -808,7 +809,8 @@ declare module '@theme/NavbarItem/NavbarNavLink' {
808
809
  readonly exact?: boolean;
809
810
  readonly label?: ReactNode;
810
811
  readonly html?: string;
811
- readonly prependBaseUrlToHref?: string;
812
+ readonly prependBaseUrlToHref?: boolean;
813
+ readonly isDropdownLink?: boolean;
812
814
  }
813
815
 
814
816
  export default function NavbarNavLink(props: Props): JSX.Element;
@@ -834,6 +836,7 @@ declare module '@theme/NavbarItem/DropdownNavbarItem' {
834
836
  declare module '@theme/NavbarItem/SearchNavbarItem' {
835
837
  export interface Props {
836
838
  readonly mobile?: boolean;
839
+ readonly className?: string;
837
840
  }
838
841
 
839
842
  export default function SearchNavbarItem(props: Props): JSX.Element;
@@ -980,17 +983,6 @@ declare module '@theme/NavbarItem' {
980
983
  export default function NavbarItem(props: Props): JSX.Element;
981
984
  }
982
985
 
983
- declare module '@theme/NavbarItem/utils' {
984
- /**
985
- * On desktop and mobile, we would apply different class names for dropdown
986
- * items.
987
- * @see https://github.com/facebook/docusaurus/pull/5431
988
- */
989
- export function getInfimaActiveClassName(
990
- mobile?: boolean,
991
- ): `${'menu' | 'navbar'}__link--active`;
992
- }
993
-
994
986
  declare module '@theme/PaginatorNavLink' {
995
987
  import type {ReactNode} from 'react';
996
988
  import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
@@ -200,6 +200,7 @@ const LocaleDropdownNavbarItemSchema = NavbarItemBaseSchema.append({
200
200
 
201
201
  const SearchItemSchema = Joi.object({
202
202
  type: Joi.string().equal('search').required(),
203
+ className: Joi.string(),
203
204
  });
204
205
 
205
206
  const NavbarItemSchema = Joi.object({
@@ -1,7 +0,0 @@
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
- export declare const getInfimaActiveClassName: (mobile?: boolean | undefined) => `${'menu' | 'navbar'}__link--active`;
@@ -1,9 +0,0 @@
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
- /* eslint-disable import/no-named-export */
8
- export const getInfimaActiveClassName = (mobile) =>
9
- mobile ? 'menu__link--active' : 'navbar__link--active';
@@ -1,13 +0,0 @@
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
- /* eslint-disable import/no-named-export */
9
-
10
- export const getInfimaActiveClassName = (
11
- mobile?: boolean,
12
- ): `${'menu' | 'navbar'}__link--active` =>
13
- mobile ? 'menu__link--active' : 'navbar__link--active';