forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.tsx
More file actions
64 lines (60 loc) · 2.07 KB
/
Copy pathHeader.tsx
File metadata and controls
64 lines (60 loc) · 2.07 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
import { useWallet, truncateAddress } from '../context/WalletContext';
export default function Header() {
const {
publicKey,
isConnected,
isConnecting,
error,
connect,
disconnect,
clearError,
} = useWallet();
return (
<nav className="relative flex flex-wrap items-center justify-between gap-3 rounded-campaign border border-soil-200 bg-white px-6 py-3 shadow-campaign">
<div className="flex items-center gap-2">
<span className="text-h4 font-bold text-soil-900">Agrocylo</span>
<span className="text-label text-soil-600">PIP</span>
</div>
<div className="flex items-center gap-3">
{isConnected && publicKey ? (
<>
<span className="rounded-lg bg-leaf-50 px-3 py-1.5 font-mono text-body-sm text-leaf-700">
{truncateAddress(publicKey)}
</span>
<button
type="button"
onClick={disconnect}
className="rounded-lg border border-soil-300 bg-white px-4 py-1.5 text-body-sm font-semibold text-soil-700 transition-colors hover:bg-soil-50"
>
Disconnect
</button>
</>
) : (
<button
type="button"
onClick={connect}
disabled={isConnecting}
className="rounded-lg bg-leaf-600 px-4 py-1.5 text-body-sm font-semibold text-white transition-colors hover:bg-leaf-700 disabled:opacity-50"
>
{isConnecting ? 'Connecting...' : 'Connect Wallet'}
</button>
)}
</div>
{error && (
<div
role="alert"
className="absolute inset-x-4 top-full z-50 mt-2 w-auto max-w-sm rounded-lg border border-status-disputed/20 bg-status-disputed-light p-3 text-body-sm text-status-disputed-dark shadow-lg sm:inset-x-auto sm:right-6"
>
{error}
<button
type="button"
onClick={clearError}
className="ml-2 font-semibold underline"
>
Dismiss
</button>
</div>
)}
</nav>
);
}