@docusaurus/theme-classic 0.0.0-4733 → 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.
Files changed (43) hide show
  1. package/lib/theme-classic.d.ts +66 -4
  2. package/lib-next/theme/ColorModeToggle/index.js +36 -59
  3. package/lib-next/theme/ColorModeToggle/styles.module.css +8 -24
  4. package/lib-next/theme/DocItem/index.js +7 -3
  5. package/lib-next/theme/DocPage/index.js +3 -7
  6. package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
  7. package/lib-next/theme/LayoutProviders/index.js +5 -4
  8. package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
  9. package/lib-next/theme/Navbar/Content/index.js +70 -0
  10. package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
  11. package/lib-next/theme/Navbar/Layout/index.js +54 -0
  12. package/lib-next/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
  13. package/lib-next/theme/Navbar/Logo/index.js +17 -0
  14. package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
  15. package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
  16. package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
  17. package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
  18. package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
  19. package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
  20. package/lib-next/theme/Navbar/index.js +6 -277
  21. package/lib-next/theme/ThemedImage/index.js +2 -2
  22. package/package.json +13 -13
  23. package/src/theme/ColorModeToggle/index.tsx +36 -63
  24. package/src/theme/ColorModeToggle/styles.module.css +8 -24
  25. package/src/theme/DocItem/index.tsx +7 -3
  26. package/src/theme/DocPage/index.tsx +4 -7
  27. package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
  28. package/src/theme/LayoutProviders/index.tsx +5 -4
  29. package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
  30. package/src/theme/Navbar/Content/index.tsx +81 -0
  31. package/src/theme/Navbar/Content/styles.module.css +15 -0
  32. package/src/theme/Navbar/Layout/index.tsx +57 -0
  33. package/src/theme/Navbar/{styles.module.css → Layout/styles.module.css} +0 -13
  34. package/src/theme/Navbar/Logo/index.tsx +19 -0
  35. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
  36. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
  37. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
  38. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
  39. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
  40. package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
  41. package/src/theme/Navbar/index.tsx +6 -292
  42. package/src/theme/ThemedImage/index.tsx +3 -2
  43. package/src/theme-classic.d.ts +66 -4
@@ -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 {SyntheticEvent} from 'react';
807
+ import type {ColorMode} from '@docusaurus/theme-common';
750
808
 
751
809
  export interface Props {
752
810
  readonly className?: string;
753
- readonly checked: boolean;
754
- readonly onChange: (e: SyntheticEvent) => void;
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 Toggle(props: Props): JSX.Element;
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, {useState, useRef, useEffect} from '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, checked: defaultChecked, onChange}) {
15
+ function ColorModeToggle({className, value, onChange}) {
16
16
  const isBrowser = useIsBrowser();
17
- const [checked, setChecked] = useState(defaultChecked);
18
- const [focused, setFocused] = useState(false);
19
- const inputRef = useRef(null);
20
- useEffect(() => {
21
- setChecked(defaultChecked);
22
- }, [defaultChecked]);
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
- className={clsx(
26
- styles.toggle,
27
- className,
28
- checked && styles.toggleChecked,
29
- focused && styles.toggleFocused,
30
- !isBrowser && styles.toggleDisabled,
31
- )}>
32
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
33
- <div
34
- className={styles.toggleButton}
35
- role="button"
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
- </div>
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
- position: relative;
10
- width: 32px;
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: #00000010;
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
+ }
@@ -15,7 +15,11 @@ import TOC from '@theme/TOC';
15
15
  import TOCCollapsible from '@theme/TOCCollapsible';
16
16
  import Heading from '@theme/Heading';
17
17
  import styles from './styles.module.css';
18
- import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
18
+ import {
19
+ HtmlClassNameProvider,
20
+ ThemeClassNames,
21
+ useWindowSize,
22
+ } from '@docusaurus/theme-common';
19
23
  import DocBreadcrumbs from '@theme/DocBreadcrumbs';
20
24
  import MDXContent from '@theme/MDXContent';
21
25
  export default function DocItem(props) {
@@ -41,7 +45,7 @@ export default function DocItem(props) {
41
45
  const renderTocDesktop =
42
46
  canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr');
43
47
  return (
44
- <>
48
+ <HtmlClassNameProvider className={`docs-doc-id-${metadata.unversionedId}`}>
45
49
  <Seo
46
50
  {...{
47
51
  title,
@@ -106,6 +110,6 @@ export default function DocItem(props) {
106
110
  </div>
107
111
  )}
108
112
  </div>
109
- </>
113
+ </HtmlClassNameProvider>
110
114
  );
111
115
  }
@@ -16,13 +16,13 @@ import {translate} from '@docusaurus/Translate';
16
16
  import clsx from 'clsx';
17
17
  import styles from './styles.module.css';
18
18
  import {
19
+ HtmlClassNameProvider,
19
20
  ThemeClassNames,
20
21
  docVersionSearchTag,
21
22
  DocsSidebarProvider,
22
23
  useDocsSidebar,
23
24
  DocsVersionProvider,
24
25
  } from '@docusaurus/theme-common';
25
- import Head from '@docusaurus/Head';
26
26
 
27
27
  function DocPageContent({
28
28
  currentDocRoute,
@@ -145,11 +145,7 @@ export default function DocPage(props) {
145
145
  ? versionMetadata.docsSidebars[sidebarName]
146
146
  : null;
147
147
  return (
148
- <>
149
- <Head>
150
- {/* TODO we should add a core addRoute({htmlClassName}) action */}
151
- <html className={versionMetadata.className} />
152
- </Head>
148
+ <HtmlClassNameProvider className={versionMetadata.className}>
153
149
  <DocsVersionProvider version={versionMetadata}>
154
150
  <DocsSidebarProvider sidebar={sidebar ?? null}>
155
151
  <DocPageContent
@@ -162,6 +158,6 @@ export default function DocPage(props) {
162
158
  </DocPageContent>
163
159
  </DocsSidebarProvider>
164
160
  </DocsVersionProvider>
165
- </>
161
+ </HtmlClassNameProvider>
166
162
  );
167
163
  }
@@ -7,35 +7,39 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {
10
- MobileSecondaryMenuFiller,
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 = ({toggleSidebar, sidebar, path}) => (
17
- <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
18
- <DocSidebarItems
19
- items={sidebar}
20
- activePath={path}
21
- onItemClick={(item) => {
22
- // Mobile sidebar should only be closed if the category has a link
23
- if (item.type === 'category' && item.href) {
24
- toggleSidebar();
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
- if (item.type === 'link') {
28
- toggleSidebar();
29
- }
30
- }}
31
- level={1}
32
- />
33
- </ul>
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
- <MobileSecondaryMenuFiller
42
+ <NavbarSecondaryMenuFiller
39
43
  component={DocSidebarMobileSecondaryMenu}
40
44
  props={props}
41
45
  />
@@ -10,8 +10,9 @@ import {
10
10
  TabGroupChoiceProvider,
11
11
  AnnouncementBarProvider,
12
12
  DocsPreferredVersionContextProvider,
13
- MobileSecondaryMenuProvider,
14
13
  ScrollControllerProvider,
14
+ NavbarProvider,
15
+ PluginHtmlClassNameProvider,
15
16
  } from '@docusaurus/theme-common';
16
17
  export default function LayoutProviders({children}) {
17
18
  return (
@@ -20,9 +21,9 @@ export default function LayoutProviders({children}) {
20
21
  <TabGroupChoiceProvider>
21
22
  <ScrollControllerProvider>
22
23
  <DocsPreferredVersionContextProvider>
23
- <MobileSecondaryMenuProvider>
24
- {children}
25
- </MobileSecondaryMenuProvider>
24
+ <PluginHtmlClassNameProvider>
25
+ <NavbarProvider>{children}</NavbarProvider>
26
+ </PluginHtmlClassNameProvider>
26
27
  </DocsPreferredVersionContextProvider>
27
28
  </ScrollControllerProvider>
28
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
+ }