mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
moved cards to drawers for mobile view
This commit is contained in:
1 parent
56bdebff5d
commit
8ef018df8a
4 files changed
+173
-84
No files matched your search
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ import { useWalletTransactions } from '@/hooks/cashu/useWalletTransactions';
|
|||||||
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
|
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
|
||||||
import { QRModal } from '@/components/ui/qr-modal';
|
import { QRModal } from '@/components/ui/qr-modal';
|
||||||
import { BalanceDisplay } from './BalanceDisplay';
|
import { BalanceDisplay } from './BalanceDisplay';
|
||||||
|
import { ActionButtons } from './ActionButtons';
|
||||||
|
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
|
||||||
import { ReceiveCard } from './ReceiveCard';
|
import { ReceiveCard } from './ReceiveCard';
|
||||||
import { SendCard } from './SendCard';
|
import { SendCard } from './SendCard';
|
||||||
import { TransactionHistory } from './TransactionHistory';
|
import { TransactionHistory } from './TransactionHistory';
|
||||||
@@ -158,6 +160,8 @@ export function CashuWallet() {
|
|||||||
const [showLightningAddressQR, setShowLightningAddressQR] = useState(false);
|
const [showLightningAddressQR, setShowLightningAddressQR] = useState(false);
|
||||||
const [lightningAddressQRCode, setLightningAddressQRCode] = useState<string>('');
|
const [lightningAddressQRCode, setLightningAddressQRCode] = useState<string>('');
|
||||||
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
|
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
|
// Ref to track if we've fetched npub.cash user info
|
||||||
const hasCheckedNpubCashRef = useRef(false);
|
const hasCheckedNpubCashRef = useRef(false);
|
||||||
@@ -308,37 +312,12 @@ export function CashuWallet() {
|
|||||||
setMintDropdownOpen={setMintDropdownOpen}
|
setMintDropdownOpen={setMintDropdownOpen}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Receive & Send Cards */}
|
{/* Action Buttons */}
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<ActionButtons
|
||||||
<ReceiveCard
|
onSendClick={() => setShowSendModal(true)}
|
||||||
mode={mode}
|
onReceiveClick={() => setShowReceiveModal(true)}
|
||||||
tokenInput={tokenInput}
|
isLoading={isLoading || isNpubCashLoading}
|
||||||
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>
|
|
||||||
|
|
||||||
{/* Sent Token Display */}
|
{/* Sent Token Display */}
|
||||||
{sentToken && (
|
{sentToken && (
|
||||||
@@ -428,6 +407,65 @@ export function CashuWallet() {
|
|||||||
onConfirm={handleConfirmRemoveMint}
|
onConfirm={handleConfirmRemoveMint}
|
||||||
isLoading={isLoading || isNpubCashLoading}
|
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>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
||||||
import { Download, Zap } from 'lucide-react';
|
import { Download, Zap } from 'lucide-react';
|
||||||
|
|
||||||
interface ReceiveCardProps {
|
interface ReceiveCardProps {
|
||||||
@@ -25,20 +24,19 @@ export function ReceiveCard({
|
|||||||
isLoading,
|
isLoading,
|
||||||
}: ReceiveCardProps) {
|
}: ReceiveCardProps) {
|
||||||
return (
|
return (
|
||||||
<Card className="border-0 shadow-none bg-muted/30">
|
<div className="space-y-6">
|
||||||
<CardHeader>
|
{/* Description */}
|
||||||
<CardTitle className="flex items-center">
|
<div className="text-center">
|
||||||
<Download className="h-5 w-5 mr-2" />
|
<p className="text-muted-foreground">
|
||||||
Receive
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription className="min-h-[2.5rem] flex items-center">
|
|
||||||
{mode === 'tokens'
|
{mode === 'tokens'
|
||||||
? 'Enter Cashu token to redeem'
|
? 'Enter Cashu token to redeem'
|
||||||
: 'Deposit funds with Lightning'
|
: 'Deposit funds with Lightning'
|
||||||
}
|
}
|
||||||
</CardDescription>
|
</p>
|
||||||
</CardHeader>
|
</div>
|
||||||
<CardContent className="space-y-4">
|
|
||||||
|
{/* Content */}
|
||||||
|
<div className="space-y-4">
|
||||||
{mode === 'tokens' ? (
|
{mode === 'tokens' ? (
|
||||||
<>
|
<>
|
||||||
{!activeMintUrl && (
|
{!activeMintUrl && (
|
||||||
@@ -46,7 +44,7 @@ export function ReceiveCard({
|
|||||||
Select a mint to receive tokens
|
Select a mint to receive tokens
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex gap-2">
|
<div className="space-y-3">
|
||||||
<Input
|
<Input
|
||||||
placeholder="cashuBo2Ft..."
|
placeholder="cashuBo2Ft..."
|
||||||
value={tokenInput}
|
value={tokenInput}
|
||||||
@@ -56,10 +54,16 @@ export function ReceiveCard({
|
|||||||
onReceive();
|
onReceive();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="flex-1"
|
className="w-full"
|
||||||
disabled={!activeMintUrl}
|
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" />
|
<Download className="h-4 w-4 mr-2" />
|
||||||
Receive
|
Receive
|
||||||
</Button>
|
</Button>
|
||||||
@@ -72,7 +76,7 @@ export function ReceiveCard({
|
|||||||
Select a mint to create Lightning invoice
|
Select a mint to create Lightning invoice
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex gap-2">
|
<div className="space-y-3">
|
||||||
<Input
|
<Input
|
||||||
placeholder="Amount (sats)"
|
placeholder="Amount (sats)"
|
||||||
type="number"
|
type="number"
|
||||||
@@ -84,15 +88,21 @@ export function ReceiveCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
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" />
|
<Zap className="h-4 w-4 mr-2" />
|
||||||
Quote
|
Quote
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
||||||
import { Send, Zap, Loader2, X } from 'lucide-react';
|
import { Send, Zap, Loader2, X } from 'lucide-react';
|
||||||
|
|
||||||
interface SendCardProps {
|
interface SendCardProps {
|
||||||
@@ -39,13 +38,10 @@ export function SendCard({
|
|||||||
isLoading,
|
isLoading,
|
||||||
}: SendCardProps) {
|
}: SendCardProps) {
|
||||||
return (
|
return (
|
||||||
<Card className="border-0 shadow-none bg-muted/30">
|
<div className="space-y-6">
|
||||||
<CardHeader>
|
{/* Description */}
|
||||||
<CardTitle className="flex items-center">
|
<div className="text-center">
|
||||||
<Send className="h-5 w-5 mr-2" />
|
<p className="text-muted-foreground">
|
||||||
Send
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription className="min-h-[2.5rem] flex items-center">
|
|
||||||
{mode === 'tokens'
|
{mode === 'tokens'
|
||||||
? 'Generate Cashu token to send'
|
? 'Generate Cashu token to send'
|
||||||
: pendingLightningAddress
|
: pendingLightningAddress
|
||||||
@@ -57,9 +53,11 @@ export function SendCard({
|
|||||||
)
|
)
|
||||||
: 'Pay Lightning invoices or addresses from balance'
|
: 'Pay Lightning invoices or addresses from balance'
|
||||||
}
|
}
|
||||||
</CardDescription>
|
</p>
|
||||||
</CardHeader>
|
</div>
|
||||||
<CardContent className="space-y-4">
|
|
||||||
|
{/* Content */}
|
||||||
|
<div className="space-y-4">
|
||||||
{mode === 'tokens' ? (
|
{mode === 'tokens' ? (
|
||||||
<>
|
<>
|
||||||
{!activeMintUrl && (
|
{!activeMintUrl && (
|
||||||
@@ -67,7 +65,7 @@ export function SendCard({
|
|||||||
Select a mint to send tokens
|
Select a mint to send tokens
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex gap-2">
|
<div className="space-y-3">
|
||||||
<Input
|
<Input
|
||||||
placeholder="Amount (sats)"
|
placeholder="Amount (sats)"
|
||||||
type="number"
|
type="number"
|
||||||
@@ -79,8 +77,14 @@ export function SendCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
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 className="h-4 w-4 mr-2" />
|
||||||
Send
|
Send
|
||||||
</Button>
|
</Button>
|
||||||
@@ -96,23 +100,25 @@ export function SendCard({
|
|||||||
{pendingLightningAddress ? (
|
{pendingLightningAddress ? (
|
||||||
// Step 2: Show amount input for Lightning address
|
// Step 2: Show amount input for Lightning address
|
||||||
<div className="space-y-3">
|
<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">
|
<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
|
<Button
|
||||||
onClick={onSend}
|
onClick={onSend}
|
||||||
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
||||||
|
className="flex-1"
|
||||||
|
size="lg"
|
||||||
>
|
>
|
||||||
{isResolvingAddress ? (
|
{isResolvingAddress ? (
|
||||||
<>
|
<>
|
||||||
@@ -133,7 +139,7 @@ export function SendCard({
|
|||||||
setPendingLightningAddress(null);
|
setPendingLightningAddress(null);
|
||||||
setLightningAddressAmount('');
|
setLightningAddressAmount('');
|
||||||
}}
|
}}
|
||||||
className="h-10 w-10"
|
className="h-12 w-12"
|
||||||
title="Cancel"
|
title="Cancel"
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4" />
|
<X className="h-4 w-4" />
|
||||||
@@ -142,7 +148,7 @@ export function SendCard({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
// Step 1: Show invoice/address input
|
// Step 1: Show invoice/address input
|
||||||
<div className="flex gap-2">
|
<div className="space-y-3">
|
||||||
<Input
|
<Input
|
||||||
placeholder="lnbc... or [email protected]"
|
placeholder="lnbc... or [email protected]"
|
||||||
value={lightningInvoice || lightningAddressInput}
|
value={lightningInvoice || lightningAddressInput}
|
||||||
@@ -161,23 +167,24 @@ export function SendCard({
|
|||||||
onSend();
|
onSend();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="flex-1"
|
className="w-full"
|
||||||
disabled={!activeMintUrl}
|
disabled={!activeMintUrl}
|
||||||
|
autoFocus
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={onSend}
|
onClick={onSend}
|
||||||
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
|
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
|
||||||
|
className="w-full"
|
||||||
|
size="lg"
|
||||||
>
|
>
|
||||||
<>
|
<Zap className="h-4 w-4 mr-2" />
|
||||||
<Zap className="h-4 w-4 mr-2" />
|
Pay
|
||||||
Pay
|
|
||||||
</>
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user