Sanitized mirror from private repository - 2026-04-20 01:32:01 UTC
This commit is contained in:
22
dashboard/ui/components/copyable.tsx
Normal file
22
dashboard/ui/components/copyable.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
import { useState, useCallback } from "react";
|
||||
|
||||
export function Copyable({ text, className = "" }: { text: string; className?: string }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const copy = useCallback(() => {
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 1500);
|
||||
}, [text]);
|
||||
|
||||
return (
|
||||
<span
|
||||
onClick={copy}
|
||||
className={`cursor-pointer hover:underline decoration-dotted underline-offset-2 ${className}`}
|
||||
title="Click to copy"
|
||||
>
|
||||
{copied ? "OK copied" : text}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user