Skip to content

Commit 907f1c7

Browse files
authored
feat: new active rounds section in secondary navbar (gitcoinco#2346)
1 parent b320f8e commit 907f1c7

4 files changed

Lines changed: 129 additions & 168 deletions

File tree

packages/common/src/components/RoundsSubNav.tsx

Lines changed: 0 additions & 160 deletions
This file was deleted.

packages/grant-explorer/src/features/common/Navbar.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { ConnectButton } from "@rainbow-me/rainbowkit";
22
import { ReactComponent as GitcoinLogo } from "../../assets/gitcoinlogo-black.svg";
33
import { ReactComponent as GrantsExplorerLogo } from "../../assets/topbar-logos-black.svg";
44
import { useNavigate } from "react-router-dom";
5-
import {
6-
RoundsSubNav,
7-
Round as NavRound,
8-
} from "common/src/components/RoundsSubNav";
5+
import { RoundsSubNav } from "../discovery/RoundsSubNav";
96
import NavbarCart from "./NavbarCart";
107
import { UserCircleIcon } from "@heroicons/react/24/outline";
118
import { useEffect } from "react";
@@ -92,7 +89,7 @@ export default function Navbar(props: NavbarProps) {
9289
</div>
9390
</div>
9491
<RoundsSubNav
95-
onClick={(round: NavRound) => {
92+
onClick={(round) => {
9693
navigate(`/round/${round.chainId}/${round.id}`);
9794
}}
9895
/>

packages/grant-explorer/src/features/common/__tests__/Navbar.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ describe("<Navbar>", () => {
7575
fireEvent.click(openSubnavButton);
7676

7777
const link = screen.getByRole("link", {
78-
name: /climate solutions/i,
78+
name: /gaming round/i,
7979
});
8080

8181
fireEvent.click(link);
8282

83-
const expectedChainId = "10";
84-
const expectedRoundId = "0xb6be0ecafdb66dd848b0480db40056ff94a9465d";
83+
const expectedChainId = "42161";
84+
const expectedRoundId = "0xd0a086c37fbd20c44f3ba2cff69208d1b62f54e3";
8585
expect(navigateMock).toHaveBeenCalledWith(
8686
`/round/${expectedChainId}/${expectedRoundId}`
8787
);
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { Dropdown as DropdownIcon } from "common/src/icons/Dropdown";
2+
import { PGN as PGNLogoIcon } from "common/src/icons/PGN";
3+
import { PGNText as PGNTextLogoIcon } from "common/src/icons/PGNText";
4+
import React, { useState } from "react";
5+
import { ChainId } from "common/src/chains";
6+
import { Round } from "allo-indexer-client";
7+
8+
export type SubNavRound = Pick<Round, "id"> & {
9+
chainId: ChainId;
10+
name: string;
11+
};
12+
13+
type Props = {
14+
onClick: (round: SubNavRound) => void;
15+
};
16+
17+
const rounds: SubNavRound[] = [
18+
{
19+
id: "0xd0a086c37fbd20c44f3ba2cff69208d1b62f54e3",
20+
name: "Gaming Round",
21+
chainId: ChainId.ARBITRUM,
22+
},
23+
{
24+
id: "0x8b70206844630d8c0a2a545e92d3c8d46a3ceaad",
25+
name: "New Protocol Ideas Round",
26+
chainId: ChainId.ARBITRUM,
27+
},
28+
{
29+
id: "0x1d16f0eedf8ced25f288056ddcbb653d0f0451ad",
30+
name: "Developer Tooling on Nova",
31+
chainId: ChainId.ARBITRUM,
32+
},
33+
{
34+
id: "0x59d79b22595b17af659ce9b03907615f53742c57",
35+
name: "Education, Community Growth & Events Round",
36+
chainId: ChainId.ARBITRUM,
37+
},
38+
{
39+
id: "0x8dce7a66e0c310f9f89e847dba83b2344d589161",
40+
name: "Vault Round 1",
41+
chainId: ChainId.FANTOM_MAINNET_CHAIN_ID,
42+
},
43+
];
44+
45+
export function RoundsSubNav(props: Props) {
46+
const [open, setOpen] = useState(false);
47+
return (
48+
<div className="bg-grey-150">
49+
<div className="mx-auto px-4 sm:px-6 lg:px-20">
50+
<div className="flex justify-between h-12 flex-row-reverse">
51+
<div className="flex items-center gap-6">
52+
<div>
53+
<a
54+
href="https://bridge.gitcoin.co"
55+
target="_blank"
56+
rel="noreferrer"
57+
className="flex-shrink-0 flex items-center"
58+
>
59+
<PGNLogoIcon className="mr-2" />
60+
<PGNTextLogoIcon fill="black" className="mt-1" />
61+
</a>
62+
</div>
63+
<div className="relative bg-white">
64+
<span
65+
style={{
66+
border: "1px solid var(--sky-600, #15B8DC)",
67+
borderRadius: "8px",
68+
padding: "4px 8px",
69+
boxShadow:
70+
"0px 1px 2px 0px rgba(0, 0, 0, 0.06), 0px 1px 3px 0px rgba(0, 0, 0, 0.10)",
71+
}}
72+
className="cursor-pointer flex gap-2 items-center"
73+
aria-label={"Open Grants Subnav"}
74+
onClick={() => setOpen(!open)}
75+
>
76+
Active rounds
77+
<DropdownIcon
78+
className="inline"
79+
direction={open ? "up" : "down"}
80+
/>
81+
</span>
82+
<div
83+
className={`absolute right-0 top-12 bg-grey-150 py-4 px-6 rounded-lg text-right whitespace-nowrap ${
84+
open ? "block" : "hidden"
85+
}`}
86+
>
87+
<ul>
88+
{rounds.map((round) => (
89+
<li key={round.id}>
90+
<a
91+
data-testid={`round-link-${round.id}`}
92+
href="#"
93+
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
94+
e.preventDefault();
95+
props.onClick(round);
96+
}}
97+
className="flex justify-end py-2 items-center"
98+
>
99+
<img
100+
src={(() => {
101+
switch (round.chainId) {
102+
case ChainId.ARBITRUM:
103+
return "/logos/arb-logo.svg";
104+
case ChainId.FANTOM_MAINNET_CHAIN_ID:
105+
return "/logos/fantom-logo.svg";
106+
}
107+
})()}
108+
alt="chain logo"
109+
data-testid="chain-logo"
110+
className="h-5 w-5 rounded-full mr-1 ml-4"
111+
/>
112+
{round.name}
113+
</a>
114+
</li>
115+
))}
116+
</ul>
117+
</div>
118+
</div>
119+
</div>
120+
</div>
121+
</div>
122+
</div>
123+
);
124+
}

0 commit comments

Comments
 (0)