@docusaurus/theme-classic 0.0.0-4760 → 0.0.0-4764

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.
@@ -4,22 +4,22 @@
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, {useState} from 'react';
7
+ import React, {useCallback, useState, useRef, useEffect} from 'react';
8
8
  import clsx from 'clsx';
9
9
  import copy from 'copy-text-to-clipboard';
10
10
  import {translate} from '@docusaurus/Translate';
11
11
  import styles from './styles.module.css';
12
12
  export default function CopyButton({code}) {
13
13
  const [isCopied, setIsCopied] = useState(false);
14
-
15
- const handleCopyCode = () => {
14
+ const copyTimeout = useRef(undefined);
15
+ const handleCopyCode = useCallback(() => {
16
16
  copy(code);
17
17
  setIsCopied(true);
18
- setTimeout(() => {
18
+ copyTimeout.current = window.setTimeout(() => {
19
19
  setIsCopied(false);
20
- }, 2000);
21
- };
22
-
20
+ }, 1000);
21
+ }, [code]);
22
+ useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
23
23
  return (
24
24
  <button
25
25
  type="button"
@@ -143,7 +143,8 @@ function DocSidebarItemCategory({
143
143
  })}>
144
144
  <Link
145
145
  className={clsx('menu__link', {
146
- 'menu__link--sublist': collapsible && !href,
146
+ 'menu__link--sublist': collapsible,
147
+ 'menu__link--sublist-caret': !href,
147
148
  'menu__link--active': isActive,
148
149
  })}
149
150
  onClick={
@@ -251,10 +252,8 @@ function DocSidebarItemLink({
251
252
  onClick: onItemClick ? () => onItemClick(item) : undefined,
252
253
  })}
253
254
  {...props}>
254
- <span>
255
- {label}
256
- {!isInternalUrl(href) && <IconExternalLink />}
257
- </span>
255
+ {label}
256
+ {!isInternalUrl(href) && <IconExternalLink />}
258
257
  </Link>
259
258
  </li>
260
259
  );
@@ -26,10 +26,8 @@ export default function FooterLinkItem({item}) {
26
26
  to: toUrl,
27
27
  })}
28
28
  {...props}>
29
- <span>
30
- {label}
31
- {href && !isInternalUrl(href) && <IconExternalLink />}
32
- </span>
29
+ {label}
30
+ {href && !isInternalUrl(href) && <IconExternalLink />}
33
31
  </Link>
34
32
  );
35
33
  }
@@ -52,17 +52,15 @@ export default function NavbarNavLink({
52
52
  : null),
53
53
  })}
54
54
  {...props}>
55
- <span>
56
- {label}
57
- {isExternalLink && (
58
- <IconExternalLink
59
- {...(isDropdownLink && {
60
- width: 12,
61
- height: 12,
62
- })}
63
- />
64
- )}
65
- </span>
55
+ {label}
56
+ {isExternalLink && (
57
+ <IconExternalLink
58
+ {...(isDropdownLink && {
59
+ width: 12,
60
+ height: 12,
61
+ })}
62
+ />
63
+ )}
66
64
  </Link>
67
65
  );
68
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4760",
3
+ "version": "0.0.0-4764",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,19 +21,19 @@
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-4760",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4760",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4760",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4760",
28
- "@docusaurus/theme-common": "0.0.0-4760",
29
- "@docusaurus/theme-translations": "0.0.0-4760",
30
- "@docusaurus/utils": "0.0.0-4760",
31
- "@docusaurus/utils-common": "0.0.0-4760",
32
- "@docusaurus/utils-validation": "0.0.0-4760",
24
+ "@docusaurus/core": "0.0.0-4764",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4764",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4764",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4764",
28
+ "@docusaurus/theme-common": "0.0.0-4764",
29
+ "@docusaurus/theme-translations": "0.0.0-4764",
30
+ "@docusaurus/utils": "0.0.0-4764",
31
+ "@docusaurus/utils-common": "0.0.0-4764",
32
+ "@docusaurus/utils-validation": "0.0.0-4764",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
36
- "infima": "0.2.0-alpha.37",
36
+ "infima": "0.2.0-alpha.38",
37
37
  "lodash": "^4.17.21",
38
38
  "postcss": "^8.4.12",
39
39
  "prism-react-renderer": "^1.3.1",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4760",
46
- "@docusaurus/types": "0.0.0-4760",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4764",
46
+ "@docusaurus/types": "0.0.0-4764",
47
47
  "@types/mdx-js__react": "^1.5.5",
48
48
  "@types/prismjs": "^1.26.0",
49
49
  "@types/rtlcss": "^3.1.2",
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": ">=14"
61
61
  },
62
- "gitHead": "ca58c5f867aec349fb405a2056d4bdb4d140a0b5"
62
+ "gitHead": "b45d59dcc7270365eb6648e8061ef3698b18ad28"
63
63
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useState} from 'react';
8
+ import React, {useCallback, useState, useRef, useEffect} from 'react';
9
9
  import clsx from 'clsx';
10
10
  import copy from 'copy-text-to-clipboard';
11
11
  import {translate} from '@docusaurus/Translate';
@@ -15,14 +15,16 @@ import styles from './styles.module.css';
15
15
 
16
16
  export default function CopyButton({code}: Props): JSX.Element {
17
17
  const [isCopied, setIsCopied] = useState(false);
18
- const handleCopyCode = () => {
18
+ const copyTimeout = useRef<number | undefined>(undefined);
19
+ const handleCopyCode = useCallback(() => {
19
20
  copy(code);
20
21
  setIsCopied(true);
21
-
22
- setTimeout(() => {
22
+ copyTimeout.current = window.setTimeout(() => {
23
23
  setIsCopied(false);
24
- }, 2000);
25
- };
24
+ }, 1000);
25
+ }, [code]);
26
+
27
+ useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
26
28
 
27
29
  return (
28
30
  <button
@@ -160,7 +160,8 @@ function DocSidebarItemCategory({
160
160
  })}>
161
161
  <Link
162
162
  className={clsx('menu__link', {
163
- 'menu__link--sublist': collapsible && !href,
163
+ 'menu__link--sublist': collapsible,
164
+ 'menu__link--sublist-caret': !href,
164
165
  'menu__link--active': isActive,
165
166
  })}
166
167
  onClick={
@@ -268,10 +269,8 @@ function DocSidebarItemLink({
268
269
  onClick: onItemClick ? () => onItemClick(item) : undefined,
269
270
  })}
270
271
  {...props}>
271
- <span>
272
- {label}
273
- {!isInternalUrl(href) && <IconExternalLink />}
274
- </span>
272
+ {label}
273
+ {!isInternalUrl(href) && <IconExternalLink />}
275
274
  </Link>
276
275
  </li>
277
276
  );
@@ -29,10 +29,8 @@ export default function FooterLinkItem({item}: Props): JSX.Element {
29
29
  to: toUrl,
30
30
  })}
31
31
  {...props}>
32
- <span>
33
- {label}
34
- {href && !isInternalUrl(href) && <IconExternalLink />}
35
- </span>
32
+ {label}
33
+ {href && !isInternalUrl(href) && <IconExternalLink />}
36
34
  </Link>
37
35
  );
38
36
  }
@@ -55,12 +55,10 @@ export default function NavbarNavLink({
55
55
  : null),
56
56
  })}
57
57
  {...props}>
58
- <span>
59
- {label}
60
- {isExternalLink && (
61
- <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
62
- )}
63
- </span>
58
+ {label}
59
+ {isExternalLink && (
60
+ <IconExternalLink {...(isDropdownLink && {width: 12, height: 12})} />
61
+ )}
64
62
  </Link>
65
63
  );
66
64
  }