@docusaurus/theme-classic 2.0.0-beta.16 → 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 +177 -36
- package/lib/index.js +10 -15
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +600 -76
- package/lib/translations.js +12 -2
- package/lib/validateThemeConfig.js +77 -28
- package/lib-next/theme/BackToTopButton/index.js +6 -104
- package/lib-next/theme/BlogArchivePage/index.js +14 -10
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPage/index.js +34 -13
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +16 -7
- package/lib-next/theme/BlogPostItem/index.js +6 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPage/index.js +56 -45
- 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 +17 -14
- package/lib-next/theme/BlogTagsPostsPage/index.js +43 -38
- 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/lib-next/theme/CodeBlock/{styles.module.css → Content/styles.module.css} +39 -29
- package/lib-next/theme/CodeBlock/CopyButton/index.js +61 -0
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- 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 +26 -164
- package/lib-next/theme/ColorModeToggle/index.js +62 -0
- package/lib-next/theme/ColorModeToggle/styles.module.css +35 -0
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +63 -19
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -15
- package/lib-next/theme/DocCard/index.js +17 -15
- package/lib-next/theme/DocCard/styles.module.css +8 -17
- package/lib-next/theme/DocCardList/index.js +20 -6
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +30 -9
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +85 -67
- 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 +30 -149
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/lib-next/theme/DocSidebar/Desktop/Content/index.js +46 -0
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +36 -0
- package/lib-next/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/lib-next/theme/DocSidebar/Mobile/index.js +49 -0
- package/lib-next/theme/DocSidebar/index.js +6 -113
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/lib-next/theme/DocSidebarItem/{styles.module.css → Html.module.css} +0 -0
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/lib-next/theme/DocSidebarItem/Link.module.css +10 -0
- package/lib-next/theme/DocSidebarItem/index.js +4 -245
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +40 -33
- package/lib-next/theme/DocTagsListPage/index.js +21 -16
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Copyright/index.js +18 -0
- package/lib-next/theme/Footer/Layout/index.js +26 -0
- package/lib-next/theme/Footer/LinkItem/index.js +33 -0
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +47 -0
- package/lib-next/theme/Footer/Links/Simple/index.js +41 -0
- package/lib-next/theme/Footer/Links/index.js +17 -0
- package/lib-next/theme/Footer/Logo/index.js +38 -0
- package/lib-next/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
- package/lib-next/theme/Footer/index.js +11 -163
- package/lib-next/theme/Heading/index.js +10 -24
- package/lib-next/theme/IconDarkMode/index.js +17 -0
- package/lib-next/theme/IconExternalLink/styles.module.css +0 -2
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/IconLanguage/index.js +3 -3
- package/lib-next/theme/IconLightMode/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +15 -10
- package/lib-next/theme/LayoutProviders/index.js +5 -4
- package/lib-next/theme/MDXComponents/A.js +11 -0
- package/lib-next/theme/MDXComponents/Code.js +28 -0
- package/lib-next/theme/MDXComponents/Details.js +20 -0
- package/lib-next/theme/MDXComponents/Head.js +26 -0
- package/lib-next/theme/MDXComponents/Heading.js +11 -0
- package/lib-next/theme/MDXComponents/Img.js +24 -0
- package/{src/theme/MDXComponents/styles.css → lib-next/theme/MDXComponents/Img.module.css} +1 -6
- package/lib-next/theme/MDXComponents/Pre.js +18 -0
- package/lib-next/theme/MDXComponents/Ul.js +21 -0
- package/lib-next/theme/MDXComponents/index.js +22 -57
- package/lib-next/theme/MDXContent/index.js +12 -0
- package/lib-next/theme/MDXPage/index.js +33 -28
- package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
- package/lib-next/theme/Navbar/Content/index.js +75 -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/Search/index.js +11 -0
- package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
- package/lib-next/theme/Navbar/index.js +6 -271
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +2 -6
- 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 +14 -3
- 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 -35
- 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/NotFound.js +38 -33
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SearchMetadata/index.js +9 -0
- package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +19 -33
- 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 +4 -16
- 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/TabItem/styles.module.css +10 -0
- package/lib-next/theme/Tabs/__tests__/index.test.js +8 -8
- package/lib-next/theme/Tabs/index.js +5 -5
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +6 -7
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/lib-next/theme/ThemedImage/index.js +3 -3
- package/package.json +25 -20
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +173 -22
- package/src/index.ts +14 -15
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -114
- package/src/theme/BlogArchivePage/index.tsx +18 -17
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPage/index.tsx +32 -13
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +14 -8
- package/src/theme/BlogPostItem/index.tsx +6 -6
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPage/index.tsx +55 -48
- 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 +17 -14
- package/src/theme/BlogTagsPostsPage/index.tsx +46 -36
- 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/src/theme/CodeBlock/{styles.module.css → Content/styles.module.css} +39 -29
- package/src/theme/CodeBlock/CopyButton/index.tsx +67 -0
- package/src/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- 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 -165
- package/src/theme/ColorModeToggle/index.tsx +67 -0
- package/src/theme/ColorModeToggle/styles.module.css +35 -0
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +65 -16
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -15
- package/src/theme/DocCard/index.tsx +24 -17
- package/src/theme/DocCard/styles.module.css +8 -17
- package/src/theme/DocCardList/index.tsx +19 -10
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +34 -7
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +72 -56
- 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 +30 -160
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +40 -0
- package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/src/theme/DocSidebar/Mobile/index.tsx +54 -0
- package/src/theme/DocSidebar/index.tsx +6 -121
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/src/theme/DocSidebarItem/{styles.module.css → Html.module.css} +0 -0
- 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 -260
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +40 -33
- package/src/theme/DocTagsListPage/index.tsx +21 -16
- package/src/theme/DocVersionBanner/index.tsx +5 -6
- package/src/theme/Footer/Copyright/index.tsx +20 -0
- package/src/theme/Footer/Layout/index.tsx +34 -0
- package/src/theme/Footer/LinkItem/index.tsx +36 -0
- package/src/theme/Footer/Links/MultiColumn/index.tsx +51 -0
- package/src/theme/Footer/Links/Simple/index.tsx +42 -0
- package/src/theme/Footer/Links/index.tsx +21 -0
- package/src/theme/Footer/Logo/index.tsx +41 -0
- package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
- package/src/theme/Footer/index.tsx +12 -186
- package/src/theme/Heading/index.tsx +10 -22
- package/src/theme/IconDarkMode/index.tsx +20 -0
- package/src/theme/IconExternalLink/styles.module.css +0 -2
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/IconLanguage/index.tsx +3 -3
- package/src/theme/IconLightMode/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +15 -10
- package/src/theme/LayoutProviders/index.tsx +5 -4
- package/src/theme/MDXComponents/A.tsx +14 -0
- package/src/theme/MDXComponents/Code.tsx +37 -0
- package/src/theme/MDXComponents/Details.tsx +25 -0
- package/src/theme/MDXComponents/Head.tsx +29 -0
- package/src/theme/MDXComponents/Heading.tsx +14 -0
- package/{lib-next/theme/MDXComponents/styles.css → src/theme/MDXComponents/Img.module.css} +1 -6
- package/src/theme/MDXComponents/Img.tsx +26 -0
- package/src/theme/MDXComponents/Pre.tsx +22 -0
- package/src/theme/MDXComponents/Ul.tsx +24 -0
- package/src/theme/MDXComponents/index.tsx +23 -66
- package/src/theme/MDXContent/index.tsx +15 -0
- package/src/theme/MDXPage/index.tsx +33 -28
- package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
- package/src/theme/Navbar/Content/index.tsx +86 -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/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/Navbar/index.tsx +6 -286
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +2 -2
- 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 +15 -3
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -29
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -39
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/NotFound.tsx +38 -33
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SearchMetadata/index.tsx +9 -0
- package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +19 -33
- 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 +4 -17
- 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 +8 -9
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +6 -8
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme/ThemedImage/index.tsx +4 -3
- package/src/theme-classic.d.ts +600 -76
- package/src/translations.ts +12 -6
- package/src/validateThemeConfig.ts +90 -39
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -86
- package/lib-next/theme/DocSidebar/styles.module.css +0 -107
- package/lib-next/theme/Seo/index.js +0 -40
- package/lib-next/theme/Toggle/index.js +0 -100
- package/lib-next/theme/Toggle/styles.module.css +0 -106
- package/src/theme/DocPage/styles.module.css +0 -86
- package/src/theme/DocSidebar/styles.module.css +0 -107
- package/src/theme/Seo/index.tsx +0 -49
- package/src/theme/Toggle/index.tsx +0 -117
- package/src/theme/Toggle/styles.module.css +0 -106
- package/src/types.d.ts +0 -11
|
@@ -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
|
+
import React from 'react';
|
|
9
|
+
import type {Props} from '@theme/Navbar/Search';
|
|
10
|
+
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
|
|
13
|
+
export default function NavbarSearch({children}: Props): JSX.Element {
|
|
14
|
+
return <div className={styles.searchBox}>{children}</div>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
@media (max-width: 996px) {
|
|
9
|
+
.searchBox {
|
|
10
|
+
position: absolute;
|
|
11
|
+
right: var(--ifm-navbar-padding-horizontal);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@media (min-width: 997px) {
|
|
16
|
+
.searchBox {
|
|
17
|
+
padding: var(--ifm-navbar-item-padding-vertical)
|
|
18
|
+
var(--ifm-navbar-item-padding-horizontal);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -5,294 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import SearchBar from '@theme/SearchBar';
|
|
12
|
-
import Toggle from '@theme/Toggle';
|
|
13
|
-
import {
|
|
14
|
-
useThemeConfig,
|
|
15
|
-
useMobileSecondaryMenuRenderer,
|
|
16
|
-
usePrevious,
|
|
17
|
-
useHistoryPopHandler,
|
|
18
|
-
useHideableNavbar,
|
|
19
|
-
useLockBodyScroll,
|
|
20
|
-
useWindowSize,
|
|
21
|
-
useColorMode,
|
|
22
|
-
} from '@docusaurus/theme-common';
|
|
23
|
-
import {useActivePlugin} from '@docusaurus/plugin-content-docs/client';
|
|
24
|
-
import NavbarItem, {type Props as NavbarItemConfig} from '@theme/NavbarItem';
|
|
25
|
-
import Logo from '@theme/Logo';
|
|
26
|
-
import IconMenu from '@theme/IconMenu';
|
|
27
|
-
import IconClose from '@theme/IconClose';
|
|
28
|
-
|
|
29
|
-
import styles from './styles.module.css';
|
|
30
|
-
|
|
31
|
-
// retrocompatible with v1
|
|
32
|
-
const DefaultNavItemPosition = 'right';
|
|
33
|
-
|
|
34
|
-
function useNavbarItems() {
|
|
35
|
-
// TODO temporary casting until ThemeConfig type is improved
|
|
36
|
-
return useThemeConfig().navbar.items as NavbarItemConfig[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// If split links by left/right
|
|
40
|
-
// if position is unspecified, fallback to right (as v1)
|
|
41
|
-
function splitNavItemsByPosition(items: NavbarItemConfig[]) {
|
|
42
|
-
const leftItems = items.filter(
|
|
43
|
-
(item) => (item.position ?? DefaultNavItemPosition) === 'left',
|
|
44
|
-
);
|
|
45
|
-
const rightItems = items.filter(
|
|
46
|
-
(item) => (item.position ?? DefaultNavItemPosition) === 'right',
|
|
47
|
-
);
|
|
48
|
-
return {
|
|
49
|
-
leftItems,
|
|
50
|
-
rightItems,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function useMobileSidebar() {
|
|
55
|
-
const windowSize = useWindowSize();
|
|
56
|
-
|
|
57
|
-
// Mobile sidebar not visible on hydration: can avoid SSR rendering
|
|
58
|
-
const shouldRender = windowSize === 'mobile'; // || windowSize === 'ssr';
|
|
59
|
-
|
|
60
|
-
const [shown, setShown] = useState(false);
|
|
61
|
-
|
|
62
|
-
// Close mobile sidebar on navigation pop
|
|
63
|
-
// Most likely firing when using the Android back button (but not only)
|
|
64
|
-
useHistoryPopHandler(() => {
|
|
65
|
-
if (shown) {
|
|
66
|
-
setShown(false);
|
|
67
|
-
// Should we prevent the navigation here?
|
|
68
|
-
// See https://github.com/facebook/docusaurus/pull/5462#issuecomment-911699846
|
|
69
|
-
return false; // prevent pop navigation
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const toggle = useCallback(() => {
|
|
75
|
-
setShown((s) => !s);
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (windowSize === 'desktop') {
|
|
80
|
-
setShown(false);
|
|
81
|
-
}
|
|
82
|
-
}, [windowSize]);
|
|
83
|
-
|
|
84
|
-
return {shouldRender, toggle, shown};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function useColorModeToggle() {
|
|
88
|
-
const {
|
|
89
|
-
colorMode: {disableSwitch},
|
|
90
|
-
} = useThemeConfig();
|
|
91
|
-
const {isDarkTheme, setLightTheme, setDarkTheme} = useColorMode();
|
|
92
|
-
const toggle = useCallback(
|
|
93
|
-
(e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
|
|
94
|
-
[setLightTheme, setDarkTheme],
|
|
95
|
-
);
|
|
96
|
-
return {isDarkTheme, toggle, disabled: disableSwitch};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function useSecondaryMenu({
|
|
100
|
-
sidebarShown,
|
|
101
|
-
toggleSidebar,
|
|
102
|
-
}: NavbarMobileSidebarProps) {
|
|
103
|
-
const content = useMobileSecondaryMenuRenderer()?.({
|
|
104
|
-
toggleSidebar,
|
|
105
|
-
});
|
|
106
|
-
const previousContent = usePrevious(content);
|
|
107
|
-
|
|
108
|
-
const [shown, setShown] = useState<boolean>(
|
|
109
|
-
() =>
|
|
110
|
-
// /!\ content is set with useEffect,
|
|
111
|
-
// so it's not available on mount anyway
|
|
112
|
-
// "return !!content" => always returns false
|
|
113
|
-
false,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
// When content is become available for the first time (set in useEffect)
|
|
117
|
-
// we set this content to be shown!
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
const contentBecameAvailable = content && !previousContent;
|
|
120
|
-
if (contentBecameAvailable) {
|
|
121
|
-
setShown(true);
|
|
122
|
-
}
|
|
123
|
-
}, [content, previousContent]);
|
|
124
|
-
|
|
125
|
-
const hasContent = !!content;
|
|
126
|
-
|
|
127
|
-
// On sidebar close, secondary menu is set to be shown on next re-opening
|
|
128
|
-
// (if any secondary menu content available)
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!hasContent) {
|
|
131
|
-
setShown(false);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (!sidebarShown) {
|
|
135
|
-
setShown(true);
|
|
136
|
-
}
|
|
137
|
-
}, [sidebarShown, hasContent]);
|
|
138
|
-
|
|
139
|
-
const hide = useCallback(() => {
|
|
140
|
-
setShown(false);
|
|
141
|
-
}, []);
|
|
142
|
-
|
|
143
|
-
return {shown, hide, content};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
type NavbarMobileSidebarProps = {
|
|
147
|
-
sidebarShown: boolean;
|
|
148
|
-
toggleSidebar: () => void;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
function NavbarMobileSidebar({
|
|
152
|
-
sidebarShown,
|
|
153
|
-
toggleSidebar,
|
|
154
|
-
}: NavbarMobileSidebarProps) {
|
|
155
|
-
useLockBodyScroll(sidebarShown);
|
|
156
|
-
const items = useNavbarItems();
|
|
157
|
-
|
|
158
|
-
const colorModeToggle = useColorModeToggle();
|
|
159
|
-
|
|
160
|
-
const secondaryMenu = useSecondaryMenu({
|
|
161
|
-
sidebarShown,
|
|
162
|
-
toggleSidebar,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<div className="navbar-sidebar">
|
|
167
|
-
<div className="navbar-sidebar__brand">
|
|
168
|
-
<Logo
|
|
169
|
-
className="navbar__brand"
|
|
170
|
-
imageClassName="navbar__logo"
|
|
171
|
-
titleClassName="navbar__title"
|
|
172
|
-
/>
|
|
173
|
-
{!colorModeToggle.disabled && (
|
|
174
|
-
<Toggle
|
|
175
|
-
className={styles.navbarSidebarToggle}
|
|
176
|
-
checked={colorModeToggle.isDarkTheme}
|
|
177
|
-
onChange={colorModeToggle.toggle}
|
|
178
|
-
/>
|
|
179
|
-
)}
|
|
180
|
-
<button
|
|
181
|
-
type="button"
|
|
182
|
-
className="clean-btn navbar-sidebar__close"
|
|
183
|
-
onClick={toggleSidebar}>
|
|
184
|
-
<IconClose
|
|
185
|
-
color="var(--ifm-color-emphasis-600)"
|
|
186
|
-
className={styles.navbarSidebarCloseSvg}
|
|
187
|
-
/>
|
|
188
|
-
</button>
|
|
189
|
-
</div>
|
|
190
|
-
|
|
191
|
-
<div
|
|
192
|
-
className={clsx('navbar-sidebar__items', {
|
|
193
|
-
'navbar-sidebar__items--show-secondary': secondaryMenu.shown,
|
|
194
|
-
})}>
|
|
195
|
-
<div className="navbar-sidebar__item menu">
|
|
196
|
-
<ul className="menu__list">
|
|
197
|
-
{items.map((item, i) => (
|
|
198
|
-
<NavbarItem mobile {...item} onClick={toggleSidebar} key={i} />
|
|
199
|
-
))}
|
|
200
|
-
</ul>
|
|
201
|
-
</div>
|
|
202
|
-
|
|
203
|
-
<div className="navbar-sidebar__item menu">
|
|
204
|
-
{items.length > 0 && (
|
|
205
|
-
<button
|
|
206
|
-
type="button"
|
|
207
|
-
className="clean-btn navbar-sidebar__back"
|
|
208
|
-
onClick={secondaryMenu.hide}>
|
|
209
|
-
<Translate
|
|
210
|
-
id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel"
|
|
211
|
-
description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)">
|
|
212
|
-
← Back to main menu
|
|
213
|
-
</Translate>
|
|
214
|
-
</button>
|
|
215
|
-
)}
|
|
216
|
-
{secondaryMenu.content}
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
</div>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import NavbarLayout from '@theme/Navbar/Layout';
|
|
10
|
+
import NavbarContent from '@theme/Navbar/Content';
|
|
222
11
|
|
|
223
12
|
export default function Navbar(): JSX.Element {
|
|
224
|
-
const {
|
|
225
|
-
navbar: {hideOnScroll, style},
|
|
226
|
-
} = useThemeConfig();
|
|
227
|
-
|
|
228
|
-
const mobileSidebar = useMobileSidebar();
|
|
229
|
-
const colorModeToggle = useColorModeToggle();
|
|
230
|
-
const activeDocPlugin = useActivePlugin();
|
|
231
|
-
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
|
|
232
|
-
|
|
233
|
-
const items = useNavbarItems();
|
|
234
|
-
const hasSearchNavbarItem = items.some((item) => item.type === 'search');
|
|
235
|
-
const {leftItems, rightItems} = splitNavItemsByPosition(items);
|
|
236
|
-
|
|
237
13
|
return (
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
'navbar--dark': style === 'dark',
|
|
242
|
-
'navbar--primary': style === 'primary',
|
|
243
|
-
'navbar-sidebar--show': mobileSidebar.shown,
|
|
244
|
-
[styles.navbarHideable]: hideOnScroll,
|
|
245
|
-
[styles.navbarHidden]: hideOnScroll && !isNavbarVisible,
|
|
246
|
-
})}>
|
|
247
|
-
<div className="navbar__inner">
|
|
248
|
-
<div className="navbar__items">
|
|
249
|
-
{(items?.length > 0 || activeDocPlugin) && (
|
|
250
|
-
<button
|
|
251
|
-
aria-label="Navigation bar toggle"
|
|
252
|
-
className="navbar__toggle clean-btn"
|
|
253
|
-
type="button"
|
|
254
|
-
tabIndex={0}
|
|
255
|
-
onClick={mobileSidebar.toggle}
|
|
256
|
-
onKeyDown={mobileSidebar.toggle}>
|
|
257
|
-
<IconMenu />
|
|
258
|
-
</button>
|
|
259
|
-
)}
|
|
260
|
-
<Logo
|
|
261
|
-
className="navbar__brand"
|
|
262
|
-
imageClassName="navbar__logo"
|
|
263
|
-
titleClassName="navbar__title"
|
|
264
|
-
/>
|
|
265
|
-
{leftItems.map((item, i) => (
|
|
266
|
-
<NavbarItem {...item} key={i} />
|
|
267
|
-
))}
|
|
268
|
-
</div>
|
|
269
|
-
<div className="navbar__items navbar__items--right">
|
|
270
|
-
{rightItems.map((item, i) => (
|
|
271
|
-
<NavbarItem {...item} key={i} />
|
|
272
|
-
))}
|
|
273
|
-
{!colorModeToggle.disabled && (
|
|
274
|
-
<Toggle
|
|
275
|
-
className={styles.toggle}
|
|
276
|
-
checked={colorModeToggle.isDarkTheme}
|
|
277
|
-
onChange={colorModeToggle.toggle}
|
|
278
|
-
/>
|
|
279
|
-
)}
|
|
280
|
-
{!hasSearchNavbarItem && <SearchBar />}
|
|
281
|
-
</div>
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<div
|
|
285
|
-
role="presentation"
|
|
286
|
-
className="navbar-sidebar__backdrop"
|
|
287
|
-
onClick={mobileSidebar.toggle}
|
|
288
|
-
/>
|
|
289
|
-
|
|
290
|
-
{mobileSidebar.shouldRender && (
|
|
291
|
-
<NavbarMobileSidebar
|
|
292
|
-
sidebarShown={mobileSidebar.shown}
|
|
293
|
-
toggleSidebar={mobileSidebar.toggle}
|
|
294
|
-
/>
|
|
295
|
-
)}
|
|
296
|
-
</nav>
|
|
14
|
+
<NavbarLayout>
|
|
15
|
+
<NavbarContent />
|
|
16
|
+
</NavbarLayout>
|
|
297
17
|
);
|
|
298
18
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
+
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
10
|
+
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
11
|
+
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|
12
|
+
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
|
|
13
|
+
import DocNavbarItem from '@theme/NavbarItem/DocNavbarItem';
|
|
14
|
+
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
15
|
+
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
|
|
16
|
+
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
17
|
+
|
|
18
|
+
import type {ComponentTypesObject} from '@theme/NavbarItem/ComponentTypes';
|
|
19
|
+
|
|
20
|
+
const ComponentTypes: ComponentTypesObject = {
|
|
21
|
+
default: DefaultNavbarItem,
|
|
22
|
+
localeDropdown: LocaleDropdownNavbarItem,
|
|
23
|
+
search: SearchNavbarItem,
|
|
24
|
+
dropdown: DropdownNavbarItem,
|
|
25
|
+
html: HtmlNavbarItem,
|
|
26
|
+
doc: DocNavbarItem,
|
|
27
|
+
docSidebar: DocSidebarNavbarItem,
|
|
28
|
+
docsVersion: DocsVersionNavbarItem,
|
|
29
|
+
docsVersionDropdown: DocsVersionDropdownNavbarItem,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default ComponentTypes;
|
|
@@ -41,7 +41,7 @@ function DefaultNavbarItemDesktop({
|
|
|
41
41
|
|
|
42
42
|
function DefaultNavbarItemMobile({
|
|
43
43
|
className,
|
|
44
|
-
isDropdownItem
|
|
44
|
+
isDropdownItem,
|
|
45
45
|
...props
|
|
46
46
|
}: DesktopOrMobileNavBarItemProps) {
|
|
47
47
|
return (
|
|
@@ -53,7 +53,7 @@ function DefaultNavbarItemMobile({
|
|
|
53
53
|
|
|
54
54
|
export default function DefaultNavbarItem({
|
|
55
55
|
mobile = false,
|
|
56
|
-
position
|
|
56
|
+
position, // Need to destructure position from props so that it doesn't get passed on.
|
|
57
57
|
...props
|
|
58
58
|
}: Props): JSX.Element {
|
|
59
59
|
const Comp = mobile ? DefaultNavbarItemMobile : DefaultNavbarItemDesktop;
|
|
@@ -7,48 +7,26 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
useLatestVersion,
|
|
12
|
-
useActiveDocContext,
|
|
13
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
14
11
|
import clsx from 'clsx';
|
|
15
12
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
16
13
|
import type {Props} from '@theme/NavbarItem/DocNavbarItem';
|
|
17
|
-
import {
|
|
18
|
-
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
19
|
-
|
|
20
|
-
function getDocInVersions(versions: GlobalVersion[], docId: string) {
|
|
21
|
-
const allDocs = versions.flatMap((version) => version.docs);
|
|
22
|
-
const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
|
|
23
|
-
if (!doc) {
|
|
24
|
-
const docIds = allDocs.map((versionDoc) => versionDoc.id).join('\n- ');
|
|
25
|
-
throw new Error(
|
|
26
|
-
`DocNavbarItem: couldn't find any doc with id "${docId}" in version${
|
|
27
|
-
versions.length ? 's' : ''
|
|
28
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
29
|
-
Available doc ids are:\n- ${docIds}`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return doc;
|
|
33
|
-
}
|
|
14
|
+
import {useLayoutDoc} from '@docusaurus/theme-common';
|
|
34
15
|
|
|
35
16
|
export default function DocNavbarItem({
|
|
36
17
|
docId,
|
|
37
18
|
label: staticLabel,
|
|
38
19
|
docsPluginId,
|
|
39
20
|
...props
|
|
40
|
-
}: Props): JSX.Element {
|
|
41
|
-
const {
|
|
42
|
-
const
|
|
43
|
-
|
|
21
|
+
}: Props): JSX.Element | null {
|
|
22
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
23
|
+
const doc = useLayoutDoc(docId, docsPluginId);
|
|
24
|
+
|
|
25
|
+
// Draft items are not displayed in the navbar.
|
|
26
|
+
if (doc === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
44
29
|
|
|
45
|
-
// Versions used to look for the doc to link to, ordered + no duplicate
|
|
46
|
-
const versions = uniq(
|
|
47
|
-
[activeVersion, preferredVersion, latestVersion].filter(
|
|
48
|
-
Boolean,
|
|
49
|
-
) as GlobalVersion[],
|
|
50
|
-
);
|
|
51
|
-
const doc = getDocInVersions(versions, docId);
|
|
52
30
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
53
31
|
|
|
54
32
|
return (
|
|
@@ -57,6 +35,9 @@ export default function DocNavbarItem({
|
|
|
57
35
|
{...props}
|
|
58
36
|
className={clsx(props.className, {
|
|
59
37
|
[activeDocInfimaClassName]:
|
|
38
|
+
// Do not make the item active if the active doc doesn't have sidebar.
|
|
39
|
+
// If `activeDoc === doc` react-router will make it active anyways,
|
|
40
|
+
// regardless of the existence of a sidebar
|
|
60
41
|
activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
|
|
61
42
|
})}
|
|
62
43
|
activeClassName={activeDocInfimaClassName}
|
|
@@ -7,48 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
useLatestVersion,
|
|
12
|
-
useActiveDocContext,
|
|
13
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
14
11
|
import clsx from 'clsx';
|
|
15
12
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
16
|
-
import {
|
|
13
|
+
import {useLayoutDocsSidebar} from '@docusaurus/theme-common';
|
|
17
14
|
|
|
18
15
|
import type {Props} from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
19
|
-
import type {
|
|
20
|
-
GlobalVersion,
|
|
21
|
-
GlobalSidebar,
|
|
22
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
23
|
-
|
|
24
|
-
function getSidebarLink(versions: GlobalVersion[], sidebarId: string) {
|
|
25
|
-
const allSidebars = versions
|
|
26
|
-
.flatMap((version) => {
|
|
27
|
-
if (version.sidebars) {
|
|
28
|
-
return Object.entries(version.sidebars);
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
})
|
|
32
|
-
.filter(
|
|
33
|
-
(sidebarItem): sidebarItem is [string, GlobalSidebar] => !!sidebarItem,
|
|
34
|
-
);
|
|
35
|
-
const sidebarEntry = allSidebars.find((sidebar) => sidebar[0] === sidebarId);
|
|
36
|
-
if (!sidebarEntry) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`DocSidebarNavbarItem: couldn't find any sidebar with id "${sidebarId}" in version${
|
|
39
|
-
versions.length ? 's' : ''
|
|
40
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
41
|
-
Available sidebar ids are:
|
|
42
|
-
- ${Object.keys(allSidebars).join('\n- ')}`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (!sidebarEntry[1].link) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`DocSidebarNavbarItem: couldn't find any document for sidebar with id "${sidebarId}"`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return sidebarEntry[1].link;
|
|
51
|
-
}
|
|
52
16
|
|
|
53
17
|
export default function DocSidebarNavbarItem({
|
|
54
18
|
sidebarId,
|
|
@@ -56,17 +20,13 @@ export default function DocSidebarNavbarItem({
|
|
|
56
20
|
docsPluginId,
|
|
57
21
|
...props
|
|
58
22
|
}: Props): JSX.Element {
|
|
59
|
-
const {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Boolean,
|
|
67
|
-
) as GlobalVersion[],
|
|
68
|
-
);
|
|
69
|
-
const sidebarLink = getSidebarLink(versions, sidebarId);
|
|
23
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
24
|
+
const sidebarLink = useLayoutDocsSidebar(sidebarId, docsPluginId).link;
|
|
25
|
+
if (!sidebarLink) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
70
30
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
71
31
|
|
|
72
32
|
return (
|
|
@@ -10,14 +10,15 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
|
10
10
|
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
11
11
|
import {
|
|
12
12
|
useVersions,
|
|
13
|
-
useLatestVersion,
|
|
14
13
|
useActiveDocContext,
|
|
15
14
|
} from '@docusaurus/plugin-content-docs/client';
|
|
16
|
-
import
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
useDocsPreferredVersion,
|
|
17
|
+
useDocsVersionCandidates,
|
|
18
|
+
} from '@docusaurus/theme-common';
|
|
18
19
|
import {translate} from '@docusaurus/Translate';
|
|
19
20
|
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
20
|
-
import type {
|
|
21
|
+
import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
21
22
|
|
|
22
23
|
const getVersionMainDoc = (version: GlobalVersion) =>
|
|
23
24
|
version.docs.find((doc) => doc.id === version.mainDocId)!;
|
|
@@ -32,36 +33,28 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
32
33
|
}: Props): JSX.Element {
|
|
33
34
|
const activeDocContext = useActiveDocContext(docsPluginId);
|
|
34
35
|
const versions = useVersions(docsPluginId);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return [...dropdownItemsBefore, ...versionLinks, ...dropdownItemsAfter];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const items = getItems();
|
|
36
|
+
const {savePreferredVersionName} = useDocsPreferredVersion(docsPluginId);
|
|
37
|
+
const versionLinks = versions.map((version) => {
|
|
38
|
+
// We try to link to the same doc, in another version
|
|
39
|
+
// When not possible, fallback to the "main doc" of the version
|
|
40
|
+
const versionDoc =
|
|
41
|
+
activeDocContext?.alternateDocVersions[version.name] ??
|
|
42
|
+
getVersionMainDoc(version);
|
|
43
|
+
return {
|
|
44
|
+
isNavLink: true,
|
|
45
|
+
label: version.label,
|
|
46
|
+
to: versionDoc.path,
|
|
47
|
+
isActive: () => version === activeDocContext?.activeVersion,
|
|
48
|
+
onClick: () => savePreferredVersionName(version.name),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
const items = [
|
|
52
|
+
...dropdownItemsBefore,
|
|
53
|
+
...versionLinks,
|
|
54
|
+
...dropdownItemsAfter,
|
|
55
|
+
];
|
|
62
56
|
|
|
63
|
-
const dropdownVersion =
|
|
64
|
-
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion;
|
|
57
|
+
const dropdownVersion = useDocsVersionCandidates(docsPluginId)[0];
|
|
65
58
|
|
|
66
59
|
// Mobile dropdown is handled a bit differently
|
|
67
60
|
const dropdownLabel =
|
|
@@ -7,13 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
useLatestVersion,
|
|
13
|
-
type GlobalVersion,
|
|
14
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
10
|
+
import {useDocsVersionCandidates} from '@docusaurus/theme-common';
|
|
11
|
+
import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
|
|
15
12
|
import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
|
|
16
|
-
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
17
13
|
|
|
18
14
|
const getVersionMainDoc = (version: GlobalVersion) =>
|
|
19
15
|
version.docs.find((doc) => doc.id === version.mainDocId)!;
|
|
@@ -24,10 +20,7 @@ export default function DocsVersionNavbarItem({
|
|
|
24
20
|
docsPluginId,
|
|
25
21
|
...props
|
|
26
22
|
}: Props): JSX.Element {
|
|
27
|
-
const
|
|
28
|
-
const {preferredVersion} = useDocsPreferredVersion(docsPluginId);
|
|
29
|
-
const latestVersion = useLatestVersion(docsPluginId);
|
|
30
|
-
const version = activeVersion ?? preferredVersion ?? latestVersion;
|
|
23
|
+
const version = useDocsVersionCandidates(docsPluginId)[0];
|
|
31
24
|
const label = staticLabel ?? version.label;
|
|
32
25
|
const path = staticTo ?? getVersionMainDoc(version).path;
|
|
33
26
|
return <DefaultNavbarItem {...props} label={label} to={path} />;
|
|
@@ -85,6 +85,9 @@ function DropdownNavbarItemDesktop({
|
|
|
85
85
|
'dropdown--show': showDropdown,
|
|
86
86
|
})}>
|
|
87
87
|
<NavbarNavLink
|
|
88
|
+
aria-haspopup="true"
|
|
89
|
+
aria-expanded={showDropdown}
|
|
90
|
+
role="button"
|
|
88
91
|
href={props.to ? undefined : '#'}
|
|
89
92
|
className={clsx('navbar__link', className)}
|
|
90
93
|
{...props}
|
|
@@ -107,7 +110,13 @@ function DropdownNavbarItemDesktop({
|
|
|
107
110
|
setShowDropdown(false);
|
|
108
111
|
const nextNavbarItem = dropdownRef.current!.nextElementSibling;
|
|
109
112
|
if (nextNavbarItem) {
|
|
110
|
-
|
|
113
|
+
const targetItem =
|
|
114
|
+
nextNavbarItem instanceof HTMLAnchorElement
|
|
115
|
+
? nextNavbarItem
|
|
116
|
+
: // Next item is another dropdown; focus on the inner
|
|
117
|
+
// anchor element instead so there's outline
|
|
118
|
+
nextNavbarItem.querySelector('a');
|
|
119
|
+
(targetItem as HTMLElement).focus();
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
122
|
}}
|
|
@@ -124,7 +133,7 @@ function DropdownNavbarItemDesktop({
|
|
|
124
133
|
function DropdownNavbarItemMobile({
|
|
125
134
|
items,
|
|
126
135
|
className,
|
|
127
|
-
position
|
|
136
|
+
position, // Need to destructure position from props so that it doesn't get passed on.
|
|
128
137
|
...props
|
|
129
138
|
}: DesktopOrMobileNavBarItemProps) {
|
|
130
139
|
const localPathname = useLocalPathname();
|
|
@@ -148,7 +157,10 @@ function DropdownNavbarItemMobile({
|
|
|
148
157
|
})}>
|
|
149
158
|
<NavbarNavLink
|
|
150
159
|
role="button"
|
|
151
|
-
className={clsx(
|
|
160
|
+
className={clsx(
|
|
161
|
+
'menu__link menu__link--sublist menu__link--sublist-caret',
|
|
162
|
+
className,
|
|
163
|
+
)}
|
|
152
164
|
{...props}
|
|
153
165
|
onClick={(e) => {
|
|
154
166
|
e.preventDefault();
|