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