|
| 1 | +import { Button as _Button, Box, MenuItem, Stack } from "@mui/material"; |
1 | 2 | import styles from "components/NavBar.module.css";
|
2 | 3 | import Link from "next/link";
|
3 |
| -import { useState } from "react"; |
4 | 4 | import { AiFillGithub } from "react-icons/ai";
|
5 | 5 | import LoginSection from "./LoginSection";
|
6 | 6 | import ThemeModePicker from "./ThemeModePicker";
|
| 7 | +import { HoverDropDownMenu } from "./common/HoverDropDownMenu"; |
7 | 8 |
|
8 |
| -const NavBarDropdown = ({ |
9 |
| - title, |
10 |
| - items, |
| 9 | +const MenuItemLink = ({ |
| 10 | + href, |
| 11 | + name, |
11 | 12 | }: {
|
12 |
| - title: string; |
13 |
| - items: any; |
| 13 | + href: string; |
| 14 | + name: string; |
14 | 15 | }): JSX.Element => {
|
15 |
| - const [dropdown, setDropdown] = useState(false); |
16 |
| - const dropdownStyle = dropdown ? { display: "block" } : {}; |
| 16 | + return ( |
| 17 | + <Link href={href} prefetch={false}> |
| 18 | + <MenuItem>{name}</MenuItem> |
| 19 | + </Link> |
| 20 | + ); |
| 21 | +}; |
| 22 | + |
| 23 | +const Button = (props: any) => { |
| 24 | + // Make button as small as possible |
| 25 | + return ( |
| 26 | + <_Button |
| 27 | + style={{ minWidth: 0, textTransform: "none", font: "inherit" }} |
| 28 | + {...props} |
| 29 | + /> |
| 30 | + ); |
| 31 | +}; |
17 | 32 |
|
| 33 | +const ButtonLink = ({ |
| 34 | + href, |
| 35 | + name, |
| 36 | +}: { |
| 37 | + href: string; |
| 38 | + name: string; |
| 39 | +}): JSX.Element => { |
18 | 40 | return (
|
19 |
| - <li |
20 |
| - onMouseEnter={() => setDropdown(true)} |
21 |
| - onMouseLeave={() => setDropdown(false)} |
22 |
| - style={{ padding: 0 }} |
23 |
| - > |
24 |
| - <div className={styles.dropdowntitle}>{title} ▾</div> |
25 |
| - <ul className={styles.dropdown} style={dropdownStyle}> |
26 |
| - {items.map((item: any) => ( |
27 |
| - <li key={item.href}> |
28 |
| - <Link href={item.href} prefetch={false}> |
29 |
| - {item.name} |
30 |
| - </Link> |
31 |
| - </li> |
32 |
| - ))} |
33 |
| - </ul> |
34 |
| - </li> |
| 41 | + <Link href={href} prefetch={false}> |
| 42 | + <Button>{name}</Button> |
| 43 | + </Link> |
35 | 44 | );
|
36 | 45 | };
|
37 | 46 |
|
@@ -119,91 +128,101 @@ function NavBar() {
|
119 | 128 | },
|
120 | 129 | ];
|
121 | 130 |
|
| 131 | + const leftLinks = [ |
| 132 | + { |
| 133 | + href: "/minihud", |
| 134 | + name: "MiniHUD", |
| 135 | + }, |
| 136 | + { |
| 137 | + href: "/hud/pytorch/executorch/main", |
| 138 | + name: "ExecuTorch", |
| 139 | + }, |
| 140 | + { |
| 141 | + href: "/hud/pytorch/vision/main", |
| 142 | + name: "TorchVision", |
| 143 | + }, |
| 144 | + { |
| 145 | + href: "/hud/pytorch/audio/main", |
| 146 | + name: "TorchAudio", |
| 147 | + }, |
| 148 | + ]; |
| 149 | + |
122 | 150 | return (
|
123 | 151 | <div className={styles.navbar}>
|
124 |
| - <div> |
125 |
| - <ul className={styles.navbarlinkslist}> |
126 |
| - <li className={styles.homeLink}> |
127 |
| - <Link prefetch={false} href="/"> |
128 |
| - PyTorch CI HUD |
129 |
| - </Link> |
130 |
| - </li> |
131 |
| - <li> |
132 |
| - <Link prefetch={false} href="/minihud"> |
133 |
| - MiniHUD |
134 |
| - </Link> |
135 |
| - </li> |
136 |
| - <li> |
137 |
| - <Link prefetch={false} href="/hud/pytorch/executorch/main"> |
138 |
| - ExecuTorch |
139 |
| - </Link> |
140 |
| - </li> |
141 |
| - <li> |
142 |
| - <Link prefetch={false} href="/hud/pytorch/vision/main"> |
143 |
| - TorchVision |
144 |
| - </Link> |
145 |
| - </li> |
146 |
| - <li> |
147 |
| - <Link prefetch={false} href="/hud/pytorch/audio/main"> |
148 |
| - TorchAudio |
149 |
| - </Link> |
150 |
| - </li> |
151 |
| - </ul> |
152 |
| - </div> |
153 |
| - <div |
154 |
| - style={{ |
155 |
| - marginLeft: "auto", |
156 |
| - marginRight: "0px", |
157 |
| - display: "flex", |
158 |
| - alignItems: "center", |
| 152 | + <Stack |
| 153 | + padding={2} |
| 154 | + direction="row" |
| 155 | + spacing={2} |
| 156 | + sx={{ |
| 157 | + justifyContent: "space-between", |
159 | 158 | }}
|
160 | 159 | >
|
161 |
| - <ul className={styles.navbarlinkslist}> |
162 |
| - <li> |
163 |
| - <Link href="https://github.com/pytorch/pytorch/wiki/Using-hud.pytorch.org"> |
164 |
| - Help |
165 |
| - </Link> |
166 |
| - </li> |
167 |
| - <li> |
168 |
| - <Link href="https://github.com/pytorch/test-infra/issues/new?assignees=&labels=&template=feature_request.yaml&title=%5Bfeature%5D%3A+"> |
169 |
| - Requests |
170 |
| - </Link> |
171 |
| - </li> |
172 |
| - <li> |
173 |
| - <Link prefetch={false} href="/metrics"> |
174 |
| - Metrics |
175 |
| - </Link> |
176 |
| - </li> |
177 |
| - <li> |
178 |
| - <Link prefetch={false} href="/kpis"> |
179 |
| - KPIs |
180 |
| - </Link> |
181 |
| - </li> |
182 |
| - <NavBarDropdown title="Benchmarks" items={benchmarksDropdown} /> |
183 |
| - <NavBarDropdown title="Dev Infra" items={devInfraDropdown} /> |
184 |
| - <li |
185 |
| - style={{ cursor: "pointer", display: "flex", alignItems: "center" }} |
186 |
| - > |
187 |
| - <Link |
188 |
| - href="https://github.com/pytorch/test-infra/tree/main/torchci" |
189 |
| - passHref |
| 160 | + <Stack |
| 161 | + direction="row" |
| 162 | + spacing={2} |
| 163 | + alignItems="center" |
| 164 | + useFlexGap |
| 165 | + sx={{ flexWrap: "wrap" }} |
| 166 | + > |
| 167 | + <Link href={"/"} prefetch={false}> |
| 168 | + <Button |
190 | 169 | style={{
|
191 |
| - color: "var(--icon-color)", |
192 |
| - display: "flex", |
193 |
| - alignItems: "center", |
| 170 | + textTransform: "none", |
| 171 | + font: "inherit", |
| 172 | + fontWeight: "bold", |
194 | 173 | }}
|
195 | 174 | >
|
| 175 | + PyTorch CI HUD |
| 176 | + </Button> |
| 177 | + </Link> |
| 178 | + {leftLinks.map((link) => ( |
| 179 | + <ButtonLink key={link.name} href={link.href} name={link.name} /> |
| 180 | + ))} |
| 181 | + </Stack> |
| 182 | + <Stack |
| 183 | + direction="row" |
| 184 | + spacing={2} |
| 185 | + alignItems="center" |
| 186 | + useFlexGap |
| 187 | + sx={{ flexWrap: "wrap" }} |
| 188 | + > |
| 189 | + <ButtonLink |
| 190 | + href="https://github.com/pytorch/pytorch/wiki/Using-hud.pytorch.org" |
| 191 | + name="Help" |
| 192 | + /> |
| 193 | + <ButtonLink |
| 194 | + href="https://github.com/pytorch/test-infra/issues/new?assignees=&labels=&template=feature_request.yaml&title=%5Bfeature%5D%3A+" |
| 195 | + name="Requests" |
| 196 | + /> |
| 197 | + <ButtonLink href="/metrics" name="Metrics" /> |
| 198 | + <ButtonLink href="/kpis" name="KPIs" /> |
| 199 | + <HoverDropDownMenu title="Benchmarks ▾"> |
| 200 | + {benchmarksDropdown.map((item) => ( |
| 201 | + <MenuItemLink key={item.name} href={item.href} name={item.name} /> |
| 202 | + ))} |
| 203 | + </HoverDropDownMenu> |
| 204 | + <HoverDropDownMenu title="Dev Infra ▾"> |
| 205 | + {devInfraDropdown.map((item) => ( |
| 206 | + <MenuItemLink key={item.name} href={item.href} name={item.name} /> |
| 207 | + ))} |
| 208 | + </HoverDropDownMenu> |
| 209 | + <Link |
| 210 | + href="https://github.com/pytorch/test-infra/tree/main/torchci" |
| 211 | + passHref |
| 212 | + style={{ |
| 213 | + color: "var(--icon-color)", |
| 214 | + }} |
| 215 | + > |
| 216 | + <Button style={{ minWidth: "0px" }} color="inherit"> |
196 | 217 | <AiFillGithub />
|
197 |
| - </Link> |
198 |
| - </li> |
199 |
| - <li> |
200 |
| - <ThemeModePicker /> |
201 |
| - </li> |
202 |
| - <li style={{ padding: "0 1rem" }}> |
203 |
| - <LoginSection></LoginSection> |
204 |
| - </li> |
205 |
| - </ul> |
206 |
| - </div> |
| 218 | + </Button> |
| 219 | + </Link> |
| 220 | + <ThemeModePicker /> |
| 221 | + <Box> |
| 222 | + <LoginSection /> |
| 223 | + </Box> |
| 224 | + </Stack> |
| 225 | + </Stack> |
207 | 226 | </div>
|
208 | 227 | );
|
209 | 228 | }
|
|
0 commit comments