'use client' /** * MobileWalletSheet — bottom-drawer shown on mobile when no injected wallet * is detected. Offers deep links to common mobile wallets so the user can * open MetaMask (or Trust / Coinbase / OKX) and land directly on this dApp. * * Rendered as a fixed overlay + slide-up panel. Backdrop tap dismisses it. * The CSS animation class `mobile-sheet-enter` is defined in globals.css. * * Usage: * setOpen(false)} /> */ import { useEffect, useState } from 'react' import { getWalletLinks } from '@/lib/mobileWallet' import type { WalletLink } from '@/lib/mobileWallet' interface Props { open: boolean onClose: () => void } export default function MobileWalletSheet({ open, onClose }: Props) { const [links, setLinks] = useState([]) // Build deep links client-side only (needs window.location.href). useEffect(() => { if (open) { setLinks(getWalletLinks(window.location.href)) } }, [open]) // Lock body scroll while sheet is open. useEffect(() => { if (open) { document.body.style.overflow = 'hidden' return () => { document.body.style.overflow = '' } } }, [open]) // Escape key closes. useEffect(() => { if (!open) return function onKey(e: KeyboardEvent) { if (e.key === 'Escape') onClose() } window.addEventListener('keydown', onKey) return () => window.removeEventListener('keydown', onKey) }, [open, onClose]) if (!open) return null return ( /* Backdrop */
{/* Sheet */}
e.stopPropagation()} > {/* Handle bar */}
{/* Header */}
Connect a wallet
Open the dApp inside your wallet's built-in browser to connect.
{/* Wallet list */} {/* WalletConnect note */}
Already in your wallet's browser? {' '}Tap Cancel to dismiss, then use the built-in browser navigation to reload the page — MetaMask should auto-detect the dApp.
{/* Close */}
) }