Skip to content

Commit

Permalink
UserBadges with a cascading approach
Browse files Browse the repository at this point in the history
  • Loading branch information
melanke committed Nov 21, 2024
1 parent e3966ea commit 9b27aae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { UserBadges } from "./UserBadges";
import { useAccount } from "wagmi";
import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline";
import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth";
import { useOutsideClick } from "~~/hooks/scaffold-eth";
Expand Down Expand Up @@ -59,6 +60,8 @@ export const HeaderMenuLinks = () => {
export const Header = () => {
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const burgerMenuRef = useRef<HTMLDivElement>(null);
const { isConnected } = useAccount();

useOutsideClick(
burgerMenuRef,
useCallback(() => setIsDrawerOpen(false), []),
Expand Down Expand Up @@ -103,7 +106,7 @@ export const Header = () => {
</ul>
</div>
<div className="navbar-end flex-grow mr-4">
<UserBadges />
{isConnected && <UserBadges />}
<RainbowKitCustomConnectButton />
<FaucetButton />
</div>
Expand Down
17 changes: 10 additions & 7 deletions packages/nextjs/components/UserBadges.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAccount } from "wagmi";
import { IdentificationIcon, PuzzlePieceIcon } from "@heroicons/react/24/outline";
import { BookmarkSquareIcon, IdentificationIcon, SignalSlashIcon } from "@heroicons/react/24/outline";
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";

export const UserBadges = () => {
Expand All @@ -21,14 +21,17 @@ export const UserBadges = () => {

return (
<div className="flex gap-2 mr-2">
{isBuilderOfBatch11 && (
<div className="tooltip tooltip-bottom" data-tip="Is builder of batch 11">
{madeCheckin ? (
<div className="tooltip tooltip-bottom" data-tip="A builder of batch 11 with confirmed checkin">
<BookmarkSquareIcon className="h-6 w-6 text-success" />
</div>
) : isBuilderOfBatch11 ? (
<div className="tooltip tooltip-bottom" data-tip="A builder of batch 11">
<IdentificationIcon className="h-6 w-6 text-success" />
</div>
)}
{madeCheckin && (
<div className="tooltip tooltip-bottom" data-tip="Made checkin">
<PuzzlePieceIcon className="h-6 w-6 text-success" />
) : (
<div className="tooltip tooltip-bottom" data-tip="Not a builder of batch 11">
<SignalSlashIcon className="h-6 w-6 opacity-50" />
</div>
)}
</div>
Expand Down

0 comments on commit 9b27aae

Please sign in to comment.