@@ -35,15 +35,27 @@ class SideNav extends React.Component {
3535 openModal ( Preferences )
3636 }
3737
38+ handleHomeButtonClick ( e ) {
39+ let { router } = this . context
40+ router . push ( '/repositories' )
41+ }
42+
43+ handleStarredButtonClick ( e ) {
44+ let { router } = this . context
45+ router . push ( '/starred' )
46+ }
47+
3848 render ( ) {
39- let { repositories, dispatch } = this . props
49+ let { repositories, dispatch, location } = this . props
4050 let repositorieElements = repositories . map ( ( repo ) => {
4151 return < RepositorySection
4252 key = { repo . key }
4353 repository = { repo }
4454 dispatch = { dispatch }
4555 />
4656 } )
57+ let isHomeActive = location . pathname . match ( / ^ \/ h o m e $ / )
58+ let isStarredActive = location . pathname . match ( / ^ \/ s t a r r e d $ / )
4759
4860 return (
4961 < div
@@ -60,13 +72,15 @@ class SideNav extends React.Component {
6072 </ div >
6173
6274 < div styleName = 'menu' >
63- < button styleName = 'menu-button'
75+ < button styleName = { isHomeActive ? 'menu-button--active' : 'menu-button' }
76+ onClick = { ( e ) => this . handleHomeButtonClick ( e ) }
6477 >
6578 < i className = 'fa fa-home' /> Home
6679 </ button >
67- < button styleName = 'menu-button'
80+ < button styleName = { isStarredActive ? 'menu-button--active' : 'menu-button' }
81+ onClick = { ( e ) => this . handleStarredButtonClick ( e ) }
6882 >
69- < i className = 'fa fa-star' /> Favorited
83+ < i className = 'fa fa-star' /> Starred
7084 </ button >
7185 </ div >
7286
@@ -84,6 +98,10 @@ class SideNav extends React.Component {
8498 }
8599}
86100
101+ SideNav . contextTypes = {
102+ router : PropTypes . shape ( { } )
103+ }
104+
87105SideNav . propTypes = {
88106 dispatch : PropTypes . func ,
89107 repositories : PropTypes . array
0 commit comments