otterscan/src/components/NavTab.tsx

26 lines
734 B
TypeScript
Raw Normal View History

2021-09-06 06:43:20 +00:00
import React, { Fragment } from "react";
2021-07-01 18:21:40 +00:00
import { NavLink } from "react-router-dom";
2021-09-06 06:43:20 +00:00
import { Tab } from "@headlessui/react";
2021-07-01 18:21:40 +00:00
2021-09-06 06:34:13 +00:00
type NavTabProps = {
2021-07-01 18:21:40 +00:00
href: string;
};
// TODO: migrate activeClassName because of: https://github.com/remix-run/react-router/releases/tag/v5.3.0
// TODO: @types/react-router-dom still doesn't support function in className
2021-09-06 06:34:13 +00:00
const NavTab: React.FC<NavTabProps> = ({ href, children }) => (
2021-09-06 06:43:20 +00:00
<Tab as={Fragment}>
<NavLink
className="text-gray-500 border-transparent hover:text-link-blue text-sm font-bold px-3 py-3 border-b-2"
activeClassName="text-link-blue border-link-blue"
to={href}
exact
replace
>
{children}
</NavLink>
</Tab>
2021-07-01 18:21:40 +00:00
);
2021-09-06 06:34:13 +00:00
export default NavTab;