-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Typography } from "@mui/material" | ||
import clsx from "clsx" | ||
import { FC } from "react" | ||
import { Link, useMatches } from "react-router-dom" | ||
|
||
const navigatableRoutes = [ | ||
{ | ||
path: "/research", | ||
label: "提交数据", | ||
}, | ||
{ | ||
path: "/discover", | ||
label: "数据查询", | ||
}, | ||
] | ||
|
||
export const NavigationBar: FC = () => { | ||
const matches = useMatches() | ||
return ( | ||
<div className="flex items-center justify-start gap-2 w-full"> | ||
{navigatableRoutes.map(({ path, label }) => ( | ||
<Link | ||
key={path} | ||
to={path} | ||
className={clsx( | ||
"px-2 py-1 transition rounded", | ||
matches.some(match => match.pathname === path) | ||
? "bg-slate-800 text-white" | ||
: "text-slate-500 hover:bg-slate-800 hover:text-white active:bg-slate-900", | ||
)} | ||
> | ||
<Typography variant="body1" component="div"> | ||
{label} | ||
</Typography> | ||
</Link> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters