|
1 | 1 | import React from 'react'; |
2 | 2 | import { Button } from '@/components/ui/button'; |
| 3 | +import { useAppKit, useAppKitModal } from '@reown/appkit'; |
| 4 | + |
| 5 | +const WALLET_ICON = "/lovable-uploads/AW.png"; |
| 6 | +const PORTAL_ICON_AVIF = "/lovable-uploads/AP1.avif"; |
| 7 | +const PORTAL_ICON_JPG = "/lovable-uploads/AP.jpg"; |
| 8 | +const ICON_SIZE = "h-7 w-7 sm:h-8 sm:w-8"; |
| 9 | + |
| 10 | +const shortAddress = (addr: string) => |
| 11 | + addr ? addr.slice(0, 6) + '...' + addr.slice(-4) : ''; |
3 | 12 |
|
4 | 13 | const ConnectButton = () => { |
5 | | - // Aquí va tu lógica personalizada de conexión de wallet |
6 | | - const handleConnectWallet = () => { |
7 | | - alert('Conectar Wallet personalizada'); |
8 | | - }; |
| 14 | + const { open } = useAppKitModal(); |
| 15 | + const { account, disconnect } = useAppKit(); |
9 | 16 |
|
10 | 17 | return ( |
11 | 18 | <div className="flex flex-wrap items-center gap-3"> |
12 | | - {/* Botón Connect Wallet con animación */} |
13 | | - <Button |
14 | | - className=" |
15 | | - bg-alien-green hover:bg-alien-green-light text-alien-gold font-nasalization rounded-full |
16 | | - flex items-center gap-2 py-1 px-3 sm:px-4 |
17 | | - transition-all duration-200 ease-in-out |
18 | | - hover:shadow-lg hover:scale-105 focus-visible:ring-2 focus-visible:ring-alien-gold |
19 | | - " |
20 | | - onClick={handleConnectWallet} |
21 | | - > |
22 | | - <img |
23 | | - src="/lovable-uploads/AW.png" |
24 | | - alt="Wallet Logo" |
25 | | - className="h-5 w-5 sm:h-6 sm:w-6 rounded-full object-cover" |
26 | | - /> |
27 | | - <span className="font-nasalization whitespace-nowrap">Connect Wallet</span> |
28 | | - </Button> |
29 | | - |
30 | | - {/* Botón Connect Portal con animación */} |
| 19 | + {account?.address ? ( |
| 20 | + <> |
| 21 | + <span |
| 22 | + className=" |
| 23 | + text-alien-gold font-mono text-xs sm:text-sm bg-alien-green px-3 py-1 rounded-full |
| 24 | + border border-alien-gold shadow transition-all duration-200 select-all |
| 25 | + " |
| 26 | + title={account.address} |
| 27 | + > |
| 28 | + {shortAddress(account.address)} |
| 29 | + </span> |
| 30 | + <Button |
| 31 | + onClick={disconnect} |
| 32 | + className=" |
| 33 | + bg-alien-green hover:bg-alien-green-light text-alien-gold rounded-full |
| 34 | + flex items-center justify-center p-2 sm:p-3 |
| 35 | + transition-all duration-200 ease-in-out |
| 36 | + hover:shadow-lg hover:scale-110 active:scale-95 focus-visible:ring-2 focus-visible:ring-alien-gold |
| 37 | + " |
| 38 | + title="Desconectar Wallet" |
| 39 | + aria-label="Desconectar Wallet" |
| 40 | + type="button" |
| 41 | + > |
| 42 | + <svg viewBox="0 0 24 24" fill="none" className="w-5 h-5"> |
| 43 | + <path d="M16 17L21 12M21 12L16 7M21 12H9" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/> |
| 44 | + <rect x="3" y="4" width="12" height="16" rx="2" stroke="currentColor" strokeWidth="2"/> |
| 45 | + </svg> |
| 46 | + </Button> |
| 47 | + </> |
| 48 | + ) : ( |
| 49 | + <Button |
| 50 | + className=" |
| 51 | + bg-alien-green hover:bg-alien-green-light text-alien-gold rounded-full |
| 52 | + flex items-center justify-center p-2 sm:p-3 |
| 53 | + transition-all duration-200 ease-in-out |
| 54 | + hover:shadow-lg hover:scale-110 active:scale-95 focus-visible:ring-2 focus-visible:ring-alien-gold |
| 55 | + " |
| 56 | + onClick={open} |
| 57 | + title="Conectar Wallet" |
| 58 | + aria-label="Conectar Wallet" |
| 59 | + type="button" |
| 60 | + > |
| 61 | + <img |
| 62 | + src={WALLET_ICON} |
| 63 | + alt="Wallet Logo" |
| 64 | + className={`${ICON_SIZE} rounded-full object-cover`} |
| 65 | + draggable={false} |
| 66 | + /> |
| 67 | + </Button> |
| 68 | + )} |
31 | 69 | <a |
32 | 70 | href="https://aliendex.lovable.app/" |
33 | 71 | target="_blank" |
34 | 72 | rel="noopener noreferrer" |
35 | 73 | className="no-underline" |
| 74 | + title="Connect Portal" |
| 75 | + aria-label="Connect Portal" |
| 76 | + tabIndex={-1} |
36 | 77 | > |
37 | 78 | <Button |
38 | 79 | className=" |
39 | | - bg-alien-green hover:bg-alien-green-light text-alien-gold font-nasalization rounded-full |
40 | | - flex items-center gap-2 py-1 px-3 sm:px-4 |
| 80 | + bg-alien-green hover:bg-alien-green-light text-alien-gold rounded-full |
| 81 | + flex items-center justify-center p-2 sm:p-3 |
41 | 82 | transition-all duration-200 ease-in-out |
42 | | - hover:shadow-lg hover:scale-105 focus-visible:ring-2 focus-visible:ring-alien-gold |
| 83 | + hover:shadow-lg hover:scale-110 active:scale-95 focus-visible:ring-2 focus-visible:ring-alien-gold |
43 | 84 | " |
| 85 | + type="button" |
44 | 86 | > |
45 | | - <span className="font-nasalization whitespace-nowrap">Connect Portal</span> |
| 87 | + <picture> |
| 88 | + <source srcSet={PORTAL_ICON_AVIF} type="image/avif" /> |
| 89 | + <img |
| 90 | + src={PORTAL_ICON_JPG} |
| 91 | + alt="Portal Icon" |
| 92 | + className={`${ICON_SIZE} rounded-full object-cover`} |
| 93 | + draggable={false} |
| 94 | + /> |
| 95 | + </picture> |
46 | 96 | </Button> |
47 | 97 | </a> |
48 | 98 | </div> |
|
0 commit comments