@docusaurus/theme-classic 2.0.0-beta.18 → 2.0.0-beta.19
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/admonitions.css +4 -0
- package/lib/default.css +3038 -0
- package/lib/getSwizzleConfig.js +9 -2
- package/lib/index.js +4 -4
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +315 -33
- package/lib/validateThemeConfig.js +72 -14
- package/lib-next/theme/BackToTopButton/index.js +6 -102
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +3 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPaginator/index.js +25 -28
- package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
- package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
- package/lib-next/theme/BlogSidebar/index.js +11 -31
- package/lib-next/theme/BlogTagsListPage/index.js +2 -3
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
- package/lib-next/theme/CodeBlock/Container/index.js +29 -0
- package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
- package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
- package/lib-next/theme/CodeBlock/Content/String.js +104 -0
- package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/lib-next/theme/CodeBlock/Line/index.js +49 -0
- package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/lib-next/theme/CodeBlock/index.js +27 -133
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/lib-next/theme/DocCardList/index.js +6 -4
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +1 -1
- package/lib-next/theme/DocItem/styles.module.css +6 -0
- package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
- package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/lib-next/theme/DocPage/Layout/index.js +34 -0
- package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/lib-next/theme/DocPage/index.js +28 -146
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
- package/lib-next/theme/DocSidebarItem/index.js +4 -246
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +3 -3
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
- package/lib-next/theme/Heading/index.js +4 -20
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +1 -1
- package/lib-next/theme/MDXComponents/Ul.js +2 -4
- package/lib-next/theme/Navbar/Content/index.js +6 -1
- package/lib-next/theme/Navbar/Logo/index.js +1 -1
- package/lib-next/theme/Navbar/Search/index.js +11 -0
- package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
- package/lib-next/theme/NavbarItem/index.js +4 -23
- package/lib-next/theme/NavbarItem/utils.js +2 -1
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SiteMetadata/index.js +8 -7
- package/lib-next/theme/SkipToContent/index.js +3 -29
- package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
- package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/lib-next/theme/TOCCollapsible/index.js +3 -13
- package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
- package/lib-next/theme/TOCItems/Tree.js +40 -0
- package/lib-next/theme/TOCItems/index.js +3 -34
- package/lib-next/theme/TabItem/index.js +3 -1
- package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
- package/lib-next/theme/Tabs/index.js +3 -3
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +2 -3
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/package.json +23 -18
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +10 -2
- package/src/index.ts +4 -3
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -112
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +3 -7
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPaginator/index.tsx +25 -28
- package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
- package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
- package/src/theme/BlogSidebar/index.tsx +10 -31
- package/src/theme/BlogTagsListPage/index.tsx +2 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
- package/src/theme/CodeBlock/Container/index.tsx +35 -0
- package/src/theme/CodeBlock/Container/styles.module.css +14 -0
- package/src/theme/CodeBlock/Content/Element.tsx +30 -0
- package/src/theme/CodeBlock/Content/String.tsx +111 -0
- package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
- package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/src/theme/CodeBlock/Line/index.tsx +48 -0
- package/src/theme/CodeBlock/Line/styles.module.css +51 -0
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme/CodeBlock/index.tsx +29 -133
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +50 -20
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/src/theme/DocCardList/index.tsx +5 -7
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +1 -1
- package/src/theme/DocItem/styles.module.css +6 -0
- package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
- package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
- package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/src/theme/DocPage/Layout/index.tsx +39 -0
- package/src/theme/DocPage/index.tsx +28 -157
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
- package/src/theme/DocSidebarItem/Html.tsx +34 -0
- package/src/theme/DocSidebarItem/Link.module.css +10 -0
- package/src/theme/DocSidebarItem/Link.tsx +58 -0
- package/src/theme/DocSidebarItem/index.tsx +4 -259
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +3 -4
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +4 -18
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +1 -1
- package/src/theme/MDXComponents/Details.tsx +2 -3
- package/src/theme/MDXComponents/Ul.tsx +2 -6
- package/src/theme/Navbar/Content/index.tsx +6 -1
- package/src/theme/Navbar/Logo/index.tsx +1 -1
- package/src/theme/Navbar/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -38
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SiteMetadata/index.tsx +8 -8
- package/src/theme/SkipToContent/index.tsx +3 -29
- package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
- package/src/theme/TOCCollapsible/index.module.css +31 -0
- package/src/theme/TOCCollapsible/index.tsx +3 -14
- package/src/theme/TOCItems/Tree.tsx +46 -0
- package/src/theme/TOCItems/index.tsx +2 -41
- package/src/theme/TabItem/index.tsx +7 -1
- package/src/theme/TabItem/styles.module.css +10 -0
- package/src/theme/Tabs/index.tsx +3 -3
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +2 -4
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme-classic.d.ts +315 -33
- package/src/validateThemeConfig.ts +80 -13
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -82
- package/src/theme/DocPage/styles.module.css +0 -82
- package/src/types.d.ts +0 -11
|
@@ -0,0 +1,39 @@
|
|
|
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, {useState} from 'react';
|
|
9
|
+
import Layout from '@theme/Layout';
|
|
10
|
+
import BackToTopButton from '@theme/BackToTopButton';
|
|
11
|
+
import type {Props} from '@theme/DocPage/Layout';
|
|
12
|
+
import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
|
|
13
|
+
import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
|
|
14
|
+
|
|
15
|
+
import styles from './index.module.css';
|
|
16
|
+
|
|
17
|
+
import {useDocsSidebar} from '@docusaurus/theme-common';
|
|
18
|
+
|
|
19
|
+
export default function DocPageLayout({children}: Props): JSX.Element {
|
|
20
|
+
const sidebar = useDocsSidebar();
|
|
21
|
+
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
|
22
|
+
return (
|
|
23
|
+
<Layout wrapperClassName={styles.docsWrapper}>
|
|
24
|
+
<BackToTopButton />
|
|
25
|
+
<div className={styles.docPage}>
|
|
26
|
+
{sidebar && (
|
|
27
|
+
<DocPageLayoutSidebar
|
|
28
|
+
sidebar={sidebar.items}
|
|
29
|
+
hiddenSidebarContainer={hiddenSidebarContainer}
|
|
30
|
+
setHiddenSidebarContainer={setHiddenSidebarContainer}
|
|
31
|
+
/>
|
|
32
|
+
)}
|
|
33
|
+
<DocPageLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
|
|
34
|
+
{children}
|
|
35
|
+
</DocPageLayoutMain>
|
|
36
|
+
</div>
|
|
37
|
+
</Layout>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -5,181 +5,52 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React
|
|
9
|
-
import renderRoutes from '@docusaurus/renderRoutes';
|
|
10
|
-
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
11
|
-
import Layout from '@theme/Layout';
|
|
12
|
-
import DocSidebar from '@theme/DocSidebar';
|
|
8
|
+
import React from 'react';
|
|
13
9
|
import NotFound from '@theme/NotFound';
|
|
14
|
-
import type {DocumentRoute} from '@theme/DocItem';
|
|
15
10
|
import type {Props} from '@theme/DocPage';
|
|
16
|
-
import
|
|
17
|
-
import BackToTopButton from '@theme/BackToTopButton';
|
|
18
|
-
import {matchPath} from '@docusaurus/router';
|
|
19
|
-
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import DocPageLayout from '@theme/DocPage/Layout';
|
|
20
12
|
|
|
21
13
|
import clsx from 'clsx';
|
|
22
|
-
import styles from './styles.module.css';
|
|
23
14
|
|
|
24
15
|
import {
|
|
25
16
|
HtmlClassNameProvider,
|
|
26
17
|
ThemeClassNames,
|
|
27
18
|
docVersionSearchTag,
|
|
28
19
|
DocsSidebarProvider,
|
|
29
|
-
useDocsSidebar,
|
|
30
20
|
DocsVersionProvider,
|
|
21
|
+
useDocRouteMetadata,
|
|
31
22
|
} from '@docusaurus/theme-common';
|
|
32
23
|
import SearchMetadata from '@theme/SearchMetadata';
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function DocPageContent({
|
|
42
|
-
currentDocRoute,
|
|
43
|
-
versionMetadata,
|
|
44
|
-
children,
|
|
45
|
-
sidebarName,
|
|
46
|
-
}: DocPageContentProps): JSX.Element {
|
|
47
|
-
const sidebar = useDocsSidebar();
|
|
48
|
-
const {pluginId, version} = versionMetadata;
|
|
49
|
-
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
|
50
|
-
const [hiddenSidebar, setHiddenSidebar] = useState(false);
|
|
51
|
-
const toggleSidebar = useCallback(() => {
|
|
52
|
-
if (hiddenSidebar) {
|
|
53
|
-
setHiddenSidebar(false);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
setHiddenSidebarContainer((value) => !value);
|
|
57
|
-
}, [hiddenSidebar]);
|
|
58
|
-
|
|
25
|
+
export default function DocPage(props: Props): JSX.Element {
|
|
26
|
+
const {versionMetadata} = props;
|
|
27
|
+
const currentDocRouteMetadata = useDocRouteMetadata(props);
|
|
28
|
+
if (!currentDocRouteMetadata) {
|
|
29
|
+
return <NotFound />;
|
|
30
|
+
}
|
|
31
|
+
const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
|
|
59
32
|
return (
|
|
60
33
|
<>
|
|
61
34
|
<SearchMetadata
|
|
62
|
-
version={version}
|
|
63
|
-
tag={docVersionSearchTag(
|
|
35
|
+
version={versionMetadata.version}
|
|
36
|
+
tag={docVersionSearchTag(
|
|
37
|
+
versionMetadata.pluginId,
|
|
38
|
+
versionMetadata.version,
|
|
39
|
+
)}
|
|
64
40
|
/>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
!e.currentTarget.classList.contains(
|
|
79
|
-
styles.docSidebarContainer!,
|
|
80
|
-
)
|
|
81
|
-
) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (hiddenSidebarContainer) {
|
|
86
|
-
setHiddenSidebar(true);
|
|
87
|
-
}
|
|
88
|
-
}}>
|
|
89
|
-
<DocSidebar
|
|
90
|
-
key={
|
|
91
|
-
// Reset sidebar state on sidebar changes
|
|
92
|
-
// See https://github.com/facebook/docusaurus/issues/3414
|
|
93
|
-
sidebarName
|
|
94
|
-
}
|
|
95
|
-
sidebar={sidebar}
|
|
96
|
-
path={currentDocRoute.path}
|
|
97
|
-
onCollapse={toggleSidebar}
|
|
98
|
-
isHidden={hiddenSidebar}
|
|
99
|
-
/>
|
|
100
|
-
|
|
101
|
-
{hiddenSidebar && (
|
|
102
|
-
<div
|
|
103
|
-
className={styles.collapsedDocSidebar}
|
|
104
|
-
title={translate({
|
|
105
|
-
id: 'theme.docs.sidebar.expandButtonTitle',
|
|
106
|
-
message: 'Expand sidebar',
|
|
107
|
-
description:
|
|
108
|
-
'The ARIA label and title attribute for expand button of doc sidebar',
|
|
109
|
-
})}
|
|
110
|
-
aria-label={translate({
|
|
111
|
-
id: 'theme.docs.sidebar.expandButtonAriaLabel',
|
|
112
|
-
message: 'Expand sidebar',
|
|
113
|
-
description:
|
|
114
|
-
'The ARIA label and title attribute for expand button of doc sidebar',
|
|
115
|
-
})}
|
|
116
|
-
tabIndex={0}
|
|
117
|
-
role="button"
|
|
118
|
-
onKeyDown={toggleSidebar}
|
|
119
|
-
onClick={toggleSidebar}>
|
|
120
|
-
<IconArrow className={styles.expandSidebarButtonIcon} />
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
123
|
-
</aside>
|
|
124
|
-
)}
|
|
125
|
-
<main
|
|
126
|
-
className={clsx(
|
|
127
|
-
styles.docMainContainer,
|
|
128
|
-
(hiddenSidebarContainer || !sidebar) &&
|
|
129
|
-
styles.docMainContainerEnhanced,
|
|
130
|
-
)}>
|
|
131
|
-
<div
|
|
132
|
-
className={clsx(
|
|
133
|
-
'container padding-top--md padding-bottom--lg',
|
|
134
|
-
styles.docItemWrapper,
|
|
135
|
-
hiddenSidebarContainer && styles.docItemWrapperEnhanced,
|
|
136
|
-
)}>
|
|
137
|
-
{children}
|
|
138
|
-
</div>
|
|
139
|
-
</main>
|
|
140
|
-
</div>
|
|
141
|
-
</Layout>
|
|
41
|
+
<HtmlClassNameProvider
|
|
42
|
+
className={clsx(
|
|
43
|
+
// TODO: it should be removed from here
|
|
44
|
+
ThemeClassNames.wrapper.docsPages,
|
|
45
|
+
ThemeClassNames.page.docsDocPage,
|
|
46
|
+
props.versionMetadata.className,
|
|
47
|
+
)}>
|
|
48
|
+
<DocsVersionProvider version={versionMetadata}>
|
|
49
|
+
<DocsSidebarProvider name={sidebarName} items={sidebarItems}>
|
|
50
|
+
<DocPageLayout>{docElement}</DocPageLayout>
|
|
51
|
+
</DocsSidebarProvider>
|
|
52
|
+
</DocsVersionProvider>
|
|
53
|
+
</HtmlClassNameProvider>
|
|
142
54
|
</>
|
|
143
55
|
);
|
|
144
56
|
}
|
|
145
|
-
|
|
146
|
-
export default function DocPage(props: Props): JSX.Element {
|
|
147
|
-
const {
|
|
148
|
-
route: {routes: docRoutes},
|
|
149
|
-
versionMetadata,
|
|
150
|
-
location,
|
|
151
|
-
} = props;
|
|
152
|
-
const currentDocRoute = docRoutes.find((docRoute) =>
|
|
153
|
-
matchPath(location.pathname, docRoute),
|
|
154
|
-
);
|
|
155
|
-
if (!currentDocRoute) {
|
|
156
|
-
return <NotFound />;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// For now, the sidebarName is added as route config: not ideal!
|
|
160
|
-
const sidebarName = currentDocRoute.sidebar;
|
|
161
|
-
|
|
162
|
-
const sidebar = sidebarName
|
|
163
|
-
? versionMetadata.docsSidebars[sidebarName]
|
|
164
|
-
: null;
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<HtmlClassNameProvider
|
|
168
|
-
className={clsx(
|
|
169
|
-
ThemeClassNames.wrapper.docsPages,
|
|
170
|
-
ThemeClassNames.page.docsDocPage,
|
|
171
|
-
versionMetadata.className,
|
|
172
|
-
)}>
|
|
173
|
-
<DocsVersionProvider version={versionMetadata}>
|
|
174
|
-
<DocsSidebarProvider sidebar={sidebar ?? null}>
|
|
175
|
-
<DocPageContent
|
|
176
|
-
currentDocRoute={currentDocRoute}
|
|
177
|
-
versionMetadata={versionMetadata}
|
|
178
|
-
sidebarName={sidebarName}>
|
|
179
|
-
{renderRoutes(docRoutes, {versionMetadata})}
|
|
180
|
-
</DocPageContent>
|
|
181
|
-
</DocsSidebarProvider>
|
|
182
|
-
</DocsVersionProvider>
|
|
183
|
-
</HtmlClassNameProvider>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
@@ -21,34 +21,31 @@ export default function DocPaginator(props: Props): JSX.Element {
|
|
|
21
21
|
message: 'Docs pages navigation',
|
|
22
22
|
description: 'The ARIA label for the docs pagination',
|
|
23
23
|
})}>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
24
|
+
{previous && (
|
|
25
|
+
<PaginatorNavLink
|
|
26
|
+
{...previous}
|
|
27
|
+
subLabel={
|
|
28
|
+
<Translate
|
|
29
|
+
id="theme.docs.paginator.previous"
|
|
30
|
+
description="The label used to navigate to the previous doc">
|
|
31
|
+
Previous
|
|
32
|
+
</Translate>
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
{next && (
|
|
37
|
+
<PaginatorNavLink
|
|
38
|
+
{...next}
|
|
39
|
+
subLabel={
|
|
40
|
+
<Translate
|
|
41
|
+
id="theme.docs.paginator.next"
|
|
42
|
+
description="The label used to navigate to the next doc">
|
|
43
|
+
Next
|
|
44
|
+
</Translate>
|
|
45
|
+
}
|
|
46
|
+
isNext
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
52
49
|
</nav>
|
|
53
50
|
);
|
|
54
51
|
}
|
|
@@ -6,13 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
:root {
|
|
9
|
-
--collapse-button-bg
|
|
9
|
+
--docusaurus-collapse-button-bg: transparent;
|
|
10
|
+
--docusaurus-collapse-button-bg-hover: rgb(0 0 0 / 10%);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[data-theme='dark']:root {
|
|
14
|
+
--docusaurus-collapse-button-bg: rgb(255 255 255 / 5%);
|
|
15
|
+
--docusaurus-collapse-button-bg-hover: rgb(255 255 255 / 10%);
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
@media (min-width: 997px) {
|
|
13
19
|
.collapseSidebarButton {
|
|
14
20
|
display: block !important;
|
|
15
|
-
background-color: var(--
|
|
21
|
+
background-color: var(--docusaurus-collapse-button-bg);
|
|
16
22
|
height: 40px;
|
|
17
23
|
position: sticky;
|
|
18
24
|
bottom: 0;
|
|
@@ -29,13 +35,9 @@
|
|
|
29
35
|
transform: rotate(0);
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
[data-theme='dark'] .collapseSidebarButton:hover,
|
|
37
|
-
[data-theme='dark'] .collapseSidebarButton:focus {
|
|
38
|
-
background-color: var(--ifm-color-emphasis-200);
|
|
38
|
+
.collapseSidebarButton:hover,
|
|
39
|
+
.collapseSidebarButton:focus {
|
|
40
|
+
background-color: var(--docusaurus-collapse-button-bg-hover);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
flex-grow: 1;
|
|
11
11
|
padding: 0.5rem;
|
|
12
12
|
}
|
|
13
|
+
@supports (scrollbar-gutter: stable) {
|
|
14
|
+
.menu {
|
|
15
|
+
padding: 0.5rem 0 0.5rem 0.5rem;
|
|
16
|
+
scrollbar-gutter: stable;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
13
19
|
|
|
14
20
|
.menuWithAnnouncementBar {
|
|
15
21
|
margin-bottom: var(--docusaurus-announcement-bar-height);
|
|
@@ -18,7 +18,9 @@ import styles from './styles.module.css';
|
|
|
18
18
|
function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
|
|
19
19
|
const {
|
|
20
20
|
navbar: {hideOnScroll},
|
|
21
|
-
|
|
21
|
+
docs: {
|
|
22
|
+
sidebar: {hideable},
|
|
23
|
+
},
|
|
22
24
|
} = useThemeConfig();
|
|
23
25
|
|
|
24
26
|
return (
|
|
@@ -30,7 +32,7 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
|
|
|
30
32
|
)}>
|
|
31
33
|
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
|
|
32
34
|
<Content path={path} sidebar={sidebar} />
|
|
33
|
-
{
|
|
35
|
+
{hideable && <CollapseButton onClick={onCollapse} />}
|
|
34
36
|
</div>
|
|
35
37
|
);
|
|
36
38
|
}
|
|
@@ -0,0 +1,210 @@
|
|
|
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, useEffect, useMemo} from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import {
|
|
11
|
+
isActiveSidebarItem,
|
|
12
|
+
usePrevious,
|
|
13
|
+
Collapsible,
|
|
14
|
+
useCollapsible,
|
|
15
|
+
findFirstCategoryLink,
|
|
16
|
+
ThemeClassNames,
|
|
17
|
+
useThemeConfig,
|
|
18
|
+
useDocSidebarItemsExpandedState,
|
|
19
|
+
isSamePath,
|
|
20
|
+
} from '@docusaurus/theme-common';
|
|
21
|
+
import Link from '@docusaurus/Link';
|
|
22
|
+
import {translate} from '@docusaurus/Translate';
|
|
23
|
+
|
|
24
|
+
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
25
|
+
import type {Props} from '@theme/DocSidebarItem/Category';
|
|
26
|
+
|
|
27
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
28
|
+
|
|
29
|
+
// If we navigate to a category and it becomes active, it should automatically
|
|
30
|
+
// expand itself
|
|
31
|
+
function useAutoExpandActiveCategory({
|
|
32
|
+
isActive,
|
|
33
|
+
collapsed,
|
|
34
|
+
setCollapsed,
|
|
35
|
+
}: {
|
|
36
|
+
isActive: boolean;
|
|
37
|
+
collapsed: boolean;
|
|
38
|
+
setCollapsed: (b: boolean) => void;
|
|
39
|
+
}) {
|
|
40
|
+
const wasActive = usePrevious(isActive);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const justBecameActive = isActive && !wasActive;
|
|
43
|
+
if (justBecameActive && collapsed) {
|
|
44
|
+
setCollapsed(false);
|
|
45
|
+
}
|
|
46
|
+
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* When a collapsible category has no link, we still link it to its first child
|
|
51
|
+
* during SSR as a temporary fallback. This allows to be able to navigate inside
|
|
52
|
+
* the category even when JS fails to load, is delayed or simply disabled
|
|
53
|
+
* React hydration becomes an optional progressive enhancement
|
|
54
|
+
* see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
|
55
|
+
* see https://github.com/facebook/docusaurus/issues/3030
|
|
56
|
+
*/
|
|
57
|
+
function useCategoryHrefWithSSRFallback(
|
|
58
|
+
item: Props['item'],
|
|
59
|
+
): string | undefined {
|
|
60
|
+
const isBrowser = useIsBrowser();
|
|
61
|
+
return useMemo(() => {
|
|
62
|
+
if (item.href) {
|
|
63
|
+
return item.href;
|
|
64
|
+
}
|
|
65
|
+
// In these cases, it's not necessary to render a fallback
|
|
66
|
+
// We skip the "findFirstCategoryLink" computation
|
|
67
|
+
if (isBrowser || !item.collapsible) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return findFirstCategoryLink(item);
|
|
71
|
+
}, [item, isBrowser]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function CollapseButton({
|
|
75
|
+
categoryLabel,
|
|
76
|
+
onClick,
|
|
77
|
+
}: {
|
|
78
|
+
categoryLabel: string;
|
|
79
|
+
onClick: ComponentProps<'button'>['onClick'];
|
|
80
|
+
}) {
|
|
81
|
+
return (
|
|
82
|
+
<button
|
|
83
|
+
aria-label={translate(
|
|
84
|
+
{
|
|
85
|
+
id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
|
|
86
|
+
message: "Toggle the collapsible sidebar category '{label}'",
|
|
87
|
+
description:
|
|
88
|
+
'The ARIA label to toggle the collapsible sidebar category',
|
|
89
|
+
},
|
|
90
|
+
{label: categoryLabel},
|
|
91
|
+
)}
|
|
92
|
+
type="button"
|
|
93
|
+
className="clean-btn menu__caret"
|
|
94
|
+
onClick={onClick}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default function DocSidebarItemCategory({
|
|
100
|
+
item,
|
|
101
|
+
onItemClick,
|
|
102
|
+
activePath,
|
|
103
|
+
level,
|
|
104
|
+
index,
|
|
105
|
+
...props
|
|
106
|
+
}: Props): JSX.Element {
|
|
107
|
+
const {items, label, collapsible, className, href} = item;
|
|
108
|
+
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
109
|
+
|
|
110
|
+
const isActive = isActiveSidebarItem(item, activePath);
|
|
111
|
+
const isCurrentPage = isSamePath(href, activePath);
|
|
112
|
+
|
|
113
|
+
const {collapsed, setCollapsed} = useCollapsible({
|
|
114
|
+
// Active categories are always initialized as expanded. The default
|
|
115
|
+
// (`item.collapsed`) is only used for non-active categories.
|
|
116
|
+
initialState: () => {
|
|
117
|
+
if (!collapsible) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return isActive ? false : item.collapsed;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
useAutoExpandActiveCategory({isActive, collapsed, setCollapsed});
|
|
125
|
+
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
|
126
|
+
function updateCollapsed(toCollapsed: boolean = !collapsed) {
|
|
127
|
+
setExpandedItem(toCollapsed ? null : index);
|
|
128
|
+
setCollapsed(toCollapsed);
|
|
129
|
+
}
|
|
130
|
+
const {
|
|
131
|
+
docs: {
|
|
132
|
+
sidebar: {autoCollapseCategories},
|
|
133
|
+
},
|
|
134
|
+
} = useThemeConfig();
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (
|
|
137
|
+
collapsible &&
|
|
138
|
+
expandedItem &&
|
|
139
|
+
expandedItem !== index &&
|
|
140
|
+
autoCollapseCategories
|
|
141
|
+
) {
|
|
142
|
+
setCollapsed(true);
|
|
143
|
+
}
|
|
144
|
+
}, [collapsible, expandedItem, index, setCollapsed, autoCollapseCategories]);
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<li
|
|
148
|
+
className={clsx(
|
|
149
|
+
ThemeClassNames.docs.docSidebarItemCategory,
|
|
150
|
+
ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
|
|
151
|
+
'menu__list-item',
|
|
152
|
+
{
|
|
153
|
+
'menu__list-item--collapsed': collapsed,
|
|
154
|
+
},
|
|
155
|
+
className,
|
|
156
|
+
)}>
|
|
157
|
+
<div
|
|
158
|
+
className={clsx('menu__list-item-collapsible', {
|
|
159
|
+
'menu__list-item-collapsible--active': isCurrentPage,
|
|
160
|
+
})}>
|
|
161
|
+
<Link
|
|
162
|
+
className={clsx('menu__link', {
|
|
163
|
+
'menu__link--sublist': collapsible,
|
|
164
|
+
'menu__link--sublist-caret': !href && collapsible,
|
|
165
|
+
'menu__link--active': isActive,
|
|
166
|
+
})}
|
|
167
|
+
onClick={
|
|
168
|
+
collapsible
|
|
169
|
+
? (e) => {
|
|
170
|
+
onItemClick?.(item);
|
|
171
|
+
if (href) {
|
|
172
|
+
updateCollapsed(false);
|
|
173
|
+
} else {
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
updateCollapsed();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
: () => {
|
|
179
|
+
onItemClick?.(item);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
aria-current={isCurrentPage ? 'page' : undefined}
|
|
183
|
+
aria-expanded={collapsible ? !collapsed : undefined}
|
|
184
|
+
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
|
185
|
+
{...props}>
|
|
186
|
+
{label}
|
|
187
|
+
</Link>
|
|
188
|
+
{href && collapsible && (
|
|
189
|
+
<CollapseButton
|
|
190
|
+
categoryLabel={label}
|
|
191
|
+
onClick={(e) => {
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
updateCollapsed();
|
|
194
|
+
}}
|
|
195
|
+
/>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
200
|
+
<DocSidebarItems
|
|
201
|
+
items={items}
|
|
202
|
+
tabIndex={collapsed ? -1 : 0}
|
|
203
|
+
onItemClick={onItemClick}
|
|
204
|
+
activePath={activePath}
|
|
205
|
+
level={level + 1}
|
|
206
|
+
/>
|
|
207
|
+
</Collapsible>
|
|
208
|
+
</li>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
@@ -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 clsx from 'clsx';
|
|
10
|
+
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
11
|
+
import type {Props} from '@theme/DocSidebarItem/Html';
|
|
12
|
+
|
|
13
|
+
import styles from './Html.module.css';
|
|
14
|
+
|
|
15
|
+
export default function DocSidebarItemHtml({
|
|
16
|
+
item,
|
|
17
|
+
level,
|
|
18
|
+
index,
|
|
19
|
+
}: Props): JSX.Element {
|
|
20
|
+
const {value, defaultStyle, className} = item;
|
|
21
|
+
return (
|
|
22
|
+
<li
|
|
23
|
+
className={clsx(
|
|
24
|
+
ThemeClassNames.docs.docSidebarItemLink,
|
|
25
|
+
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
|
26
|
+
defaultStyle && `${styles.menuHtmlItem} menu__list-item`,
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
key={index}
|
|
30
|
+
// eslint-disable-next-line react/no-danger
|
|
31
|
+
dangerouslySetInnerHTML={{__html: value}}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|