@docusaurus/theme-classic 2.0.0-beta.14 → 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 (152) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +7 -16
  3. package/lib/theme-classic.d.ts +89 -182
  4. package/lib/validateThemeConfig.js +13 -1
  5. package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
  6. package/lib-next/theme/BlogListPaginator/index.js +12 -12
  7. package/lib-next/theme/BlogPostAuthor/index.js +1 -1
  8. package/lib-next/theme/BlogPostAuthors/index.js +12 -2
  9. package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
  10. package/lib-next/theme/BlogPostItem/index.js +12 -15
  11. package/lib-next/theme/BlogPostPage/index.js +10 -7
  12. package/lib-next/theme/BlogPostPaginator/index.js +11 -15
  13. package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
  14. package/lib-next/theme/CodeBlock/index.js +44 -9
  15. package/lib-next/theme/CodeBlock/styles.module.css +12 -7
  16. package/lib-next/theme/DocCard/styles.module.css +3 -3
  17. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
  18. package/lib-next/theme/DocItem/index.js +9 -6
  19. package/lib-next/theme/DocItem/styles.module.css +2 -2
  20. package/lib-next/theme/DocPage/index.js +7 -3
  21. package/lib-next/theme/DocPage/styles.module.css +1 -0
  22. package/lib-next/theme/DocPaginator/index.js +26 -4
  23. package/lib-next/theme/DocSidebar/index.js +2 -2
  24. package/lib-next/theme/DocSidebar/styles.module.css +1 -0
  25. package/lib-next/theme/DocSidebarItem/index.js +43 -21
  26. package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
  27. package/lib-next/theme/DocSidebarItems/index.js +28 -0
  28. package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +12 -2
  29. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  30. package/lib-next/theme/Footer/styles.module.css +2 -1
  31. package/lib-next/theme/Heading/index.js +39 -42
  32. package/lib-next/theme/Heading/styles.css +1 -1
  33. package/lib-next/theme/Layout/index.js +1 -2
  34. package/lib-next/theme/LayoutHead/index.js +5 -9
  35. package/lib-next/theme/LayoutProviders/index.js +6 -6
  36. package/lib-next/theme/MDXComponents/index.js +18 -31
  37. package/lib-next/theme/MDXComponents/styles.css +4 -0
  38. package/lib-next/theme/MDXPage/index.js +3 -10
  39. package/lib-next/theme/Navbar/index.js +6 -6
  40. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  41. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  42. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
  43. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
  44. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  45. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
  46. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  47. package/lib-next/theme/NavbarItem/index.js +1 -2
  48. package/lib-next/theme/{hooks/styles.css → NavbarItem/utils.js} +3 -4
  49. package/lib-next/theme/PaginatorNavLink/index.js +20 -0
  50. package/lib-next/theme/SkipToContent/index.js +1 -1
  51. package/lib-next/theme/SkipToContent/styles.module.css +7 -0
  52. package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
  53. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  54. package/lib-next/theme/Tabs/index.js +6 -3
  55. package/lib-next/theme/Tag/styles.module.css +4 -4
  56. package/lib-next/theme/ThemedImage/index.js +2 -2
  57. package/lib-next/theme/Toggle/styles.module.css +16 -15
  58. package/lib-next/theme/prism-include-languages.js +10 -3
  59. package/package.json +16 -17
  60. package/src/index.ts +10 -21
  61. package/src/theme/Admonition/index.tsx +1 -1
  62. package/src/theme/BackToTopButton/styles.module.css +1 -1
  63. package/src/theme/BlogListPaginator/index.tsx +12 -12
  64. package/src/theme/BlogPostAuthor/index.tsx +1 -1
  65. package/src/theme/BlogPostAuthors/index.tsx +12 -2
  66. package/src/theme/BlogPostAuthors/styles.module.css +10 -0
  67. package/src/theme/BlogPostItem/index.tsx +13 -15
  68. package/src/theme/BlogPostPage/index.tsx +10 -7
  69. package/src/theme/BlogPostPaginator/index.tsx +11 -15
  70. package/src/theme/BlogSidebar/styles.module.css +2 -0
  71. package/src/theme/CodeBlock/index.tsx +45 -10
  72. package/src/theme/CodeBlock/styles.module.css +12 -7
  73. package/src/theme/DocCard/index.tsx +2 -2
  74. package/src/theme/DocCard/styles.module.css +3 -3
  75. package/src/theme/DocCardList/index.tsx +1 -1
  76. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
  77. package/src/theme/DocItem/index.tsx +9 -6
  78. package/src/theme/DocItem/styles.module.css +2 -2
  79. package/src/theme/DocItemFooter/index.tsx +1 -1
  80. package/src/theme/DocPage/index.tsx +8 -4
  81. package/src/theme/DocPage/styles.module.css +1 -0
  82. package/src/theme/DocPaginator/index.tsx +26 -4
  83. package/src/theme/DocSidebar/index.tsx +3 -3
  84. package/src/theme/DocSidebar/styles.module.css +1 -0
  85. package/src/theme/DocSidebarItem/index.tsx +34 -23
  86. package/src/theme/DocSidebarItem/styles.module.css +1 -0
  87. package/src/theme/DocSidebarItems/index.tsx +32 -0
  88. package/src/theme/{UserPreferencesContext.ts → DocSidebarItems/styles.module.css} +11 -3
  89. package/src/theme/DocVersionBanner/index.tsx +3 -3
  90. package/src/theme/Footer/index.tsx +4 -4
  91. package/src/theme/Footer/styles.module.css +2 -1
  92. package/src/theme/Heading/index.tsx +39 -46
  93. package/src/theme/Heading/styles.css +1 -1
  94. package/src/theme/Layout/index.tsx +1 -2
  95. package/src/theme/LayoutHead/index.tsx +4 -8
  96. package/src/theme/LayoutProviders/index.tsx +6 -6
  97. package/src/theme/MDXComponents/index.tsx +26 -37
  98. package/src/theme/MDXComponents/styles.css +4 -0
  99. package/src/theme/MDXPage/index.tsx +3 -11
  100. package/src/theme/Navbar/index.tsx +7 -7
  101. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  102. package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
  103. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
  104. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
  105. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
  106. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
  107. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  108. package/src/theme/NavbarItem/index.tsx +3 -5
  109. package/{lib-next/theme/UserPreferencesContext.js → src/theme/NavbarItem/utils.ts} +4 -3
  110. package/src/theme/PaginatorNavLink/index.tsx +22 -0
  111. package/src/theme/SkipToContent/index.tsx +1 -1
  112. package/src/theme/SkipToContent/styles.module.css +7 -0
  113. package/src/theme/TOCCollapsible/styles.module.css +2 -2
  114. package/src/theme/TOCItems/index.tsx +2 -2
  115. package/src/theme/Tabs/index.tsx +7 -4
  116. package/src/theme/Tag/styles.module.css +4 -4
  117. package/src/theme/TagsListByLetter/index.tsx +1 -1
  118. package/src/theme/ThemedImage/index.tsx +2 -2
  119. package/src/theme/Toggle/index.tsx +1 -1
  120. package/src/theme/Toggle/styles.module.css +16 -15
  121. package/src/theme/prism-include-languages.ts +10 -3
  122. package/src/theme-classic.d.ts +89 -182
  123. package/src/translations.ts +2 -2
  124. package/src/validateThemeConfig.ts +16 -0
  125. package/lib-next/theme/DocPaginatorNavLink/index.js +0 -36
  126. package/lib-next/theme/ThemeContext.js +0 -9
  127. package/lib-next/theme/ThemeProvider/index.js +0 -28
  128. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  129. package/lib-next/theme/hooks/useDocs.js +0 -10
  130. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  131. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  132. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  133. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  134. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  135. package/lib-next/theme/hooks/useTheme.js +0 -81
  136. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  137. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  138. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  139. package/src/theme/DocPaginatorNavLink/index.tsx +0 -38
  140. package/src/theme/ThemeContext.ts +0 -15
  141. package/src/theme/ThemeProvider/index.tsx +0 -28
  142. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  143. package/src/theme/hooks/useDocs.ts +0 -11
  144. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  145. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  146. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  147. package/src/theme/hooks/usePrismTheme.ts +0 -22
  148. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  149. package/src/theme/hooks/useTheme.ts +0 -91
  150. package/src/theme/hooks/useThemeContext.ts +0 -23
  151. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  152. package/src/theme/hooks/useWindowSize.ts +0 -69
@@ -7,71 +7,15 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import Link from '@docusaurus/Link';
11
- import useBaseUrl from '@docusaurus/useBaseUrl';
10
+
11
+ import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
12
+
12
13
  import type {
13
- NavLinkProps,
14
14
  DesktopOrMobileNavBarItemProps,
15
15
  Props,
16
16
  } from '@theme/NavbarItem/DefaultNavbarItem';
17
- import IconExternalLink from '@theme/IconExternalLink';
18
- import isInternalUrl from '@docusaurus/isInternalUrl';
19
- import {isRegexpStringMatch} from '@docusaurus/theme-common';
20
- import {getInfimaActiveClassName} from './index';
21
-
22
- const dropdownLinkActiveClass = 'dropdown__link--active';
23
-
24
- export function NavLink({
25
- activeBasePath,
26
- activeBaseRegex,
27
- to,
28
- href,
29
- label,
30
- activeClassName = '',
31
- prependBaseUrlToHref,
32
- ...props
33
- }: NavLinkProps): JSX.Element {
34
- // TODO all this seems hacky
35
- // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
36
- const toUrl = useBaseUrl(to);
37
- const activeBaseUrl = useBaseUrl(activeBasePath);
38
- const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
39
- const isExternalLink = label && href && !isInternalUrl(href);
40
- const isDropdownLink = activeClassName === dropdownLinkActiveClass;
41
17
 
42
- return (
43
- <Link
44
- {...(href
45
- ? {
46
- href: prependBaseUrlToHref ? normalizedHref : href,
47
- }
48
- : {
49
- isNavLink: true,
50
- activeClassName: !props.className?.includes(activeClassName)
51
- ? activeClassName
52
- : '',
53
- to: toUrl,
54
- ...(activeBasePath || activeBaseRegex
55
- ? {
56
- isActive: (_match, location) =>
57
- activeBaseRegex
58
- ? isRegexpStringMatch(activeBaseRegex, location.pathname)
59
- : location.pathname.startsWith(activeBaseUrl),
60
- }
61
- : null),
62
- })}
63
- {...props}>
64
- {isExternalLink ? (
65
- <span>
66
- {label}
67
- <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
68
- </span>
69
- ) : (
70
- label
71
- )}
72
- </Link>
73
- );
74
- }
18
+ import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
75
19
 
76
20
  function DefaultNavbarItemDesktop({
77
21
  className,
@@ -79,7 +23,7 @@ function DefaultNavbarItemDesktop({
79
23
  ...props
80
24
  }: DesktopOrMobileNavBarItemProps) {
81
25
  const element = (
82
- <NavLink
26
+ <NavbarNavLink
83
27
  className={clsx(
84
28
  isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
85
29
  className,
@@ -102,7 +46,7 @@ function DefaultNavbarItemMobile({
102
46
  }: DesktopOrMobileNavBarItemProps) {
103
47
  return (
104
48
  <li className="menu__list-item">
105
- <NavLink className={clsx('menu__link', className)} {...props} />
49
+ <NavbarNavLink className={clsx('menu__link', className)} {...props} />
106
50
  </li>
107
51
  );
108
52
  }
@@ -7,14 +7,17 @@
7
7
 
8
8
  import React from 'react';
9
9
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
- import {useLatestVersion, useActiveDocContext} from '@theme/hooks/useDocs';
10
+ import {
11
+ useLatestVersion,
12
+ useActiveDocContext,
13
+ } from '@docusaurus/plugin-content-docs/client';
11
14
  import clsx from 'clsx';
12
- import {getInfimaActiveClassName} from './index';
15
+ import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
13
16
  import type {Props} from '@theme/NavbarItem/DocNavbarItem';
14
17
  import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
15
- import type {GlobalDataVersion} from '@docusaurus/plugin-content-docs';
18
+ import type {GlobalVersion} from '@docusaurus/plugin-content-docs/client';
16
19
 
17
- function getDocInVersions(versions: GlobalDataVersion[], docId: string) {
20
+ function getDocInVersions(versions: GlobalVersion[], docId: string) {
18
21
  const allDocs = versions.flatMap((version) => version.docs);
19
22
  const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
20
23
  if (!doc) {
@@ -43,7 +46,7 @@ export default function DocNavbarItem({
43
46
  const versions = uniq(
44
47
  [activeVersion, preferredVersion, latestVersion].filter(
45
48
  Boolean,
46
- ) as GlobalDataVersion[],
49
+ ) as GlobalVersion[],
47
50
  );
48
51
  const doc = getDocInVersions(versions, docId);
49
52
  const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
@@ -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';
@@ -84,7 +84,7 @@ function DropdownNavbarItemDesktop({
84
84
  'dropdown--right': position === 'right',
85
85
  'dropdown--show': showDropdown,
86
86
  })}>
87
- <NavLink
87
+ <NavbarNavLink
88
88
  href={props.to ? undefined : '#'}
89
89
  className={clsx('navbar__link', className)}
90
90
  {...props}
@@ -96,7 +96,7 @@ function DropdownNavbarItemDesktop({
96
96
  }
97
97
  }}>
98
98
  {props.children ?? props.label}
99
- </NavLink>
99
+ </NavbarNavLink>
100
100
  <ul className="dropdown__menu">
101
101
  {items.map((childItemProps, i) => (
102
102
  <NavbarItem
@@ -146,7 +146,7 @@ function DropdownNavbarItemMobile({
146
146
  className={clsx('menu__list-item', {
147
147
  'menu__list-item--collapsed': collapsed,
148
148
  })}>
149
- <NavLink
149
+ <NavbarNavLink
150
150
  role="button"
151
151
  className={clsx('menu__link menu__link--sublist', className)}
152
152
  {...props}
@@ -155,7 +155,7 @@ function DropdownNavbarItemMobile({
155
155
  toggleCollapsed();
156
156
  }}>
157
157
  {props.children ?? props.label}
158
- </NavLink>
158
+ </NavbarNavLink>
159
159
  <Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
160
160
  {items.map((childItemProps, i) => (
161
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,
@@ -4,6 +4,7 @@
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 {createContext} from 'react';
8
- const UserPreferencesContext = createContext(undefined);
9
- export default UserPreferencesContext;
7
+
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
 
@@ -83,7 +86,7 @@ function TabsComponent(props: Props): JSX.Element {
83
86
  );
84
87
  }
85
88
 
86
- const {tabGroupChoices, setTabGroupChoices} = useUserPreferencesContext();
89
+ const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
87
90
  const [selectedValue, setSelectedValue] = useState(defaultValue);
88
91
  const tabRefs: (HTMLLIElement | null)[] = [];
89
92
  const {blockElementScrollPositionUntilNextRender} =
@@ -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 {