Files
fristy ad943fff8c
Build & Push / Lint & Build (push) Successful in 1m15s
Build & Push / Build & Push Image (push) Successful in 52s
Initial commit: fristy.net personal site
2026-09-10 04:59:12 +03:00

41 lines
1.0 KiB
TypeScript

"use client";
import { useState } from "react";
export function CopyEmail({
email,
copyLabel,
copiedLabel,
}: {
email: string;
copyLabel: string;
copiedLabel: string;
}) {
const [copied, setCopied] = useState(false);
async function copy() {
try {
await navigator.clipboard.writeText(email);
} catch {
const area = document.createElement("textarea");
area.value = email;
document.body.appendChild(area);
area.select();
document.execCommand("copy");
document.body.removeChild(area);
}
setCopied(true);
window.setTimeout(() => setCopied(false), 2000);
}
return (
<button
type="button"
onClick={copy}
className="rounded-full border border-white/15 px-5 py-3 text-sm text-zinc-300 transition-colors hover:border-blurple hover:text-white"
>
{copied ? copiedLabel : copyLabel}
</button>
);
}