From 4bc1e1e23c2fb7a49c6929c573c70c51567e3c52 Mon Sep 17 00:00:00 2001 From: mori-dev Date: Wed, 30 Nov 2016 19:28:30 +0700 Subject: [PATCH] feat: Add 'Hello World' page --- src/containers/main_container.js | 28 ++++++++++++++++++++++++++++ src/index.js | 22 ++++++++++++++++++++++ src/reducers/index.js | 8 ++++++++ src/sagas/index.js | 10 ++++++++++ src/store/configure_store.js | 25 +++++++++++++++++++++++++ www/index.html | 11 +++++++++++ 6 files changed, 104 insertions(+) create mode 100644 src/containers/main_container.js create mode 100644 src/index.js create mode 100644 src/reducers/index.js create mode 100644 src/sagas/index.js create mode 100644 src/store/configure_store.js create mode 100644 www/index.html diff --git a/src/containers/main_container.js b/src/containers/main_container.js new file mode 100644 index 0000000..aaf4dda --- /dev/null +++ b/src/containers/main_container.js @@ -0,0 +1,28 @@ +// @flow +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import AppBar from 'material-ui/AppBar'; + +function mapStateToProps(state: Object): Object { + return {}; +} + +function mapDispatchToProps(dispatch: Function): Object { + return {}; +} + +class MainContainer extends Component { + + props: {}; + + render() { + return ( +
+ +

HELLO WORLD

+
+ ); + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(MainContainer); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..6f20294 --- /dev/null +++ b/src/index.js @@ -0,0 +1,22 @@ +import React from 'react' +import ReactDOM from 'react-dom' +import { Provider } from 'react-redux'; +import getMuiTheme from 'material-ui/styles/getMuiTheme'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; +import injectTapEventPlugin from 'react-tap-event-plugin'; +import configureStore from './store/configure_store'; +import MainContainer from './containers/main_container'; + +export const store = configureStore(); + +// https://github.com/callemall/material-ui/issues/4670 +injectTapEventPlugin(); + +ReactDOM.render( + + + + + , + document.getElementById('root'), +) diff --git a/src/reducers/index.js b/src/reducers/index.js new file mode 100644 index 0000000..03a1aa3 --- /dev/null +++ b/src/reducers/index.js @@ -0,0 +1,8 @@ +import { routerReducer } from 'react-router-redux'; +import { combineReducers } from 'redux'; + +const rootReducer = combineReducers({ + routing: routerReducer, +}); + +export default rootReducer; diff --git a/src/sagas/index.js b/src/sagas/index.js new file mode 100644 index 0000000..bf26f99 --- /dev/null +++ b/src/sagas/index.js @@ -0,0 +1,10 @@ +// @flow +import 'babel-polyfill'; +// import { fork } from 'redux-saga/effects'; +// import { watchFoo } from './foo'; + +export default function* rootSaga(): Generator { + yield [ + // fork(watchFoo), + ]; +} diff --git a/src/store/configure_store.js b/src/store/configure_store.js new file mode 100644 index 0000000..b431c76 --- /dev/null +++ b/src/store/configure_store.js @@ -0,0 +1,25 @@ +import { createStore, applyMiddleware, compose } from 'redux'; +import createLogger from 'redux-logger'; +import createSagaMiddleware from 'redux-saga'; +import { routerMiddleware } from 'react-router-redux'; +import { browserHistory } from 'react-router'; +import rootSaga from '../sagas/index'; +import rootReducer from '../reducers'; + +const routing = routerMiddleware(browserHistory); +const sagaMiddleware = createSagaMiddleware(); +const enhancer = compose( + applyMiddleware( + routing, + sagaMiddleware, + createLogger(), + ), +); + +function configureStore(initialState) { + const store = createStore(rootReducer, initialState, enhancer); + sagaMiddleware.run(rootSaga); + return store; +} + +export default configureStore; diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..1c007fa --- /dev/null +++ b/www/index.html @@ -0,0 +1,11 @@ + + + + + title 欄 + + +
+ + +