-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNavigationBar.tsx
112 lines (103 loc) · 3.22 KB
/
NavigationBar.tsx
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { useLayoutEffect, useState } from 'react'
import { Nav } from 'react-bootstrap'
import { useLocation } from 'react-router'
import styled from 'styled-components'
import { LinkWithQuery } from '../../../components/LinkWithQuery'
type Totals = {
bidders: number
candidates: number
members: number
maxMembers: number
suspendedMembers: number
}
const NavigationBar = ({ totals }: { totals: Totals }) => {
const [showSubNav, setShowSubNav] = useState(false)
const location = useLocation()
useLayoutEffect(() => {
setShowSubNav(location.pathname.startsWith('/explore/poi'))
}, [location])
return (
<>
<StyledNav
defaultActiveKey="/explore/bidders"
className={showSubNav ? 'd-block d-lg-flex py-2 mt-4' : 'd-block d-lg-flex py-2 my-4'}
>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/bidders">
Bidders ({totals.bidders})
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/candidates">
Candidates ({totals.candidates})
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/members">
Members ({totals.members}/{totals.maxMembers})
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/suspended">
Suspended Members ({totals.suspendedMembers})
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/poi">
Proof of Ink
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/journey">
Journey
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/payouts">
Payouts
</Nav.Link>
</StyledNavItem>
</StyledNav>
{showSubNav && (
<StyledNav defaultActiveKey="/explore/poi/examples" className="py-2 mb-4">
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/poi/examples">
Examples
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/poi/rules">
Rules
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/poi/gallery">
Gallery
</Nav.Link>
</StyledNavItem>
<StyledNavItem>
<Nav.Link as={LinkWithQuery} to="/explore/poi/next-head">
Next Head
</Nav.Link>
</StyledNavItem>
</StyledNav>
)}
</>
)
}
const StyledNav = styled(Nav)`
border-bottom: 1px solid ${(props) => props.theme.colors.darkGrey};
border-top: 1px solid ${(props) => props.theme.colors.darkGrey};
`
const StyledNavItem = styled(Nav.Item)`
.nav-link {
color: ${(props) => props.theme.colors.lightGrey};
}
.nav-link:hover {
color: ${(props) => props.theme.colors.darkGrey};
}
.nav-link.active {
color: ${(props) => props.theme.colors.white};
}
`
export { NavigationBar }