feat: add code block component

This commit is contained in:
Jason
2023-09-14 14:52:35 -07:00
parent 6c44113242
commit 7696618c37
13 changed files with 822 additions and 70 deletions

28
components/CopyButton.tsx Normal file
View File

@@ -0,0 +1,28 @@
import { Clipboard, ClipboardCheck } from 'lucide-react'
const CopyIcon = ({ copied }) => (
<div className="flex h-5 w-5 items-center justify-center">
{copied ? (
<ClipboardCheck className="text-green-400" />
) : (
<Clipboard className="text-gray-300" />
)}
</div>
)
const CopyButton = ({ onClick, copied, hovered }) => (
<button
aria-label="Copy code"
type="button"
className={`border-1 absolute right-0.5 top-0.5 m-1 flex h-7 w-7 items-center justify-center rounded bg-accent transition-all duration-200 ${
copied
? 'border-green-400 opacity-100 focus:border-green-400 focus:outline-none'
: 'opacity-0'
} ${hovered ? '!opacity-100' : ''}`}
onClick={onClick}
>
<CopyIcon copied={copied} />
</button>
)
export default CopyButton