-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.tsx
More file actions
148 lines (142 loc) · 5.42 KB
/
index.tsx
File metadata and controls
148 lines (142 loc) · 5.42 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
"use client";
import React from "react";
import Image from "next/image";
import { ConnectButton } from "@rainbow-me/rainbowkit";
import { isDevelopment } from "@/lib/chains.config";
export const CustomConnectButton: React.FC = () => {
return (
<ConnectButton.Custom>
{({
account,
chain,
openAccountModal,
openChainModal,
openConnectModal,
authenticationStatus,
mounted,
}) => {
const ready = mounted && authenticationStatus !== "loading";
const connected =
ready &&
account &&
chain &&
(!authenticationStatus || authenticationStatus === "authenticated");
return (
<div
{...(!ready && {
"aria-hidden": true,
style: {
opacity: 0,
pointerEvents: "none",
userSelect: "none",
},
})}
>
{(() => {
if (!connected) {
return (
<button
onClick={openConnectModal}
type="button"
className="flex items-center gap-2 px-4 py-2 bg-black text-white font-medium text-sm rounded-md hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black disabled:opacity-50 disabled:cursor-not-allowed"
>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
/>
</svg>
<span className="hidden sm:inline">Connect Wallet</span>
<span className="sm:hidden">Connect</span>
</button>
);
}
if (chain.unsupported) {
return (
<button
onClick={openChainModal}
type="button"
className="flex items-center gap-2 px-4 py-2 bg-red-600 text-white font-medium text-sm rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
>
<span className="hidden sm:inline">Wrong network</span>
<span className="sm:hidden">Wrong net</span>
</button>
);
}
return (
<div className="flex gap-2">
<button
onClick={openChainModal}
type="button"
className="flex items-center gap-1 px-2 py-2 bg-gray-800 text-white text-sm rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500"
>
{chain.hasIcon && (
<div
style={{
background: chain.iconBackground,
width: 16,
height: 16,
borderRadius: 999,
overflow: "hidden",
marginRight: 4,
}}
>
{chain.iconUrl && (
<Image
loader={({ src }) => src}
width={16}
height={16}
className="rounded-full"
alt={chain.name ?? "Chain icon"}
src={chain.iconUrl}
/>
)}
</div>
)}
<span className="hidden sm:inline">
{chain.name}
{isDevelopment && (
<span className="ml-1 text-yellow-400 text-xs">
(DEV)
</span>
)}
</span>
</button>
<button
onClick={openAccountModal}
type="button"
className="flex items-center gap-2 px-4 py-2 bg-black text-white font-medium text-sm rounded-md hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
/>
</svg>
<span className="hidden sm:inline">
{account.displayName}
</span>
</button>
</div>
);
})()}
</div>
);
}}
</ConnectButton.Custom>
);
};