@docusaurus/theme-classic 0.0.0-5052 → 0.0.0-5057
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/getSwizzleConfig.js +0 -7
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +3 -2
- package/lib/theme/NavbarItem/DocNavbarItem.js +4 -11
- package/lib/theme/NavbarItem/DocSidebarNavbarItem.js +1 -7
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -1
- package/lib/theme/NavbarItem/DropdownNavbarItem.js +10 -4
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +10 -2
- package/lib/theme/NavbarItem/NavbarNavLink.d.ts +1 -1
- package/lib/theme/NavbarItem/NavbarNavLink.js +1 -6
- package/package.json +14 -14
- package/src/getSwizzleConfig.ts +0 -7
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +3 -2
- package/src/theme/NavbarItem/DocNavbarItem.tsx +4 -12
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +1 -8
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +0 -1
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +6 -6
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +10 -2
- package/src/theme/NavbarItem/NavbarNavLink.tsx +1 -7
- package/src/theme-classic.d.ts +2 -12
- package/lib/theme/NavbarItem/utils.d.ts +0 -7
- package/lib/theme/NavbarItem/utils.js +0 -9
- package/src/theme/NavbarItem/utils.ts +0 -13
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -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',
|
|
@@ -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 ??
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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({
|
|
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=
|
|
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={
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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
|
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-5057",
|
|
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-
|
|
24
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
27
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
23
|
+
"@docusaurus/core": "0.0.0-5057",
|
|
24
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5057",
|
|
25
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5057",
|
|
26
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5057",
|
|
27
|
+
"@docusaurus/theme-common": "0.0.0-5057",
|
|
28
|
+
"@docusaurus/theme-translations": "0.0.0-5057",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-5057",
|
|
30
|
+
"@docusaurus/utils-common": "0.0.0-5057",
|
|
31
|
+
"@docusaurus/utils-validation": "0.0.0-5057",
|
|
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-
|
|
47
|
-
"@docusaurus/types": "0.0.0-
|
|
46
|
+
"@docusaurus/module-type-aliases": "0.0.0-5057",
|
|
47
|
+
"@docusaurus/types": "0.0.0-5057",
|
|
48
48
|
"@types/mdx-js__react": "^1.5.5",
|
|
49
49
|
"@types/nprogress": "^0.2.0",
|
|
50
50
|
"@types/prismjs": "^1.26.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
|
-
"node": ">=14"
|
|
61
|
+
"node": ">=16.14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3f928ce89e585ef863bb6b25450198cd7537c275"
|
|
64
64
|
}
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -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',
|
|
@@ -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 ??
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
115
|
+
nextNavbarItem.querySelector('a')!;
|
|
116
|
+
targetItem.focus();
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
}}
|
|
121
|
-
activeClassName=
|
|
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={
|
|
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:
|
|
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
|
-
|
|
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
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -809,7 +809,8 @@ declare module '@theme/NavbarItem/NavbarNavLink' {
|
|
|
809
809
|
readonly exact?: boolean;
|
|
810
810
|
readonly label?: ReactNode;
|
|
811
811
|
readonly html?: string;
|
|
812
|
-
readonly prependBaseUrlToHref?:
|
|
812
|
+
readonly prependBaseUrlToHref?: boolean;
|
|
813
|
+
readonly isDropdownLink?: boolean;
|
|
813
814
|
}
|
|
814
815
|
|
|
815
816
|
export default function NavbarNavLink(props: Props): JSX.Element;
|
|
@@ -982,17 +983,6 @@ declare module '@theme/NavbarItem' {
|
|
|
982
983
|
export default function NavbarItem(props: Props): JSX.Element;
|
|
983
984
|
}
|
|
984
985
|
|
|
985
|
-
declare module '@theme/NavbarItem/utils' {
|
|
986
|
-
/**
|
|
987
|
-
* On desktop and mobile, we would apply different class names for dropdown
|
|
988
|
-
* items.
|
|
989
|
-
* @see https://github.com/facebook/docusaurus/pull/5431
|
|
990
|
-
*/
|
|
991
|
-
export function getInfimaActiveClassName(
|
|
992
|
-
mobile?: boolean,
|
|
993
|
-
): `${'menu' | 'navbar'}__link--active`;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
986
|
declare module '@theme/PaginatorNavLink' {
|
|
997
987
|
import type {ReactNode} from 'react';
|
|
998
988
|
import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
|
|
@@ -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';
|