moved cards to drawers for mobile view

This commit is contained in:
lemonknowsall committed 2025-10-16 23:32:07 -07:00
1 parent 56bdebff5d
commit 8ef018df8a
4 files changed
+173 -84

No files matched your search

+34
View File
@@ -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 (
<div className="flex gap-6 justify-center py-8">
<Button
variant="outline"
size="icon"
onClick={onReceiveClick}
disabled={isLoading}
className="h-16 w-16 rounded-full shadow-lg hover:shadow-xl transition-all duration-200 hover:scale-105"
>
<Download className="h-7 w-7" />
</Button>
<Button
variant="outline"
size="icon"
onClick={onSendClick}
disabled={isLoading}
className="h-16 w-16 rounded-full shadow-lg hover:shadow-xl transition-all duration-200 hover:scale-105"
>
<Send className="h-7 w-7" />
</Button>
</div>
);
}
+69 -31
View File
@@ -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<string>('');
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(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 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<ReceiveCard
mode={mode}
tokenInput={tokenInput}
setTokenInput={setTokenInput}
quoteAmount={quoteAmount}
setQuoteAmount={setQuoteAmount}
activeMintUrl={activeMintUrl}
onReceive={handleReceive}
isLoading={isLoading || isNpubCashLoading}
/>
<SendCard
mode={mode}
sendAmount={sendAmount}
setSendAmount={setSendAmount}
lightningInvoice={lightningInvoice}
setLightningInvoice={setLightningInvoice}
lightningAddressInput={lightningAddressInput}
setLightningAddressInput={setLightningAddressInput}
lightningAddressAmount={lightningAddressAmount}
setLightningAddressAmount={setLightningAddressAmount}
pendingLightningAddress={pendingLightningAddress}
setPendingLightningAddress={setPendingLightningAddress}
activeMintUrl={activeMintUrl}
onSend={handleSend}
isResolvingAddress={isResolvingAddress}
isLoading={isLoading || isNpubCashLoading}
/>
</div>
{/* Action Buttons */}
<ActionButtons
onSendClick={() => 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 */}
<Drawer open={showSendModal} onOpenChange={setShowSendModal}>
<DrawerContent className="min-h-[50vh] max-h-[85vh]">
<DrawerHeader>
<DrawerTitle>Send</DrawerTitle>
</DrawerHeader>
<div className="px-4 pb-4">
<SendCard
mode={mode}
sendAmount={sendAmount}
setSendAmount={setSendAmount}
lightningInvoice={lightningInvoice}
setLightningInvoice={setLightningInvoice}
lightningAddressInput={lightningAddressInput}
setLightningAddressInput={setLightningAddressInput}
lightningAddressAmount={lightningAddressAmount}
setLightningAddressAmount={setLightningAddressAmount}
pendingLightningAddress={pendingLightningAddress}
setPendingLightningAddress={setPendingLightningAddress}
activeMintUrl={activeMintUrl}
onSend={() => {
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}
/>
</div>
</DrawerContent>
</Drawer>
<Drawer open={showReceiveModal} onOpenChange={setShowReceiveModal}>
<DrawerContent className="min-h-[50vh] max-h-[85vh]">
<DrawerHeader>
<DrawerTitle>Receive</DrawerTitle>
</DrawerHeader>
<div className="px-4 pb-4">
<ReceiveCard
mode={mode}
tokenInput={tokenInput}
setTokenInput={setTokenInput}
quoteAmount={quoteAmount}
setQuoteAmount={setQuoteAmount}
activeMintUrl={activeMintUrl}
onReceive={() => {
handleReceive();
setShowReceiveModal(false);
}}
isLoading={isLoading || isNpubCashLoading}
/>
</div>
</DrawerContent>
</Drawer>
</>
</div>
</>
+28 -18
View File
@@ -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 (
<Card className="border-0 shadow-none bg-muted/30">
<CardHeader>
<CardTitle className="flex items-center">
<Download className="h-5 w-5 mr-2" />
Receive
</CardTitle>
<CardDescription className="min-h-[2.5rem] flex items-center">
<div className="space-y-6">
{/* Description */}
<div className="text-center">
<p className="text-muted-foreground">
{mode === 'tokens'
? 'Enter Cashu token to redeem'
: 'Deposit funds with Lightning'
}
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
</p>
</div>
{/* Content */}
<div className="space-y-4">
{mode === 'tokens' ? (
<>
{!activeMintUrl && (
@@ -46,7 +44,7 @@ export function ReceiveCard({
Select a mint to receive tokens
</div>
)}
<div className="flex gap-2">
<div className="space-y-3">
<Input
placeholder="cashuBo2Ft..."
value={tokenInput}
@@ -56,10 +54,16 @@ export function ReceiveCard({
onReceive();
}
}}
className="flex-1"
className="w-full"
disabled={!activeMintUrl}
autoFocus
/>
<Button onClick={onReceive} disabled={!tokenInput.trim() || !activeMintUrl || isLoading}>
<Button
onClick={onReceive}
disabled={!tokenInput.trim() || !activeMintUrl || isLoading}
className="w-full"
size="lg"
>
<Download className="h-4 w-4 mr-2" />
Receive
</Button>
@@ -72,7 +76,7 @@ export function ReceiveCard({
Select a mint to create Lightning invoice
</div>
)}
<div className="flex gap-2">
<div className="space-y-3">
<Input
placeholder="Amount (sats)"
type="number"
@@ -84,15 +88,21 @@ export function ReceiveCard({
}
}}
disabled={!activeMintUrl}
autoFocus
/>
<Button onClick={onReceive} disabled={!quoteAmount || !activeMintUrl || isLoading}>
<Button
onClick={onReceive}
disabled={!quoteAmount || !activeMintUrl || isLoading}
className="w-full"
size="lg"
>
<Zap className="h-4 w-4 mr-2" />
Quote
</Button>
</div>
</>
)}
</CardContent>
</Card>
</div>
</div>
);
}
+42 -35
View File
@@ -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 (
<Card className="border-0 shadow-none bg-muted/30">
<CardHeader>
<CardTitle className="flex items-center">
<Send className="h-5 w-5 mr-2" />
Send
</CardTitle>
<CardDescription className="min-h-[2.5rem] flex items-center">
<div className="space-y-6">
{/* Description */}
<div className="text-center">
<p className="text-muted-foreground">
{mode === 'tokens'
? 'Generate Cashu token to send'
: pendingLightningAddress
@@ -57,9 +53,11 @@ export function SendCard({
)
: 'Pay Lightning invoices or addresses from balance'
}
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
</p>
</div>
{/* Content */}
<div className="space-y-4">
{mode === 'tokens' ? (
<>
{!activeMintUrl && (
@@ -67,7 +65,7 @@ export function SendCard({
Select a mint to send tokens
</div>
)}
<div className="flex gap-2">
<div className="space-y-3">
<Input
placeholder="Amount (sats)"
type="number"
@@ -79,8 +77,14 @@ export function SendCard({
}
}}
disabled={!activeMintUrl}
autoFocus
/>
<Button onClick={onSend} disabled={!sendAmount || !activeMintUrl || isLoading}>
<Button
onClick={onSend}
disabled={!sendAmount || !activeMintUrl || isLoading}
className="w-full"
size="lg"
>
<Send className="h-4 w-4 mr-2" />
Send
</Button>
@@ -96,23 +100,25 @@ export function SendCard({
{pendingLightningAddress ? (
// Step 2: Show amount input for Lightning address
<div className="space-y-3">
<Input
placeholder="Amount (sats)"
type="number"
value={lightningAddressAmount}
onChange={(e) => setLightningAddressAmount(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && lightningAddressAmount && activeMintUrl && !isResolvingAddress && !isLoading) {
onSend();
}
}}
autoFocus
disabled={!activeMintUrl}
/>
<div className="flex gap-2">
<Input
placeholder="Amount (sats)"
type="number"
value={lightningAddressAmount}
onChange={(e) => setLightningAddressAmount(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && lightningAddressAmount && activeMintUrl && !isResolvingAddress && !isLoading) {
onSend();
}
}}
autoFocus
disabled={!activeMintUrl}
/>
<Button
onClick={onSend}
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
className="flex-1"
size="lg"
>
{isResolvingAddress ? (
<>
@@ -133,7 +139,7 @@ export function SendCard({
setPendingLightningAddress(null);
setLightningAddressAmount('');
}}
className="h-10 w-10"
className="h-12 w-12"
title="Cancel"
>
<X className="h-4 w-4" />
@@ -142,7 +148,7 @@ export function SendCard({
</div>
) : (
// Step 1: Show invoice/address input
<div className="flex gap-2">
<div className="space-y-3">
<Input
placeholder="lnbc... or [email protected]"
value={lightningInvoice || lightningAddressInput}
@@ -161,23 +167,24 @@ export function SendCard({
onSend();
}
}}
className="flex-1"
className="w-full"
disabled={!activeMintUrl}
autoFocus
/>
<Button
onClick={onSend}
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
className="w-full"
size="lg"
>
<>
<Zap className="h-4 w-4 mr-2" />
Pay
</>
<Zap className="h-4 w-4 mr-2" />
Pay
</Button>
</div>
)}
</>
)}
</CardContent>
</Card>
</div>
</div>
);
}