-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from hypercerts-org/feature/nav-menu
Feature/nav menu
- Loading branch information
Showing
7 changed files
with
305 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,114 @@ | ||
import { ConnectButton as RainbowKitConnectButton } from "@rainbow-me/rainbowkit"; | ||
export const ConnectButton = () => { | ||
return <RainbowKitConnectButton />; | ||
import { ConnectButton as ConnectButtonInternal } from "@rainbow-me/rainbowkit"; | ||
import { Button, ButtonProps } from "@chakra-ui/react"; | ||
|
||
export const ConnectButton = ({ ...buttonProps }: ButtonProps) => { | ||
return ( | ||
<ConnectButtonInternal.Custom> | ||
{({ | ||
account, | ||
chain, | ||
openAccountModal, | ||
openChainModal, | ||
openConnectModal, | ||
authenticationStatus, | ||
mounted, | ||
}) => { | ||
// Note: If your app doesn't use authentication, you | ||
// can remove all 'authenticationStatus' checks | ||
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 | ||
{...buttonProps} | ||
variant={"blackAndWhite"} | ||
onClick={openConnectModal} | ||
type="button" | ||
> | ||
Connect wallet | ||
</Button> | ||
); | ||
} | ||
|
||
if (chain.unsupported) { | ||
return ( | ||
<Button | ||
{...buttonProps} | ||
variant={"blackAndWhite"} | ||
onClick={openChainModal} | ||
type="button" | ||
> | ||
Wrong network | ||
</Button> | ||
); | ||
} | ||
|
||
return ( | ||
<div style={{ display: "flex", gap: 12 }}> | ||
<Button | ||
{...buttonProps} | ||
variant={"blackAndWhiteOutline"} | ||
onClick={openChainModal} | ||
style={{ display: "flex", alignItems: "center" }} | ||
type="button" | ||
> | ||
{chain.hasIcon && ( | ||
<div | ||
style={{ | ||
background: chain.iconBackground, | ||
width: 12, | ||
height: 12, | ||
borderRadius: 999, | ||
overflow: "hidden", | ||
marginRight: 4, | ||
}} | ||
> | ||
{chain.iconUrl && ( | ||
<img | ||
alt={chain.name ?? "Chain icon"} | ||
src={chain.iconUrl} | ||
style={{ width: 12, height: 12 }} | ||
/> | ||
)} | ||
</div> | ||
)} | ||
{chain.name} | ||
</Button> | ||
|
||
<Button | ||
{...buttonProps} | ||
onClick={openAccountModal} | ||
type="button" | ||
variant={"blackAndWhite"} | ||
> | ||
{account.displayName} | ||
{account.displayBalance | ||
? ` (${account.displayBalance})` | ||
: ""} | ||
</Button> | ||
</div> | ||
); | ||
})()} | ||
</div> | ||
); | ||
}} | ||
</ConnectButtonInternal.Custom> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.