Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import { Typography, TypographyProps } from "@mui/material"; import classNames from "classnames"; import NotificationBadge from "components/NotificationBadge"; import Link from "next/link"; import { useRouter } from "next/router"; import { baseRoute } from "routes"; import { useNavLinkStyles } from "./useNavLinkStyles"; interface NavButtonProps { route: string; label: string; labelVariant?: Exclude<TypographyProps["variant"], undefined>; notificationCount?: number; } export default function NavButton({ route, label, labelVariant = "h3", notificationCount, }: NavButtonProps) { const classes = useNavLinkStyles(); const router = useRouter(); const isActive = route === baseRoute ? router.asPath === route : router.asPath.includes(route); return ( <Link href={route} className={classNames(classes.link, { [classes.notification]: !!notificationCount, [classes.selected]: isActive, })} > <NotificationBadge count={notificationCount}> <Typography variant={labelVariant} className={classes.label} noWrap> {label} </Typography> </NotificationBadge> </Link> ); } |