From d3da520e4bab401191b04aabb5cb477b737fbaa4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Jan 2026 20:27:32 +0000 Subject: [PATCH] feat: add line-clamp and expandable raw transaction view Changes: - Replace truncate with line-clamp-1 on zap message for proper single-line clamping - Add expandable 'Show Raw Transaction' section in transaction detail dialog - Collapsible with ChevronRight/ChevronDown icons - Shows JSON.stringify(transaction, null, 2) in scrollable pre block - Uses CodeCopyButton component for consistent copy UX - Max height 60 (15rem) with overflow-y-auto for long transactions - Add state management for raw transaction expansion and copy status - Reset raw transaction state when dialog closes UI improvements: - Clean expansion interaction with hover effects - Properly formatted JSON with 2-space indentation - Accessible copy button with aria-label - Auto-collapses when closing the dialog --- src/components/WalletViewer.tsx | 59 +++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/src/components/WalletViewer.tsx b/src/components/WalletViewer.tsx index 15c4678..bd988a2 100644 --- a/src/components/WalletViewer.tsx +++ b/src/components/WalletViewer.tsx @@ -19,6 +19,7 @@ import { ArrowDownLeft, LogOut, ChevronDown, + ChevronRight, } from "lucide-react"; import { Virtuoso } from "react-virtuoso"; import { useWallet } from "@/hooks/useWallet"; @@ -55,6 +56,7 @@ import { useNostrEvent } from "@/hooks/useNostrEvent"; import { KindRenderer } from "./nostr/kinds"; import { RichText } from "./nostr/RichText"; import { UserName } from "./nostr/UserName"; +import { CodeCopyButton } from "./CodeCopyButton"; interface Transaction { type: "incoming" | "outgoing"; @@ -326,7 +328,7 @@ function TransactionLabel({ transaction }: { transaction: Transaction }) {
{zapInfo.message && ( - + (null); const [detailDialogOpen, setDetailDialogOpen] = useState(false); + const [showRawTransaction, setShowRawTransaction] = useState(false); + const [copiedRawTx, setCopiedRawTx] = useState(false); // Load wallet info when connected useEffect(() => { @@ -1191,7 +1195,16 @@ export default function WalletViewer() { {/* Transaction Detail Dialog */} - + { + setDetailDialogOpen(open); + if (!open) { + setShowRawTransaction(false); + setCopiedRawTx(false); + } + }} + > Transaction Details @@ -1277,6 +1290,42 @@ export default function WalletViewer() { {/* Zap Details (if this is a zap payment) */} + + {/* Raw Transaction (expandable) */} +
+ + + {showRawTransaction && ( +
+
+
+                          {JSON.stringify(selectedTransaction, null, 2)}
+                        
+ { + navigator.clipboard.writeText( + JSON.stringify(selectedTransaction, null, 2), + ); + setCopiedRawTx(true); + setTimeout(() => setCopiedRawTx(false), 2000); + }} + label="Copy transaction JSON" + /> +
+
+ )} +
)} @@ -1284,7 +1333,11 @@ export default function WalletViewer() {