-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): introduce modular structure
- Loading branch information
feychenie
committed
Feb 14, 2019
1 parent
0e9fded
commit f3c4a6c
Showing
22 changed files
with
156 additions
and
81 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
NODE_PATH=src/modules |
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
File renamed without changes.
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,46 @@ | ||
import React from "react"; | ||
|
||
import { Header } from "semantic-ui-react"; | ||
import { connect } from "react-redux"; | ||
|
||
import { updateTitle, updateClockDisplay } from "../actions"; | ||
|
||
const TitleInput = connect( | ||
(state, ownProps) => ({ title: state[ownProps.namespace].appTitle }), | ||
dispatch => ({ handleTitleChange: value => dispatch(updateTitle(value)) }) | ||
)(({ title, handleTitleChange }) => ( | ||
<input value={title} onChange={e => handleTitleChange(e.target.value)} /> | ||
)); | ||
|
||
const DisplayInput = connect( | ||
(state, ownProps) => ({ | ||
displayClock: state[ownProps.namespace].displayClock | ||
}), | ||
dispatch => ({ | ||
handleClockDisplay: value => dispatch(updateClockDisplay(value)) // dispatch(updateClockDisplay(value)) | ||
}) | ||
)(({ displayClock, handleClockDisplay }) => ( | ||
<input | ||
type="checkbox" | ||
onChange={e => handleClockDisplay(e.target.checked)} | ||
checked={displayClock} | ||
/> | ||
)); | ||
|
||
const ConfigPage = ({ namespace }) => ( | ||
<> | ||
<Header>About this site</Header> | ||
<p> | ||
<TitleInput namespace={namespace} /> | ||
</p> | ||
<p> | ||
<label>Display clock ? </label> | ||
<DisplayInput namespace={namespace} /> | ||
</p> | ||
</> | ||
); | ||
ConfigPage.defaultProps = { | ||
handleTitleChange: a => a | ||
}; | ||
|
||
export default ConfigPage; |
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,19 @@ | ||
import { UPDATE_TITLE, DISPLAY_CLOCK } from "./actions"; | ||
|
||
const initialConfig = { | ||
appTitle: "Super", | ||
displayClock: true | ||
}; | ||
|
||
const configReducer = (state = initialConfig, action) => { | ||
switch (action.type) { | ||
case UPDATE_TITLE: | ||
return { ...state, appTitle: action.payload }; | ||
case DISPLAY_CLOCK: | ||
return { ...state, displayClock: action.payload }; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default configReducer; |
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,19 @@ | ||
import React from "react"; | ||
import { Route } from "react-router-dom"; | ||
|
||
import ConfigPage from "./pages/ConfigPage"; | ||
|
||
const ConfigRoutes = ({ prefix, namespace }) => ( | ||
<> | ||
<Route | ||
path={prefix} | ||
render={props => <ConfigPage namespace={namespace} {...props} />} | ||
/> | ||
</> | ||
); | ||
|
||
ConfigRoutes.defautProps = { | ||
prefix: "/config" | ||
}; | ||
|
||
export default ConfigRoutes; |
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,6 @@ | ||
export const FETCH_SHOWS = "FETCH_SHOWS"; | ||
|
||
export const fetchShows = () => ({ | ||
type: FETCH_SHOWS, | ||
payload: "" | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,4 @@ | ||
import ShowPage from "./ShowPage"; | ||
import ShowPages from "./ShowPages"; | ||
|
||
export { ShowPage, ShowPages }; |
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 @@ | ||
const initialState = { | ||
shows: [] | ||
}; | ||
|
||
const cases = {}; | ||
|
||
// cases["actionName"] = (state, action) => state; // | ||
|
||
const reducer = (state = initialState, action) => { | ||
if (cases[action.type]) return cases[action.type](state, action); | ||
return state; | ||
}; | ||
|
||
export default reducer; |
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,19 @@ | ||
import React from "react"; | ||
import { Route } from "react-router-dom"; | ||
|
||
import ShowsPage from "./pages/ShowsPage"; | ||
import ShowPage from "./pages/ShowPage"; | ||
|
||
const ShowsRoutes = ({ prefix, namespace }) => ( | ||
<> | ||
<Route path={prefix} component={ShowsPage} /> | ||
<Route path={`${prefix}/:id`} component={ShowPage} /> | ||
</> | ||
); | ||
|
||
ShowsRoutes.defautProps = { | ||
prefix: "/shows", | ||
namespace: "shows" | ||
}; | ||
|
||
export default ShowsRoutes; |
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,14 +1,11 @@ | ||
import { UPDATE_TITLE, DISPLAY_CLOCK } from "./actions"; | ||
import { combineReducers } from "redux"; | ||
|
||
const appReducer = (state = {}, action) => { | ||
switch (action.type) { | ||
case UPDATE_TITLE: | ||
return { ...state, appTitle: action.payload }; | ||
case DISPLAY_CLOCK: | ||
return { ...state, displayClock: action.payload }; | ||
default: | ||
return state; | ||
} | ||
}; | ||
import configReducer from "config/reducer"; | ||
import showsReducer from "shows/reducer"; | ||
|
||
const appReducer = combineReducers({ | ||
shows: showsReducer, | ||
config: configReducer | ||
}); | ||
|
||
export default appReducer; |
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