Emboldened component, copyToClipboard

This commit is contained in:
2024-12-22 12:31:37 -06:00
parent eb35c9cf2f
commit ef2a41f1f4
2 changed files with 36 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
import { cn, type ClassValue } from "@/util";
type EmboldenedProps = {
children: string | number;
className?: ClassValue;
copyable?: boolean;
};
const Emboldened = ({ children, copyable }: EmboldenedProps) => {
function copyToClipboard() {
// Copy to clipboard
navigator.clipboard.writeText(children.toString());
}
return (
<span
onClick={copyable ? copyToClipboard : undefined}
className={cn(
"bg-zinc-900/40 rounded border border-zinc-700 py-0.5 px-1 font-mono text-teal-400",
{
"cursor-pointer": copyable,
}
)}
>
{children}
</span>
);
};
export default Emboldened;