@docusaurus/theme-classic 0.0.0-4735 → 0.0.0-4738

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 (65) hide show
  1. package/lib/theme-classic.d.ts +63 -33
  2. package/lib-next/theme/BlogArchivePage/index.js +13 -9
  3. package/lib-next/theme/BlogListPage/index.js +34 -13
  4. package/lib-next/theme/BlogPostPage/index.js +56 -45
  5. package/lib-next/theme/BlogTagsListPage/index.js +16 -12
  6. package/lib-next/theme/BlogTagsPostsPage/index.js +40 -33
  7. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +27 -6
  8. package/lib-next/theme/DocItem/index.js +78 -63
  9. package/lib-next/theme/DocPage/index.js +85 -77
  10. package/lib-next/theme/DocPage/styles.module.css +0 -4
  11. package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
  12. package/lib-next/theme/DocTagDocListPage/index.js +38 -31
  13. package/lib-next/theme/DocTagsListPage/index.js +21 -16
  14. package/lib-next/theme/Layout/index.js +15 -10
  15. package/lib-next/theme/LayoutProviders/index.js +4 -6
  16. package/lib-next/theme/MDXPage/index.js +32 -26
  17. package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
  18. package/lib-next/theme/Navbar/Content/index.js +70 -0
  19. package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
  20. package/lib-next/theme/Navbar/Layout/index.js +54 -0
  21. package/{src/theme/Navbar → lib-next/theme/Navbar/Layout}/styles.module.css +0 -13
  22. package/lib-next/theme/Navbar/Logo/index.js +17 -0
  23. package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
  24. package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
  25. package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
  26. package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
  27. package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
  28. package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
  29. package/lib-next/theme/Navbar/index.js +6 -273
  30. package/lib-next/theme/NotFound.js +38 -33
  31. package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +11 -26
  32. package/package.json +13 -13
  33. package/src/theme/BlogArchivePage/index.tsx +13 -9
  34. package/src/theme/BlogListPage/index.tsx +32 -13
  35. package/src/theme/BlogPostPage/index.tsx +55 -48
  36. package/src/theme/BlogTagsListPage/index.tsx +16 -12
  37. package/src/theme/BlogTagsPostsPage/index.tsx +39 -32
  38. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +31 -4
  39. package/src/theme/DocItem/index.tsx +65 -52
  40. package/src/theme/DocPage/index.tsx +85 -77
  41. package/src/theme/DocPage/styles.module.css +0 -4
  42. package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
  43. package/src/theme/DocTagDocListPage/index.tsx +38 -30
  44. package/src/theme/DocTagsListPage/index.tsx +21 -16
  45. package/src/theme/Layout/index.tsx +15 -10
  46. package/src/theme/LayoutProviders/index.tsx +4 -6
  47. package/src/theme/MDXPage/index.tsx +32 -26
  48. package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
  49. package/src/theme/Navbar/Content/index.tsx +81 -0
  50. package/src/theme/Navbar/Content/styles.module.css +15 -0
  51. package/src/theme/Navbar/Layout/index.tsx +57 -0
  52. package/{lib-next/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -13
  53. package/src/theme/Navbar/Logo/index.tsx +19 -0
  54. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
  55. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
  56. package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
  57. package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
  58. package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
  59. package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
  60. package/src/theme/Navbar/index.tsx +6 -292
  61. package/src/theme/NotFound.tsx +38 -33
  62. package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +11 -25
  63. package/src/theme-classic.d.ts +63 -33
  64. package/lib-next/theme/Seo/index.js +0 -40
  65. package/src/theme/Seo/index.tsx +0 -49
@@ -10,10 +10,6 @@
10
10
  --doc-sidebar-hidden-width: 30px;
11
11
  }
12
12
 
13
- :global(.docs-wrapper) {
14
- display: flex;
15
- }
16
-
17
13
  .docPage,
18
14
  .docMainContainer {
19
15
  display: flex;
@@ -8,40 +8,43 @@
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
10
  import {
11
- MobileSecondaryMenuFiller,
12
- type MobileSecondaryMenuComponent,
11
+ NavbarSecondaryMenuFiller,
12
+ type NavbarSecondaryMenuComponent,
13
13
  ThemeClassNames,
14
+ useNavbarMobileSidebar,
14
15
  } from '@docusaurus/theme-common';
15
16
  import DocSidebarItems from '@theme/DocSidebarItems';
16
17
  import type {Props} from '@theme/DocSidebar/Mobile';
17
18
 
18
19
  // eslint-disable-next-line react/function-component-definition
19
- const DocSidebarMobileSecondaryMenu: MobileSecondaryMenuComponent<Props> = ({
20
- toggleSidebar,
20
+ const DocSidebarMobileSecondaryMenu: NavbarSecondaryMenuComponent<Props> = ({
21
21
  sidebar,
22
22
  path,
23
- }) => (
24
- <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
25
- <DocSidebarItems
26
- items={sidebar}
27
- activePath={path}
28
- onItemClick={(item) => {
29
- // Mobile sidebar should only be closed if the category has a link
30
- if (item.type === 'category' && item.href) {
31
- toggleSidebar();
32
- }
33
- if (item.type === 'link') {
34
- toggleSidebar();
35
- }
36
- }}
37
- level={1}
38
- />
39
- </ul>
40
- );
23
+ }) => {
24
+ const mobileSidebar = useNavbarMobileSidebar();
25
+ return (
26
+ <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
27
+ <DocSidebarItems
28
+ items={sidebar}
29
+ activePath={path}
30
+ onItemClick={(item) => {
31
+ // Mobile sidebar should only be closed if the category has a link
32
+ if (item.type === 'category' && item.href) {
33
+ mobileSidebar.toggle();
34
+ }
35
+ if (item.type === 'link') {
36
+ mobileSidebar.toggle();
37
+ }
38
+ }}
39
+ level={1}
40
+ />
41
+ </ul>
42
+ );
43
+ };
41
44
 
42
45
  function DocSidebarMobile(props: Props) {
43
46
  return (
44
- <MobileSecondaryMenuFiller
47
+ <NavbarSecondaryMenuFiller
45
48
  component={DocSidebarMobileSecondaryMenu}
46
49
  props={props}
47
50
  />
@@ -9,10 +9,17 @@ import React from 'react';
9
9
 
10
10
  import Layout from '@theme/Layout';
11
11
  import Link from '@docusaurus/Link';
12
- import {ThemeClassNames, usePluralForm} from '@docusaurus/theme-common';
12
+ import {
13
+ PageMetadata,
14
+ HtmlClassNameProvider,
15
+ ThemeClassNames,
16
+ usePluralForm,
17
+ } from '@docusaurus/theme-common';
13
18
  import type {PropTagDocListDoc} from '@docusaurus/plugin-content-docs';
14
19
  import Translate, {translate} from '@docusaurus/Translate';
15
20
  import type {Props} from '@theme/DocTagDocListPage';
21
+ import SearchMetadata from '@theme/SearchMetadata';
22
+ import clsx from 'clsx';
16
23
 
17
24
  // Very simple pluralization: probably good enough for now
18
25
  function useNDocsTaggedPlural() {
@@ -55,35 +62,36 @@ export default function DocTagDocListPage({tag}: Props): JSX.Element {
55
62
  );
56
63
 
57
64
  return (
58
- <Layout
59
- title={title}
60
- wrapperClassName={ThemeClassNames.wrapper.docsPages}
61
- pageClassName={ThemeClassNames.page.docsTagDocListPage}
62
- searchMetadata={{
63
- // assign unique search tag to exclude this page from search results!
64
- tag: 'doc_tag_doc_list',
65
- }}>
66
- <div className="container margin-vert--lg">
67
- <div className="row">
68
- <main className="col col--8 col--offset-2">
69
- <header className="margin-bottom--xl">
70
- <h1>{title}</h1>
71
- <Link href={tag.allTagsPath}>
72
- <Translate
73
- id="theme.tags.tagsPageLink"
74
- description="The label of the link targeting the tag list page">
75
- View All Tags
76
- </Translate>
77
- </Link>
78
- </header>
79
- <section className="margin-vert--lg">
80
- {tag.docs.map((doc) => (
81
- <DocItem key={doc.id} doc={doc} />
82
- ))}
83
- </section>
84
- </main>
65
+ <HtmlClassNameProvider
66
+ className={clsx(
67
+ ThemeClassNames.wrapper.docsPages,
68
+ ThemeClassNames.page.docsTagDocListPage,
69
+ )}>
70
+ <PageMetadata title={title} />
71
+ <SearchMetadata tag="doc_tag_doc_list" />
72
+ <Layout>
73
+ <div className="container margin-vert--lg">
74
+ <div className="row">
75
+ <main className="col col--8 col--offset-2">
76
+ <header className="margin-bottom--xl">
77
+ <h1>{title}</h1>
78
+ <Link href={tag.allTagsPath}>
79
+ <Translate
80
+ id="theme.tags.tagsPageLink"
81
+ description="The label of the link targeting the tag list page">
82
+ View All Tags
83
+ </Translate>
84
+ </Link>
85
+ </header>
86
+ <section className="margin-vert--lg">
87
+ {tag.docs.map((doc) => (
88
+ <DocItem key={doc.id} doc={doc} />
89
+ ))}
90
+ </section>
91
+ </main>
92
+ </div>
85
93
  </div>
86
- </div>
87
- </Layout>
94
+ </Layout>
95
+ </HtmlClassNameProvider>
88
96
  );
89
97
  }
@@ -9,31 +9,36 @@ import React from 'react';
9
9
 
10
10
  import Layout from '@theme/Layout';
11
11
  import {
12
+ PageMetadata,
13
+ HtmlClassNameProvider,
12
14
  ThemeClassNames,
13
15
  translateTagsPageTitle,
14
16
  } from '@docusaurus/theme-common';
15
17
  import TagsListByLetter from '@theme/TagsListByLetter';
16
18
  import type {Props} from '@theme/DocTagsListPage';
19
+ import SearchMetadata from '@theme/SearchMetadata';
20
+ import clsx from 'clsx';
17
21
 
18
22
  export default function DocTagsListPage({tags}: Props): JSX.Element {
19
23
  const title = translateTagsPageTitle();
20
24
  return (
21
- <Layout
22
- title={title}
23
- wrapperClassName={ThemeClassNames.wrapper.docsPages}
24
- pageClassName={ThemeClassNames.page.docsTagsListPage}
25
- searchMetadata={{
26
- // assign unique search tag to exclude this page from search results!
27
- tag: 'doc_tags_list',
28
- }}>
29
- <div className="container margin-vert--lg">
30
- <div className="row">
31
- <main className="col col--8 col--offset-2">
32
- <h1>{title}</h1>
33
- <TagsListByLetter tags={tags} />
34
- </main>
25
+ <HtmlClassNameProvider
26
+ className={clsx(
27
+ ThemeClassNames.wrapper.docsPages,
28
+ ThemeClassNames.page.docsTagsListPage,
29
+ )}>
30
+ <PageMetadata title={title} />
31
+ <SearchMetadata tag="doc_tags_list" />
32
+ <Layout>
33
+ <div className="container margin-vert--lg">
34
+ <div className="row">
35
+ <main className="col col--8 col--offset-2">
36
+ <h1>{title}</h1>
37
+ <TagsListByLetter tags={tags} />
38
+ </main>
39
+ </div>
35
40
  </div>
36
- </div>
37
- </Layout>
41
+ </Layout>
42
+ </HtmlClassNameProvider>
38
43
  );
39
44
  }
@@ -13,20 +13,30 @@ import AnnouncementBar from '@theme/AnnouncementBar';
13
13
  import Navbar from '@theme/Navbar';
14
14
  import Footer from '@theme/Footer';
15
15
  import LayoutProviders from '@theme/LayoutProviders';
16
- import LayoutHead from '@theme/LayoutHead';
17
16
  import type {Props} from '@theme/Layout';
18
- import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
17
+ import {
18
+ PageMetadata,
19
+ ThemeClassNames,
20
+ useKeyboardNavigation,
21
+ } from '@docusaurus/theme-common';
19
22
  import ErrorPageContent from '@theme/ErrorPageContent';
20
23
  import './styles.css';
21
24
 
22
25
  export default function Layout(props: Props): JSX.Element {
23
- const {children, noFooter, wrapperClassName, pageClassName} = props;
26
+ const {
27
+ children,
28
+ noFooter,
29
+ wrapperClassName,
30
+ // not really layout-related, but kept for convenience/retro-compatibility
31
+ title,
32
+ description,
33
+ } = props;
24
34
 
25
35
  useKeyboardNavigation();
26
36
 
27
37
  return (
28
38
  <LayoutProviders>
29
- <LayoutHead {...props} />
39
+ <PageMetadata title={title} description={description} />
30
40
 
31
41
  <SkipToContent />
32
42
 
@@ -34,12 +44,7 @@ export default function Layout(props: Props): JSX.Element {
34
44
 
35
45
  <Navbar />
36
46
 
37
- <div
38
- className={clsx(
39
- ThemeClassNames.wrapper.main,
40
- wrapperClassName,
41
- pageClassName,
42
- )}>
47
+ <div className={clsx(ThemeClassNames.wrapper.main, wrapperClassName)}>
43
48
  <ErrorBoundary fallback={ErrorPageContent}>{children}</ErrorBoundary>
44
49
  </div>
45
50
 
@@ -11,8 +11,8 @@ import {
11
11
  TabGroupChoiceProvider,
12
12
  AnnouncementBarProvider,
13
13
  DocsPreferredVersionContextProvider,
14
- MobileSecondaryMenuProvider,
15
14
  ScrollControllerProvider,
15
+ NavbarProvider,
16
16
  PluginHtmlClassNameProvider,
17
17
  } from '@docusaurus/theme-common';
18
18
  import type {Props} from '@theme/LayoutProviders';
@@ -24,11 +24,9 @@ export default function LayoutProviders({children}: Props): JSX.Element {
24
24
  <TabGroupChoiceProvider>
25
25
  <ScrollControllerProvider>
26
26
  <DocsPreferredVersionContextProvider>
27
- <MobileSecondaryMenuProvider>
28
- <PluginHtmlClassNameProvider>
29
- {children}
30
- </PluginHtmlClassNameProvider>
31
- </MobileSecondaryMenuProvider>
27
+ <PluginHtmlClassNameProvider>
28
+ <NavbarProvider>{children}</NavbarProvider>
29
+ </PluginHtmlClassNameProvider>
32
30
  </DocsPreferredVersionContextProvider>
33
31
  </ScrollControllerProvider>
34
32
  </TabGroupChoiceProvider>
@@ -11,43 +11,49 @@ import Layout from '@theme/Layout';
11
11
  import MDXContent from '@theme/MDXContent';
12
12
  import type {Props} from '@theme/MDXPage';
13
13
  import TOC from '@theme/TOC';
14
- import {ThemeClassNames} from '@docusaurus/theme-common';
14
+ import {
15
+ PageMetadata,
16
+ HtmlClassNameProvider,
17
+ ThemeClassNames,
18
+ } from '@docusaurus/theme-common';
15
19
 
16
20
  import styles from './styles.module.css';
17
21
 
18
22
  export default function MDXPage(props: Props): JSX.Element {
19
23
  const {content: MDXPageContent} = props;
20
24
  const {
21
- metadata: {title, description, permalink, frontMatter},
25
+ metadata: {title, description, frontMatter},
22
26
  } = MDXPageContent;
23
27
  const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
24
28
  frontMatter;
25
29
 
26
30
  return (
27
- <Layout
28
- title={title}
29
- description={description}
30
- permalink={permalink}
31
- wrapperClassName={wrapperClassName ?? ThemeClassNames.wrapper.mdxPages}
32
- pageClassName={ThemeClassNames.page.mdxPage}>
33
- <main className="container container--fluid margin-vert--lg">
34
- <div className={clsx('row', styles.mdxPageWrapper)}>
35
- <div className={clsx('col', !hideTableOfContents && 'col--8')}>
36
- <MDXContent>
37
- <MDXPageContent />
38
- </MDXContent>
39
- </div>
40
- {!hideTableOfContents && MDXPageContent.toc && (
41
- <div className="col col--2">
42
- <TOC
43
- toc={MDXPageContent.toc}
44
- minHeadingLevel={frontMatter.toc_min_heading_level}
45
- maxHeadingLevel={frontMatter.toc_max_heading_level}
46
- />
31
+ <HtmlClassNameProvider
32
+ className={clsx(
33
+ wrapperClassName ?? ThemeClassNames.wrapper.mdxPages,
34
+ ThemeClassNames.page.mdxPage,
35
+ )}>
36
+ <PageMetadata title={title} description={description} />
37
+ <Layout>
38
+ <main className="container container--fluid margin-vert--lg">
39
+ <div className={clsx('row', styles.mdxPageWrapper)}>
40
+ <div className={clsx('col', !hideTableOfContents && 'col--8')}>
41
+ <MDXContent>
42
+ <MDXPageContent />
43
+ </MDXContent>
47
44
  </div>
48
- )}
49
- </div>
50
- </main>
51
- </Layout>
45
+ {!hideTableOfContents && MDXPageContent.toc && (
46
+ <div className="col col--2">
47
+ <TOC
48
+ toc={MDXPageContent.toc}
49
+ minHeadingLevel={frontMatter.toc_min_heading_level}
50
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
51
+ />
52
+ </div>
53
+ )}
54
+ </div>
55
+ </main>
56
+ </Layout>
57
+ </HtmlClassNameProvider>
52
58
  );
53
59
  }
@@ -0,0 +1,30 @@
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 {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
9
+ import ColorModeToggle from '@theme/ColorModeToggle';
10
+ import type {Props} from '@theme/Navbar/ColorModeToggle';
11
+ import React from 'react';
12
+
13
+ export default function NavbarColorModeToggle({
14
+ className,
15
+ }: Props): JSX.Element | null {
16
+ const disabled = useThemeConfig().colorMode.disableSwitch;
17
+ const {colorMode, setColorMode} = useColorMode();
18
+
19
+ if (disabled) {
20
+ return null;
21
+ }
22
+
23
+ return (
24
+ <ColorModeToggle
25
+ className={className}
26
+ value={colorMode}
27
+ onChange={setColorMode}
28
+ />
29
+ );
30
+ }
@@ -0,0 +1,81 @@
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, {type ReactNode} from 'react';
9
+ import type {Props as NavbarItemConfig} from '@theme/NavbarItem';
10
+ import NavbarItem from '@theme/NavbarItem';
11
+ import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
12
+ import SearchBar from '@theme/SearchBar';
13
+ import {
14
+ splitNavbarItems,
15
+ useNavbarMobileSidebar,
16
+ useThemeConfig,
17
+ } from '@docusaurus/theme-common';
18
+ import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
19
+ import NavbarLogo from '@theme/Navbar/Logo';
20
+ import styles from './styles.module.css';
21
+
22
+ function useNavbarItems() {
23
+ // TODO temporary casting until ThemeConfig type is improved
24
+ return useThemeConfig().navbar.items as NavbarItemConfig[];
25
+ }
26
+
27
+ function NavbarItems({items}: {items: NavbarItemConfig[]}): JSX.Element {
28
+ return (
29
+ <>
30
+ {items.map((item, i) => (
31
+ <NavbarItem {...item} key={i} />
32
+ ))}
33
+ </>
34
+ );
35
+ }
36
+
37
+ function NavbarContentLayout({
38
+ left,
39
+ right,
40
+ }: {
41
+ left: ReactNode;
42
+ right: ReactNode;
43
+ }) {
44
+ return (
45
+ <div className="navbar__inner">
46
+ <div className="navbar__items">{left}</div>
47
+ <div className="navbar__items navbar__items--right">{right}</div>
48
+ </div>
49
+ );
50
+ }
51
+
52
+ export default function NavbarContent(): JSX.Element {
53
+ const mobileSidebar = useNavbarMobileSidebar();
54
+
55
+ const items = useNavbarItems();
56
+ const [leftItems, rightItems] = splitNavbarItems(items);
57
+
58
+ const autoAddSearchBar = !items.some((item) => item.type === 'search');
59
+
60
+ return (
61
+ <NavbarContentLayout
62
+ left={
63
+ // TODO stop hardcoding items?
64
+ <>
65
+ {!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
66
+ <NavbarLogo />
67
+ <NavbarItems items={leftItems} />
68
+ </>
69
+ }
70
+ right={
71
+ // TODO stop hardcoding items?
72
+ // Ask the user to add the respective navbar items => more flexible
73
+ <>
74
+ <NavbarItems items={rightItems} />
75
+ <NavbarColorModeToggle className={styles.colorModeToggle} />
76
+ {autoAddSearchBar && <SearchBar />}
77
+ </>
78
+ }
79
+ />
80
+ );
81
+ }
@@ -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,57 @@
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, {type ComponentProps} from 'react';
9
+ import clsx from 'clsx';
10
+ import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
11
+ import type {Props} from '@theme/Navbar/Layout';
12
+ import {
13
+ useThemeConfig,
14
+ useHideableNavbar,
15
+ useNavbarMobileSidebar,
16
+ } from '@docusaurus/theme-common';
17
+
18
+ import styles from './styles.module.css';
19
+
20
+ function NavbarBackdrop(props: ComponentProps<'div'>) {
21
+ return (
22
+ <div
23
+ role="presentation"
24
+ {...props}
25
+ className={clsx('navbar-sidebar__backdrop', props.className)}
26
+ />
27
+ );
28
+ }
29
+
30
+ export default function NavbarLayout({children}: Props): JSX.Element {
31
+ const {
32
+ navbar: {hideOnScroll, style},
33
+ } = useThemeConfig();
34
+ const mobileSidebar = useNavbarMobileSidebar();
35
+ const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
36
+ return (
37
+ <nav
38
+ ref={navbarRef}
39
+ className={clsx(
40
+ 'navbar',
41
+ 'navbar--fixed-top',
42
+ hideOnScroll && [
43
+ styles.navbarHideable,
44
+ !isNavbarVisible && styles.navbarHidden,
45
+ ],
46
+ {
47
+ 'navbar--dark': style === 'dark',
48
+ 'navbar--primary': style === 'primary',
49
+ 'navbar-sidebar--show': mobileSidebar.shown,
50
+ },
51
+ )}>
52
+ {children}
53
+ <NavbarBackdrop onClick={mobileSidebar.toggle} />
54
+ <NavbarMobileSidebar />
55
+ </nav>
56
+ );
57
+ }
@@ -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,19 @@
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 Logo from '@theme/Logo';
10
+
11
+ export default function NavbarLogo(): JSX.Element {
12
+ return (
13
+ <Logo
14
+ className="navbar__brand"
15
+ imageClassName="navbar__logo"
16
+ titleClassName="navbar__title"
17
+ />
18
+ );
19
+ }
@@ -0,0 +1,34 @@
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 NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
10
+ import IconClose from '@theme/IconClose';
11
+ import NavbarLogo from '@theme/Navbar/Logo';
12
+ import {useNavbarMobileSidebar} from '@docusaurus/theme-common';
13
+
14
+ function CloseButton() {
15
+ const mobileSidebar = useNavbarMobileSidebar();
16
+ return (
17
+ <button
18
+ type="button"
19
+ className="clean-btn navbar-sidebar__close"
20
+ onClick={() => mobileSidebar.toggle()}>
21
+ <IconClose color="var(--ifm-color-emphasis-600)" />
22
+ </button>
23
+ );
24
+ }
25
+
26
+ export default function NavbarMobileSidebarHeader(): JSX.Element {
27
+ return (
28
+ <div className="navbar-sidebar__brand">
29
+ <NavbarLogo />
30
+ <NavbarColorModeToggle className="margin-right--md" />
31
+ <CloseButton />
32
+ </div>
33
+ );
34
+ }
@@ -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
+
8
+ import React from 'react';
9
+ import clsx from 'clsx';
10
+ import type {Props} from '@theme/Navbar/MobileSidebar/Layout';
11
+ import {useNavbarSecondaryMenu} from '@docusaurus/theme-common';
12
+
13
+ export default function NavbarMobileSidebarLayout({
14
+ header,
15
+ primaryMenu,
16
+ secondaryMenu,
17
+ }: Props): JSX.Element {
18
+ const {shown: secondaryMenuShown} = useNavbarSecondaryMenu();
19
+ return (
20
+ <div className="navbar-sidebar">
21
+ {header}
22
+ <div
23
+ className={clsx('navbar-sidebar__items', {
24
+ 'navbar-sidebar__items--show-secondary': secondaryMenuShown,
25
+ })}>
26
+ <div className="navbar-sidebar__item menu">{primaryMenu}</div>
27
+ <div className="navbar-sidebar__item menu">{secondaryMenu}</div>
28
+ </div>
29
+ </div>
30
+ );
31
+ }