@@ -91,30 +96,32 @@ function Chapter() {
questionIndex + 1
}`}
+ >{textToCopy}
{
+ navigator.clipboard.writeText(textToCopy).then(() => {
+ setHasCopied({...hasCopied, [textToCopy]: true})
+ });
+ }}
aria-label="Copy to clipboard"
icon={
- hasCopied ? (
+ hasCopied[textToCopy] ? (
) : (
@@ -128,7 +135,7 @@ function Chapter() {
);
},
}}
- />
+ >{question.question}
@@ -211,7 +222,7 @@ function Chapter() {
- This progress check is a demo.
+ This progress check is a demo.
diff --git a/src/components/tech-guru-show-off.jsx b/src/components/tech-guru-show-off.jsx
index fb7113e..1b1cb35 100644
--- a/src/components/tech-guru-show-off.jsx
+++ b/src/components/tech-guru-show-off.jsx
@@ -68,12 +68,12 @@ const UserMessage = ({ message, user, index }) => {
>
{message}
@@ -90,6 +90,7 @@ const GuruMessage = ({ message, index }) => {
threshold: 0.1,
triggerOnce: true,
});
+ const [hasCopied, setHasCopied] = useState({});
return (
<>
@@ -103,20 +104,20 @@ const GuruMessage = ({ message, index }) => {
{
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || "");
const textToCopy = String(children).replace(/\n$/, "");
- const { hasCopied, onCopy } = useClipboard(textToCopy);
+ setHasCopied({...hasCopied, [textToCopy]: false})
return !inline && match ? (
+ >{textToCopy}
{
border="none"
background="none"
color="whiteAlpha.900"
- onClick={onCopy}
+ onClick={() => {
+ navigator.clipboard.writeText(textToCopy).then(() => {
+ setHasCopied({...hasCopied, [textToCopy]: true})
+ });
+ }}
aria-label="Copy to clipboard"
icon={
- hasCopied ? (
+ hasCopied[textToCopy] ? (
) : (
@@ -191,7 +195,15 @@ const TechGuruFeature = () => {
};
return (
-
+