@docusaurus/theme-classic 0.0.0-4927 → 0.0.0-4928

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.
@@ -1061,6 +1061,19 @@ declare module '@theme/TOCItems' {
1061
1061
  export default function TOCItems(props: Props): JSX.Element;
1062
1062
  }
1063
1063
 
1064
+ declare module '@theme/TOCItems/Tree' {
1065
+ import type {TOCTreeNode} from '@docusaurus/theme-common';
1066
+
1067
+ export interface Props {
1068
+ readonly toc: readonly TOCTreeNode[];
1069
+ readonly className: string;
1070
+ readonly linkClassName: string | null;
1071
+ readonly isChild?: boolean;
1072
+ }
1073
+
1074
+ export default function TOCItems(props: Props): JSX.Element;
1075
+ }
1076
+
1064
1077
  declare module '@theme/TOC' {
1065
1078
  import type {TOCItem} from '@docusaurus/types';
1066
1079
 
@@ -1101,6 +1114,18 @@ declare module '@theme/TOCCollapsible' {
1101
1114
  export default function TOCCollapsible(props: Props): JSX.Element;
1102
1115
  }
1103
1116
 
1117
+ declare module '@theme/TOCCollapsible/CollapseButton' {
1118
+ import type {ComponentProps} from 'react';
1119
+
1120
+ export interface Props extends ComponentProps<'button'> {
1121
+ collapsed: boolean;
1122
+ }
1123
+
1124
+ export default function TOCCollapsibleCollapseButton(
1125
+ props: Props,
1126
+ ): JSX.Element;
1127
+ }
1128
+
1104
1129
  declare module '@theme/ColorModeToggle' {
1105
1130
  import type {ColorMode} from '@docusaurus/theme-common';
1106
1131
 
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import clsx from 'clsx';
9
+ import Translate from '@docusaurus/Translate';
10
+ import styles from './CollapseButton.module.css';
11
+ export default function TOCCollapsibleCollapseButton({collapsed, ...props}) {
12
+ return (
13
+ <button
14
+ type="button"
15
+ {...props}
16
+ className={clsx(
17
+ 'clean-btn',
18
+ styles.tocCollapsibleButton,
19
+ !collapsed && styles.tocCollapsibleButtonExpanded,
20
+ props.className,
21
+ )}>
22
+ <Translate
23
+ id="theme.TOCCollapsible.toggleButtonLabel"
24
+ description="The label used by the button on the collapsible TOC component">
25
+ On this page
26
+ </Translate>
27
+ </button>
28
+ );
29
+ }
@@ -5,12 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .tocCollapsible {
9
- background-color: var(--ifm-menu-color-background-active);
10
- border-radius: var(--ifm-global-radius);
11
- margin: 1rem 0;
12
- }
13
-
14
8
  .tocCollapsibleButton {
15
9
  font-size: inherit;
16
10
  display: flex;
@@ -30,21 +24,6 @@
30
24
  transition: transform var(--ifm-transition-fast);
31
25
  }
32
26
 
33
- .tocCollapsibleContent > ul {
34
- border-left: none;
35
- border-top: 1px solid var(--ifm-color-emphasis-300);
36
- padding: 0.2rem 0;
37
- font-size: 15px;
38
- }
39
-
40
- .tocCollapsibleContent ul li {
41
- margin: 0.4rem 0.8rem;
42
- }
43
-
44
- .tocCollapsibleContent a {
45
- display: block;
46
- }
47
-
48
- .tocCollapsibleExpanded .tocCollapsibleButton::after {
27
+ .tocCollapsibleButtonExpanded::after {
49
28
  transform: none;
50
29
  }
@@ -6,10 +6,10 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import Translate from '@docusaurus/Translate';
10
9
  import {useCollapsible, Collapsible} from '@docusaurus/theme-common';
11
- import styles from './styles.module.css';
10
+ import styles from './index.module.css';
12
11
  import TOCItems from '@theme/TOCItems';
12
+ import CollapseButton from '@theme/TOCCollapsible/CollapseButton';
13
13
  export default function TOCCollapsible({
14
14
  toc,
15
15
  className,
@@ -26,17 +26,7 @@ export default function TOCCollapsible({
26
26
  !collapsed && styles.tocCollapsibleExpanded,
27
27
  className,
28
28
  )}>
29
- <button
30
- type="button"
31
- className={clsx('clean-btn', styles.tocCollapsibleButton)}
32
- onClick={toggleCollapsed}>
33
- <Translate
34
- id="theme.TOCCollapsible.toggleButtonLabel"
35
- description="The label used by the button on the collapsible TOC component">
36
- On this page
37
- </Translate>
38
- </button>
39
-
29
+ <CollapseButton collapsed={collapsed} onClick={toggleCollapsed} />
40
30
  <Collapsible
41
31
  lazy
42
32
  className={styles.tocCollapsibleContent}
@@ -0,0 +1,31 @@
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
+ .tocCollapsible {
9
+ background-color: var(--ifm-menu-color-background-active);
10
+ border-radius: var(--ifm-global-radius);
11
+ margin: 1rem 0;
12
+ }
13
+
14
+ .tocCollapsibleContent > ul {
15
+ border-left: none;
16
+ border-top: 1px solid var(--ifm-color-emphasis-300);
17
+ padding: 0.2rem 0;
18
+ font-size: 15px;
19
+ }
20
+
21
+ .tocCollapsibleContent ul li {
22
+ margin: 0.4rem 0.8rem;
23
+ }
24
+
25
+ .tocCollapsibleContent a {
26
+ display: block;
27
+ }
28
+
29
+ .tocCollapsibleExpanded {
30
+ transform: none;
31
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+
9
+ // Recursive component rendering the toc tree
10
+
11
+ /* eslint-disable jsx-a11y/control-has-associated-label */
12
+ function TOCItemTree({toc, className, linkClassName, isChild}) {
13
+ if (!toc.length) {
14
+ return null;
15
+ }
16
+
17
+ return (
18
+ <ul className={isChild ? undefined : className}>
19
+ {toc.map((heading) => (
20
+ <li key={heading.id}>
21
+ <a
22
+ href={`#${heading.id}`}
23
+ className={linkClassName ?? undefined} // Developer provided the HTML, so assume it's safe.
24
+ // eslint-disable-next-line react/no-danger
25
+ dangerouslySetInnerHTML={{
26
+ __html: heading.value,
27
+ }}
28
+ />
29
+ <TOCItemTree
30
+ isChild
31
+ toc={heading.children}
32
+ className={className}
33
+ linkClassName={linkClassName}
34
+ />
35
+ </li>
36
+ ))}
37
+ </ul>
38
+ );
39
+ } // Memo only the tree root is enough
40
+
41
+ export default React.memo(TOCItemTree);
@@ -5,43 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, {useMemo} from 'react';
8
+ import TOCItemTree from '@theme/TOCItems/Tree';
8
9
  import {
9
10
  useThemeConfig,
10
11
  useTOCHighlight,
11
12
  useFilteredAndTreeifiedTOC,
12
- } from '@docusaurus/theme-common'; // Recursive component rendering the toc tree
13
-
14
- /* eslint-disable jsx-a11y/control-has-associated-label */
15
-
16
- function TOCItemList({toc, className, linkClassName, isChild}) {
17
- if (!toc.length) {
18
- return null;
19
- }
20
-
21
- return (
22
- <ul className={isChild ? undefined : className}>
23
- {toc.map((heading) => (
24
- <li key={heading.id}>
25
- <a
26
- href={`#${heading.id}`}
27
- className={linkClassName ?? undefined} // Developer provided the HTML, so assume it's safe.
28
- // eslint-disable-next-line react/no-danger
29
- dangerouslySetInnerHTML={{
30
- __html: heading.value,
31
- }}
32
- />
33
- <TOCItemList
34
- isChild
35
- toc={heading.children}
36
- className={className}
37
- linkClassName={linkClassName}
38
- />
39
- </li>
40
- ))}
41
- </ul>
42
- );
43
- }
44
-
13
+ } from '@docusaurus/theme-common';
45
14
  export default function TOCItems({
46
15
  toc,
47
16
  className = 'table-of-contents table-of-contents__left-border',
@@ -75,7 +44,7 @@ export default function TOCItems({
75
44
  }, [linkClassName, linkActiveClassName, minHeadingLevel, maxHeadingLevel]);
76
45
  useTOCHighlight(tocHighlightConfig);
77
46
  return (
78
- <TOCItemList
47
+ <TOCItemTree
79
48
  toc={tocTree}
80
49
  className={className}
81
50
  linkClassName={linkClassName}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4927",
3
+ "version": "0.0.0-4928",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,15 +21,15 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4927",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4927",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4927",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4927",
28
- "@docusaurus/theme-common": "0.0.0-4927",
29
- "@docusaurus/theme-translations": "0.0.0-4927",
30
- "@docusaurus/utils": "0.0.0-4927",
31
- "@docusaurus/utils-common": "0.0.0-4927",
32
- "@docusaurus/utils-validation": "0.0.0-4927",
24
+ "@docusaurus/core": "0.0.0-4928",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4928",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4928",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4928",
28
+ "@docusaurus/theme-common": "0.0.0-4928",
29
+ "@docusaurus/theme-translations": "0.0.0-4928",
30
+ "@docusaurus/utils": "0.0.0-4928",
31
+ "@docusaurus/utils-common": "0.0.0-4928",
32
+ "@docusaurus/utils-validation": "0.0.0-4928",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -46,8 +46,8 @@
46
46
  "@babel/cli": "^7.17.6",
47
47
  "@babel/core": "^7.17.9",
48
48
  "@babel/preset-typescript": "^7.16.7",
49
- "@docusaurus/module-type-aliases": "0.0.0-4927",
50
- "@docusaurus/types": "0.0.0-4927",
49
+ "@docusaurus/module-type-aliases": "0.0.0-4928",
50
+ "@docusaurus/types": "0.0.0-4928",
51
51
  "@types/mdx-js__react": "^1.5.5",
52
52
  "@types/nprogress": "^0.2.0",
53
53
  "@types/prismjs": "^1.26.0",
@@ -64,5 +64,5 @@
64
64
  "engines": {
65
65
  "node": ">=14"
66
66
  },
67
- "gitHead": "1c97d81e5046a346360d7c79d5c1e715b37a94d9"
67
+ "gitHead": "fc6b6a5b2caee19226c279ad3ec7098ee567a123"
68
68
  }
@@ -5,12 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- .tocCollapsible {
9
- background-color: var(--ifm-menu-color-background-active);
10
- border-radius: var(--ifm-global-radius);
11
- margin: 1rem 0;
12
- }
13
-
14
8
  .tocCollapsibleButton {
15
9
  font-size: inherit;
16
10
  display: flex;
@@ -30,21 +24,6 @@
30
24
  transition: transform var(--ifm-transition-fast);
31
25
  }
32
26
 
33
- .tocCollapsibleContent > ul {
34
- border-left: none;
35
- border-top: 1px solid var(--ifm-color-emphasis-300);
36
- padding: 0.2rem 0;
37
- font-size: 15px;
38
- }
39
-
40
- .tocCollapsibleContent ul li {
41
- margin: 0.4rem 0.8rem;
42
- }
43
-
44
- .tocCollapsibleContent a {
45
- display: block;
46
- }
47
-
48
- .tocCollapsibleExpanded .tocCollapsibleButton::after {
27
+ .tocCollapsibleButtonExpanded::after {
49
28
  transform: none;
50
29
  }
@@ -0,0 +1,35 @@
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 clsx from 'clsx';
10
+ import Translate from '@docusaurus/Translate';
11
+ import styles from './CollapseButton.module.css';
12
+ import type {Props} from '@theme/TOCCollapsible/CollapseButton';
13
+
14
+ export default function TOCCollapsibleCollapseButton({
15
+ collapsed,
16
+ ...props
17
+ }: Props): JSX.Element {
18
+ return (
19
+ <button
20
+ type="button"
21
+ {...props}
22
+ className={clsx(
23
+ 'clean-btn',
24
+ styles.tocCollapsibleButton,
25
+ !collapsed && styles.tocCollapsibleButtonExpanded,
26
+ props.className,
27
+ )}>
28
+ <Translate
29
+ id="theme.TOCCollapsible.toggleButtonLabel"
30
+ description="The label used by the button on the collapsible TOC component">
31
+ On this page
32
+ </Translate>
33
+ </button>
34
+ );
35
+ }
@@ -0,0 +1,31 @@
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
+ .tocCollapsible {
9
+ background-color: var(--ifm-menu-color-background-active);
10
+ border-radius: var(--ifm-global-radius);
11
+ margin: 1rem 0;
12
+ }
13
+
14
+ .tocCollapsibleContent > ul {
15
+ border-left: none;
16
+ border-top: 1px solid var(--ifm-color-emphasis-300);
17
+ padding: 0.2rem 0;
18
+ font-size: 15px;
19
+ }
20
+
21
+ .tocCollapsibleContent ul li {
22
+ margin: 0.4rem 0.8rem;
23
+ }
24
+
25
+ .tocCollapsibleContent a {
26
+ display: block;
27
+ }
28
+
29
+ .tocCollapsibleExpanded {
30
+ transform: none;
31
+ }
@@ -7,11 +7,11 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import Translate from '@docusaurus/Translate';
11
10
  import {useCollapsible, Collapsible} from '@docusaurus/theme-common';
12
- import styles from './styles.module.css';
11
+ import styles from './index.module.css';
13
12
  import TOCItems from '@theme/TOCItems';
14
13
  import type {Props} from '@theme/TOCCollapsible';
14
+ import CollapseButton from '@theme/TOCCollapsible/CollapseButton';
15
15
 
16
16
  export default function TOCCollapsible({
17
17
  toc,
@@ -22,7 +22,6 @@ export default function TOCCollapsible({
22
22
  const {collapsed, toggleCollapsed} = useCollapsible({
23
23
  initialState: true,
24
24
  });
25
-
26
25
  return (
27
26
  <div
28
27
  className={clsx(
@@ -30,17 +29,7 @@ export default function TOCCollapsible({
30
29
  !collapsed && styles.tocCollapsibleExpanded,
31
30
  className,
32
31
  )}>
33
- <button
34
- type="button"
35
- className={clsx('clean-btn', styles.tocCollapsibleButton)}
36
- onClick={toggleCollapsed}>
37
- <Translate
38
- id="theme.TOCCollapsible.toggleButtonLabel"
39
- description="The label used by the button on the collapsible TOC component">
40
- On this page
41
- </Translate>
42
- </button>
43
-
32
+ <CollapseButton collapsed={collapsed} onClick={toggleCollapsed} />
44
33
  <Collapsible
45
34
  lazy
46
35
  className={styles.tocCollapsibleContent}
@@ -0,0 +1,46 @@
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 type {Props} from '@theme/TOCItems/Tree';
10
+
11
+ // Recursive component rendering the toc tree
12
+ /* eslint-disable jsx-a11y/control-has-associated-label */
13
+ function TOCItemTree({
14
+ toc,
15
+ className,
16
+ linkClassName,
17
+ isChild,
18
+ }: Props): JSX.Element | null {
19
+ if (!toc.length) {
20
+ return null;
21
+ }
22
+ return (
23
+ <ul className={isChild ? undefined : className}>
24
+ {toc.map((heading) => (
25
+ <li key={heading.id}>
26
+ <a
27
+ href={`#${heading.id}`}
28
+ className={linkClassName ?? undefined}
29
+ // Developer provided the HTML, so assume it's safe.
30
+ // eslint-disable-next-line react/no-danger
31
+ dangerouslySetInnerHTML={{__html: heading.value}}
32
+ />
33
+ <TOCItemTree
34
+ isChild
35
+ toc={heading.children}
36
+ className={className}
37
+ linkClassName={linkClassName}
38
+ />
39
+ </li>
40
+ ))}
41
+ </ul>
42
+ );
43
+ }
44
+
45
+ // Memo only the tree root is enough
46
+ export default React.memo(TOCItemTree);
@@ -7,53 +7,14 @@
7
7
 
8
8
  import React, {useMemo} from 'react';
9
9
  import type {Props} from '@theme/TOCItems';
10
+ import TOCItemTree from '@theme/TOCItems/Tree';
10
11
  import {
11
12
  type TOCHighlightConfig,
12
- type TOCTreeNode,
13
13
  useThemeConfig,
14
14
  useTOCHighlight,
15
15
  useFilteredAndTreeifiedTOC,
16
16
  } from '@docusaurus/theme-common';
17
17
 
18
- // Recursive component rendering the toc tree
19
- /* eslint-disable jsx-a11y/control-has-associated-label */
20
- function TOCItemList({
21
- toc,
22
- className,
23
- linkClassName,
24
- isChild,
25
- }: {
26
- readonly toc: readonly TOCTreeNode[];
27
- readonly className: string;
28
- readonly linkClassName: string | null;
29
- readonly isChild?: boolean;
30
- }): JSX.Element | null {
31
- if (!toc.length) {
32
- return null;
33
- }
34
- return (
35
- <ul className={isChild ? undefined : className}>
36
- {toc.map((heading) => (
37
- <li key={heading.id}>
38
- <a
39
- href={`#${heading.id}`}
40
- className={linkClassName ?? undefined}
41
- // Developer provided the HTML, so assume it's safe.
42
- // eslint-disable-next-line react/no-danger
43
- dangerouslySetInnerHTML={{__html: heading.value}}
44
- />
45
- <TOCItemList
46
- isChild
47
- toc={heading.children}
48
- className={className}
49
- linkClassName={linkClassName}
50
- />
51
- </li>
52
- ))}
53
- </ul>
54
- );
55
- }
56
-
57
18
  export default function TOCItems({
58
19
  toc,
59
20
  className = 'table-of-contents table-of-contents__left-border',
@@ -90,7 +51,7 @@ export default function TOCItems({
90
51
  useTOCHighlight(tocHighlightConfig);
91
52
 
92
53
  return (
93
- <TOCItemList
54
+ <TOCItemTree
94
55
  toc={tocTree}
95
56
  className={className}
96
57
  linkClassName={linkClassName}
@@ -1061,6 +1061,19 @@ declare module '@theme/TOCItems' {
1061
1061
  export default function TOCItems(props: Props): JSX.Element;
1062
1062
  }
1063
1063
 
1064
+ declare module '@theme/TOCItems/Tree' {
1065
+ import type {TOCTreeNode} from '@docusaurus/theme-common';
1066
+
1067
+ export interface Props {
1068
+ readonly toc: readonly TOCTreeNode[];
1069
+ readonly className: string;
1070
+ readonly linkClassName: string | null;
1071
+ readonly isChild?: boolean;
1072
+ }
1073
+
1074
+ export default function TOCItems(props: Props): JSX.Element;
1075
+ }
1076
+
1064
1077
  declare module '@theme/TOC' {
1065
1078
  import type {TOCItem} from '@docusaurus/types';
1066
1079
 
@@ -1101,6 +1114,18 @@ declare module '@theme/TOCCollapsible' {
1101
1114
  export default function TOCCollapsible(props: Props): JSX.Element;
1102
1115
  }
1103
1116
 
1117
+ declare module '@theme/TOCCollapsible/CollapseButton' {
1118
+ import type {ComponentProps} from 'react';
1119
+
1120
+ export interface Props extends ComponentProps<'button'> {
1121
+ collapsed: boolean;
1122
+ }
1123
+
1124
+ export default function TOCCollapsibleCollapseButton(
1125
+ props: Props,
1126
+ ): JSX.Element;
1127
+ }
1128
+
1104
1129
  declare module '@theme/ColorModeToggle' {
1105
1130
  import type {ColorMode} from '@docusaurus/theme-common';
1106
1131