@docusaurus/theme-classic 0.0.0-4735 → 0.0.0-4736
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 +59 -1
- package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
- package/lib-next/theme/LayoutProviders/index.js +4 -6
- package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
- package/lib-next/theme/Navbar/Content/index.js +70 -0
- package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
- package/lib-next/theme/Navbar/Layout/index.js +54 -0
- package/lib-next/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
- package/lib-next/theme/Navbar/Logo/index.js +17 -0
- package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
- package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
- package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
- package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
- package/lib-next/theme/Navbar/index.js +6 -273
- package/package.json +13 -13
- package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
- package/src/theme/LayoutProviders/index.tsx +4 -6
- package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
- package/src/theme/Navbar/Content/index.tsx +81 -0
- package/src/theme/Navbar/Content/styles.module.css +15 -0
- package/src/theme/Navbar/Layout/index.tsx +57 -0
- package/src/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
- package/src/theme/Navbar/Logo/index.tsx +19 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
- package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
- package/src/theme/Navbar/index.tsx +6 -292
- package/src/theme-classic.d.ts +59 -1
package/lib/theme-classic.d.ts
CHANGED
|
@@ -460,6 +460,64 @@ declare module '@theme/Navbar' {
|
|
|
460
460
|
export default function Navbar(): JSX.Element;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
declare module '@theme/Navbar/ColorModeToggle' {
|
|
464
|
+
export interface Props {
|
|
465
|
+
readonly className?: string;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export default function NavbarColorModeToggle(
|
|
469
|
+
props: Props,
|
|
470
|
+
): JSX.Element | null;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
declare module '@theme/Navbar/Logo' {
|
|
474
|
+
export default function NavbarLogo(): JSX.Element;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare module '@theme/Navbar/Content' {
|
|
478
|
+
export default function NavbarContent(): JSX.Element;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
declare module '@theme/Navbar/Layout' {
|
|
482
|
+
export interface Props {
|
|
483
|
+
children: React.ReactNode;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export default function NavbarLayout(props: Props): JSX.Element;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
declare module '@theme/Navbar/MobileSidebar' {
|
|
490
|
+
export default function NavbarMobileSidebar(): JSX.Element;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
declare module '@theme/Navbar/MobileSidebar/Layout' {
|
|
494
|
+
import type {ReactNode} from 'react';
|
|
495
|
+
|
|
496
|
+
interface Props {
|
|
497
|
+
header: ReactNode;
|
|
498
|
+
primaryMenu: ReactNode;
|
|
499
|
+
secondaryMenu: ReactNode;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export default function NavbarMobileSidebarLayout(props: Props): JSX.Element;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
declare module '@theme/Navbar/MobileSidebar/Toggle' {
|
|
506
|
+
export default function NavbarMobileSidebarToggle(): JSX.Element;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
declare module '@theme/Navbar/MobileSidebar/PrimaryMenu' {
|
|
510
|
+
export default function NavbarMobileSidebarPrimaryMenu(): JSX.Element;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
declare module '@theme/Navbar/MobileSidebar/SecondaryMenu' {
|
|
514
|
+
export default function NavbarMobileSidebarSecondaryMenu(): JSX.Element;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
declare module '@theme/Navbar/MobileSidebar/Header' {
|
|
518
|
+
export default function NavbarMobileSidebarHeader(): JSX.Element;
|
|
519
|
+
}
|
|
520
|
+
|
|
463
521
|
declare module '@theme/NavbarItem/DefaultNavbarItem' {
|
|
464
522
|
import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
|
|
465
523
|
|
|
@@ -758,7 +816,7 @@ declare module '@theme/ColorModeToggle' {
|
|
|
758
816
|
readonly onChange: (colorMode: ColorMode) => void;
|
|
759
817
|
}
|
|
760
818
|
|
|
761
|
-
export default function
|
|
819
|
+
export default function ColorModeToggle(props: Props): JSX.Element;
|
|
762
820
|
}
|
|
763
821
|
|
|
764
822
|
declare module '@theme/Logo' {
|
|
@@ -7,35 +7,39 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
NavbarSecondaryMenuFiller,
|
|
11
11
|
ThemeClassNames,
|
|
12
|
+
useNavbarMobileSidebar,
|
|
12
13
|
} from '@docusaurus/theme-common';
|
|
13
14
|
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line react/function-component-definition
|
|
16
|
-
const DocSidebarMobileSecondaryMenu = ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const DocSidebarMobileSecondaryMenu = ({sidebar, path}) => {
|
|
18
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
19
|
+
return (
|
|
20
|
+
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
|
21
|
+
<DocSidebarItems
|
|
22
|
+
items={sidebar}
|
|
23
|
+
activePath={path}
|
|
24
|
+
onItemClick={(item) => {
|
|
25
|
+
// Mobile sidebar should only be closed if the category has a link
|
|
26
|
+
if (item.type === 'category' && item.href) {
|
|
27
|
+
mobileSidebar.toggle();
|
|
28
|
+
}
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
30
|
+
if (item.type === 'link') {
|
|
31
|
+
mobileSidebar.toggle();
|
|
32
|
+
}
|
|
33
|
+
}}
|
|
34
|
+
level={1}
|
|
35
|
+
/>
|
|
36
|
+
</ul>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
35
39
|
|
|
36
40
|
function DocSidebarMobile(props) {
|
|
37
41
|
return (
|
|
38
|
-
<
|
|
42
|
+
<NavbarSecondaryMenuFiller
|
|
39
43
|
component={DocSidebarMobileSecondaryMenu}
|
|
40
44
|
props={props}
|
|
41
45
|
/>
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
TabGroupChoiceProvider,
|
|
11
11
|
AnnouncementBarProvider,
|
|
12
12
|
DocsPreferredVersionContextProvider,
|
|
13
|
-
MobileSecondaryMenuProvider,
|
|
14
13
|
ScrollControllerProvider,
|
|
14
|
+
NavbarProvider,
|
|
15
15
|
PluginHtmlClassNameProvider,
|
|
16
16
|
} from '@docusaurus/theme-common';
|
|
17
17
|
export default function LayoutProviders({children}) {
|
|
@@ -21,11 +21,9 @@ export default function LayoutProviders({children}) {
|
|
|
21
21
|
<TabGroupChoiceProvider>
|
|
22
22
|
<ScrollControllerProvider>
|
|
23
23
|
<DocsPreferredVersionContextProvider>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</PluginHtmlClassNameProvider>
|
|
28
|
-
</MobileSecondaryMenuProvider>
|
|
24
|
+
<PluginHtmlClassNameProvider>
|
|
25
|
+
<NavbarProvider>{children}</NavbarProvider>
|
|
26
|
+
</PluginHtmlClassNameProvider>
|
|
29
27
|
</DocsPreferredVersionContextProvider>
|
|
30
28
|
</ScrollControllerProvider>
|
|
31
29
|
</TabGroupChoiceProvider>
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
|
|
8
|
+
import ColorModeToggle from '@theme/ColorModeToggle';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export default function NavbarColorModeToggle({className}) {
|
|
11
|
+
const disabled = useThemeConfig().colorMode.disableSwitch;
|
|
12
|
+
const {colorMode, setColorMode} = useColorMode();
|
|
13
|
+
|
|
14
|
+
if (disabled) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ColorModeToggle
|
|
20
|
+
className={className}
|
|
21
|
+
value={colorMode}
|
|
22
|
+
onChange={setColorMode}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import NavbarItem from '@theme/NavbarItem';
|
|
9
|
+
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
|
|
10
|
+
import SearchBar from '@theme/SearchBar';
|
|
11
|
+
import {
|
|
12
|
+
splitNavbarItems,
|
|
13
|
+
useNavbarMobileSidebar,
|
|
14
|
+
useThemeConfig,
|
|
15
|
+
} from '@docusaurus/theme-common';
|
|
16
|
+
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
|
17
|
+
import NavbarLogo from '@theme/Navbar/Logo';
|
|
18
|
+
import styles from './styles.module.css';
|
|
19
|
+
|
|
20
|
+
function useNavbarItems() {
|
|
21
|
+
// TODO temporary casting until ThemeConfig type is improved
|
|
22
|
+
return useThemeConfig().navbar.items;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function NavbarItems({items}) {
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{items.map((item, i) => (
|
|
29
|
+
<NavbarItem {...item} key={i} />
|
|
30
|
+
))}
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function NavbarContentLayout({left, right}) {
|
|
36
|
+
return (
|
|
37
|
+
<div className="navbar__inner">
|
|
38
|
+
<div className="navbar__items">{left}</div>
|
|
39
|
+
<div className="navbar__items navbar__items--right">{right}</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function NavbarContent() {
|
|
45
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
46
|
+
const items = useNavbarItems();
|
|
47
|
+
const [leftItems, rightItems] = splitNavbarItems(items);
|
|
48
|
+
const autoAddSearchBar = !items.some((item) => item.type === 'search');
|
|
49
|
+
return (
|
|
50
|
+
<NavbarContentLayout
|
|
51
|
+
left={
|
|
52
|
+
// TODO stop hardcoding items?
|
|
53
|
+
<>
|
|
54
|
+
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
|
|
55
|
+
<NavbarLogo />
|
|
56
|
+
<NavbarItems items={leftItems} />
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
right={
|
|
60
|
+
// TODO stop hardcoding items?
|
|
61
|
+
// Ask the user to add the respective navbar items => more flexible
|
|
62
|
+
<>
|
|
63
|
+
<NavbarItems items={rightItems} />
|
|
64
|
+
<NavbarColorModeToggle className={styles.colorModeToggle} />
|
|
65
|
+
{autoAddSearchBar && <SearchBar />}
|
|
66
|
+
</>
|
|
67
|
+
}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/*
|
|
9
|
+
Hide color mode toggle in small viewports
|
|
10
|
+
*/
|
|
11
|
+
@media (max-width: 996px) {
|
|
12
|
+
.colorModeToggle {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
|
|
10
|
+
import {
|
|
11
|
+
useThemeConfig,
|
|
12
|
+
useHideableNavbar,
|
|
13
|
+
useNavbarMobileSidebar,
|
|
14
|
+
} from '@docusaurus/theme-common';
|
|
15
|
+
import styles from './styles.module.css';
|
|
16
|
+
|
|
17
|
+
function NavbarBackdrop(props) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
role="presentation"
|
|
21
|
+
{...props}
|
|
22
|
+
className={clsx('navbar-sidebar__backdrop', props.className)}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function NavbarLayout({children}) {
|
|
28
|
+
const {
|
|
29
|
+
navbar: {hideOnScroll, style},
|
|
30
|
+
} = useThemeConfig();
|
|
31
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
32
|
+
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
|
|
33
|
+
return (
|
|
34
|
+
<nav
|
|
35
|
+
ref={navbarRef}
|
|
36
|
+
className={clsx(
|
|
37
|
+
'navbar',
|
|
38
|
+
'navbar--fixed-top',
|
|
39
|
+
hideOnScroll && [
|
|
40
|
+
styles.navbarHideable,
|
|
41
|
+
!isNavbarVisible && styles.navbarHidden,
|
|
42
|
+
],
|
|
43
|
+
{
|
|
44
|
+
'navbar--dark': style === 'dark',
|
|
45
|
+
'navbar--primary': style === 'primary',
|
|
46
|
+
'navbar-sidebar--show': mobileSidebar.shown,
|
|
47
|
+
},
|
|
48
|
+
)}>
|
|
49
|
+
{children}
|
|
50
|
+
<NavbarBackdrop onClick={mobileSidebar.toggle} />
|
|
51
|
+
<NavbarMobileSidebar />
|
|
52
|
+
</nav>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -5,15 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/*
|
|
9
|
-
Hide toggle in small viewports
|
|
10
|
-
*/
|
|
11
|
-
@media (max-width: 996px) {
|
|
12
|
-
.toggle {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
8
|
.navbarHideable {
|
|
18
9
|
transition: transform var(--ifm-transition-fast) ease;
|
|
19
10
|
}
|
|
@@ -21,7 +12,3 @@ Hide toggle in small viewports
|
|
|
21
12
|
.navbarHidden {
|
|
22
13
|
transform: translate3d(0, calc(-100% - 2px), 0);
|
|
23
14
|
}
|
|
24
|
-
|
|
25
|
-
.navbarSidebarToggle {
|
|
26
|
-
margin-right: 1rem;
|
|
27
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import Logo from '@theme/Logo';
|
|
9
|
+
export default function NavbarLogo() {
|
|
10
|
+
return (
|
|
11
|
+
<Logo
|
|
12
|
+
className="navbar__brand"
|
|
13
|
+
imageClassName="navbar__logo"
|
|
14
|
+
titleClassName="navbar__title"
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
|
|
9
|
+
import IconClose from '@theme/IconClose';
|
|
10
|
+
import NavbarLogo from '@theme/Navbar/Logo';
|
|
11
|
+
import {useNavbarMobileSidebar} from '@docusaurus/theme-common';
|
|
12
|
+
|
|
13
|
+
function CloseButton() {
|
|
14
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
15
|
+
return (
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
className="clean-btn navbar-sidebar__close"
|
|
19
|
+
onClick={() => mobileSidebar.toggle()}>
|
|
20
|
+
<IconClose color="var(--ifm-color-emphasis-600)" />
|
|
21
|
+
</button>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function NavbarMobileSidebarHeader() {
|
|
26
|
+
return (
|
|
27
|
+
<div className="navbar-sidebar__brand">
|
|
28
|
+
<NavbarLogo />
|
|
29
|
+
<NavbarColorModeToggle className="margin-right--md" />
|
|
30
|
+
<CloseButton />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {useNavbarSecondaryMenu} from '@docusaurus/theme-common';
|
|
10
|
+
export default function NavbarMobileSidebarLayout({
|
|
11
|
+
header,
|
|
12
|
+
primaryMenu,
|
|
13
|
+
secondaryMenu,
|
|
14
|
+
}) {
|
|
15
|
+
const {shown: secondaryMenuShown} = useNavbarSecondaryMenu();
|
|
16
|
+
return (
|
|
17
|
+
<div className="navbar-sidebar">
|
|
18
|
+
{header}
|
|
19
|
+
<div
|
|
20
|
+
className={clsx('navbar-sidebar__items', {
|
|
21
|
+
'navbar-sidebar__items--show-secondary': secondaryMenuShown,
|
|
22
|
+
})}>
|
|
23
|
+
<div className="navbar-sidebar__item menu">{primaryMenu}</div>
|
|
24
|
+
<div className="navbar-sidebar__item menu">{secondaryMenu}</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import {useNavbarMobileSidebar, useThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import NavbarItem from '../../../NavbarItem';
|
|
10
|
+
|
|
11
|
+
function useNavbarItems() {
|
|
12
|
+
// TODO temporary casting until ThemeConfig type is improved
|
|
13
|
+
return useThemeConfig().navbar.items;
|
|
14
|
+
} // The primary menu displays the navbar items
|
|
15
|
+
|
|
16
|
+
export default function NavbarMobilePrimaryMenu() {
|
|
17
|
+
const mobileSidebar = useNavbarMobileSidebar(); // TODO how can the order be defined for mobile?
|
|
18
|
+
// Should we allow providing a different list of items?
|
|
19
|
+
|
|
20
|
+
const items = useNavbarItems();
|
|
21
|
+
return (
|
|
22
|
+
<ul className="menu__list">
|
|
23
|
+
{items.map((item, i) => (
|
|
24
|
+
<NavbarItem
|
|
25
|
+
mobile
|
|
26
|
+
{...item}
|
|
27
|
+
onClick={() => mobileSidebar.toggle()}
|
|
28
|
+
key={i}
|
|
29
|
+
/>
|
|
30
|
+
))}
|
|
31
|
+
</ul>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import {useNavbarSecondaryMenu, useThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import Translate from '@docusaurus/Translate';
|
|
10
|
+
|
|
11
|
+
function SecondaryMenuBackButton(props) {
|
|
12
|
+
return (
|
|
13
|
+
<button {...props} type="button" className="clean-btn navbar-sidebar__back">
|
|
14
|
+
<Translate
|
|
15
|
+
id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel"
|
|
16
|
+
description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)">
|
|
17
|
+
← Back to main menu
|
|
18
|
+
</Translate>
|
|
19
|
+
</button>
|
|
20
|
+
);
|
|
21
|
+
} // The secondary menu slides from the right and shows contextual information
|
|
22
|
+
// such as the docs sidebar
|
|
23
|
+
|
|
24
|
+
export default function NavbarMobileSidebarSecondaryMenu() {
|
|
25
|
+
const isPrimaryMenuEmpty = useThemeConfig().navbar.items.length === 0;
|
|
26
|
+
const secondaryMenu = useNavbarSecondaryMenu();
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{/* edge-case: prevent returning to the primaryMenu when it's empty */}
|
|
30
|
+
{!isPrimaryMenuEmpty && (
|
|
31
|
+
<SecondaryMenuBackButton onClick={() => secondaryMenu.hide()} />
|
|
32
|
+
)}
|
|
33
|
+
{secondaryMenu.content}
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import IconMenu from '@theme/IconMenu';
|
|
9
|
+
import {useNavbarMobileSidebar} from '@docusaurus/theme-common';
|
|
10
|
+
export default function MobileSidebarToggle() {
|
|
11
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
12
|
+
return (
|
|
13
|
+
<button
|
|
14
|
+
onClick={mobileSidebar.toggle}
|
|
15
|
+
onKeyDown={mobileSidebar.toggle}
|
|
16
|
+
aria-label="Navigation bar toggle"
|
|
17
|
+
className="navbar__toggle clean-btn"
|
|
18
|
+
type="button"
|
|
19
|
+
tabIndex={0}>
|
|
20
|
+
<IconMenu />
|
|
21
|
+
</button>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import NavbarMobileSidebarLayout from '@theme/Navbar/MobileSidebar/Layout';
|
|
9
|
+
import NavbarMobileSidebarHeader from '@theme/Navbar/MobileSidebar/Header';
|
|
10
|
+
import {
|
|
11
|
+
useLockBodyScroll,
|
|
12
|
+
useNavbarMobileSidebar,
|
|
13
|
+
} from '@docusaurus/theme-common';
|
|
14
|
+
import NavbarMobileSidebarPrimaryMenu from '@theme/Navbar/MobileSidebar/PrimaryMenu';
|
|
15
|
+
import NavbarMobileSidebarSecondaryMenu from '@theme/Navbar/MobileSidebar/SecondaryMenu';
|
|
16
|
+
export default function NavbarMobileSidebar() {
|
|
17
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
18
|
+
useLockBodyScroll(mobileSidebar.shown);
|
|
19
|
+
|
|
20
|
+
if (!mobileSidebar.shouldRender) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<NavbarMobileSidebarLayout
|
|
26
|
+
header={<NavbarMobileSidebarHeader />}
|
|
27
|
+
primaryMenu={<NavbarMobileSidebarPrimaryMenu />}
|
|
28
|
+
secondaryMenu={<NavbarMobileSidebarSecondaryMenu />}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|