Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add network switch banner #89

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
import { Navbar } from "flowbite-react";
import { SvgLoader } from "react-svgmt";

import { useAccount, useSwitchChain } from "wagmi";
import { CollectionSwitcher } from "#/components/CollectionSwitcher";
import NavLink from "#/components/NavLink";
import Profile from "#/components/Profile";
import { DEFAULT_CHAIN } from "#/constants";

export default function Header() {
const { chain } = useAccount();
const { switchChain } = useSwitchChain();

const isInvalidChain = chain?.id !== DEFAULT_CHAIN.id;
return (
<div className="pt-2 sm:pt-4 pb-24">
<div className={isInvalidChain ? "sm:pt-4 pb-24 mt-16 md:mt-10" : "pt-2 sm:pt-4 pb-24"}>
{isInvalidChain && (
<div
className={
"absolute top-0 left-0 w-full bg-black/[.03] dark:bg-white/[.03] py-3 text-center text-gray-600 dark:text-gray-400"
}
>
You're connected to a different network.{" "}
<span
onClick={() => switchChain({ chainId: DEFAULT_CHAIN.id })}
className={"font-extrabold text-primary underline cursor-pointer"}
>
Switch to {DEFAULT_CHAIN.name}
</span>{" "}
and continue using the app.
</div>
)}
<Navbar fluid={true} rounded={true} border={false}>
<Navbar.Brand href="/">
<SvgLoader src="/govnft.svg" className="block h-7 w-auto mr-4" alt="GOVNFT" />
Expand Down