Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added appReducer; created toggle feature, refactored component code (#22
) * added appReducer; created toggle feature, refactored component code * added color to denote selected toggle * added unselected color * removed loggin; renamed files for readability
- Loading branch information
1 parent
8d95a4f
commit 74b0ad0
Showing
15 changed files
with
113 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,46 @@ | ||
import React, {Component} from 'react'; | ||
import './App.css'; | ||
|
||
// Redux | ||
import {connect} from 'react-redux'; | ||
import {bindActionCreators} from 'redux'; | ||
import {changeView} from './actions/changeViewActions'; | ||
|
||
// constants | ||
import * as constants from './constants/viewConstants'; | ||
|
||
// components | ||
import Map from './components/Map'; | ||
import Sidebar from './components/Sidebar'; | ||
import ToggleView from './components/ToggleView'; | ||
import ListView from './components/ListView'; | ||
|
||
class App extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<Sidebar /> | ||
<Map /> | ||
<ToggleView /> | ||
{this.props.view === constants.MAP_VIEW ? <Map /> : <ListView /> } | ||
<ToggleView view={this.props.view} changeView={this.props.changeView}/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
function mapStateToProps(state) { | ||
return { | ||
view: state.changeViewReducer.view | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
changeView: bindActionCreators(changeView, dispatch) | ||
}; | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(App); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const CHANGE_VIEW = 'CHANGE_VIEW'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as types from './actionsTypes'; | ||
|
||
export function changeView(appView){ | ||
return {type: types.CHANGE_VIEW, payload: appView}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.centerDiv { | ||
text-align: center; | ||
} | ||
|
||
.titleText { | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, {Component} from 'react'; | ||
import './ListView.css'; | ||
|
||
class ListView extends Component { | ||
render() { | ||
return ( | ||
<div className="centerDiv"> | ||
<h1 className="titleText">This is the List View</h1> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ListView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const MAP_VIEW = "MAP_VIEW"; | ||
export const LIST_VIEW = "LIST_VIEW"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CHANGE_VIEW } from '../actions/actionsTypes'; | ||
import initialState from './initialState'; | ||
|
||
export default (state = initialState, action) => { | ||
switch (action.type) { | ||
case CHANGE_VIEW: | ||
return { | ||
...state, | ||
view: action.payload | ||
} | ||
default: | ||
return state; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { combineReducers } from 'redux'; | ||
import emptyReducer from './empty'; | ||
import changeViewReducer from './changeViewReducer'; | ||
|
||
export default combineReducers({ | ||
emptyReducer | ||
changeViewReducer | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as constants from '../constants/viewConstants'; | ||
|
||
export default { | ||
view: constants.MAP_VIEW | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters