summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/js/.editorconfig9
-rw-r--r--src/main/js/src/components/errors/Error404.js6
-rw-r--r--src/main/js/src/containers/App/index.js15
-rw-r--r--src/main/js/src/containers/Counter/actions.js12
-rw-r--r--src/main/js/src/containers/Counter/index.js68
-rw-r--r--src/main/js/src/containers/Counter/reducer.js24
-rw-r--r--src/main/js/src/containers/Counter/saga.js6
-rw-r--r--src/main/js/src/index.js14
-rw-r--r--src/main/js/src/reducers.js6
-rw-r--r--src/main/js/src/sagas.js4
-rw-r--r--src/main/js/src/store.js38
11 files changed, 105 insertions, 97 deletions
diff --git a/src/main/js/.editorconfig b/src/main/js/.editorconfig
new file mode 100644
index 00000000..32c3b3d4
--- /dev/null
+++ b/src/main/js/.editorconfig
@@ -0,0 +1,9 @@
+root = false
+
+[*]
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+indent_size = 2 \ No newline at end of file
diff --git a/src/main/js/src/components/errors/Error404.js b/src/main/js/src/components/errors/Error404.js
index 13ce5ae5..b657482d 100644
--- a/src/main/js/src/components/errors/Error404.js
+++ b/src/main/js/src/components/errors/Error404.js
@@ -1,8 +1,8 @@
import React from 'react'
import { Link } from 'react-router'
-const Error404 = () => <div>
- <h1>No Match</h1>
- <Link to="/">Take me back home ! 🏠</Link>
+const Error404 = () => <div>
+ <h1>No Match</h1>
+ <Link to="/">Take me back home ! 🏠</Link>
</div>
export default Error404 \ No newline at end of file
diff --git a/src/main/js/src/containers/App/index.js b/src/main/js/src/containers/App/index.js
index b190f960..e7eef332 100644
--- a/src/main/js/src/containers/App/index.js
+++ b/src/main/js/src/containers/App/index.js
@@ -1,10 +1,9 @@
import React from 'react'
import { Link } from 'react-router'
-export default () => {
- return <div>
- <h1>Hello World</h1>
- <Link to="/counter">Go to counter +/-</Link>
- <br/>
- <Link to="/404">Go to 404</Link>
- </div>
-} \ No newline at end of file
+
+export default () => <div>
+ <h1>Hello World</h1>
+ <Link to="/counter">Go to counter</Link>
+ <br></br>
+ <Link to="/404">Go to 404</Link>
+ </div> \ No newline at end of file
diff --git a/src/main/js/src/containers/Counter/actions.js b/src/main/js/src/containers/Counter/actions.js
index 01cd8d67..abd6babb 100644
--- a/src/main/js/src/containers/Counter/actions.js
+++ b/src/main/js/src/containers/Counter/actions.js
@@ -1,20 +1,20 @@
import {
- INCREMENT, DECREMENT,
- INCREMENT_IF_ODD, INCREMENT_ASYNC
+ INCREMENT, DECREMENT,
+ INCREMENT_IF_ODD, INCREMENT_ASYNC
} from './constants'
export const increment = () => ({
- type: INCREMENT
+ type: INCREMENT
})
export const decrement = () => ({
- type: DECREMENT
+ type: DECREMENT
})
export const incrementIfOdd = () => ({
- type: INCREMENT_IF_ODD
+ type: INCREMENT_IF_ODD
})
export const incrementAsync = () => ({
- type: INCREMENT_ASYNC
+ type: INCREMENT_ASYNC
}) \ No newline at end of file
diff --git a/src/main/js/src/containers/Counter/index.js b/src/main/js/src/containers/Counter/index.js
index a91af8f5..0be665fd 100644
--- a/src/main/js/src/containers/Counter/index.js
+++ b/src/main/js/src/containers/Counter/index.js
@@ -2,50 +2,50 @@ import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import {
- increment,
- decrement,
- incrementAsync,
- incrementIfOdd
+ increment,
+ decrement,
+ incrementAsync,
+ incrementIfOdd
} from './actions'
-const Counter = ({ value, increment, decrement, incrementIfOdd, incrementAsync }) =>
- <p>
- Clicked: {value} times
- {' '}
- <button onClick={increment}>
- +
- </button>
- {' '}
- <button onClick={decrement}>
- -
- </button>
- {' '}
- <button onClick={incrementIfOdd}>
- Increment if odd
- </button>
- {' '}
- <button onClick={incrementAsync}>
- Increment async
- </button>
- </p>
+const Counter = ({value, increment, decrement, incrementIfOdd, incrementAsync}) =>
+ <p>
+ Clicked: {value} times
+ {' '}
+ <button onClick={increment}>
+ +
+ </button>
+ {' '}
+ <button onClick={decrement}>
+ -
+ </button>
+ {' '}
+ <button onClick={incrementIfOdd}>
+ Increment if odd
+ </button>
+ {' '}
+ <button onClick={incrementAsync}>
+ Increment async
+ </button>
+ </p>
Counter.propTypes = {
- value: PropTypes.number.isRequired,
- increment: PropTypes.func.isRequired,
- decrement: PropTypes.func.isRequired,
- incrementAsync: PropTypes.func.isRequired,
- incrementIfOdd: PropTypes.func.isRequired
+ value: PropTypes.number.isRequired,
+ increment: PropTypes.func.isRequired,
+ decrement: PropTypes.func.isRequired,
+ incrementAsync: PropTypes.func.isRequired,
+ incrementIfOdd: PropTypes.func.isRequired
}
const mapStateToProps = (state) => ({
- value: state.counter
+ value: state.counter
})
const mapDispatchToProps = {
- increment,
- decrement,
- incrementAsync,
- incrementIfOdd
+ increment,
+ decrement,
+ incrementAsync,
+ incrementIfOdd
}
export default connect(mapStateToProps, mapDispatchToProps)(Counter) \ No newline at end of file
diff --git a/src/main/js/src/containers/Counter/reducer.js b/src/main/js/src/containers/Counter/reducer.js
index 586c4e0a..44006f3e 100644
--- a/src/main/js/src/containers/Counter/reducer.js
+++ b/src/main/js/src/containers/Counter/reducer.js
@@ -1,17 +1,17 @@
import {
- INCREMENT, DECREMENT,
- INCREMENT_IF_ODD
+ INCREMENT, DECREMENT,
+ INCREMENT_IF_ODD
} from './constants'
export default function reducer(state = 0, action) {
- switch (action.type) {
- case INCREMENT:
- return state + 1
- case DECREMENT:
- return state - 1
- case INCREMENT_IF_ODD:
- return (state % 2 === 0) ? state + 1 : state
- default:
- return state
- }
+ switch (action.type) {
+ case INCREMENT:
+ return state + 1
+ case DECREMENT:
+ return state - 1
+ case INCREMENT_IF_ODD:
+ return (state % 2 === 0) ? state + 1 : state
+ default:
+ return state
+ }
} \ No newline at end of file
diff --git a/src/main/js/src/containers/Counter/saga.js b/src/main/js/src/containers/Counter/saga.js
index fe210620..0b9e2866 100644
--- a/src/main/js/src/containers/Counter/saga.js
+++ b/src/main/js/src/containers/Counter/saga.js
@@ -5,10 +5,10 @@ import { increment } from './actions'
import { INCREMENT_ASYNC } from './constants'
export function* incrementAsync() {
- yield call(delay, 1000)
- yield put(increment())
+ yield call(delay, 1000)
+ yield put(increment())
}
export default function* counterSaga() {
- yield takeEvery(INCREMENT_ASYNC, incrementAsync)
+ yield takeEvery(INCREMENT_ASYNC, incrementAsync)
} \ No newline at end of file
diff --git a/src/main/js/src/index.js b/src/main/js/src/index.js
index 926c756a..97af0f59 100644
--- a/src/main/js/src/index.js
+++ b/src/main/js/src/index.js
@@ -16,13 +16,13 @@ import Error404 from './components/errors/Error404'
ReactDOM.render(
<Provider store={store}>
- <BrowserRouter>
- <div className="app">
- <Match exactly pattern="/" component={App} />
- <Match exactly pattern="/counter" component={Counter}/>
- <Miss component={Error404} />
- </div>
- </BrowserRouter>
+ <BrowserRouter>
+ <div className="app">
+ <Match exactly pattern="/" component={App}/>
+ <Match exactly pattern="/counter" component={Counter}/>
+ <Miss component={Error404}/>
+ </div>
+ </BrowserRouter>
</Provider>,
document.getElementById('root')
);
diff --git a/src/main/js/src/reducers.js b/src/main/js/src/reducers.js
index 82540b00..79014615 100644
--- a/src/main/js/src/reducers.js
+++ b/src/main/js/src/reducers.js
@@ -2,7 +2,7 @@ import { combineReducers } from 'redux'
import counterReducer from './containers/Counter/reducer'
export default function createReducer() {
- return combineReducers({
- counter: counterReducer
- })
+ return combineReducers({
+ counter: counterReducer
+ })
} \ No newline at end of file
diff --git a/src/main/js/src/sagas.js b/src/main/js/src/sagas.js
index 80222362..24776bf2 100644
--- a/src/main/js/src/sagas.js
+++ b/src/main/js/src/sagas.js
@@ -3,5 +3,5 @@ import { fork } from 'redux-saga/effects'
import counterSaga from './containers/Counter/saga'
export default function* rootSaga() {
- yield fork(counterSaga)
-} \ No newline at end of file
+ yield fork(counterSaga)
+}
diff --git a/src/main/js/src/store.js b/src/main/js/src/store.js
index bbeb51bd..31c8aa71 100644
--- a/src/main/js/src/store.js
+++ b/src/main/js/src/store.js
@@ -5,29 +5,29 @@ import createSagaMiddleware from 'redux-saga'
import rootSaga from './sagas'
export default function configureStore(initialState = {}) {
- const sagaMiddleware = createSagaMiddleware()
+ const sagaMiddleware = createSagaMiddleware()
- const middlewares = [
- sagaMiddleware
- ]
+ const middlewares = [
+ sagaMiddleware
+ ]
- const enhancers = [
- applyMiddleware(...middlewares)
- ]
+ const enhancers = [
+ applyMiddleware(...middlewares)
+ ]
- const composeEnhancers =
- process.env.NODE_ENV !== 'production' &&
- typeof window === 'object' &&
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
+ const composeEnhancers =
+ process.env.NODE_ENV !== 'production' &&
+ typeof window === 'object' &&
+ window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
+ window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
- const store = createStore(
- createReducer(),
- initialState,
- composeEnhancers(...enhancers)
- )
+ const store = createStore(
+ createReducer(),
+ initialState,
+ composeEnhancers(...enhancers)
+ )
- sagaMiddleware.run(rootSaga)
+ sagaMiddleware.run(rootSaga)
- return store
+ return store
}
bgstack15