@docusaurus/theme-classic 0.0.0-4762 → 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"
@@ -252,10 +252,8 @@ function DocSidebarItemLink({
252
252
  onClick: onItemClick ? () => onItemClick(item) : undefined,
253
253
  })}
254
254
  {...props}>
255
- <span>
256
- {label}
257
- {!isInternalUrl(href) && <IconExternalLink />}
258
- </span>
255
+ {label}
256
+ {!isInternalUrl(href) && <IconExternalLink />}
259
257
  </Link>
260
258
  </li>
261
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-4762",
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,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-4762",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4762",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4762",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4762",
28
- "@docusaurus/theme-common": "0.0.0-4762",
29
- "@docusaurus/theme-translations": "0.0.0-4762",
30
- "@docusaurus/utils": "0.0.0-4762",
31
- "@docusaurus/utils-common": "0.0.0-4762",
32
- "@docusaurus/utils-validation": "0.0.0-4762",
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",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4762",
46
- "@docusaurus/types": "0.0.0-4762",
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": "cff0f3b00d451a251a7b0d0e0dbe02d793e29e9f"
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
@@ -269,10 +269,8 @@ function DocSidebarItemLink({
269
269
  onClick: onItemClick ? () => onItemClick(item) : undefined,
270
270
  })}
271
271
  {...props}>
272
- <span>
273
- {label}
274
- {!isInternalUrl(href) && <IconExternalLink />}
275
- </span>
272
+ {label}
273
+ {!isInternalUrl(href) && <IconExternalLink />}
276
274
  </Link>
277
275
  </li>
278
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
  }