forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectWalletButton.tsx
More file actions
97 lines (89 loc) · 3.04 KB
/
Copy pathConnectWalletButton.tsx
File metadata and controls
97 lines (89 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use client';
import React from 'react';
import { ChevronRight, Wallet } from 'lucide-react';
import { useWallet } from '@/wallet';
import { shortenAddress } from '@/wallet';
import { WalletGlyph } from './WalletGlyph';
interface ConnectWalletButtonProps {
className?: string;
fullWidth?: boolean;
}
export function ConnectWalletButton({
className = '',
fullWidth = false
}: ConnectWalletButtonProps) {
const {
currentWallet,
openModal,
status
} = useWallet();
if (currentWallet) {
return (
<button
onClick={openModal}
className={`group flex items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.03] px-3 py-2 text-left transition-all hover:border-white/20 hover:bg-white/[0.05] ${fullWidth ? 'w-full' : ''} ${className}`}
>
<WalletGlyph
walletId={
currentWallet.id
}
family={
currentWallet.family
}
shortName={getShortName(
currentWallet.name
)}
size="sm"
/>
<div className="min-w-0 flex-1">
<div className="text-[10px] font-black uppercase tracking-[0.28em] text-slate-500">
Connected
</div>
<div className="truncate text-sm font-semibold text-white">
{
currentWallet.name
}
</div>
<div className="truncate text-xs text-slate-400">
{shortenAddress(
currentWallet.address
)}
</div>
</div>
<ChevronRight
size={16}
className="text-slate-500 transition-transform group-hover:translate-x-0.5 group-hover:text-white"
/>
</button>
);
}
return (
<button
onClick={openModal}
className={`group inline-flex items-center justify-center gap-2 rounded-2xl border border-electric-violet/20 bg-gradient-to-r from-electric-violet via-[#93D3EC] to-soft-purple px-5 py-3 font-bold text-white shadow-[0_18px_40px_rgba(163,163,163,0.28)] transition-all hover:scale-[1.01] hover:shadow-[0_22px_50px_rgba(163,163,163,0.34)] ${fullWidth ? 'w-full' : ''} ${className}`}
>
<Wallet
size={16}
className={
status ===
'connecting'
? 'animate-pulse'
: ''
}
/>
<span>
Connect Wallet
</span>
</button>
);
}
function getShortName(
name: string
) {
return name
.split(/\s+/)
.map((part) => part[0])
.join('')
.slice(0, 2)
.toUpperCase();
}