-
Notifications
You must be signed in to change notification settings - Fork 46
/
Sidebar.js
executable file
·69 lines (54 loc) · 1.67 KB
/
Sidebar.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
58
59
60
61
62
63
64
65
66
67
68
69
import React from 'react'
import { connect } from 'react-redux'
import Link, { NavLink } from 'redux-first-router-link'
import { goToPage } from '../actions'
import styles from '../css/Sidebar'
const Sidebar = ({ onClick, path }) =>
<div className={styles.sidebar}>
<h2>SEO-FRIENDLY LINKS</h2>
<NavLink activeClassName={styles.active} exact to='/'>HOME</NavLink>
<NavLink activeClassName={styles.active} to='/list/db-graphql'>
DB & GRAPHQL
</NavLink>
<NavLink activeClassName={styles.active} to={['list', 'react-redux']}>
REACT & REDUX
</NavLink>
<NavLink
activeClassName={styles.active}
to={{ type: 'LIST', payload: { category: 'fp' } }}
>
FP
</NavLink>
<div style={{ height: 20 }} />
<h2>EVENT HANDLERS</h2>
<span className={active(path, '/')} onClick={() => onClick('HOME')}>
HOME
</span>
<span
className={active(path, '/list/db-graphql')}
onClick={() => onClick('LIST', 'db-graphql')}
>
DB & GRAPHQL
</span>
<span
className={active(path, '/list/react-redux')}
onClick={() => onClick('LIST', 'react-redux')}
>
REACT & REDUX
</span>
<span
className={active(path, '/list/fp')}
onClick={() => onClick('LIST', 'fp')}
>
FP
</span>
<div style={{ height: 14 }} />
<NavLink to={{ type: 'ADMIN' }} activeClassName={styles.active}>
ADMIN
</NavLink>
</div>
const active = (currentPath, path) =>
currentPath === path ? styles.active : ''
const mapDispatch = { onClick: goToPage }
const mapState = ({ location }) => ({ path: location.pathname })
export default connect(mapState, mapDispatch)(Sidebar)