Skip to content

Commit d970cdd

Browse files
committed
refactor: Simplify CodeWithCopy component to support inline only
1 parent 3b75d10 commit d970cdd

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

docs/components/CodeWithCopy.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,14 @@ import Copy from "@/components/Copy";
33
import Tooltip from "@radui/ui/Tooltip";
44

55
const CodeWithCopy = ({ code }) => {
6-
const copyContent = code
7-
.replace(/\n{2,}/g, "\n") // Replace multiple newlines with single newline
8-
.trim(); // Remove leading/trailing whitespace
9-
106
return (
117
<Code>
12-
<span className="flex items-center relative min-h-[2.06rem]">
13-
<span
14-
className={`whitespace-pre-wrap mr-10`}
15-
style={{ wordBreak: "break-word" }}
16-
>
17-
{code}
8+
<span className="flex items-center">
9+
<span className="mr-2">
10+
{code}
11+
</span>
12+
<Copy content={code} />
1813
</span>
19-
<Tooltip
20-
label="Copy"
21-
placement="bottom"
22-
className="absolute top-0 right-0"
23-
>
24-
<Copy content={copyContent} />
25-
</Tooltip>
26-
</span>
2714
</Code>
2815
);
2916
};

0 commit comments

Comments
 (0)