Skip to content

Commit ccdafca

Browse files
committed
add: click-to-copy on donate address
1 parent 0e65601 commit ccdafca

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

app/globals.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,16 @@
23502350
font-size: 0.6875rem;
23512351
color: var(--color-cyan);
23522352
word-break: break-all;
2353+
background: none;
2354+
border: none;
2355+
padding: 0;
2356+
cursor: pointer;
2357+
text-align: left;
2358+
transition: opacity 0.15s ease;
2359+
}
2360+
2361+
.nl-donate-addr:hover {
2362+
opacity: 0.7;
23532363
}
23542364

23552365
.nl-table-wrap {

components/newsletter/DonateFooter.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
'use client';
22

3+
import { useState } from 'react';
34
import { QRCodeSVG } from 'qrcode.react';
45

56
interface DonateFooterProps {
67
address: string;
78
}
89

910
export function DonateFooter({ address }: DonateFooterProps) {
11+
const [copied, setCopied] = useState(false);
1012
const truncated = `${address.slice(0, 16)}${address.slice(-16)}`;
1113

14+
function handleCopy() {
15+
navigator.clipboard.writeText(address);
16+
setCopied(true);
17+
setTimeout(() => setCopied(false), 2000);
18+
}
19+
1220
return (
1321
<div className="nl-donate">
1422
<QRCodeSVG
@@ -20,7 +28,9 @@ export function DonateFooter({ address }: DonateFooterProps) {
2028
/>
2129
<div className="nl-donate-text">
2230
<span className="nl-donate-label">Support CipherScan</span>
23-
<code className="nl-donate-addr" title={address}>{truncated}</code>
31+
<button className="nl-donate-addr" onClick={handleCopy} title="Click to copy">
32+
{copied ? 'Copied ✓' : truncated}
33+
</button>
2434
</div>
2535
</div>
2636
);

0 commit comments

Comments
 (0)