File size: 679 Bytes
1c0c94d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import { useState } from 'react'
import { shortHash } from '../../lib/format.js'
export default function EvidenceHash({ hash }) {
const [copied, setCopied] = useState(false)
if (!hash) return <span className="muted">—</span>
const copy = () => {
navigator.clipboard?.writeText(hash).then(() => {
setCopied(true)
setTimeout(() => setCopied(false), 1500)
})
}
return (
<span className="row" style={{ gap: 8 }}>
<span className="hash" title={hash}>
{shortHash(hash)}
</span>
<button className="ghost" onClick={copy} style={{ padding: '2px 8px' }}>
{copied ? 'copied' : 'copy'}
</button>
</span>
)
}
|