@docusaurus/theme-classic 0.0.0-4369 → 0.0.0-4378

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 (82) hide show
  1. package/lib/index.js +0 -2
  2. package/lib/theme-classic.d.ts +57 -161
  3. package/lib-next/theme/CodeBlock/index.js +1 -1
  4. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
  5. package/lib-next/theme/DocItem/index.js +7 -4
  6. package/lib-next/theme/DocSidebar/index.js +2 -2
  7. package/lib-next/theme/DocSidebarItem/index.js +3 -16
  8. package/lib-next/theme/DocSidebarItems/index.js +26 -0
  9. package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +11 -2
  10. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  11. package/lib-next/theme/Heading/index.js +39 -42
  12. package/lib-next/theme/Layout/index.js +1 -2
  13. package/lib-next/theme/LayoutProviders/index.js +6 -6
  14. package/lib-next/theme/MDXComponents/index.js +6 -6
  15. package/lib-next/theme/Navbar/index.js +6 -6
  16. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  17. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  18. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +5 -2
  19. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +1 -1
  20. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  21. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
  22. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  23. package/lib-next/theme/NavbarItem/index.js +0 -2
  24. package/lib-next/theme/{ThemeContext.js → NavbarItem/utils.js} +3 -3
  25. package/lib-next/theme/SkipToContent/index.js +1 -1
  26. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  27. package/lib-next/theme/Tabs/index.js +6 -3
  28. package/lib-next/theme/ThemedImage/index.js +2 -2
  29. package/package.json +12 -12
  30. package/src/index.ts +0 -4
  31. package/src/theme/CodeBlock/index.tsx +1 -1
  32. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
  33. package/src/theme/DocItem/index.tsx +7 -4
  34. package/src/theme/DocSidebar/index.tsx +2 -2
  35. package/src/theme/DocSidebarItem/index.tsx +3 -19
  36. package/src/theme/DocSidebarItems/index.tsx +31 -0
  37. package/{lib-next/theme/hooks/styles.css → src/theme/DocSidebarItems/styles.module.css} +11 -2
  38. package/src/theme/DocVersionBanner/index.tsx +1 -1
  39. package/src/theme/Heading/index.tsx +39 -46
  40. package/src/theme/Layout/index.tsx +1 -2
  41. package/src/theme/LayoutProviders/index.tsx +6 -6
  42. package/src/theme/MDXComponents/index.tsx +6 -6
  43. package/src/theme/Navbar/index.tsx +6 -6
  44. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  45. package/src/theme/NavbarItem/DocNavbarItem.tsx +5 -2
  46. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +7 -3
  47. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +1 -1
  48. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +1 -1
  49. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
  50. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  51. package/src/theme/NavbarItem/index.tsx +0 -3
  52. package/src/theme/{UserPreferencesContext.ts → NavbarItem/utils.ts} +3 -5
  53. package/src/theme/SkipToContent/index.tsx +1 -1
  54. package/src/theme/Tabs/index.tsx +6 -3
  55. package/src/theme/ThemedImage/index.tsx +2 -2
  56. package/src/theme-classic.d.ts +57 -161
  57. package/lib-next/theme/ThemeProvider/index.js +0 -28
  58. package/lib-next/theme/UserPreferencesContext.js +0 -9
  59. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  60. package/lib-next/theme/hooks/useDocs.js +0 -10
  61. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  62. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  63. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  64. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  65. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  66. package/lib-next/theme/hooks/useTheme.js +0 -81
  67. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  68. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  69. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  70. package/src/theme/ThemeContext.ts +0 -15
  71. package/src/theme/ThemeProvider/index.tsx +0 -28
  72. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  73. package/src/theme/hooks/useDocs.ts +0 -11
  74. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  75. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  76. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  77. package/src/theme/hooks/usePrismTheme.ts +0 -22
  78. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  79. package/src/theme/hooks/useTheme.ts +0 -91
  80. package/src/theme/hooks/useThemeContext.ts +0 -23
  81. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  82. package/src/theme/hooks/useWindowSize.ts +0 -69
package/lib/index.js CHANGED
@@ -178,8 +178,6 @@ options) {
178
178
  configureWebpack() {
179
179
  const prismLanguages = additionalLanguages.map(lang => `prism-${lang}`).join('|');
180
180
  return {
181
- ignoreWarnings: [// See https://github.com/facebook/docusaurus/pull/3382
182
- e => e.message.includes("Can't resolve '@theme-init/hooks/useDocs")],
183
181
  plugins: [new ContextReplacementPlugin(/prismjs[\\/]components$/, new RegExp(`^./(${prismLanguages})$`))]
184
182
  };
185
183
  },
@@ -149,23 +149,33 @@ declare module '@theme/DocSidebar' {
149
149
  declare module '@theme/DocSidebarItem' {
150
150
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
151
151
 
152
- type DocSidebarPropsBase = {
152
+ export type DocSidebarPropsBase = {
153
153
  readonly activePath: string;
154
154
  readonly onItemClick?: (item: PropSidebarItem) => void;
155
155
  readonly level: number;
156
156
  readonly tabIndex?: number;
157
157
  };
158
158
 
159
- export interface Props extends DocSidebarPropsBase {
159
+ export interface Props {
160
+ readonly activePath: string;
161
+ readonly onItemClick?: (item: PropSidebarItem) => void;
162
+ readonly level: number;
163
+ readonly tabIndex?: number;
160
164
  readonly item: PropSidebarItem;
161
165
  }
162
- const DocSidebarItem: (props: Props) => JSX.Element;
163
- export default DocSidebarItem;
164
166
 
165
- export type DocSidebarItemsProps = DocSidebarPropsBase & {
167
+ export default function DocSidebarItem(props: Props): JSX.Element;
168
+ }
169
+
170
+ declare module '@theme/DocSidebarItems' {
171
+ import type {Props as DocSidebarItemProps} from '@theme/DocSidebarItem';
172
+ import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
173
+
174
+ export type Props = Omit<DocSidebarItemProps, 'item'> & {
166
175
  readonly items: readonly PropSidebarItem[];
167
176
  };
168
- export const DocSidebarItems: (props: DocSidebarItemsProps) => JSX.Element;
177
+
178
+ export default function DocSidebarItems(props: Props): JSX.Element;
169
179
  }
170
180
 
171
181
  declare module '@theme/DocVersionSuggestions' {
@@ -196,92 +206,13 @@ declare module '@theme/Footer' {
196
206
  declare module '@theme/Heading' {
197
207
  import type {ComponentProps} from 'react';
198
208
 
199
- export type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
200
- export interface Props extends ComponentProps<HeadingType> {}
201
-
202
- const Heading: (Tag: HeadingType) => (props: Props) => JSX.Element;
203
- export default Heading;
204
- export const MainHeading: (props: Props) => JSX.Element;
205
- }
206
-
207
- declare module '@theme/hooks/useHideableNavbar' {
208
- export type useHideableNavbarReturns = {
209
- readonly navbarRef: (node: HTMLElement | null) => void;
210
- readonly isNavbarVisible: boolean;
211
- };
212
-
213
- const useHideableNavbar: (hideOnScroll: boolean) => useHideableNavbarReturns;
214
- export default useHideableNavbar;
215
- }
216
-
217
- declare module '@theme/hooks/useLockBodyScroll' {
218
- const useLockBodyScroll: (lock?: boolean) => void;
219
- export default useLockBodyScroll;
220
- }
221
-
222
- declare module '@theme/hooks/usePrismTheme' {
223
- import type defaultTheme from 'prism-react-renderer/themes/palenight';
224
-
225
- const usePrismTheme: () => typeof defaultTheme;
226
- export default usePrismTheme;
227
- }
228
-
229
- declare module '@theme/hooks/useTabGroupChoice' {
230
- export type useTabGroupChoiceReturns = {
231
- readonly tabGroupChoices: {readonly [groupId: string]: string};
232
- readonly setTabGroupChoices: (groupId: string, newChoice: string) => void;
233
- };
234
-
235
- const useTabGroupChoice: () => useTabGroupChoiceReturns;
236
- export default useTabGroupChoice;
237
- }
238
-
239
- declare module '@theme/hooks/useTheme' {
240
- export type useThemeReturns = {
241
- readonly isDarkTheme: boolean;
242
- readonly setLightTheme: () => void;
243
- readonly setDarkTheme: () => void;
244
- };
209
+ type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
245
210
 
246
- const useTheme: () => useThemeReturns;
247
- export default useTheme;
248
- }
249
-
250
- declare module '@theme/hooks/useThemeContext' {
251
- export type ThemeContextProps = {
252
- isDarkTheme: boolean;
253
- setLightTheme: () => void;
254
- setDarkTheme: () => void;
255
- };
256
-
257
- export default function useThemeContext(): ThemeContextProps;
258
- }
259
-
260
- declare module '@theme/hooks/useUserPreferencesContext' {
261
- export type UserPreferencesContextProps = {
262
- tabGroupChoices: {readonly [groupId: string]: string};
263
- setTabGroupChoices: (groupId: string, newChoice: string) => void;
264
- };
265
-
266
- export default function useUserPreferencesContext(): UserPreferencesContextProps;
267
- }
268
-
269
- declare module '@theme/hooks/useWindowSize' {
270
- export const windowSizes: {
271
- desktop: 'desktop';
272
- mobile: 'mobile';
273
- ssr: 'ssr';
274
- };
275
-
276
- export type WindowSize = keyof typeof windowSizes;
277
-
278
- export default function useWindowSize(): WindowSize;
279
- }
280
-
281
- declare module '@theme/hooks/useKeyboardNavigation' {
282
- const useKeyboardNavigation: () => void;
211
+ export interface Props extends ComponentProps<HeadingType> {
212
+ as: HeadingType;
213
+ }
283
214
 
284
- export default useKeyboardNavigation;
215
+ export default function Heading(props: Props): JSX.Element;
285
216
  }
286
217
 
287
218
  declare module '@theme/Layout' {
@@ -303,8 +234,7 @@ declare module '@theme/Layout' {
303
234
  };
304
235
  }
305
236
 
306
- const Layout: (props: Props) => JSX.Element;
307
- export default Layout;
237
+ export default function Layout(props: Props): JSX.Element;
308
238
  }
309
239
 
310
240
  declare module '@theme/LayoutHead' {
@@ -312,8 +242,17 @@ declare module '@theme/LayoutHead' {
312
242
 
313
243
  export interface Props extends Omit<LayoutProps, 'children'> {}
314
244
 
315
- const LayoutHead: (props: Props) => JSX.Element;
316
- export default LayoutHead;
245
+ export default function LayoutHead(props: Props): JSX.Element;
246
+ }
247
+
248
+ declare module '@theme/LayoutProviders' {
249
+ import type {ReactNode} from 'react';
250
+
251
+ export interface Props {
252
+ readonly children: ReactNode;
253
+ }
254
+
255
+ export default function LayoutProviders(props: Props): JSX.Element;
317
256
  }
318
257
 
319
258
  declare module '@theme/SearchMetadata' {
@@ -372,18 +311,9 @@ declare module '@theme/Navbar' {
372
311
  }
373
312
 
374
313
  declare module '@theme/NavbarItem/DefaultNavbarItem' {
375
- import type {ReactNode} from 'react';
376
- import type {LinkProps} from '@docusaurus/Link';
377
-
378
- export type NavLinkProps = LinkProps & {
379
- readonly activeBasePath?: string;
380
- readonly activeBaseRegex?: string;
381
- readonly exact?: boolean;
382
- readonly label?: ReactNode;
383
- readonly prependBaseUrlToHref?: string;
384
- };
314
+ import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
385
315
 
386
- export type DesktopOrMobileNavBarItemProps = NavLinkProps & {
316
+ export type DesktopOrMobileNavBarItemProps = NavbarNavLinkProps & {
387
317
  readonly isDropdownItem?: boolean;
388
318
  readonly className?: string;
389
319
  readonly position?: 'left' | 'right';
@@ -393,17 +323,30 @@ declare module '@theme/NavbarItem/DefaultNavbarItem' {
393
323
  readonly mobile?: boolean;
394
324
  }
395
325
 
396
- export const NavLink: (props: NavLinkProps) => JSX.Element;
326
+ export default function DefaultNavbarItem(props: Props): JSX.Element;
327
+ }
397
328
 
398
- const DefaultNavbarItem: (props: Props) => JSX.Element;
399
- export default DefaultNavbarItem;
329
+ declare module '@theme/NavbarItem/NavbarNavLink' {
330
+ import type {ReactNode} from 'react';
331
+ import type {LinkProps} from '@docusaurus/Link';
332
+
333
+ export type Props = LinkProps & {
334
+ readonly activeBasePath?: string;
335
+ readonly activeBaseRegex?: string;
336
+ readonly exact?: boolean;
337
+ readonly label?: ReactNode;
338
+ readonly prependBaseUrlToHref?: string;
339
+ };
340
+
341
+ export default function NavbarNavLink(props: Props): JSX.Element;
400
342
  }
401
343
 
402
344
  declare module '@theme/NavbarItem/DropdownNavbarItem' {
403
- import type {NavLinkProps} from '@theme/NavbarItem/DefaultNavbarItem';
345
+ import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
346
+
404
347
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
405
348
 
406
- export type DesktopOrMobileNavBarItemProps = NavLinkProps & {
349
+ export type DesktopOrMobileNavBarItemProps = NavbarNavLinkProps & {
407
350
  readonly position?: 'left' | 'right';
408
351
  readonly items: readonly LinkLikeNavbarItemProps[];
409
352
  readonly className?: string;
@@ -526,6 +469,10 @@ declare module '@theme/NavbarItem' {
526
469
  export default NavbarItem;
527
470
  }
528
471
 
472
+ declare module '@theme/NavbarItem/utils' {
473
+ export function getInfimaActiveClassName(mobile?: boolean): string;
474
+ }
475
+
529
476
  declare module '@theme/PaginatorNavLink' {
530
477
  import type {ReactNode} from 'react';
531
478
  import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
@@ -602,17 +549,6 @@ declare module '@theme/Details' {
602
549
  export default Details;
603
550
  }
604
551
 
605
- declare module '@theme/ThemeProvider' {
606
- import type {ReactNode} from 'react';
607
-
608
- export interface Props {
609
- readonly children: ReactNode;
610
- }
611
-
612
- const ThemeProvider: (props: Props) => JSX.Element;
613
- export default ThemeProvider;
614
- }
615
-
616
552
  declare module '@theme/TOCItems' {
617
553
  import type {TOCItem} from '@docusaurus/types';
618
554
 
@@ -693,46 +629,6 @@ declare module '@theme/Toggle' {
693
629
  export default Toggle;
694
630
  }
695
631
 
696
- declare module '@theme/UserPreferencesProvider' {
697
- import type {ReactNode} from 'react';
698
-
699
- export interface Props {
700
- readonly children: ReactNode;
701
- }
702
-
703
- const UserPreferencesProvider: (props: Props) => JSX.Element;
704
- export default UserPreferencesProvider;
705
- }
706
-
707
- declare module '@theme/LayoutProviders' {
708
- import type {ReactNode} from 'react';
709
-
710
- export interface Props {
711
- readonly children: ReactNode;
712
- }
713
-
714
- const LayoutProviders: (props: Props) => JSX.Element;
715
- export default LayoutProviders;
716
- }
717
-
718
- declare module '@theme/ThemeContext' {
719
- import type {Context} from 'react';
720
- import type {ThemeContextProps} from '@theme/hooks/useThemeContext';
721
-
722
- const ThemeContext: Context<ThemeContextProps | undefined>;
723
- export default ThemeContext;
724
- }
725
-
726
- declare module '@theme/UserPreferencesContext' {
727
- import type {Context} from 'react';
728
- import type {UserPreferencesContextProps} from '@theme/hooks/useUserPreferencesContext';
729
-
730
- const UserPreferencesContext: Context<
731
- UserPreferencesContextProps | undefined
732
- >;
733
- export default UserPreferencesContext;
734
- }
735
-
736
632
  declare module '@theme/Logo' {
737
633
  import type {ComponentProps} from 'react';
738
634
 
@@ -15,8 +15,8 @@ import {
15
15
  parseLanguage,
16
16
  parseLines,
17
17
  ThemeClassNames,
18
+ usePrismTheme,
18
19
  } from '@docusaurus/theme-common';
19
- import usePrismTheme from '@theme/hooks/usePrismTheme';
20
20
  import styles from './styles.module.css';
21
21
  export default function CodeBlock({
22
22
  children,
@@ -11,7 +11,7 @@ import DocPaginator from '@theme/DocPaginator';
11
11
  import Seo from '@theme/Seo';
12
12
  import DocVersionBanner from '@theme/DocVersionBanner';
13
13
  import DocVersionBadge from '@theme/DocVersionBadge';
14
- import {MainHeading} from '@theme/Heading';
14
+ import Heading from '@theme/Heading';
15
15
  import useBaseUrl from '@docusaurus/useBaseUrl';
16
16
  import styles from './styles.module.css';
17
17
  export default function DocCategoryGeneratedIndexPage({
@@ -30,9 +30,9 @@ export default function DocCategoryGeneratedIndexPage({
30
30
  <DocVersionBanner />
31
31
  <DocVersionBadge />
32
32
  <header>
33
- <MainHeading className={styles.title}>
33
+ <Heading as="h1" className={styles.title}>
34
34
  {categoryGeneratedIndex.title}
35
- </MainHeading>
35
+ </Heading>
36
36
  {categoryGeneratedIndex.description && (
37
37
  <p>{categoryGeneratedIndex.description}</p>
38
38
  )}
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import useWindowSize from '@theme/hooks/useWindowSize';
10
9
  import DocPaginator from '@theme/DocPaginator';
11
10
  import DocVersionBanner from '@theme/DocVersionBanner';
12
11
  import DocVersionBadge from '@theme/DocVersionBadge';
@@ -14,9 +13,9 @@ import Seo from '@theme/Seo';
14
13
  import DocItemFooter from '@theme/DocItemFooter';
15
14
  import TOC from '@theme/TOC';
16
15
  import TOCCollapsible from '@theme/TOCCollapsible';
17
- import {MainHeading} from '@theme/Heading';
16
+ import Heading from '@theme/Heading';
18
17
  import styles from './styles.module.css';
19
- import {ThemeClassNames} from '@docusaurus/theme-common';
18
+ import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
20
19
  export default function DocItem(props) {
21
20
  const {content: DocContent} = props;
22
21
  const {metadata, frontMatter} = DocContent;
@@ -79,7 +78,11 @@ export default function DocItem(props) {
79
78
  To make both cases consistent, the added title is added under the same div.markdown block
80
79
  See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
81
80
  */}
82
- {shouldAddTitle && <MainHeading>{title}</MainHeading>}
81
+ {shouldAddTitle && (
82
+ <header>
83
+ <Heading as="h1">{title}</Heading>
84
+ </header>
85
+ )}
83
86
 
84
87
  <DocContent />
85
88
  </div>
@@ -12,12 +12,12 @@ import {
12
12
  MobileSecondaryMenuFiller,
13
13
  ThemeClassNames,
14
14
  useScrollPosition,
15
+ useWindowSize,
15
16
  } from '@docusaurus/theme-common';
16
- import useWindowSize from '@theme/hooks/useWindowSize';
17
17
  import Logo from '@theme/Logo';
18
18
  import IconArrow from '@theme/IconArrow';
19
19
  import {translate} from '@docusaurus/Translate';
20
- import {DocSidebarItems} from '@theme/DocSidebarItem';
20
+ import DocSidebarItems from '@theme/DocSidebarItems';
21
21
  import styles from './styles.module.css';
22
22
 
23
23
  function useShowAnnouncementBar() {
@@ -4,7 +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 React, {useEffect, memo, useMemo} from 'react';
7
+ import React, {useEffect, useMemo} from 'react';
8
8
  import clsx from 'clsx';
9
9
  import {
10
10
  isActiveSidebarItem,
@@ -18,22 +18,9 @@ import Link from '@docusaurus/Link';
18
18
  import isInternalUrl from '@docusaurus/isInternalUrl';
19
19
  import {translate} from '@docusaurus/Translate';
20
20
  import IconExternalLink from '@theme/IconExternalLink';
21
+ import DocSidebarItems from '@theme/DocSidebarItems';
21
22
  import styles from './styles.module.css';
22
- import useIsBrowser from '@docusaurus/useIsBrowser'; // Optimize sidebar at each "level"
23
- // TODO this item should probably not receive the "activePath" props
24
- // TODO this triggers whole sidebar re-renders on navigation
25
-
26
- export const DocSidebarItems = memo(({items, ...props}) => (
27
- <>
28
- {items.map((item, index) => (
29
- <DocSidebarItem
30
- key={index} // sidebar is static, the index does not change
31
- item={item}
32
- {...props}
33
- />
34
- ))}
35
- </>
36
- ));
23
+ import useIsBrowser from '@docusaurus/useIsBrowser';
37
24
  export default function DocSidebarItem({item, ...props}) {
38
25
  switch (item.type) {
39
26
  case 'category':
@@ -0,0 +1,26 @@
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, {memo} from 'react';
8
+ import DocSidebarItem from '@theme/DocSidebarItem';
9
+
10
+ // TODO this item should probably not receive the "activePath" props
11
+ // TODO this triggers whole sidebar re-renders on navigation
12
+ function DocSidebarItems({items, ...props}) {
13
+ return (
14
+ <>
15
+ {items.map((item, index) => (
16
+ <DocSidebarItem
17
+ key={index} // sidebar is static, the index does not change
18
+ item={item}
19
+ {...props}
20
+ />
21
+ ))}
22
+ </>
23
+ );
24
+ } // Optimize sidebar at each "level"
25
+
26
+ export default memo(DocSidebarItems);
@@ -5,6 +5,15 @@
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;
8
+ @media (min-width: 997px) {
9
+ .menuLinkText {
10
+ cursor: initial;
11
+ }
12
+ .menuLinkText:hover {
13
+ background: none;
14
+ }
15
+
16
+ .menuLinkText.hasHref {
17
+ cursor: pointer;
18
+ }
10
19
  }
@@ -8,7 +8,10 @@ import React from 'react';
8
8
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
9
9
  import Link from '@docusaurus/Link';
10
10
  import Translate from '@docusaurus/Translate';
11
- import {useActivePlugin, useDocVersionSuggestions} from '@theme/hooks/useDocs';
11
+ import {
12
+ useActivePlugin,
13
+ useDocVersionSuggestions,
14
+ } from '@docusaurus/plugin-content-docs/client';
12
15
  import {
13
16
  ThemeClassNames,
14
17
  useDocsPreferredVersion,
@@ -10,53 +10,50 @@ import {translate} from '@docusaurus/Translate';
10
10
  import {useThemeConfig} from '@docusaurus/theme-common';
11
11
  import './styles.css';
12
12
  import styles from './styles.module.css';
13
- // eslint-disable-next-line react/function-component-definition
14
- export const MainHeading = ({...props}) => (
15
- <header>
16
- <h1
17
- {...props}
18
- id={undefined} // h1 headings do not need an id because they don't appear in the TOC
19
- >
20
- {props.children}
21
- </h1>
22
- </header>
23
- );
24
13
 
25
- const createAnchorHeading =
26
- (Tag) =>
27
- ({id, ...props}) => {
28
- const {
29
- navbar: {hideOnScroll},
30
- } = useThemeConfig();
14
+ function AnchorHeading({as: As, id, ...props}) {
15
+ const {
16
+ navbar: {hideOnScroll},
17
+ } = useThemeConfig();
18
+
19
+ if (!id) {
20
+ return <As {...props} />;
21
+ }
31
22
 
32
- if (!id) {
33
- return <Tag {...props} />;
34
- }
23
+ return (
24
+ <As
25
+ {...props}
26
+ className={clsx('anchor', {
27
+ [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
28
+ [styles.anchorWithStickyNavbar]: !hideOnScroll,
29
+ })}
30
+ id={id}>
31
+ {props.children}
32
+ <a
33
+ className="hash-link"
34
+ href={`#${id}`}
35
+ title={translate({
36
+ id: 'theme.common.headingLinkTitle',
37
+ message: 'Direct link to heading',
38
+ description: 'Title for link to heading',
39
+ })}>
40
+ &#8203;
41
+ </a>
42
+ </As>
43
+ );
44
+ }
35
45
 
46
+ export default function Heading({as, ...props}) {
47
+ if (as === 'h1') {
36
48
  return (
37
- <Tag
49
+ <h1
38
50
  {...props}
39
- className={clsx('anchor', {
40
- [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
41
- [styles.anchorWithStickyNavbar]: !hideOnScroll,
42
- })}
43
- id={id}>
51
+ id={undefined} // h1 headings do not need an id because they don't appear in the TOC
52
+ >
44
53
  {props.children}
45
- <a
46
- className="hash-link"
47
- href={`#${id}`}
48
- title={translate({
49
- id: 'theme.common.headingLinkTitle',
50
- message: 'Direct link to heading',
51
- description: 'Title for link to heading',
52
- })}>
53
- &#8203;
54
- </a>
55
- </Tag>
54
+ </h1>
56
55
  );
57
- };
58
-
59
- const Heading = (headingType) =>
60
- headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
56
+ }
61
57
 
62
- export default Heading;
58
+ return <AnchorHeading as={as} {...props} />;
59
+ }
@@ -13,8 +13,7 @@ import Navbar from '@theme/Navbar';
13
13
  import Footer from '@theme/Footer';
14
14
  import LayoutProviders from '@theme/LayoutProviders';
15
15
  import LayoutHead from '@theme/LayoutHead';
16
- import useKeyboardNavigation from '@theme/hooks/useKeyboardNavigation';
17
- import {ThemeClassNames} from '@docusaurus/theme-common';
16
+ import {ThemeClassNames, useKeyboardNavigation} from '@docusaurus/theme-common';
18
17
  import ErrorPageContent from '@theme/ErrorPageContent';
19
18
  import './styles.css';
20
19
 
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import ThemeProvider from '@theme/ThemeProvider';
9
- import UserPreferencesProvider from '@theme/UserPreferencesProvider';
10
8
  import {
9
+ ColorModeProvider,
10
+ TabGroupChoiceProvider,
11
11
  AnnouncementBarProvider,
12
12
  DocsPreferredVersionContextProvider,
13
13
  MobileSecondaryMenuProvider,
@@ -15,9 +15,9 @@ import {
15
15
  } from '@docusaurus/theme-common';
16
16
  export default function LayoutProviders({children}) {
17
17
  return (
18
- <ThemeProvider>
18
+ <ColorModeProvider>
19
19
  <AnnouncementBarProvider>
20
- <UserPreferencesProvider>
20
+ <TabGroupChoiceProvider>
21
21
  <ScrollControllerProvider>
22
22
  <DocsPreferredVersionContextProvider>
23
23
  <MobileSecondaryMenuProvider>
@@ -25,8 +25,8 @@ export default function LayoutProviders({children}) {
25
25
  </MobileSecondaryMenuProvider>
26
26
  </DocsPreferredVersionContextProvider>
27
27
  </ScrollControllerProvider>
28
- </UserPreferencesProvider>
28
+ </TabGroupChoiceProvider>
29
29
  </AnnouncementBarProvider>
30
- </ThemeProvider>
30
+ </ColorModeProvider>
31
31
  );
32
32
  }
@@ -55,11 +55,11 @@ const MDXComponents = {
55
55
  </Details>
56
56
  );
57
57
  },
58
- h1: Heading('h1'),
59
- h2: Heading('h2'),
60
- h3: Heading('h3'),
61
- h4: Heading('h4'),
62
- h5: Heading('h5'),
63
- h6: Heading('h6'),
58
+ h1: (props) => <Heading as="h1" {...props} />,
59
+ h2: (props) => <Heading as="h2" {...props} />,
60
+ h3: (props) => <Heading as="h3" {...props} />,
61
+ h4: (props) => <Heading as="h4" {...props} />,
62
+ h5: (props) => <Heading as="h5" {...props} />,
63
+ h6: (props) => <Heading as="h6" {...props} />,
64
64
  };
65
65
  export default MDXComponents;
@@ -9,17 +9,17 @@ import clsx from 'clsx';
9
9
  import Translate from '@docusaurus/Translate';
10
10
  import SearchBar from '@theme/SearchBar';
11
11
  import Toggle from '@theme/Toggle';
12
- import useThemeContext from '@theme/hooks/useThemeContext';
13
12
  import {
14
13
  useThemeConfig,
15
14
  useMobileSecondaryMenuRenderer,
16
15
  usePrevious,
17
16
  useHistoryPopHandler,
17
+ useHideableNavbar,
18
+ useLockBodyScroll,
19
+ useWindowSize,
20
+ useColorMode,
18
21
  } from '@docusaurus/theme-common';
19
- import useHideableNavbar from '@theme/hooks/useHideableNavbar';
20
- import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
21
- import useWindowSize from '@theme/hooks/useWindowSize';
22
- import {useActivePlugin} from '@theme/hooks/useDocs';
22
+ import {useActivePlugin} from '@docusaurus/plugin-content-docs/client';
23
23
  import NavbarItem from '@theme/NavbarItem';
24
24
  import Logo from '@theme/Logo';
25
25
  import IconMenu from '@theme/IconMenu';
@@ -84,7 +84,7 @@ function useColorModeToggle() {
84
84
  const {
85
85
  colorMode: {disableSwitch},
86
86
  } = useThemeConfig();
87
- const {isDarkTheme, setLightTheme, setDarkTheme} = useThemeContext();
87
+ const {isDarkTheme, setLightTheme, setDarkTheme} = useColorMode();
88
88
  const toggle = useCallback(
89
89
  (e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
90
90
  [setLightTheme, setDarkTheme],