From 8ef018df8affe5ddbbd7f6441d2770f3d3ee52d2 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Thu, 16 Oct 2025 23:32:07 -0700 Subject: [PATCH] moved cards to drawers for mobile view --- src/components/wallet/ActionButtons.tsx | 34 ++++++++ src/components/wallet/CashuWallet.tsx | 100 ++++++++++++++++-------- src/components/wallet/ReceiveCard.tsx | 46 ++++++----- src/components/wallet/SendCard.tsx | 77 +++++++++--------- 4 files changed, 173 insertions(+), 84 deletions(-) create mode 100644 src/components/wallet/ActionButtons.tsx diff --git a/src/components/wallet/ActionButtons.tsx b/src/components/wallet/ActionButtons.tsx new file mode 100644 index 0000000..b2fa02e --- /dev/null +++ b/src/components/wallet/ActionButtons.tsx @@ -0,0 +1,34 @@ +import { Button } from '@/components/ui/button'; +import { Send, Download } from 'lucide-react'; + +interface ActionButtonsProps { + onSendClick: () => void; + onReceiveClick: () => void; + isLoading?: boolean; +} + +export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: ActionButtonsProps) { + return ( +
+ + + +
+ ); +} diff --git a/src/components/wallet/CashuWallet.tsx b/src/components/wallet/CashuWallet.tsx index 08e6414..1adf7db 100644 --- a/src/components/wallet/CashuWallet.tsx +++ b/src/components/wallet/CashuWallet.tsx @@ -12,6 +12,8 @@ import { useWalletTransactions } from '@/hooks/cashu/useWalletTransactions'; import { useHistoryManager } from '@/hooks/cashu/useHistoryManager'; import { QRModal } from '@/components/ui/qr-modal'; import { BalanceDisplay } from './BalanceDisplay'; +import { ActionButtons } from './ActionButtons'; +import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer'; import { ReceiveCard } from './ReceiveCard'; import { SendCard } from './SendCard'; import { TransactionHistory } from './TransactionHistory'; @@ -158,6 +160,8 @@ export function CashuWallet() { const [showLightningAddressQR, setShowLightningAddressQR] = useState(false); const [lightningAddressQRCode, setLightningAddressQRCode] = useState(''); const [npubCashUserInfo, setNpubCashUserInfo] = useState(null); + const [showSendModal, setShowSendModal] = useState(false); + const [showReceiveModal, setShowReceiveModal] = useState(false); // Ref to track if we've fetched npub.cash user info const hasCheckedNpubCashRef = useRef(false); @@ -308,37 +312,12 @@ export function CashuWallet() { setMintDropdownOpen={setMintDropdownOpen} /> - {/* Receive & Send Cards */} -
- - - -
+ {/* Action Buttons */} + setShowSendModal(true)} + onReceiveClick={() => setShowReceiveModal(true)} + isLoading={isLoading || isNpubCashLoading} + /> {/* Sent Token Display */} {sentToken && ( @@ -428,6 +407,65 @@ export function CashuWallet() { onConfirm={handleConfirmRemoveMint} isLoading={isLoading || isNpubCashLoading} /> + + {/* Bottom Drawer Modals */} + + + + Send + +
+ { + const wasPendingBefore = pendingLightningAddress !== null && pendingLightningAddress !== ''; + handleSend(); + // Only close drawer after lightning address flow is complete + // Don't close on Step 1 (address input), only close on Step 2 (amount input) + if (mode === 'tokens' || wasPendingBefore) { + setShowSendModal(false); + } + }} + isResolvingAddress={isResolvingAddress} + isLoading={isLoading || isNpubCashLoading} + /> +
+
+
+ + + + + Receive + +
+ { + handleReceive(); + setShowReceiveModal(false); + }} + isLoading={isLoading || isNpubCashLoading} + /> +
+
+
diff --git a/src/components/wallet/ReceiveCard.tsx b/src/components/wallet/ReceiveCard.tsx index 0abe497..faa68b5 100644 --- a/src/components/wallet/ReceiveCard.tsx +++ b/src/components/wallet/ReceiveCard.tsx @@ -1,6 +1,5 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Download, Zap } from 'lucide-react'; interface ReceiveCardProps { @@ -25,20 +24,19 @@ export function ReceiveCard({ isLoading, }: ReceiveCardProps) { return ( - - - - - Receive - - +
+ {/* Description */} +
+

{mode === 'tokens' ? 'Enter Cashu token to redeem' : 'Deposit funds with Lightning' } - - - +

+
+ + {/* Content */} +
{mode === 'tokens' ? ( <> {!activeMintUrl && ( @@ -46,7 +44,7 @@ export function ReceiveCard({ Select a mint to receive tokens
)} -
+
- @@ -72,7 +76,7 @@ export function ReceiveCard({ Select a mint to create Lightning invoice
)} -
+
-
)} - - +
+
); } diff --git a/src/components/wallet/SendCard.tsx b/src/components/wallet/SendCard.tsx index ed0184b..b2e6e1a 100644 --- a/src/components/wallet/SendCard.tsx +++ b/src/components/wallet/SendCard.tsx @@ -1,6 +1,5 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Send, Zap, Loader2, X } from 'lucide-react'; interface SendCardProps { @@ -39,13 +38,10 @@ export function SendCard({ isLoading, }: SendCardProps) { return ( - - - - - Send - - +
+ {/* Description */} +
+

{mode === 'tokens' ? 'Generate Cashu token to send' : pendingLightningAddress @@ -57,9 +53,11 @@ export function SendCard({ ) : 'Pay Lightning invoices or addresses from balance' } - - - +

+
+ + {/* Content */} +
{mode === 'tokens' ? ( <> {!activeMintUrl && ( @@ -67,7 +65,7 @@ export function SendCard({ Select a mint to send tokens
)} -
+
- @@ -96,23 +100,25 @@ export function SendCard({ {pendingLightningAddress ? ( // Step 2: Show amount input for Lightning address
+ setLightningAddressAmount(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter' && lightningAddressAmount && activeMintUrl && !isResolvingAddress && !isLoading) { + onSend(); + } + }} + autoFocus + disabled={!activeMintUrl} + />
- setLightningAddressAmount(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Enter' && lightningAddressAmount && activeMintUrl && !isResolvingAddress && !isLoading) { - onSend(); - } - }} - autoFocus - disabled={!activeMintUrl} - />
) : ( // Step 1: Show invoice/address input -
+
)} )} - - +
+
); }