@docusaurus/theme-classic 2.0.0-beta.13 → 2.0.0-beta.15

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 (299) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +7 -16
  3. package/lib/theme-classic.d.ts +111 -188
  4. package/lib/translations.js +13 -4
  5. package/lib/validateThemeConfig.js +18 -4
  6. package/lib-next/theme/Admonition/index.js +101 -0
  7. package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
  8. package/lib-next/theme/BlogListPaginator/index.js +12 -12
  9. package/lib-next/theme/BlogPostAuthor/index.js +1 -1
  10. package/lib-next/theme/BlogPostAuthors/index.js +12 -2
  11. package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
  12. package/lib-next/theme/BlogPostItem/index.js +12 -15
  13. package/lib-next/theme/BlogPostPage/index.js +10 -7
  14. package/lib-next/theme/BlogPostPaginator/index.js +11 -15
  15. package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
  16. package/lib-next/theme/CodeBlock/index.js +51 -10
  17. package/lib-next/theme/CodeBlock/styles.module.css +18 -7
  18. package/lib-next/theme/DocCard/styles.module.css +3 -3
  19. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
  20. package/lib-next/theme/DocItem/index.js +9 -6
  21. package/lib-next/theme/DocItem/styles.module.css +2 -2
  22. package/lib-next/theme/DocPage/index.js +7 -3
  23. package/lib-next/theme/DocPage/styles.module.css +1 -0
  24. package/lib-next/theme/DocPaginator/index.js +11 -13
  25. package/lib-next/theme/DocSidebar/index.js +2 -2
  26. package/lib-next/theme/DocSidebar/styles.module.css +1 -0
  27. package/lib-next/theme/DocSidebarItem/index.js +43 -21
  28. package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
  29. package/lib-next/theme/DocSidebarItems/index.js +28 -0
  30. package/{lib/theme/DocSidebarItem → lib-next/theme/DocSidebarItems}/styles.module.css +1 -0
  31. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  32. package/lib-next/theme/Footer/index.js +73 -35
  33. package/lib-next/theme/Footer/styles.module.css +2 -1
  34. package/lib-next/theme/Heading/index.js +39 -43
  35. package/lib-next/theme/Heading/styles.css +1 -1
  36. package/lib-next/theme/Layout/index.js +1 -2
  37. package/lib-next/theme/LayoutHead/index.js +5 -9
  38. package/lib-next/theme/LayoutProviders/index.js +6 -6
  39. package/lib-next/theme/MDXComponents/index.js +18 -31
  40. package/lib-next/theme/MDXComponents/styles.css +4 -0
  41. package/lib-next/theme/MDXPage/index.js +3 -10
  42. package/lib-next/theme/Navbar/index.js +6 -6
  43. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  44. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  45. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
  46. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
  47. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  48. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +6 -7
  49. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  50. package/lib-next/theme/NavbarItem/index.js +1 -2
  51. package/lib-next/theme/{UserPreferencesContext.js → NavbarItem/utils.js} +3 -3
  52. package/lib-next/theme/PaginatorNavLink/index.js +20 -0
  53. package/lib-next/theme/SkipToContent/index.js +1 -1
  54. package/lib-next/theme/SkipToContent/styles.module.css +7 -0
  55. package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
  56. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  57. package/lib-next/theme/Tabs/index.js +20 -10
  58. package/lib-next/theme/Tag/styles.module.css +4 -4
  59. package/lib-next/theme/ThemedImage/index.js +2 -2
  60. package/lib-next/theme/Toggle/styles.module.css +16 -15
  61. package/lib-next/theme/prism-include-languages.js +10 -3
  62. package/package.json +17 -19
  63. package/src/index.ts +12 -26
  64. package/src/theme/Admonition/index.tsx +106 -0
  65. package/src/theme/BackToTopButton/styles.module.css +1 -1
  66. package/src/theme/BlogListPaginator/index.tsx +12 -12
  67. package/src/theme/BlogPostAuthor/index.tsx +1 -1
  68. package/src/theme/BlogPostAuthors/index.tsx +12 -2
  69. package/src/theme/BlogPostAuthors/styles.module.css +10 -0
  70. package/src/theme/BlogPostItem/index.tsx +13 -15
  71. package/src/theme/BlogPostPage/index.tsx +10 -7
  72. package/src/theme/BlogPostPaginator/index.tsx +11 -15
  73. package/src/theme/BlogSidebar/styles.module.css +2 -0
  74. package/src/theme/CodeBlock/index.tsx +52 -11
  75. package/src/theme/CodeBlock/styles.module.css +18 -7
  76. package/src/theme/DocCard/index.tsx +2 -2
  77. package/src/theme/DocCard/styles.module.css +3 -3
  78. package/src/theme/DocCardList/index.tsx +1 -1
  79. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
  80. package/src/theme/DocItem/index.tsx +9 -6
  81. package/src/theme/DocItem/styles.module.css +2 -2
  82. package/src/theme/DocItemFooter/index.tsx +1 -1
  83. package/src/theme/DocPage/index.tsx +8 -4
  84. package/src/theme/DocPage/styles.module.css +1 -0
  85. package/src/theme/DocPaginator/index.tsx +13 -15
  86. package/src/theme/DocSidebar/index.tsx +3 -3
  87. package/src/theme/DocSidebar/styles.module.css +1 -0
  88. package/src/theme/DocSidebarItem/index.tsx +34 -23
  89. package/src/theme/DocSidebarItem/styles.module.css +1 -0
  90. package/src/theme/DocSidebarItems/index.tsx +32 -0
  91. package/{lib/theme/DocItemFooter → src/theme/DocSidebarItems}/styles.module.css +10 -8
  92. package/src/theme/DocVersionBanner/index.tsx +3 -3
  93. package/src/theme/Footer/index.tsx +84 -38
  94. package/src/theme/Footer/styles.module.css +2 -1
  95. package/src/theme/Heading/index.tsx +39 -47
  96. package/src/theme/Heading/styles.css +1 -1
  97. package/src/theme/Layout/index.tsx +1 -2
  98. package/src/theme/LayoutHead/index.tsx +4 -8
  99. package/src/theme/LayoutProviders/index.tsx +6 -6
  100. package/src/theme/MDXComponents/index.tsx +26 -37
  101. package/src/theme/MDXComponents/styles.css +4 -0
  102. package/src/theme/MDXPage/index.tsx +3 -11
  103. package/src/theme/Navbar/index.tsx +7 -7
  104. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  105. package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
  106. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
  107. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
  108. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
  109. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +6 -7
  110. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  111. package/src/theme/NavbarItem/index.tsx +3 -5
  112. package/{lib-next/theme/hooks/styles.css → src/theme/NavbarItem/utils.ts} +3 -3
  113. package/src/theme/PaginatorNavLink/index.tsx +22 -0
  114. package/src/theme/SkipToContent/index.tsx +1 -1
  115. package/src/theme/SkipToContent/styles.module.css +7 -0
  116. package/src/theme/TOCCollapsible/styles.module.css +2 -2
  117. package/src/theme/TOCItems/index.tsx +2 -2
  118. package/src/theme/Tabs/index.tsx +25 -10
  119. package/src/theme/Tag/styles.module.css +4 -4
  120. package/src/theme/TagsListByLetter/index.tsx +1 -1
  121. package/src/theme/ThemedImage/index.tsx +2 -2
  122. package/src/theme/Toggle/index.tsx +1 -1
  123. package/src/theme/Toggle/styles.module.css +16 -15
  124. package/src/theme/prism-include-languages.ts +10 -3
  125. package/src/theme-classic.d.ts +111 -188
  126. package/src/translations.ts +36 -16
  127. package/src/validateThemeConfig.ts +25 -4
  128. package/babel.config.js +0 -35
  129. package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  130. package/lib/__tests__/translations.test.js +0 -112
  131. package/lib/__tests__/validateThemeConfig.test.js +0 -607
  132. package/lib/theme/AnnouncementBar/index.js +0 -68
  133. package/lib/theme/AnnouncementBar/styles.module.css +0 -63
  134. package/lib/theme/BackToTopButton/index.js +0 -140
  135. package/lib/theme/BackToTopButton/styles.module.css +0 -42
  136. package/lib/theme/BlogArchivePage/index.js +0 -89
  137. package/lib/theme/BlogLayout/index.js +0 -51
  138. package/lib/theme/BlogListPage/index.js +0 -60
  139. package/lib/theme/BlogListPaginator/index.js +0 -63
  140. package/lib/theme/BlogPostAuthor/index.js +0 -51
  141. package/lib/theme/BlogPostAuthor/styles.module.css +0 -12
  142. package/lib/theme/BlogPostAuthors/index.js +0 -47
  143. package/lib/theme/BlogPostAuthors/styles.module.css +0 -11
  144. package/lib/theme/BlogPostItem/index.js +0 -152
  145. package/lib/theme/BlogPostItem/styles.module.css +0 -18
  146. package/lib/theme/BlogPostPage/index.js +0 -82
  147. package/lib/theme/BlogPostPaginator/index.js +0 -64
  148. package/lib/theme/BlogSidebar/index.js +0 -49
  149. package/lib/theme/BlogSidebar/styles.module.css +0 -44
  150. package/lib/theme/BlogTagsListPage/index.js +0 -40
  151. package/lib/theme/BlogTagsPostsPage/index.js +0 -86
  152. package/lib/theme/CodeBlock/index.js +0 -133
  153. package/lib/theme/CodeBlock/styles.module.css +0 -65
  154. package/lib/theme/Details/index.js +0 -30
  155. package/lib/theme/Details/styles.module.css +0 -13
  156. package/lib/theme/DocCard/index.js +0 -84
  157. package/lib/theme/DocCard/styles.module.css +0 -43
  158. package/lib/theme/DocCardList/index.js +0 -28
  159. package/lib/theme/DocCategoryGeneratedIndexPage/index.js +0 -57
  160. package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +0 -18
  161. package/lib/theme/DocItem/index.js +0 -112
  162. package/lib/theme/DocItem/styles.module.css +0 -22
  163. package/lib/theme/DocItemFooter/index.js +0 -79
  164. package/lib/theme/DocPage/index.js +0 -154
  165. package/lib/theme/DocPage/styles.module.css +0 -85
  166. package/lib/theme/DocPaginator/index.js +0 -62
  167. package/lib/theme/DocSidebar/index.js +0 -134
  168. package/lib/theme/DocSidebar/styles.module.css +0 -106
  169. package/lib/theme/DocSidebarItem/index.js +0 -209
  170. package/lib/theme/DocTagDocListPage/index.js +0 -89
  171. package/lib/theme/DocTagsListPage/index.js +0 -44
  172. package/lib/theme/DocVersionBadge/index.js +0 -34
  173. package/lib/theme/DocVersionBanner/index.js +0 -130
  174. package/lib/theme/EditThisPage/index.js +0 -33
  175. package/lib/theme/ErrorPageContent.js +0 -43
  176. package/lib/theme/Footer/index.js +0 -119
  177. package/lib/theme/Footer/styles.module.css +0 -15
  178. package/lib/theme/Heading/index.js +0 -71
  179. package/lib/theme/Heading/styles.css +0 -22
  180. package/lib/theme/Heading/styles.module.css +0 -19
  181. package/lib/theme/IconArrow/index.js +0 -28
  182. package/lib/theme/IconClose/index.js +0 -31
  183. package/lib/theme/IconEdit/index.js +0 -34
  184. package/lib/theme/IconEdit/styles.module.css +0 -11
  185. package/lib/theme/IconExternalLink/index.js +0 -30
  186. package/lib/theme/IconExternalLink/styles.module.css +0 -12
  187. package/lib/theme/IconLanguage/index.js +0 -29
  188. package/lib/theme/IconMenu/index.js +0 -30
  189. package/lib/theme/LastUpdated/index.js +0 -63
  190. package/lib/theme/Layout/index.js +0 -68
  191. package/lib/theme/Layout/styles.css +0 -27
  192. package/lib/theme/LayoutHead/index.js +0 -149
  193. package/lib/theme/LayoutProviders/index.js +0 -40
  194. package/lib/theme/Logo/index.js +0 -62
  195. package/lib/theme/MDXComponents/index.js +0 -106
  196. package/lib/theme/MDXComponents/styles.css +0 -11
  197. package/lib/theme/MDXPage/index.js +0 -67
  198. package/lib/theme/MDXPage/styles.module.css +0 -10
  199. package/lib/theme/Navbar/index.js +0 -267
  200. package/lib/theme/Navbar/styles.module.css +0 -27
  201. package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -113
  202. package/lib/theme/NavbarItem/DocNavbarItem.js +0 -62
  203. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -83
  204. package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
  205. package/lib/theme/NavbarItem/DropdownNavbarItem.js +0 -155
  206. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +0 -68
  207. package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +0 -11
  208. package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
  209. package/lib/theme/NavbarItem/index.js +0 -74
  210. package/lib/theme/NotFound.js +0 -57
  211. package/lib/theme/SearchBar.js +0 -15
  212. package/lib/theme/SearchMetadata/index.js +0 -33
  213. package/lib/theme/Seo/index.js +0 -52
  214. package/lib/theme/SkipToContent/index.js +0 -71
  215. package/lib/theme/SkipToContent/styles.module.css +0 -14
  216. package/lib/theme/TOC/index.js +0 -39
  217. package/lib/theme/TOC/styles.module.css +0 -23
  218. package/lib/theme/TOCCollapsible/index.js +0 -53
  219. package/lib/theme/TOCCollapsible/styles.module.css +0 -50
  220. package/lib/theme/TOCInline/index.js +0 -33
  221. package/lib/theme/TOCInline/styles.module.css +0 -12
  222. package/lib/theme/TOCItems/index.js +0 -78
  223. package/lib/theme/TabItem/index.js +0 -32
  224. package/lib/theme/Tabs/__tests__/index.test.js +0 -123
  225. package/lib/theme/Tabs/index.js +0 -173
  226. package/lib/theme/Tabs/styles.module.css +0 -10
  227. package/lib/theme/Tag/index.js +0 -40
  228. package/lib/theme/Tag/styles.module.css +0 -70
  229. package/lib/theme/TagsListByLetter/index.js +0 -48
  230. package/lib/theme/TagsListByLetter/styles.module.css +0 -11
  231. package/lib/theme/TagsListInline/index.js +0 -44
  232. package/lib/theme/TagsListInline/styles.module.css +0 -15
  233. package/lib/theme/ThemeContext.js +0 -21
  234. package/lib/theme/ThemeProvider/index.js +0 -43
  235. package/lib/theme/ThemedImage/index.js +0 -47
  236. package/lib/theme/ThemedImage/styles.module.css +0 -18
  237. package/lib/theme/Toggle/index.js +0 -91
  238. package/lib/theme/Toggle/styles.module.css +0 -105
  239. package/lib/theme/UserPreferencesContext.js +0 -18
  240. package/lib/theme/UserPreferencesProvider/index.js +0 -41
  241. package/lib/theme/hooks/styles.css +0 -10
  242. package/lib/theme/hooks/useDocs.js +0 -18
  243. package/lib/theme/hooks/useHideableNavbar.js +0 -74
  244. package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
  245. package/lib/theme/hooks/useLocationHash.js +0 -28
  246. package/lib/theme/hooks/useLockBodyScroll.js +0 -26
  247. package/lib/theme/hooks/usePrismTheme.js +0 -36
  248. package/lib/theme/hooks/useTabGroupChoice.js +0 -51
  249. package/lib/theme/hooks/useTheme.js +0 -97
  250. package/lib/theme/hooks/useThemeContext.js +0 -31
  251. package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
  252. package/lib/theme/hooks/useWindowSize.js +0 -68
  253. package/lib/theme/prism-include-languages.js +0 -40
  254. package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  255. package/lib-next/__tests__/translations.test.js +0 -128
  256. package/lib-next/__tests__/validateThemeConfig.test.js +0 -607
  257. package/lib-next/admonitions.css +0 -35
  258. package/lib-next/deps.d.ts +0 -13
  259. package/lib-next/index.js +0 -227
  260. package/lib-next/prism-include-languages.js +0 -9
  261. package/lib-next/theme/ThemeContext.js +0 -9
  262. package/lib-next/theme/ThemeProvider/index.js +0 -28
  263. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  264. package/lib-next/theme/hooks/useDocs.js +0 -10
  265. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  266. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  267. package/lib-next/theme/hooks/useLocationHash.js +0 -20
  268. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  269. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  270. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  271. package/lib-next/theme/hooks/useTheme.js +0 -81
  272. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  273. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  274. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  275. package/lib-next/theme-classic.d.ts +0 -806
  276. package/lib-next/translations.js +0 -141
  277. package/lib-next/types.d.ts +0 -11
  278. package/lib-next/validateThemeConfig.js +0 -344
  279. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
  280. package/src/__tests__/translations.test.ts +0 -116
  281. package/src/__tests__/validateThemeConfig.test.js +0 -607
  282. package/src/theme/Tabs/__tests__/index.test.tsx +0 -129
  283. package/src/theme/ThemeContext.ts +0 -15
  284. package/src/theme/ThemeProvider/index.tsx +0 -28
  285. package/src/theme/UserPreferencesContext.ts +0 -12
  286. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  287. package/src/theme/hooks/styles.css +0 -10
  288. package/src/theme/hooks/useDocs.ts +0 -11
  289. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  290. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  291. package/src/theme/hooks/useLocationHash.ts +0 -25
  292. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  293. package/src/theme/hooks/usePrismTheme.ts +0 -22
  294. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  295. package/src/theme/hooks/useTheme.ts +0 -91
  296. package/src/theme/hooks/useThemeContext.ts +0 -23
  297. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  298. package/src/theme/hooks/useWindowSize.ts +0 -69
  299. package/tsconfig.json +0 -11
@@ -0,0 +1,84 @@
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 DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
+ import {
11
+ useLatestVersion,
12
+ useActiveDocContext,
13
+ } from '@docusaurus/plugin-content-docs/client';
14
+ import clsx from 'clsx';
15
+ import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
16
+ import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
17
+
18
+ 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
+
53
+ export default function DocSidebarNavbarItem({
54
+ sidebarId,
55
+ label,
56
+ docsPluginId,
57
+ ...props
58
+ }: Props): JSX.Element {
59
+ const {activeVersion, activeDoc} = useActiveDocContext(docsPluginId);
60
+ const {preferredVersion} = useDocsPreferredVersion(docsPluginId);
61
+ const latestVersion = useLatestVersion(docsPluginId);
62
+
63
+ // Versions used to look for the doc to link to, ordered + no duplicate
64
+ const versions = uniq(
65
+ [activeVersion, preferredVersion, latestVersion].filter(
66
+ Boolean,
67
+ ) as GlobalVersion[],
68
+ );
69
+ const sidebarLink = getSidebarLink(versions, sidebarId);
70
+ const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
71
+
72
+ return (
73
+ <DefaultNavbarItem
74
+ exact
75
+ {...props}
76
+ className={clsx(props.className, {
77
+ [activeDocInfimaClassName]: activeDoc?.sidebar === sidebarId,
78
+ })}
79
+ activeClassName={activeDocInfimaClassName}
80
+ label={label ?? sidebarLink.label}
81
+ to={sidebarLink.path}
82
+ />
83
+ );
84
+ }
@@ -12,13 +12,14 @@ import {
12
12
  useVersions,
13
13
  useLatestVersion,
14
14
  useActiveDocContext,
15
- } from '@theme/hooks/useDocs';
15
+ } from '@docusaurus/plugin-content-docs/client';
16
16
  import type {Props} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
17
17
  import {useDocsPreferredVersion} from '@docusaurus/theme-common';
18
18
  import {translate} from '@docusaurus/Translate';
19
- import type {GlobalDataVersion} from '@docusaurus/plugin-content-docs';
19
+ import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
20
+ import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
20
21
 
21
- const getVersionMainDoc = (version: GlobalDataVersion) =>
22
+ const getVersionMainDoc = (version: GlobalVersion) =>
22
23
  version.docs.find((doc) => doc.id === version.mainDocId)!;
23
24
 
24
25
  export default function DocsVersionDropdownNavbarItem({
@@ -36,7 +37,7 @@ export default function DocsVersionDropdownNavbarItem({
36
37
  const {preferredVersion, savePreferredVersionName} =
37
38
  useDocsPreferredVersion(docsPluginId);
38
39
 
39
- function getItems() {
40
+ function getItems(): LinkLikeNavbarItemProps[] {
40
41
  const versionLinks = versions.map((version) => {
41
42
  // We try to link to the same doc, in another version
42
43
  // When not possible, fallback to the "main doc" of the version
@@ -64,7 +65,7 @@ export default function DocsVersionDropdownNavbarItem({
64
65
 
65
66
  // Mobile dropdown is handled a bit differently
66
67
  const dropdownLabel =
67
- mobile && items
68
+ mobile && items.length > 1
68
69
  ? translate({
69
70
  id: 'theme.navbar.mobileVersionsDropdown.label',
70
71
  message: 'Versions',
@@ -73,7 +74,9 @@ export default function DocsVersionDropdownNavbarItem({
73
74
  })
74
75
  : dropdownVersion.label;
75
76
  const dropdownTo =
76
- mobile && items ? undefined : getVersionMainDoc(dropdownVersion).path;
77
+ mobile && items.length > 1
78
+ ? undefined
79
+ : getVersionMainDoc(dropdownVersion).path;
77
80
 
78
81
  // We don't want to render a version dropdown with 0 or 1 item
79
82
  // If we build the site with a single docs version (onlyIncludeVersions: ['1.0.0'])
@@ -10,8 +10,8 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
10
  import {
11
11
  useActiveVersion,
12
12
  useLatestVersion,
13
- GlobalVersion,
14
- } from '@theme/hooks/useDocs';
13
+ type GlobalVersion,
14
+ } from '@docusaurus/plugin-content-docs/client';
15
15
  import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
16
16
  import {useDocsPreferredVersion} from '@docusaurus/theme-common';
17
17
 
@@ -20,7 +20,7 @@ import type {
20
20
  } from '@theme/NavbarItem/DropdownNavbarItem';
21
21
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
22
22
 
23
- import {NavLink} from '@theme/NavbarItem/DefaultNavbarItem';
23
+ import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
24
24
  import NavbarItem from '@theme/NavbarItem';
25
25
 
26
26
  const dropdownLinkActiveClass = 'dropdown__link--active';
@@ -55,7 +55,6 @@ function DropdownNavbarItemDesktop({
55
55
  ...props
56
56
  }: DesktopOrMobileNavBarItemProps) {
57
57
  const dropdownRef = useRef<HTMLDivElement>(null);
58
- const dropdownMenuRef = useRef<HTMLUListElement>(null);
59
58
  const [showDropdown, setShowDropdown] = useState(false);
60
59
 
61
60
  useEffect(() => {
@@ -85,7 +84,7 @@ function DropdownNavbarItemDesktop({
85
84
  'dropdown--right': position === 'right',
86
85
  'dropdown--show': showDropdown,
87
86
  })}>
88
- <NavLink
87
+ <NavbarNavLink
89
88
  href={props.to ? undefined : '#'}
90
89
  className={clsx('navbar__link', className)}
91
90
  {...props}
@@ -97,8 +96,8 @@ function DropdownNavbarItemDesktop({
97
96
  }
98
97
  }}>
99
98
  {props.children ?? props.label}
100
- </NavLink>
101
- <ul ref={dropdownMenuRef} className="dropdown__menu">
99
+ </NavbarNavLink>
100
+ <ul className="dropdown__menu">
102
101
  {items.map((childItemProps, i) => (
103
102
  <NavbarItem
104
103
  isDropdownItem
@@ -147,7 +146,7 @@ function DropdownNavbarItemMobile({
147
146
  className={clsx('menu__list-item', {
148
147
  'menu__list-item--collapsed': collapsed,
149
148
  })}>
150
- <NavLink
149
+ <NavbarNavLink
151
150
  role="button"
152
151
  className={clsx('menu__link menu__link--sublist', className)}
153
152
  {...props}
@@ -156,7 +155,7 @@ function DropdownNavbarItemMobile({
156
155
  toggleCollapsed();
157
156
  }}>
158
157
  {props.children ?? props.label}
159
- </NavLink>
158
+ </NavbarNavLink>
160
159
  <Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
161
160
  {items.map((childItemProps, i) => (
162
161
  <NavbarItem
@@ -0,0 +1,68 @@
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 Link from '@docusaurus/Link';
10
+ import useBaseUrl from '@docusaurus/useBaseUrl';
11
+ import type {Props} from '@theme/NavbarItem/NavbarNavLink';
12
+ import IconExternalLink from '@theme/IconExternalLink';
13
+ import isInternalUrl from '@docusaurus/isInternalUrl';
14
+ import {isRegexpStringMatch} from '@docusaurus/theme-common';
15
+
16
+ const dropdownLinkActiveClass = 'dropdown__link--active';
17
+
18
+ export default function NavbarNavLink({
19
+ activeBasePath,
20
+ activeBaseRegex,
21
+ to,
22
+ href,
23
+ label,
24
+ activeClassName = '',
25
+ prependBaseUrlToHref,
26
+ ...props
27
+ }: Props): JSX.Element {
28
+ // TODO all this seems hacky
29
+ // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
30
+ const toUrl = useBaseUrl(to);
31
+ const activeBaseUrl = useBaseUrl(activeBasePath);
32
+ const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
33
+ const isExternalLink = label && href && !isInternalUrl(href);
34
+ const isDropdownLink = activeClassName === dropdownLinkActiveClass;
35
+
36
+ return (
37
+ <Link
38
+ {...(href
39
+ ? {
40
+ href: prependBaseUrlToHref ? normalizedHref : href,
41
+ }
42
+ : {
43
+ isNavLink: true,
44
+ activeClassName: !props.className?.includes(activeClassName)
45
+ ? activeClassName
46
+ : '',
47
+ to: toUrl,
48
+ ...(activeBasePath || activeBaseRegex
49
+ ? {
50
+ isActive: (_match, location) =>
51
+ activeBaseRegex
52
+ ? isRegexpStringMatch(activeBaseRegex, location.pathname)
53
+ : location.pathname.startsWith(activeBaseUrl),
54
+ }
55
+ : null),
56
+ })}
57
+ {...props}>
58
+ {isExternalLink ? (
59
+ <span>
60
+ {label}
61
+ <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
62
+ </span>
63
+ ) : (
64
+ label
65
+ )}
66
+ </Link>
67
+ );
68
+ }
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
10
  import DropdownNavbarItem, {
11
- Props as DropdownNavbarItemProps,
11
+ type Props as DropdownNavbarItemProps,
12
12
  } from '@theme/NavbarItem/DropdownNavbarItem';
13
13
  import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
14
14
  import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
@@ -16,7 +16,7 @@ import type {Types, Props} from '@theme/NavbarItem';
16
16
 
17
17
  const NavbarItemComponents: Record<
18
18
  Exclude<Types, undefined>,
19
- // TODO: properly type this
19
+ // Not really worth typing, as we pass all props down immediately
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
21
  () => (props: any) => JSX.Element
22
22
  > = {
@@ -32,6 +32,7 @@ const NavbarItemComponents: Record<
32
32
  docsVersionDropdown: () =>
33
33
  require('@theme/NavbarItem/DocsVersionDropdownNavbarItem').default,
34
34
  doc: () => require('@theme/NavbarItem/DocNavbarItem').default,
35
+ docSidebar: () => require('@theme/NavbarItem/DocSidebarNavbarItem').default,
35
36
  /* eslint-enable @typescript-eslint/no-var-requires, global-require */
36
37
  } as const;
37
38
 
@@ -57,9 +58,6 @@ function getComponentType(
57
58
  return type as NavbarItemComponentType;
58
59
  }
59
60
 
60
- export const getInfimaActiveClassName = (mobile?: boolean): string =>
61
- mobile ? 'menu__link--active' : 'navbar__link--active';
62
-
63
61
  export default function NavbarItem({type, ...props}: Props): JSX.Element {
64
62
  const componentType = getComponentType(
65
63
  type,
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- body:not(.navigation-with-keyboard) *:not(input):focus {
9
- outline: none;
10
- }
8
+ // eslint-disable-next-line import/no-named-export
9
+ export const getInfimaActiveClassName = (mobile?: boolean): string =>
10
+ mobile ? 'menu__link--active' : 'navbar__link--active';
@@ -0,0 +1,22 @@
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 Link from '@docusaurus/Link';
10
+ import type {Props} from '@theme/PaginatorNavLink';
11
+
12
+ function PaginatorNavLink(props: Props): JSX.Element {
13
+ const {permalink, title, subLabel} = props;
14
+ return (
15
+ <Link className="pagination-nav__link" to={permalink}>
16
+ {subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
17
+ <div className="pagination-nav__label">{title}</div>
18
+ </Link>
19
+ );
20
+ }
21
+
22
+ export default PaginatorNavLink;
@@ -40,7 +40,7 @@ function SkipToContent(): JSX.Element {
40
40
  });
41
41
 
42
42
  return (
43
- <div ref={containerRef}>
43
+ <div ref={containerRef} role="region">
44
44
  {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
45
45
  <a href="#" className={styles.skipToContent} onClick={handleSkip}>
46
46
  <Translate
@@ -1,3 +1,10 @@
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
+
1
8
  .skipToContent {
2
9
  position: fixed;
3
10
  top: 1rem;
@@ -20,7 +20,7 @@
20
20
  width: 100%;
21
21
  }
22
22
 
23
- .tocCollapsibleButton:after {
23
+ .tocCollapsibleButton::after {
24
24
  content: '';
25
25
  background: var(--ifm-menu-link-sublist-icon) 50% 50% / 2rem 2rem no-repeat;
26
26
  filter: var(--ifm-menu-link-sublist-icon-filter);
@@ -45,6 +45,6 @@
45
45
  display: block;
46
46
  }
47
47
 
48
- .tocCollapsibleExpanded .tocCollapsibleButton:after {
48
+ .tocCollapsibleExpanded .tocCollapsibleButton::after {
49
49
  transform: none;
50
50
  }
@@ -7,9 +7,9 @@
7
7
 
8
8
  import React, {useMemo} from 'react';
9
9
  import type {TOCItemsProps} from '@theme/TOCItems';
10
- import {TOCItem} from '@docusaurus/types';
10
+ import type {TOCItem} from '@docusaurus/types';
11
11
  import {
12
- TOCHighlightConfig,
12
+ type TOCHighlightConfig,
13
13
  useThemeConfig,
14
14
  useTOCFilter,
15
15
  useTOCHighlight,
@@ -10,11 +10,14 @@ import React, {
10
10
  cloneElement,
11
11
  Children,
12
12
  isValidElement,
13
- ReactElement,
13
+ type ReactElement,
14
14
  } from 'react';
15
15
  import useIsBrowser from '@docusaurus/useIsBrowser';
16
- import useUserPreferencesContext from '@theme/hooks/useUserPreferencesContext';
17
- import {useScrollPositionBlocker, duplicates} from '@docusaurus/theme-common';
16
+ import {
17
+ useScrollPositionBlocker,
18
+ duplicates,
19
+ useTabGroupChoice,
20
+ } from '@docusaurus/theme-common';
18
21
  import type {Props} from '@theme/Tabs';
19
22
  import type {Props as TabItemProps} from '@theme/TabItem';
20
23
 
@@ -51,7 +54,13 @@ function TabsComponent(props: Props): JSX.Element {
51
54
  );
52
55
  });
53
56
  const values =
54
- valuesProp ?? children.map(({props: {value, label}}) => ({value, label}));
57
+ valuesProp ??
58
+ // We only pick keys that we recognize. MDX would inject some keys by default
59
+ children.map(({props: {value, label, attributes}}) => ({
60
+ value,
61
+ label,
62
+ attributes,
63
+ }));
55
64
  const dup = duplicates(values, (a, b) => a.value === b.value);
56
65
  if (dup.length > 0) {
57
66
  throw new Error(
@@ -77,7 +86,7 @@ function TabsComponent(props: Props): JSX.Element {
77
86
  );
78
87
  }
79
88
 
80
- const {tabGroupChoices, setTabGroupChoices} = useUserPreferencesContext();
89
+ const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
81
90
  const [selectedValue, setSelectedValue] = useState(defaultValue);
82
91
  const tabRefs: (HTMLLIElement | null)[] = [];
83
92
  const {blockElementScrollPositionUntilNextRender} =
@@ -144,19 +153,25 @@ function TabsComponent(props: Props): JSX.Element {
144
153
  },
145
154
  className,
146
155
  )}>
147
- {values.map(({value, label}) => (
156
+ {values.map(({value, label, attributes}) => (
148
157
  <li
149
158
  role="tab"
150
159
  tabIndex={selectedValue === value ? 0 : -1}
151
160
  aria-selected={selectedValue === value}
152
- className={clsx('tabs__item', styles.tabItem, {
153
- 'tabs__item--active': selectedValue === value,
154
- })}
155
161
  key={value}
156
162
  ref={(tabControl) => tabRefs.push(tabControl)}
157
163
  onKeyDown={handleKeydown}
158
164
  onFocus={handleTabChange}
159
- onClick={handleTabChange}>
165
+ onClick={handleTabChange}
166
+ {...attributes}
167
+ className={clsx(
168
+ 'tabs__item',
169
+ styles.tabItem,
170
+ attributes?.className as string,
171
+ {
172
+ 'tabs__item--active': selectedValue === value,
173
+ },
174
+ )}>
160
175
  {label ?? value}
161
176
  </li>
162
177
  ))}
@@ -33,8 +33,8 @@
33
33
  border-left: 0;
34
34
  }
35
35
 
36
- .tagWithCount:before,
37
- .tagWithCount:after {
36
+ .tagWithCount::before,
37
+ .tagWithCount::after {
38
38
  content: '';
39
39
  position: absolute;
40
40
  top: 50%;
@@ -42,7 +42,7 @@
42
42
  transition: inherit;
43
43
  }
44
44
 
45
- .tagWithCount:before {
45
+ .tagWithCount::before {
46
46
  right: 100%;
47
47
  transform: translate(50%, -50%) rotate(-45deg);
48
48
  width: 1.18rem;
@@ -51,7 +51,7 @@
51
51
  border-bottom: 0;
52
52
  }
53
53
 
54
- .tagWithCount:after {
54
+ .tagWithCount::after {
55
55
  left: 0;
56
56
  transform: translateY(-50%);
57
57
  width: 0.5rem;
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import Tag from '@theme/Tag';
10
10
  import type {Props} from '@theme/TagsListByLetter';
11
- import {listTagsByLetters, TagLetterEntry} from '@docusaurus/theme-common';
11
+ import {listTagsByLetters, type TagLetterEntry} from '@docusaurus/theme-common';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
@@ -9,14 +9,14 @@ import React from 'react';
9
9
  import clsx from 'clsx';
10
10
 
11
11
  import useIsBrowser from '@docusaurus/useIsBrowser';
12
- import useThemeContext from '@theme/hooks/useThemeContext';
12
+ import {useColorMode} from '@docusaurus/theme-common';
13
13
  import type {Props} from '@theme/ThemedImage';
14
14
 
15
15
  import styles from './styles.module.css';
16
16
 
17
17
  function ThemedImage(props: Props): JSX.Element {
18
18
  const isBrowser = useIsBrowser();
19
- const {isDarkTheme} = useThemeContext();
19
+ const {isDarkTheme} = useColorMode();
20
20
  const {sources, className, alt = '', ...propsRest} = props;
21
21
 
22
22
  type SourceName = keyof Props['sources'];
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React, {useState, useRef, memo} from 'react';
9
9
  import type {Props} from '@theme/Toggle';
10
- import {useThemeConfig, ColorModeConfig} from '@docusaurus/theme-common';
10
+ import {useThemeConfig, type ColorModeConfig} from '@docusaurus/theme-common';
11
11
  import useIsBrowser from '@docusaurus/useIsBrowser';
12
12
 
13
13
  import clsx from 'clsx';
@@ -39,16 +39,16 @@
39
39
  position: absolute;
40
40
  width: 14px;
41
41
  height: 10px;
42
- top: 0px;
43
- bottom: 0px;
42
+ top: 0;
43
+ bottom: 0;
44
44
  margin: auto 0;
45
45
  left: 8px;
46
46
  opacity: 0;
47
47
  transition: opacity 0.25s ease;
48
48
  }
49
49
 
50
- [data-theme='dark'] .toggle .toggleTrackCheck,
51
- .toggleChecked .toggleTrackCheck {
50
+ .toggleChecked .toggleTrackCheck,
51
+ [data-theme='dark'] .toggle .toggleTrackCheck {
52
52
  opacity: 1;
53
53
  transition: opacity 0.25s ease;
54
54
  }
@@ -57,16 +57,16 @@
57
57
  position: absolute;
58
58
  width: 10px;
59
59
  height: 10px;
60
- top: 0px;
61
- bottom: 0px;
60
+ top: 0;
61
+ bottom: 0;
62
62
  margin: auto 0;
63
63
  right: 10px;
64
64
  opacity: 1;
65
65
  transition: opacity 0.25s ease;
66
66
  }
67
67
 
68
- [data-theme='dark'] .toggle .toggleTrackX,
69
- .toggleChecked .toggleTrackX {
68
+ .toggleChecked .toggleTrackX,
69
+ [data-theme='dark'] .toggle .toggleTrackX {
70
70
  opacity: 0;
71
71
  }
72
72
 
@@ -82,18 +82,19 @@
82
82
  transition: all 0.25s ease;
83
83
  }
84
84
 
85
- [data-theme='dark'] .toggle .toggleTrackThumb,
86
- .toggleChecked .toggleTrackThumb {
87
- left: 27px;
88
- }
89
-
90
85
  .toggleFocused .toggleTrackThumb,
91
86
  .toggle:hover .toggleTrackThumb {
92
- box-shadow: 0px 0px 2px 3px var(--ifm-color-primary);
87
+ box-shadow: 0 0 2px 3px var(--ifm-color-primary);
88
+ }
89
+
90
+ /* stylelint-disable-next-line no-descending-specificity */
91
+ .toggleChecked .toggleTrackThumb,
92
+ [data-theme='dark'] .toggle .toggleTrackThumb {
93
+ left: 27px;
93
94
  }
94
95
 
95
96
  .toggle:active:not(.toggleDisabled) .toggleTrackThumb {
96
- box-shadow: 0px 0px 5px 5px var(--ifm-color-primary);
97
+ box-shadow: 0 0 5px 5px var(--ifm-color-primary);
97
98
  }
98
99
 
99
100
  .toggleIcon {
@@ -12,14 +12,21 @@ import type * as PrismNamespace from 'prismjs';
12
12
  const prismIncludeLanguages = (PrismObject: typeof PrismNamespace): void => {
13
13
  if (ExecutionEnvironment.canUseDOM) {
14
14
  const {
15
- themeConfig: {prism = {}},
15
+ themeConfig: {prism},
16
16
  } = siteConfig;
17
- const {additionalLanguages = []} = prism as {additionalLanguages: string[]};
17
+ const {additionalLanguages} = prism as {additionalLanguages: string[]};
18
18
 
19
+ // Prism components work on the Prism instance on the window, while
20
+ // prism-react-renderer uses its own Prism instance. We temporarily mount
21
+ // the instance onto window, import components to enhance it, then remove it
22
+ // to avoid polluting global namespace.
23
+ // You can mutate this object: registering plugins, deleting languages... As
24
+ // long as you don't re-assign it
19
25
  window.Prism = PrismObject;
20
26
 
21
27
  additionalLanguages.forEach((lang) => {
22
- require(`prismjs/components/prism-${lang}`); // eslint-disable-line
28
+ // eslint-disable-next-line global-require, import/no-dynamic-require
29
+ require(`prismjs/components/prism-${lang}`);
23
30
  });
24
31
 
25
32
  delete (window as Window & {Prism?: typeof PrismNamespace}).Prism;