mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-14 08:52:22 +00:00
Update CopyableCode.tsx
This commit is contained in:
parent
8bf675450a
commit
9f6cf2eb71
@ -26,32 +26,26 @@ const CopyableCode: React.FC<CopyableCodeProps> = ({ code, language, className }
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("relative w-full", className)}>
|
<div className={cn("relative w-full", className)}>
|
||||||
<div className="w-full overflow-x-auto">
|
|
||||||
<pre
|
<pre
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full min-w-0 bg-gray-100 p-2 sm:p-3 md:p-4 rounded-md overflow-x-auto",
|
"bg-gray-100 p-2 rounded-md overflow-x-auto",
|
||||||
"text-xs sm:text-sm md:text-base",
|
"text-sm",
|
||||||
"max-w-full",
|
"w-full min-w-[300px] max-w-full",
|
||||||
language ? `language-${language}` : "",
|
language ? `language-${language}` : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<code className="whitespace-pre">{decodeURIComponent(code)}</code>
|
<code className="whitespace-pre">{decodeURIComponent(code)}</code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={copyToClipboard}
|
onClick={copyToClipboard}
|
||||||
className="absolute top-1 right-1 sm:top-2 sm:right-2 p-1 sm:p-2 bg-white rounded-md shadow-sm hover:bg-gray-100 transition-colors"
|
className="absolute top-1 right-1 p-1 bg-white rounded-md shadow-sm hover:bg-gray-100 transition-colors"
|
||||||
aria-label="Copy code"
|
aria-label="Copy code"
|
||||||
>
|
>
|
||||||
{isCopied ? (
|
{isCopied ? <Check className="h-3 w-3 text-green-500" /> : <Copy className="h-3 w-3 text-gray-500" />}
|
||||||
<Check className="h-3 w-3 sm:h-4 sm:w-4 text-green-500" />
|
|
||||||
) : (
|
|
||||||
<Copy className="h-3 w-3 sm:h-4 sm:w-4 text-gray-500" />
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CopyableCode
|
export default CopyableCode
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user