@docusaurus/theme-classic 0.0.0-4366 → 0.0.0-4377

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 (80) 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/Tabs/__tests__/index.test.js +8 -6
  26. package/lib-next/theme/Tabs/index.js +6 -3
  27. package/lib-next/theme/ThemedImage/index.js +2 -2
  28. package/package.json +12 -12
  29. package/src/index.ts +0 -4
  30. package/src/theme/CodeBlock/index.tsx +1 -1
  31. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
  32. package/src/theme/DocItem/index.tsx +7 -4
  33. package/src/theme/DocSidebar/index.tsx +2 -2
  34. package/src/theme/DocSidebarItem/index.tsx +3 -19
  35. package/src/theme/DocSidebarItems/index.tsx +31 -0
  36. package/{lib-next/theme/hooks/styles.css → src/theme/DocSidebarItems/styles.module.css} +11 -2
  37. package/src/theme/DocVersionBanner/index.tsx +1 -1
  38. package/src/theme/Heading/index.tsx +39 -46
  39. package/src/theme/Layout/index.tsx +1 -2
  40. package/src/theme/LayoutProviders/index.tsx +6 -6
  41. package/src/theme/MDXComponents/index.tsx +6 -6
  42. package/src/theme/Navbar/index.tsx +6 -6
  43. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  44. package/src/theme/NavbarItem/DocNavbarItem.tsx +5 -2
  45. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +7 -3
  46. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +1 -1
  47. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +1 -1
  48. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
  49. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  50. package/src/theme/NavbarItem/index.tsx +0 -3
  51. package/src/theme/{UserPreferencesContext.ts → NavbarItem/utils.ts} +3 -5
  52. package/src/theme/Tabs/index.tsx +6 -3
  53. package/src/theme/ThemedImage/index.tsx +2 -2
  54. package/src/theme-classic.d.ts +57 -161
  55. package/lib-next/theme/ThemeProvider/index.js +0 -28
  56. package/lib-next/theme/UserPreferencesContext.js +0 -9
  57. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  58. package/lib-next/theme/hooks/useDocs.js +0 -10
  59. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  60. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  61. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  62. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  63. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  64. package/lib-next/theme/hooks/useTheme.js +0 -81
  65. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  66. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  67. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  68. package/src/theme/ThemeContext.ts +0 -15
  69. package/src/theme/ThemeProvider/index.tsx +0 -28
  70. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  71. package/src/theme/hooks/useDocs.ts +0 -11
  72. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  73. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  74. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  75. package/src/theme/hooks/usePrismTheme.ts +0 -22
  76. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  77. package/src/theme/hooks/useTheme.ts +0 -91
  78. package/src/theme/hooks/useThemeContext.ts +0 -23
  79. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  80. package/src/theme/hooks/useWindowSize.ts +0 -69
@@ -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
 
@@ -1,28 +0,0 @@
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, {useMemo} from 'react';
8
- import useTheme from '@theme/hooks/useTheme';
9
- import ThemeContext from '@theme/ThemeContext';
10
-
11
- function ThemeProvider(props) {
12
- const {isDarkTheme, setLightTheme, setDarkTheme} = useTheme();
13
- const contextValue = useMemo(
14
- () => ({
15
- isDarkTheme,
16
- setLightTheme,
17
- setDarkTheme,
18
- }),
19
- [isDarkTheme, setLightTheme, setDarkTheme],
20
- );
21
- return (
22
- <ThemeContext.Provider value={contextValue}>
23
- {props.children}
24
- </ThemeContext.Provider>
25
- );
26
- }
27
-
28
- export default ThemeProvider;
@@ -1,9 +0,0 @@
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 {createContext} from 'react';
8
- const UserPreferencesContext = createContext(undefined);
9
- export default UserPreferencesContext;
@@ -1,27 +0,0 @@
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, {useMemo} from 'react';
8
- import useTabGroupChoice from '@theme/hooks/useTabGroupChoice';
9
- import UserPreferencesContext from '@theme/UserPreferencesContext';
10
-
11
- function UserPreferencesProvider(props) {
12
- const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
13
- const contextValue = useMemo(
14
- () => ({
15
- tabGroupChoices,
16
- setTabGroupChoices,
17
- }),
18
- [tabGroupChoices, setTabGroupChoices],
19
- );
20
- return (
21
- <UserPreferencesContext.Provider value={contextValue}>
22
- {props.children}
23
- </UserPreferencesContext.Provider>
24
- );
25
- }
26
-
27
- export default UserPreferencesProvider;
@@ -1,10 +0,0 @@
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
- // Re-expose useDocs
8
- // Ensure it's always statically available even if user is not using the docs plugin
9
- // Problem reported for the blog-only mode: https://github.com/facebook/docusaurus/issues/3360
10
- export * from '@docusaurus/plugin-content-docs/lib/theme/hooks/useDocs';
@@ -1,66 +0,0 @@
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 {useState, useCallback, useRef} from 'react';
8
- import {useLocationChange, useScrollPosition} from '@docusaurus/theme-common';
9
-
10
- const useHideableNavbar = (hideOnScroll) => {
11
- const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
12
- const isFocusedAnchor = useRef(false);
13
- const navbarHeight = useRef(0);
14
- const navbarRef = useCallback((node) => {
15
- if (node !== null) {
16
- navbarHeight.current = node.getBoundingClientRect().height;
17
- }
18
- }, []);
19
- useScrollPosition((currentPosition, lastPosition) => {
20
- if (!hideOnScroll) {
21
- return;
22
- }
23
-
24
- const scrollTop = currentPosition.scrollY; // It needed for mostly to handle rubber band scrolling
25
-
26
- if (scrollTop < navbarHeight.current) {
27
- setIsNavbarVisible(true);
28
- return;
29
- }
30
-
31
- if (isFocusedAnchor.current) {
32
- isFocusedAnchor.current = false;
33
- return;
34
- }
35
-
36
- const lastScrollTop = lastPosition?.scrollY;
37
- const documentHeight =
38
- document.documentElement.scrollHeight - navbarHeight.current;
39
- const windowHeight = window.innerHeight;
40
-
41
- if (lastScrollTop && scrollTop >= lastScrollTop) {
42
- setIsNavbarVisible(false);
43
- } else if (scrollTop + windowHeight < documentHeight) {
44
- setIsNavbarVisible(true);
45
- }
46
- });
47
- useLocationChange((locationChangeEvent) => {
48
- if (!hideOnScroll) {
49
- return;
50
- }
51
-
52
- if (locationChangeEvent.location.hash) {
53
- isFocusedAnchor.current = true;
54
- setIsNavbarVisible(false);
55
- return;
56
- }
57
-
58
- setIsNavbarVisible(true);
59
- });
60
- return {
61
- navbarRef,
62
- isNavbarVisible,
63
- };
64
- };
65
-
66
- export default useHideableNavbar;
@@ -1,35 +0,0 @@
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 {useEffect} from 'react';
8
- import './styles.css'; // This hook detect keyboard focus indicator to not show outline for mouse users
9
- // Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
10
-
11
- function useKeyboardNavigation() {
12
- useEffect(() => {
13
- const keyboardFocusedClassName = 'navigation-with-keyboard';
14
-
15
- function handleOutlineStyles(e) {
16
- if (e.type === 'keydown' && e.key === 'Tab') {
17
- document.body.classList.add(keyboardFocusedClassName);
18
- }
19
-
20
- if (e.type === 'mousedown') {
21
- document.body.classList.remove(keyboardFocusedClassName);
22
- }
23
- }
24
-
25
- document.addEventListener('keydown', handleOutlineStyles);
26
- document.addEventListener('mousedown', handleOutlineStyles);
27
- return () => {
28
- document.body.classList.remove(keyboardFocusedClassName);
29
- document.removeEventListener('keydown', handleOutlineStyles);
30
- document.removeEventListener('mousedown', handleOutlineStyles);
31
- };
32
- }, []);
33
- }
34
-
35
- export default useKeyboardNavigation;
@@ -1,18 +0,0 @@
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 {useEffect} from 'react';
8
-
9
- function useLockBodyScroll(lock = true) {
10
- useEffect(() => {
11
- document.body.style.overflow = lock ? 'hidden' : 'visible';
12
- return () => {
13
- document.body.style.overflow = 'visible';
14
- };
15
- }, [lock]);
16
- }
17
-
18
- export default useLockBodyScroll;
@@ -1,20 +0,0 @@
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 defaultTheme from 'prism-react-renderer/themes/palenight';
8
- import useThemeContext from '@theme/hooks/useThemeContext';
9
- import {useThemeConfig} from '@docusaurus/theme-common';
10
-
11
- const usePrismTheme = () => {
12
- const {prism} = useThemeConfig();
13
- const {isDarkTheme} = useThemeContext();
14
- const lightModeTheme = prism.theme || defaultTheme;
15
- const darkModeTheme = prism.darkTheme || lightModeTheme;
16
- const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
17
- return prismTheme;
18
- };
19
-
20
- export default usePrismTheme;
@@ -1,39 +0,0 @@
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 {useState, useCallback, useEffect} from 'react';
8
- import {createStorageSlot, listStorageKeys} from '@docusaurus/theme-common';
9
- const TAB_CHOICE_PREFIX = 'docusaurus.tab.';
10
-
11
- const useTabGroupChoice = () => {
12
- const [tabGroupChoices, setChoices] = useState({});
13
- const setChoiceSyncWithLocalStorage = useCallback((groupId, newChoice) => {
14
- createStorageSlot(`${TAB_CHOICE_PREFIX}${groupId}`).set(newChoice);
15
- }, []);
16
- useEffect(() => {
17
- try {
18
- const localStorageChoices = {};
19
- listStorageKeys().forEach((storageKey) => {
20
- if (storageKey.startsWith(TAB_CHOICE_PREFIX)) {
21
- const groupId = storageKey.substring(TAB_CHOICE_PREFIX.length);
22
- localStorageChoices[groupId] = createStorageSlot(storageKey).get();
23
- }
24
- });
25
- setChoices(localStorageChoices);
26
- } catch (err) {
27
- console.error(err);
28
- }
29
- }, []);
30
- return {
31
- tabGroupChoices,
32
- setTabGroupChoices: (groupId, newChoice) => {
33
- setChoices((oldChoices) => ({...oldChoices, [groupId]: newChoice}));
34
- setChoiceSyncWithLocalStorage(groupId, newChoice);
35
- },
36
- };
37
- };
38
-
39
- export default useTabGroupChoice;
@@ -1,81 +0,0 @@
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 {useState, useCallback, useEffect} from 'react';
8
- import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
9
- import {useThemeConfig, createStorageSlot} from '@docusaurus/theme-common';
10
- const ThemeStorage = createStorageSlot('theme');
11
- const themes = {
12
- light: 'light',
13
- dark: 'dark',
14
- };
15
-
16
- // Ensure to always return a valid theme even if input is invalid
17
- const coerceToTheme = (theme) =>
18
- theme === themes.dark ? themes.dark : themes.light;
19
-
20
- const getInitialTheme = (defaultMode) => {
21
- if (!ExecutionEnvironment.canUseDOM) {
22
- return coerceToTheme(defaultMode);
23
- }
24
-
25
- return coerceToTheme(document.documentElement.getAttribute('data-theme'));
26
- };
27
-
28
- const storeTheme = (newTheme) => {
29
- createStorageSlot('theme').set(coerceToTheme(newTheme));
30
- };
31
-
32
- const useTheme = () => {
33
- const {
34
- colorMode: {defaultMode, disableSwitch, respectPrefersColorScheme},
35
- } = useThemeConfig();
36
- const [theme, setTheme] = useState(getInitialTheme(defaultMode));
37
- const setLightTheme = useCallback(() => {
38
- setTheme(themes.light);
39
- storeTheme(themes.light);
40
- }, []);
41
- const setDarkTheme = useCallback(() => {
42
- setTheme(themes.dark);
43
- storeTheme(themes.dark);
44
- }, []);
45
- useEffect(() => {
46
- document.documentElement.setAttribute('data-theme', coerceToTheme(theme));
47
- }, [theme]);
48
- useEffect(() => {
49
- if (disableSwitch) {
50
- return;
51
- }
52
-
53
- try {
54
- const storedTheme = ThemeStorage.get();
55
-
56
- if (storedTheme !== null) {
57
- setTheme(coerceToTheme(storedTheme));
58
- }
59
- } catch (err) {
60
- console.error(err);
61
- }
62
- }, [disableSwitch, setTheme]);
63
- useEffect(() => {
64
- if (disableSwitch && !respectPrefersColorScheme) {
65
- return;
66
- }
67
-
68
- window
69
- .matchMedia('(prefers-color-scheme: dark)')
70
- .addListener(({matches}) => {
71
- setTheme(matches ? themes.dark : themes.light);
72
- });
73
- }, [disableSwitch, respectPrefersColorScheme]);
74
- return {
75
- isDarkTheme: theme === themes.dark,
76
- setLightTheme,
77
- setDarkTheme,
78
- };
79
- };
80
-
81
- export default useTheme;
@@ -1,22 +0,0 @@
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 {useContext} from 'react';
8
- import ThemeContext from '@theme/ThemeContext';
9
-
10
- function useThemeContext() {
11
- const context = useContext(ThemeContext);
12
-
13
- if (context == null) {
14
- throw new Error(
15
- '"useThemeContext" is used outside of "Layout" component. Please see https://docusaurus.io/docs/api/themes/configuration#usethemecontext.',
16
- );
17
- }
18
-
19
- return context;
20
- }
21
-
22
- export default useThemeContext;
@@ -1,22 +0,0 @@
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 {useContext} from 'react';
8
- import UserPreferencesContext from '@theme/UserPreferencesContext';
9
-
10
- function useUserPreferencesContext() {
11
- const context = useContext(UserPreferencesContext);
12
-
13
- if (context == null) {
14
- throw new Error(
15
- '"useUserPreferencesContext" is used outside of "Layout" component.',
16
- );
17
- }
18
-
19
- return context;
20
- }
21
-
22
- export default useUserPreferencesContext;