@docusaurus/theme-classic 0.0.0-4734 → 0.0.0-4737
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 +66 -4
- package/lib-next/theme/ColorModeToggle/index.js +36 -59
- package/lib-next/theme/ColorModeToggle/styles.module.css +8 -24
- 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 -277
- package/lib-next/theme/ThemedImage/index.js +2 -2
- package/package.json +13 -13
- package/src/theme/ColorModeToggle/index.tsx +36 -63
- package/src/theme/ColorModeToggle/styles.module.css +8 -24
- 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/ThemedImage/index.tsx +3 -2
- package/src/theme-classic.d.ts +66 -4
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
|
|
|
@@ -746,15 +804,19 @@ declare module '@theme/TOCCollapsible' {
|
|
|
746
804
|
}
|
|
747
805
|
|
|
748
806
|
declare module '@theme/ColorModeToggle' {
|
|
749
|
-
import type {
|
|
807
|
+
import type {ColorMode} from '@docusaurus/theme-common';
|
|
750
808
|
|
|
751
809
|
export interface Props {
|
|
752
810
|
readonly className?: string;
|
|
753
|
-
readonly
|
|
754
|
-
|
|
811
|
+
readonly value: ColorMode;
|
|
812
|
+
/**
|
|
813
|
+
* The parameter represents the "to-be" value. For example, if currently in
|
|
814
|
+
* dark mode, clicking the button should call `onChange("light")`
|
|
815
|
+
*/
|
|
816
|
+
readonly onChange: (colorMode: ColorMode) => void;
|
|
755
817
|
}
|
|
756
818
|
|
|
757
|
-
export default function
|
|
819
|
+
export default function ColorModeToggle(props: Props): JSX.Element;
|
|
758
820
|
}
|
|
759
821
|
|
|
760
822
|
declare module '@theme/Logo' {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import IconLightMode from '@theme/IconLightMode';
|
|
@@ -12,72 +12,49 @@ import IconDarkMode from '@theme/IconDarkMode';
|
|
|
12
12
|
import clsx from 'clsx';
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
|
|
15
|
-
function ColorModeToggle({className,
|
|
15
|
+
function ColorModeToggle({className, value, onChange}) {
|
|
16
16
|
const isBrowser = useIsBrowser();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const title = translate(
|
|
18
|
+
{
|
|
19
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
20
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
21
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
mode:
|
|
25
|
+
value === 'dark'
|
|
26
|
+
? translate({
|
|
27
|
+
message: 'dark mode',
|
|
28
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
29
|
+
description: 'The name for the dark color mode',
|
|
30
|
+
})
|
|
31
|
+
: translate({
|
|
32
|
+
message: 'light mode',
|
|
33
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
34
|
+
description: 'The name for the light color mode',
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
);
|
|
23
38
|
return (
|
|
24
|
-
<div
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
tabIndex={-1}
|
|
37
|
-
onClick={() => inputRef.current?.click()}>
|
|
39
|
+
<div className={clsx(styles.toggle, className)}>
|
|
40
|
+
<button
|
|
41
|
+
className={clsx(
|
|
42
|
+
'clean-btn',
|
|
43
|
+
styles.toggleButton,
|
|
44
|
+
!isBrowser && styles.toggleButtonDisabled,
|
|
45
|
+
)}
|
|
46
|
+
type="button"
|
|
47
|
+
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
|
|
48
|
+
disabled={!isBrowser}
|
|
49
|
+
title={title}
|
|
50
|
+
aria-label={title}>
|
|
38
51
|
<IconLightMode
|
|
39
52
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
40
53
|
/>
|
|
41
54
|
<IconDarkMode
|
|
42
55
|
className={clsx(styles.toggleIcon, styles.darkToggleIcon)}
|
|
43
56
|
/>
|
|
44
|
-
</
|
|
45
|
-
|
|
46
|
-
<input
|
|
47
|
-
ref={inputRef}
|
|
48
|
-
checked={checked}
|
|
49
|
-
type="checkbox"
|
|
50
|
-
className={styles.toggleScreenReader}
|
|
51
|
-
aria-label={translate(
|
|
52
|
-
{
|
|
53
|
-
message: 'Switch between dark and light mode (currently {mode})',
|
|
54
|
-
id: 'theme.colorToggle.ariaLabel',
|
|
55
|
-
description: 'The ARIA label for the navbar color mode toggle',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
mode: checked
|
|
59
|
-
? translate({
|
|
60
|
-
message: 'dark mode',
|
|
61
|
-
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
62
|
-
description: 'The name for the dark color mode',
|
|
63
|
-
})
|
|
64
|
-
: translate({
|
|
65
|
-
message: 'light mode',
|
|
66
|
-
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
67
|
-
description: 'The name for the light color mode',
|
|
68
|
-
}),
|
|
69
|
-
},
|
|
70
|
-
)}
|
|
71
|
-
onChange={onChange}
|
|
72
|
-
onClick={() => setChecked(!checked)}
|
|
73
|
-
onFocus={() => setFocused(true)}
|
|
74
|
-
onBlur={() => setFocused(false)}
|
|
75
|
-
onKeyDown={(e) => {
|
|
76
|
-
if (e.key === 'Enter') {
|
|
77
|
-
inputRef.current?.click();
|
|
78
|
-
}
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
57
|
+
</button>
|
|
81
58
|
</div>
|
|
82
59
|
);
|
|
83
60
|
}
|
|
@@ -6,28 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
.toggle {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
height: 32px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.toggleScreenReader {
|
|
15
|
-
border: 0;
|
|
16
|
-
clip: rect(0 0 0 0);
|
|
17
|
-
height: 1px;
|
|
18
|
-
margin: -1px;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
position: absolute;
|
|
21
|
-
width: 1px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.toggleDisabled {
|
|
25
|
-
cursor: not-allowed;
|
|
9
|
+
width: 2rem;
|
|
10
|
+
height: 2rem;
|
|
26
11
|
}
|
|
27
12
|
|
|
28
13
|
.toggleButton {
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
user-select: none;
|
|
31
14
|
-webkit-tap-highlight-color: transparent;
|
|
32
15
|
align-items: center;
|
|
33
16
|
display: flex;
|
|
@@ -35,17 +18,18 @@
|
|
|
35
18
|
width: 100%;
|
|
36
19
|
height: 100%;
|
|
37
20
|
border-radius: 50%;
|
|
21
|
+
transition: background var(--ifm-transition-fast);
|
|
38
22
|
}
|
|
39
23
|
|
|
40
24
|
.toggleButton:hover {
|
|
41
|
-
background-color
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[data-theme='dark'] .toggleButton:hover {
|
|
45
|
-
background-color: #ffffff20;
|
|
25
|
+
background: var(--ifm-color-emphasis-200);
|
|
46
26
|
}
|
|
47
27
|
|
|
48
28
|
[data-theme='light'] .darkToggleIcon,
|
|
49
29
|
[data-theme='dark'] .lightToggleIcon {
|
|
50
30
|
display: none;
|
|
51
31
|
}
|
|
32
|
+
|
|
33
|
+
.toggleButtonDisabled {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
@@ -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
|
+
}
|