2018-08-10 06:14:51 +00:00
|
|
|
// @flow
|
2021-07-12 18:57:17 +00:00
|
|
|
import { m } from "framer-motion";
|
2020-06-20 20:59:15 +00:00
|
|
|
import * as React from "react";
|
2021-08-05 22:03:55 +00:00
|
|
|
import styled, { useTheme } from "styled-components";
|
|
|
|
import NavLinkWithChildrenFunc from "components/NavLink";
|
2018-08-10 06:14:51 +00:00
|
|
|
|
2019-08-09 06:09:09 +00:00
|
|
|
type Props = {
|
2021-07-12 18:57:17 +00:00
|
|
|
children: React.Node,
|
2019-08-09 06:09:09 +00:00
|
|
|
};
|
|
|
|
|
2021-07-12 18:57:17 +00:00
|
|
|
const TabLink = styled(NavLinkWithChildrenFunc)`
|
2019-07-08 04:40:34 +00:00
|
|
|
position: relative;
|
2021-02-10 04:13:09 +00:00
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
2018-08-10 06:14:51 +00:00
|
|
|
font-weight: 500;
|
2019-07-08 04:40:34 +00:00
|
|
|
font-size: 14px;
|
2020-08-09 01:53:11 +00:00
|
|
|
color: ${(props) => props.theme.textTertiary};
|
2019-01-08 07:42:55 +00:00
|
|
|
margin-right: 24px;
|
2021-02-14 21:18:33 +00:00
|
|
|
padding: 6px 0;
|
2019-01-08 07:42:55 +00:00
|
|
|
|
|
|
|
&:hover {
|
2020-08-09 01:53:11 +00:00
|
|
|
color: ${(props) => props.theme.textSecondary};
|
2019-01-08 07:42:55 +00:00
|
|
|
}
|
2018-08-10 06:14:51 +00:00
|
|
|
`;
|
|
|
|
|
2021-07-12 18:57:17 +00:00
|
|
|
const Active = styled(m.div)`
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
height: 3px;
|
|
|
|
width: 100%;
|
|
|
|
border-top-left-radius: 2px;
|
|
|
|
border-top-right-radius: 2px;
|
|
|
|
background: ${(props) => props.theme.textSecondary};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const transition = {
|
|
|
|
type: "spring",
|
|
|
|
stiffness: 500,
|
|
|
|
damping: 30,
|
|
|
|
};
|
|
|
|
|
2021-08-05 22:03:55 +00:00
|
|
|
export default function Tab({ children, ...rest }: Props) {
|
|
|
|
const theme = useTheme();
|
2018-08-10 06:14:51 +00:00
|
|
|
const activeStyle = {
|
2020-08-08 22:18:37 +00:00
|
|
|
color: theme.textSecondary,
|
2018-08-10 06:14:51 +00:00
|
|
|
};
|
|
|
|
|
2021-07-12 18:57:17 +00:00
|
|
|
return (
|
|
|
|
<TabLink {...rest} activeStyle={activeStyle}>
|
|
|
|
{(match) => (
|
|
|
|
<>
|
|
|
|
{children}
|
|
|
|
{match && (
|
|
|
|
<Active
|
|
|
|
layoutId="underline"
|
|
|
|
initial={false}
|
|
|
|
transition={transition}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</TabLink>
|
|
|
|
);
|
2018-08-10 06:14:51 +00:00
|
|
|
}
|