From 954954ba78f6f45e24b084d91b6a5ddef88e41bc Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Jan 2026 22:24:08 +0000 Subject: [PATCH] feat: improve wallet button UX and add detailed info dialog UI improvements: - Remove border and padding from wallet button (use ghost variant) - Remove "sats" suffix from balance display (show just the number) - Change click behavior to show detailed wallet info dialog Wallet info dialog: - Show balance prominently without suffix - Display wallet alias if available - Show lightning address (lud16) if present - List all supported NWC methods as badges - Display connected relay URLs - Add disconnect button with confirmation toast This provides a cleaner header appearance and better wallet management with all details accessible in one place. --- src/components/WalletButton.tsx | 127 ++++++++++++++++++++++++++++++-- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/src/components/WalletButton.tsx b/src/components/WalletButton.tsx index 06b82d3..69f9a98 100644 --- a/src/components/WalletButton.tsx +++ b/src/components/WalletButton.tsx @@ -1,13 +1,22 @@ import { useState } from "react"; -import { Wallet, Zap } from "lucide-react"; +import { Wallet, Zap, X } from "lucide-react"; import { useGrimoire } from "@/core/state"; import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; import ConnectWalletDialog from "@/components/ConnectWalletDialog"; +import { toast } from "sonner"; export default function WalletButton() { - const { state } = useGrimoire(); + const { state, disconnectNWC } = useGrimoire(); const nwcConnection = state.nwcConnection; const [showConnectWallet, setShowConnectWallet] = useState(false); + const [showWalletInfo, setShowWalletInfo] = useState(false); function formatBalance(millisats?: number): string { if (millisats === undefined) return "—"; @@ -15,6 +24,20 @@ export default function WalletButton() { return sats.toLocaleString(); } + function handleDisconnect() { + disconnectNWC(); + setShowWalletInfo(false); + toast.success("Wallet disconnected"); + } + + function handleClick() { + if (nwcConnection) { + setShowWalletInfo(true); + } else { + setShowConnectWallet(true); + } + } + return ( <> + {/* Wallet Info Dialog */} + {nwcConnection && ( + + + + Wallet Info + + Connected Lightning wallet details + + + +
+ {/* Balance */} +
+ Balance: + + {formatBalance(nwcConnection.balance)} + +
+ + {/* Wallet Alias */} + {nwcConnection.info?.alias && ( +
+ Wallet: + + {nwcConnection.info.alias} + +
+ )} + + {/* Lightning Address */} + {nwcConnection.lud16 && ( +
+ + Address: + + + {nwcConnection.lud16} + +
+ )} + + {/* Supported Methods */} + {nwcConnection.info?.methods && + nwcConnection.info.methods.length > 0 && ( +
+ + Supported Methods: + +
+ {nwcConnection.info.methods.map((method) => ( + + {method} + + ))} +
+
+ )} + + {/* Relays */} +
+ Relays: +
+ {nwcConnection.relays.map((relay) => ( +
+ {relay} +
+ ))} +
+
+ + {/* Disconnect Button */} + +
+
+
+ )} + + {/* Wallet Button */} {nwcConnection ? ( ) : (