Skip to content

Commit c5b9257

Browse files
authored
Update ConnectButton.tsx
Signed-off-by: Aitor Alien <[email protected]>
1 parent 929ba61 commit c5b9257

File tree

1 file changed

+77
-27
lines changed

1 file changed

+77
-27
lines changed

src/components/Header/ConnectButton.tsx

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,98 @@
11
import React from 'react';
22
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) : '';
312

413
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();
916

1017
return (
1118
<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+
)}
3169
<a
3270
href="https://aliendex.lovable.app/"
3371
target="_blank"
3472
rel="noopener noreferrer"
3573
className="no-underline"
74+
title="Connect Portal"
75+
aria-label="Connect Portal"
76+
tabIndex={-1}
3677
>
3778
<Button
3879
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
4182
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
4384
"
85+
type="button"
4486
>
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>
4696
</Button>
4797
</a>
4898
</div>

0 commit comments

Comments
 (0)