otterscan/src/block/NavButton.tsx

36 lines
897 B
TypeScript
Raw Normal View History

import { ethers } from "ethers";
2021-07-04 01:33:34 +00:00
import { NavLink } from "react-router-dom";
import { blockURL } from "../url";
2021-07-04 01:33:34 +00:00
type NavButtonProps = {
blockNum: number;
disabled?: boolean;
urlBuilder?: (blockNumber: ethers.providers.BlockTag) => string;
2021-07-04 01:33:34 +00:00
};
const NavButton: React.FC<NavButtonProps> = ({
blockNum,
disabled,
urlBuilder,
2021-07-04 01:33:34 +00:00
children,
}) => {
if (disabled) {
return (
<span className="bg-link-blue bg-opacity-10 text-gray-400 rounded px-2 py-1 text-xs">
{children}
</span>
);
}
return (
<NavLink
className="transition-colors bg-link-blue bg-opacity-10 text-link-blue hover:bg-opacity-100 hover:text-white disabled:bg-link-blue disabled:text-gray-400 disabled:cursor-default rounded px-2 py-1 text-xs"
to={urlBuilder ? urlBuilder(blockNum) : blockURL(blockNum)}
2021-07-04 01:33:34 +00:00
>
{children}
</NavLink>
);
};
export default NavButton;