docs: bug fixes for copy and color mode (#8626)
* docs: bug fixes for copy and color mode * remove unused dependency
This commit is contained in:
1 parent
46310e32d0
commit
66c39ef876
5 files changed
+11
-17
No files matched your search
@@ -67,7 +67,6 @@
|
|||||||
"@segment/analytics-next": "^1.55.0",
|
"@segment/analytics-next": "^1.55.0",
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
"algoliasearch": "^4.20.0",
|
"algoliasearch": "^4.20.0",
|
||||||
"copy-text-to-clipboard": "^3.2.0",
|
|
||||||
"framer-motion": "^11.3.21",
|
"framer-motion": "^11.3.21",
|
||||||
"mermaid": "^10.9.0",
|
"mermaid": "^10.9.0",
|
||||||
"npm-to-yarn": "^2.1.0",
|
"npm-to-yarn": "^2.1.0",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const Sidebar = ({
|
|||||||
})
|
})
|
||||||
useKeyboardShortcut({
|
useKeyboardShortcut({
|
||||||
metakey: true,
|
metakey: true,
|
||||||
shortcutKeys: ["."],
|
shortcutKeys: ["\\"],
|
||||||
action: () => {
|
action: () => {
|
||||||
setDesktopSidebarOpen((prev) => !prev)
|
setDesktopSidebarOpen((prev) => !prev)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef, useState } from "react"
|
import { useCallback, useEffect, useRef, useState } from "react"
|
||||||
import copy from "copy-text-to-clipboard"
|
|
||||||
|
|
||||||
type useCopyReturnType = {
|
type useCopyReturnType = {
|
||||||
isCopied: boolean
|
isCopied: boolean
|
||||||
@@ -13,11 +12,15 @@ export const useCopy = (text: string): useCopyReturnType => {
|
|||||||
const copyTimeout = useRef<number>(0)
|
const copyTimeout = useRef<number>(0)
|
||||||
|
|
||||||
const handleCopy = useCallback(() => {
|
const handleCopy = useCallback(() => {
|
||||||
copy(text)
|
navigator.clipboard
|
||||||
setIsCopied(true)
|
.writeText(text.trim())
|
||||||
copyTimeout.current = window.setTimeout(() => {
|
.then(() => {
|
||||||
setIsCopied(false)
|
setIsCopied(true)
|
||||||
}, 1000)
|
copyTimeout.current = window.setTimeout(() => {
|
||||||
|
setIsCopied(false)
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
}, [text])
|
}, [text])
|
||||||
|
|
||||||
useEffect(() => () => window.clearTimeout(copyTimeout.current), [])
|
useEffect(() => () => window.clearTimeout(copyTimeout.current), [])
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ export const ColorModeProvider = ({ children }: ColorModeProviderProps) => {
|
|||||||
const theme = localStorage.getItem("theme")
|
const theme = localStorage.getItem("theme")
|
||||||
if (theme && (theme === "light" || theme === "dark")) {
|
if (theme && (theme === "light" || theme === "dark")) {
|
||||||
setColorMode(theme)
|
setColorMode(theme)
|
||||||
setLoaded(true)
|
|
||||||
}
|
}
|
||||||
|
setLoaded(true)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -6510,13 +6510,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"copy-text-to-clipboard@npm:^3.2.0":
|
|
||||||
version: 3.2.0
|
|
||||||
resolution: "copy-text-to-clipboard@npm:3.2.0"
|
|
||||||
checksum: d60fdadc59d526e19d56ad23cec2b292d33c771a5091621bd322d138804edd3c10eb2367d46ec71b39f5f7f7116a2910b332281aeb36a5b679199d746a8a5381
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"copy-to-clipboard@npm:^3.3.3":
|
"copy-to-clipboard@npm:^3.3.3":
|
||||||
version: 3.3.3
|
version: 3.3.3
|
||||||
resolution: "copy-to-clipboard@npm:3.3.3"
|
resolution: "copy-to-clipboard@npm:3.3.3"
|
||||||
@@ -7264,7 +7257,6 @@ __metadata:
|
|||||||
"@uidotdev/usehooks": ^2.4.1
|
"@uidotdev/usehooks": ^2.4.1
|
||||||
algoliasearch: ^4.20.0
|
algoliasearch: ^4.20.0
|
||||||
clsx: ^2.0.0
|
clsx: ^2.0.0
|
||||||
copy-text-to-clipboard: ^3.2.0
|
|
||||||
cpy-cli: ^5.0.0
|
cpy-cli: ^5.0.0
|
||||||
eslint: ^8
|
eslint: ^8
|
||||||
eslint-config-docs: "*"
|
eslint-config-docs: "*"
|
||||||
|
|||||||
Reference in new issue
Block a user