Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/src/app/[locale]/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { useUserStore, selectUser } from "../../stores/useUserStore";
import { logoutUser } from "../../lib/session";
import { useNotificationPreferences, useUpdateNotificationPreferences } from "../../hooks/useApi";
import { COPY_FEEDBACK_RESET_MS } from "../../components/ui";
// ─── Types ────────────────────────────────────────────────────────────────────

interface NotificationPrefs {
Expand Down Expand Up @@ -52,6 +53,30 @@ const SECTIONS = [

type SectionId = (typeof SECTIONS)[number]["id"];

// ─── Copy-to-clipboard helper ─────────────────────────────────────────────────

function CopyButton({ value }: { value: string }) {
const [copied, setCopied] = useState(false);

const handleCopy = () => {
navigator.clipboard.writeText(value).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), COPY_FEEDBACK_RESET_MS);
});
};

return (
<button
onClick={handleCopy}
className="p-1.5 rounded-md text-zinc-400 hover:text-zinc-700 hover:bg-zinc-100 dark:hover:text-zinc-200 dark:hover:bg-zinc-800 transition-colors"
title="Copy to clipboard"
aria-label={copied ? "Copied to clipboard" : "Copy to clipboard"}
>
{copied ? <CheckCheck className="h-4 w-4 text-green-500" /> : <Copy className="h-4 w-4" />}
</button>
);
}

// ─── Toggle switch ─────────────────────────────────────────────────────────────

function Toggle({
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/[locale]/wallet/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "../../stores/useWalletStore";
import Link from "next/link";
import { QRCodeSVG } from "qrcode.react";
import { COPY_FEEDBACK_RESET_MS } from "../../components/ui";

// ─── Helpers ──────────────────────────────────────────────────────────────────

Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/components/ui.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const COPY_FEEDBACK_RESET_MS = 2000;
9 changes: 7 additions & 2 deletions frontend/src/app/components/ui/TxHashLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useState } from "react";
import { Copy, Check, ExternalLink } from "lucide-react";
import { getTxUrl, truncateHash } from "../../utils/stellar";
import { COPY_FEEDBACK_RESET_MS } from "../../constants/ui";

interface TxHashLinkProps {
txHash: string;
Expand All @@ -15,8 +16,12 @@ export function TxHashLink({ txHash, chars = 8, className = "" }: TxHashLinkProp

async function handleCopy() {
await navigator.clipboard.writeText(txHash);

setCopied(true);
setTimeout(() => setCopied(false), 2000);

setTimeout(() => {
setCopied(false);
}, COPY_FEEDBACK_RESET_MS);
}

return (
Expand Down Expand Up @@ -50,4 +55,4 @@ export function TxHashLink({ txHash, chars = 8, className = "" }: TxHashLinkProp
</a>
</span>
);
}
}
Loading