@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.
- package/lib/theme-classic.d.ts +63 -33
- package/lib-next/theme/BlogArchivePage/index.js +13 -9
- package/lib-next/theme/BlogListPage/index.js +34 -13
- package/lib-next/theme/BlogPostPage/index.js +56 -45
- package/lib-next/theme/BlogTagsListPage/index.js +16 -12
- package/lib-next/theme/BlogTagsPostsPage/index.js +40 -33
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +27 -6
- package/lib-next/theme/DocItem/index.js +78 -63
- package/lib-next/theme/DocPage/index.js +85 -77
- package/lib-next/theme/DocPage/styles.module.css +0 -4
- package/lib-next/theme/DocSidebar/Mobile/index.js +24 -20
- package/lib-next/theme/DocTagDocListPage/index.js +38 -31
- package/lib-next/theme/DocTagsListPage/index.js +21 -16
- package/lib-next/theme/Layout/index.js +15 -10
- package/lib-next/theme/LayoutProviders/index.js +4 -6
- package/lib-next/theme/MDXPage/index.js +32 -26
- 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/{src/theme/Navbar → lib-next/theme/Navbar/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/lib-next/theme/NotFound.js +38 -33
- package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +11 -26
- package/package.json +13 -13
- package/src/theme/BlogArchivePage/index.tsx +13 -9
- package/src/theme/BlogListPage/index.tsx +32 -13
- package/src/theme/BlogPostPage/index.tsx +55 -48
- package/src/theme/BlogTagsListPage/index.tsx +16 -12
- package/src/theme/BlogTagsPostsPage/index.tsx +39 -32
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +31 -4
- package/src/theme/DocItem/index.tsx +65 -52
- package/src/theme/DocPage/index.tsx +85 -77
- package/src/theme/DocPage/styles.module.css +0 -4
- package/src/theme/DocSidebar/Mobile/index.tsx +26 -23
- package/src/theme/DocTagDocListPage/index.tsx +38 -30
- package/src/theme/DocTagsListPage/index.tsx +21 -16
- package/src/theme/Layout/index.tsx +15 -10
- package/src/theme/LayoutProviders/index.tsx +4 -6
- package/src/theme/MDXPage/index.tsx +32 -26
- 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/{lib-next/theme/Navbar → src/theme/Navbar/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/NotFound.tsx +38 -33
- package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +11 -25
- package/src/theme-classic.d.ts +63 -33
- package/lib-next/theme/Seo/index.js +0 -40
- package/src/theme/Seo/index.tsx +0 -49
|
@@ -8,40 +8,43 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
type
|
|
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:
|
|
20
|
-
toggleSidebar,
|
|
20
|
+
const DocSidebarMobileSecondaryMenu: NavbarSecondaryMenuComponent<Props> = ({
|
|
21
21
|
sidebar,
|
|
22
22
|
path,
|
|
23
|
-
}) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
<
|
|
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 {
|
|
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
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
</
|
|
87
|
-
</
|
|
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
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
</
|
|
37
|
-
</
|
|
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 {
|
|
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 {
|
|
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
|
-
<
|
|
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
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
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 {
|
|
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,
|
|
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
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
<div className={clsx('
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
}
|