@docusaurus/theme-classic 0.0.0-4366 → 0.0.0-4377
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/index.js +0 -2
- package/lib/theme-classic.d.ts +57 -161
- package/lib-next/theme/CodeBlock/index.js +1 -1
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
- package/lib-next/theme/DocItem/index.js +7 -4
- package/lib-next/theme/DocSidebar/index.js +2 -2
- package/lib-next/theme/DocSidebarItem/index.js +3 -16
- package/lib-next/theme/DocSidebarItems/index.js +26 -0
- package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +11 -2
- package/lib-next/theme/DocVersionBanner/index.js +4 -1
- package/lib-next/theme/Heading/index.js +39 -42
- package/lib-next/theme/Layout/index.js +1 -2
- package/lib-next/theme/LayoutProviders/index.js +6 -6
- package/lib-next/theme/MDXComponents/index.js +6 -6
- package/lib-next/theme/Navbar/index.js +6 -6
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +5 -2
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +1 -1
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
- package/lib-next/theme/NavbarItem/index.js +0 -2
- package/lib-next/theme/{ThemeContext.js → NavbarItem/utils.js} +3 -3
- package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
- package/lib-next/theme/Tabs/index.js +6 -3
- package/lib-next/theme/ThemedImage/index.js +2 -2
- package/package.json +12 -12
- package/src/index.ts +0 -4
- package/src/theme/CodeBlock/index.tsx +1 -1
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
- package/src/theme/DocItem/index.tsx +7 -4
- package/src/theme/DocSidebar/index.tsx +2 -2
- package/src/theme/DocSidebarItem/index.tsx +3 -19
- package/src/theme/DocSidebarItems/index.tsx +31 -0
- package/{lib-next/theme/hooks/styles.css → src/theme/DocSidebarItems/styles.module.css} +11 -2
- package/src/theme/DocVersionBanner/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +39 -46
- package/src/theme/Layout/index.tsx +1 -2
- package/src/theme/LayoutProviders/index.tsx +6 -6
- package/src/theme/MDXComponents/index.tsx +6 -6
- package/src/theme/Navbar/index.tsx +6 -6
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
- package/src/theme/NavbarItem/DocNavbarItem.tsx +5 -2
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +7 -3
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +1 -1
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +1 -1
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
- package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
- package/src/theme/NavbarItem/index.tsx +0 -3
- package/src/theme/{UserPreferencesContext.ts → NavbarItem/utils.ts} +3 -5
- package/src/theme/Tabs/index.tsx +6 -3
- package/src/theme/ThemedImage/index.tsx +2 -2
- package/src/theme-classic.d.ts +57 -161
- package/lib-next/theme/ThemeProvider/index.js +0 -28
- package/lib-next/theme/UserPreferencesContext.js +0 -9
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
- package/lib-next/theme/hooks/useDocs.js +0 -10
- package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
- package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
- package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
- package/lib-next/theme/hooks/usePrismTheme.js +0 -20
- package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
- package/lib-next/theme/hooks/useTheme.js +0 -81
- package/lib-next/theme/hooks/useThemeContext.js +0 -22
- package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
- package/lib-next/theme/hooks/useWindowSize.js +0 -59
- package/src/theme/ThemeContext.ts +0 -15
- package/src/theme/ThemeProvider/index.tsx +0 -28
- package/src/theme/UserPreferencesProvider/index.tsx +0 -30
- package/src/theme/hooks/useDocs.ts +0 -11
- package/src/theme/hooks/useHideableNavbar.ts +0 -72
- package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
- package/src/theme/hooks/useLockBodyScroll.ts +0 -20
- package/src/theme/hooks/usePrismTheme.ts +0 -22
- package/src/theme/hooks/useTabGroupChoice.ts +0 -46
- package/src/theme/hooks/useTheme.ts +0 -91
- package/src/theme/hooks/useThemeContext.ts +0 -23
- package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
- package/src/theme/hooks/useWindowSize.ts +0 -69
|
@@ -7,62 +7,55 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import type {
|
|
10
|
+
import type {Props} from '@theme/Heading';
|
|
11
11
|
import {translate} from '@docusaurus/Translate';
|
|
12
12
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
13
13
|
|
|
14
14
|
import './styles.css';
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function AnchorHeading({as: As, id, ...props}: Props) {
|
|
18
|
+
const {
|
|
19
|
+
navbar: {hideOnScroll},
|
|
20
|
+
} = useThemeConfig();
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (!id) {
|
|
23
|
+
return <As {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<As
|
|
23
28
|
{...props}
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
className={clsx('anchor', {
|
|
30
|
+
[styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
|
|
31
|
+
[styles.anchorWithStickyNavbar]: !hideOnScroll,
|
|
32
|
+
})}
|
|
33
|
+
id={id}>
|
|
26
34
|
{props.children}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
<a
|
|
36
|
+
className="hash-link"
|
|
37
|
+
href={`#${id}`}
|
|
38
|
+
title={translate({
|
|
39
|
+
id: 'theme.common.headingLinkTitle',
|
|
40
|
+
message: 'Direct link to heading',
|
|
41
|
+
description: 'Title for link to heading',
|
|
42
|
+
})}>
|
|
43
|
+
​
|
|
44
|
+
</a>
|
|
45
|
+
</As>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function Heading({as, ...props}: Props) {
|
|
50
|
+
if (as === 'h1') {
|
|
42
51
|
return (
|
|
43
|
-
<
|
|
52
|
+
<h1
|
|
44
53
|
{...props}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[styles.anchorWithStickyNavbar]: !hideOnScroll,
|
|
48
|
-
})}
|
|
49
|
-
id={id}>
|
|
54
|
+
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
55
|
+
>
|
|
50
56
|
{props.children}
|
|
51
|
-
|
|
52
|
-
className="hash-link"
|
|
53
|
-
href={`#${id}`}
|
|
54
|
-
title={translate({
|
|
55
|
-
id: 'theme.common.headingLinkTitle',
|
|
56
|
-
message: 'Direct link to heading',
|
|
57
|
-
description: 'Title for link to heading',
|
|
58
|
-
})}>
|
|
59
|
-
​
|
|
60
|
-
</a>
|
|
61
|
-
</Tag>
|
|
57
|
+
</h1>
|
|
62
58
|
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
|
|
67
|
-
|
|
68
|
-
export default Heading;
|
|
59
|
+
}
|
|
60
|
+
return <AnchorHeading as={as} {...props} />;
|
|
61
|
+
}
|
|
@@ -15,8 +15,7 @@ import Footer from '@theme/Footer';
|
|
|
15
15
|
import LayoutProviders from '@theme/LayoutProviders';
|
|
16
16
|
import LayoutHead from '@theme/LayoutHead';
|
|
17
17
|
import type {Props} from '@theme/Layout';
|
|
18
|
-
import useKeyboardNavigation from '@theme
|
|
19
|
-
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
18
|
+
import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
|
|
20
19
|
import ErrorPageContent from '@theme/ErrorPageContent';
|
|
21
20
|
import './styles.css';
|
|
22
21
|
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import ThemeProvider from '@theme/ThemeProvider';
|
|
10
|
-
import UserPreferencesProvider from '@theme/UserPreferencesProvider';
|
|
11
9
|
import {
|
|
10
|
+
ColorModeProvider,
|
|
11
|
+
TabGroupChoiceProvider,
|
|
12
12
|
AnnouncementBarProvider,
|
|
13
13
|
DocsPreferredVersionContextProvider,
|
|
14
14
|
MobileSecondaryMenuProvider,
|
|
@@ -18,9 +18,9 @@ import type {Props} from '@theme/LayoutProviders';
|
|
|
18
18
|
|
|
19
19
|
export default function LayoutProviders({children}: Props): JSX.Element {
|
|
20
20
|
return (
|
|
21
|
-
<
|
|
21
|
+
<ColorModeProvider>
|
|
22
22
|
<AnnouncementBarProvider>
|
|
23
|
-
<
|
|
23
|
+
<TabGroupChoiceProvider>
|
|
24
24
|
<ScrollControllerProvider>
|
|
25
25
|
<DocsPreferredVersionContextProvider>
|
|
26
26
|
<MobileSecondaryMenuProvider>
|
|
@@ -28,8 +28,8 @@ export default function LayoutProviders({children}: Props): JSX.Element {
|
|
|
28
28
|
</MobileSecondaryMenuProvider>
|
|
29
29
|
</DocsPreferredVersionContextProvider>
|
|
30
30
|
</ScrollControllerProvider>
|
|
31
|
-
</
|
|
31
|
+
</TabGroupChoiceProvider>
|
|
32
32
|
</AnnouncementBarProvider>
|
|
33
|
-
</
|
|
33
|
+
</ColorModeProvider>
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -67,12 +67,12 @@ const MDXComponents: MDXComponentsObject = {
|
|
|
67
67
|
</Details>
|
|
68
68
|
);
|
|
69
69
|
},
|
|
70
|
-
h1: Heading
|
|
71
|
-
h2: Heading
|
|
72
|
-
h3: Heading
|
|
73
|
-
h4: Heading
|
|
74
|
-
h5: Heading
|
|
75
|
-
h6: Heading
|
|
70
|
+
h1: (props) => <Heading as="h1" {...props} />,
|
|
71
|
+
h2: (props) => <Heading as="h2" {...props} />,
|
|
72
|
+
h3: (props) => <Heading as="h3" {...props} />,
|
|
73
|
+
h4: (props) => <Heading as="h4" {...props} />,
|
|
74
|
+
h5: (props) => <Heading as="h5" {...props} />,
|
|
75
|
+
h6: (props) => <Heading as="h6" {...props} />,
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export default MDXComponents;
|
|
@@ -10,17 +10,17 @@ import clsx from 'clsx';
|
|
|
10
10
|
import Translate from '@docusaurus/Translate';
|
|
11
11
|
import SearchBar from '@theme/SearchBar';
|
|
12
12
|
import Toggle from '@theme/Toggle';
|
|
13
|
-
import useThemeContext from '@theme/hooks/useThemeContext';
|
|
14
13
|
import {
|
|
15
14
|
useThemeConfig,
|
|
16
15
|
useMobileSecondaryMenuRenderer,
|
|
17
16
|
usePrevious,
|
|
18
17
|
useHistoryPopHandler,
|
|
18
|
+
useHideableNavbar,
|
|
19
|
+
useLockBodyScroll,
|
|
20
|
+
useWindowSize,
|
|
21
|
+
useColorMode,
|
|
19
22
|
} from '@docusaurus/theme-common';
|
|
20
|
-
import
|
|
21
|
-
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
|
22
|
-
import useWindowSize from '@theme/hooks/useWindowSize';
|
|
23
|
-
import {useActivePlugin} from '@theme/hooks/useDocs';
|
|
23
|
+
import {useActivePlugin} from '@docusaurus/plugin-content-docs/client';
|
|
24
24
|
import NavbarItem, {type Props as NavbarItemConfig} from '@theme/NavbarItem';
|
|
25
25
|
import Logo from '@theme/Logo';
|
|
26
26
|
import IconMenu from '@theme/IconMenu';
|
|
@@ -88,7 +88,7 @@ function useColorModeToggle() {
|
|
|
88
88
|
const {
|
|
89
89
|
colorMode: {disableSwitch},
|
|
90
90
|
} = useThemeConfig();
|
|
91
|
-
const {isDarkTheme, setLightTheme, setDarkTheme} =
|
|
91
|
+
const {isDarkTheme, setLightTheme, setDarkTheme} = useColorMode();
|
|
92
92
|
const toggle = useCallback(
|
|
93
93
|
(e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
|
|
94
94
|
[setLightTheme, setDarkTheme],
|
|
@@ -7,71 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
|
|
11
|
-
import
|
|
10
|
+
|
|
11
|
+
import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
|
|
12
|
+
|
|
12
13
|
import type {
|
|
13
|
-
NavLinkProps,
|
|
14
14
|
DesktopOrMobileNavBarItemProps,
|
|
15
15
|
Props,
|
|
16
16
|
} from '@theme/NavbarItem/DefaultNavbarItem';
|
|
17
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
18
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
19
|
-
import {isRegexpStringMatch} from '@docusaurus/theme-common';
|
|
20
|
-
import {getInfimaActiveClassName} from './index';
|
|
21
|
-
|
|
22
|
-
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
23
|
-
|
|
24
|
-
export function NavLink({
|
|
25
|
-
activeBasePath,
|
|
26
|
-
activeBaseRegex,
|
|
27
|
-
to,
|
|
28
|
-
href,
|
|
29
|
-
label,
|
|
30
|
-
activeClassName = '',
|
|
31
|
-
prependBaseUrlToHref,
|
|
32
|
-
...props
|
|
33
|
-
}: NavLinkProps): JSX.Element {
|
|
34
|
-
// TODO all this seems hacky
|
|
35
|
-
// {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
|
|
36
|
-
const toUrl = useBaseUrl(to);
|
|
37
|
-
const activeBaseUrl = useBaseUrl(activeBasePath);
|
|
38
|
-
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
|
|
39
|
-
const isExternalLink = label && href && !isInternalUrl(href);
|
|
40
|
-
const isDropdownLink = activeClassName === dropdownLinkActiveClass;
|
|
41
17
|
|
|
42
|
-
|
|
43
|
-
<Link
|
|
44
|
-
{...(href
|
|
45
|
-
? {
|
|
46
|
-
href: prependBaseUrlToHref ? normalizedHref : href,
|
|
47
|
-
}
|
|
48
|
-
: {
|
|
49
|
-
isNavLink: true,
|
|
50
|
-
activeClassName: !props.className?.includes(activeClassName)
|
|
51
|
-
? activeClassName
|
|
52
|
-
: '',
|
|
53
|
-
to: toUrl,
|
|
54
|
-
...(activeBasePath || activeBaseRegex
|
|
55
|
-
? {
|
|
56
|
-
isActive: (_match, location) =>
|
|
57
|
-
activeBaseRegex
|
|
58
|
-
? isRegexpStringMatch(activeBaseRegex, location.pathname)
|
|
59
|
-
: location.pathname.startsWith(activeBaseUrl),
|
|
60
|
-
}
|
|
61
|
-
: null),
|
|
62
|
-
})}
|
|
63
|
-
{...props}>
|
|
64
|
-
{isExternalLink ? (
|
|
65
|
-
<span>
|
|
66
|
-
{label}
|
|
67
|
-
<IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
|
|
68
|
-
</span>
|
|
69
|
-
) : (
|
|
70
|
-
label
|
|
71
|
-
)}
|
|
72
|
-
</Link>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
18
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
75
19
|
|
|
76
20
|
function DefaultNavbarItemDesktop({
|
|
77
21
|
className,
|
|
@@ -79,7 +23,7 @@ function DefaultNavbarItemDesktop({
|
|
|
79
23
|
...props
|
|
80
24
|
}: DesktopOrMobileNavBarItemProps) {
|
|
81
25
|
const element = (
|
|
82
|
-
<
|
|
26
|
+
<NavbarNavLink
|
|
83
27
|
className={clsx(
|
|
84
28
|
isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
|
|
85
29
|
className,
|
|
@@ -102,7 +46,7 @@ function DefaultNavbarItemMobile({
|
|
|
102
46
|
}: DesktopOrMobileNavBarItemProps) {
|
|
103
47
|
return (
|
|
104
48
|
<li className="menu__list-item">
|
|
105
|
-
<
|
|
49
|
+
<NavbarNavLink className={clsx('menu__link', className)} {...props} />
|
|
106
50
|
</li>
|
|
107
51
|
);
|
|
108
52
|
}
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useLatestVersion,
|
|
12
|
+
useActiveDocContext,
|
|
13
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
11
14
|
import clsx from 'clsx';
|
|
12
|
-
import {getInfimaActiveClassName} from '
|
|
15
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
13
16
|
import type {Props} from '@theme/NavbarItem/DocNavbarItem';
|
|
14
17
|
import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
|
|
15
18
|
import type {GlobalDataVersion} from '@docusaurus/plugin-content-docs';
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useLatestVersion,
|
|
12
|
+
useActiveDocContext,
|
|
13
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
11
14
|
import clsx from 'clsx';
|
|
12
|
-
import {getInfimaActiveClassName} from '
|
|
13
|
-
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
15
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
14
16
|
import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
|
|
17
|
+
|
|
18
|
+
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
15
19
|
import type {
|
|
16
20
|
GlobalDataVersion,
|
|
17
21
|
GlobalDataSidebar,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useVersions,
|
|
13
13
|
useLatestVersion,
|
|
14
14
|
useActiveDocContext,
|
|
15
|
-
} from '@
|
|
15
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
16
16
|
import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
17
17
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
18
18
|
import {translate} from '@docusaurus/Translate';
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useActiveVersion,
|
|
12
12
|
useLatestVersion,
|
|
13
13
|
type GlobalVersion,
|
|
14
|
-
} from '@
|
|
14
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
15
15
|
import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
|
|
16
16
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
} from '@theme/NavbarItem/DropdownNavbarItem';
|
|
21
21
|
import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
|
|
22
22
|
|
|
23
|
-
import
|
|
23
|
+
import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
|
|
24
24
|
import NavbarItem from '@theme/NavbarItem';
|
|
25
25
|
|
|
26
26
|
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
@@ -84,7 +84,7 @@ function DropdownNavbarItemDesktop({
|
|
|
84
84
|
'dropdown--right': position === 'right',
|
|
85
85
|
'dropdown--show': showDropdown,
|
|
86
86
|
})}>
|
|
87
|
-
<
|
|
87
|
+
<NavbarNavLink
|
|
88
88
|
href={props.to ? undefined : '#'}
|
|
89
89
|
className={clsx('navbar__link', className)}
|
|
90
90
|
{...props}
|
|
@@ -96,7 +96,7 @@ function DropdownNavbarItemDesktop({
|
|
|
96
96
|
}
|
|
97
97
|
}}>
|
|
98
98
|
{props.children ?? props.label}
|
|
99
|
-
</
|
|
99
|
+
</NavbarNavLink>
|
|
100
100
|
<ul className="dropdown__menu">
|
|
101
101
|
{items.map((childItemProps, i) => (
|
|
102
102
|
<NavbarItem
|
|
@@ -146,7 +146,7 @@ function DropdownNavbarItemMobile({
|
|
|
146
146
|
className={clsx('menu__list-item', {
|
|
147
147
|
'menu__list-item--collapsed': collapsed,
|
|
148
148
|
})}>
|
|
149
|
-
<
|
|
149
|
+
<NavbarNavLink
|
|
150
150
|
role="button"
|
|
151
151
|
className={clsx('menu__link menu__link--sublist', className)}
|
|
152
152
|
{...props}
|
|
@@ -155,7 +155,7 @@ function DropdownNavbarItemMobile({
|
|
|
155
155
|
toggleCollapsed();
|
|
156
156
|
}}>
|
|
157
157
|
{props.children ?? props.label}
|
|
158
|
-
</
|
|
158
|
+
</NavbarNavLink>
|
|
159
159
|
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
160
160
|
{items.map((childItemProps, i) => (
|
|
161
161
|
<NavbarItem
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import React from 'react';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
11
|
+
import type {Props} from '@theme/NavbarItem/NavbarNavLink';
|
|
12
|
+
import IconExternalLink from '@theme/IconExternalLink';
|
|
13
|
+
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
14
|
+
import {isRegexpStringMatch} from '@docusaurus/theme-common';
|
|
15
|
+
|
|
16
|
+
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
17
|
+
|
|
18
|
+
export default function NavbarNavLink({
|
|
19
|
+
activeBasePath,
|
|
20
|
+
activeBaseRegex,
|
|
21
|
+
to,
|
|
22
|
+
href,
|
|
23
|
+
label,
|
|
24
|
+
activeClassName = '',
|
|
25
|
+
prependBaseUrlToHref,
|
|
26
|
+
...props
|
|
27
|
+
}: Props): JSX.Element {
|
|
28
|
+
// TODO all this seems hacky
|
|
29
|
+
// {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
|
|
30
|
+
const toUrl = useBaseUrl(to);
|
|
31
|
+
const activeBaseUrl = useBaseUrl(activeBasePath);
|
|
32
|
+
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
|
|
33
|
+
const isExternalLink = label && href && !isInternalUrl(href);
|
|
34
|
+
const isDropdownLink = activeClassName === dropdownLinkActiveClass;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Link
|
|
38
|
+
{...(href
|
|
39
|
+
? {
|
|
40
|
+
href: prependBaseUrlToHref ? normalizedHref : href,
|
|
41
|
+
}
|
|
42
|
+
: {
|
|
43
|
+
isNavLink: true,
|
|
44
|
+
activeClassName: !props.className?.includes(activeClassName)
|
|
45
|
+
? activeClassName
|
|
46
|
+
: '',
|
|
47
|
+
to: toUrl,
|
|
48
|
+
...(activeBasePath || activeBaseRegex
|
|
49
|
+
? {
|
|
50
|
+
isActive: (_match, location) =>
|
|
51
|
+
activeBaseRegex
|
|
52
|
+
? isRegexpStringMatch(activeBaseRegex, location.pathname)
|
|
53
|
+
: location.pathname.startsWith(activeBaseUrl),
|
|
54
|
+
}
|
|
55
|
+
: null),
|
|
56
|
+
})}
|
|
57
|
+
{...props}>
|
|
58
|
+
{isExternalLink ? (
|
|
59
|
+
<span>
|
|
60
|
+
{label}
|
|
61
|
+
<IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
|
|
62
|
+
</span>
|
|
63
|
+
) : (
|
|
64
|
+
label
|
|
65
|
+
)}
|
|
66
|
+
</Link>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -58,9 +58,6 @@ function getComponentType(
|
|
|
58
58
|
return type as NavbarItemComponentType;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export const getInfimaActiveClassName = (mobile?: boolean): string =>
|
|
62
|
-
mobile ? 'menu__link--active' : 'navbar__link--active';
|
|
63
|
-
|
|
64
61
|
export default function NavbarItem({type, ...props}: Props): JSX.Element {
|
|
65
62
|
const componentType = getComponentType(
|
|
66
63
|
type,
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default UserPreferencesContext;
|
|
8
|
+
// eslint-disable-next-line import/no-named-export
|
|
9
|
+
export const getInfimaActiveClassName = (mobile?: boolean): string =>
|
|
10
|
+
mobile ? 'menu__link--active' : 'navbar__link--active';
|
package/src/theme/Tabs/index.tsx
CHANGED
|
@@ -13,8 +13,11 @@ import React, {
|
|
|
13
13
|
type ReactElement,
|
|
14
14
|
} from 'react';
|
|
15
15
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
16
|
-
import
|
|
17
|
-
|
|
16
|
+
import {
|
|
17
|
+
useScrollPositionBlocker,
|
|
18
|
+
duplicates,
|
|
19
|
+
useTabGroupChoice,
|
|
20
|
+
} from '@docusaurus/theme-common';
|
|
18
21
|
import type {Props} from '@theme/Tabs';
|
|
19
22
|
import type {Props as TabItemProps} from '@theme/TabItem';
|
|
20
23
|
|
|
@@ -83,7 +86,7 @@ function TabsComponent(props: Props): JSX.Element {
|
|
|
83
86
|
);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
const {tabGroupChoices, setTabGroupChoices} =
|
|
89
|
+
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
87
90
|
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
88
91
|
const tabRefs: (HTMLLIElement | null)[] = [];
|
|
89
92
|
const {blockElementScrollPositionUntilNextRender} =
|
|
@@ -9,14 +9,14 @@ import React from 'react';
|
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
|
|
11
11
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
12
|
-
import
|
|
12
|
+
import {useColorMode} from '@docusaurus/theme-common';
|
|
13
13
|
import type {Props} from '@theme/ThemedImage';
|
|
14
14
|
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
|
|
17
17
|
function ThemedImage(props: Props): JSX.Element {
|
|
18
18
|
const isBrowser = useIsBrowser();
|
|
19
|
-
const {isDarkTheme} =
|
|
19
|
+
const {isDarkTheme} = useColorMode();
|
|
20
20
|
const {sources, className, alt = '', ...propsRest} = props;
|
|
21
21
|
|
|
22
22
|
type SourceName = keyof Props['sources'];
|