/
Tab.js
57 lines (51 loc) · 1.07 KB
/
Tab.js
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
47
48
49
50
51
52
53
54
55
56
57
import React from 'react'
import { Link, Route } from 'react-router-dom'
import styled, { css } from '@xstyled/styled-components'
import { up } from '@xstyled/system'
export const TabList = styled.ul`
padding: 0;
margin: 0;
margin-bottom: -1rpx;
list-style-type: none;
display: flex;
font-weight: medium;
font-size: 14;
`
export const TabItem = styled.li`
padding: 0;
margin: 0;
border-bottom: 1;
border-color: transparent;
transition: base;
transition-property: border-color;
&[aria-current='true'] {
border-color: darker;
}
`
export const TabItemLink = styled.a`
color: darker;
text-decoration: none;
padding: 2 3;
display: block;
overflow-x: auto;
${up(
'md',
css`
padding: 3;
overflow-x: visible;
`,
)}
`
export function RouterTabItem({ children, exact, to }) {
return (
<Route exact={exact} path={to}>
{({ match }) => (
<TabItem aria-current={Boolean(match)}>
<TabItemLink as={Link} to={to}>
{children}
</TabItemLink>
</TabItem>
)}
</Route>
)
}