Skip to content

Commit

Permalink
Merge pull request #5 from bearsunday/skeleton
Browse files Browse the repository at this point in the history
update UI skeleton
  • Loading branch information
koriym authored Dec 19, 2016
2 parents 062c5bc + 9bba475 commit 896bbc0
Show file tree
Hide file tree
Showing 15 changed files with 5,294 additions and 17 deletions.
2 changes: 2 additions & 0 deletions ui-skeleton/redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"mocha": "^3.2.0",
"react-addons-test-utils": "^15.4.1",
"react-hot-loader": "^1.3.1",
"redux-logger": "^2.7.4",
"redux-thunk": "^2.1.0",
"rimraf": "^2.5.4",
"webpack": "^1.12.15",
"webpack-hot-middleware": "^2.13.2",
Expand Down
4 changes: 2 additions & 2 deletions ui-skeleton/redux/ui/src/page/example/app/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import configureStore from '../common/store/configureStore';
import App from '../common/components/App';
import configureStore from '../store/configureStore';
import App from '../components/App';

global.App = App;
global.configureStore = configureStore;
4 changes: 2 additions & 2 deletions ui-skeleton/redux/ui/src/page/example/app/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import configureStore from '../common/store/configureStore';
import App from '../common/components/App';
import configureStore from '../store/configureStore';
import App from '../components/App';

global.App = App;
global.configureStore = configureStore;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import { helloWorld } from '../actions';
import Hello from './../components/Hello';
import Hello from '../components/Hello';

const mapStateToProps = (state) => ({
message: state.hello.message,
Expand Down
23 changes: 23 additions & 0 deletions ui-skeleton/redux/ui/src/page/example/store/configureStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createStore, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger';
import rootReducer from '../reducers';

export default function configureStore(preloadedState) {
const store = createStore(
rootReducer,
preloadedState,
compose(
applyMiddleware(thunkMiddleware, createLogger()),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextReducer = require('../reducers').default; // eslint-disable-line global-require
store.replaceReducer(nextReducer);
});
}
return store;
}
4 changes: 2 additions & 2 deletions ui-skeleton/redux/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ module.exports = {
],
loaders: [
{
test: /\.jsx?$/,
test: /\.(js|jsx)$/,
loaders: ['react-hot', 'babel'],
exclude: /(node_modules)/
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
loader: ExtractTextPlugin.extract("style", "css")
},
{
test: /\.json$/,
Expand Down
21 changes: 21 additions & 0 deletions ui-skeleton/redux/var/www/Index.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use BEAR\ReactJsModule\Ssr;

/* @var $ssr Ssr */
list($markup, $script) = $ssr->render(['hello']);

return <<<"EOT"
<!doctype>
<html>
<head>
<title>{$ssr->escape('title')}</title>
</head>
<body>
<div id="root">{$markup}</div>
<script src="build/react.bundle.js"></script>
<script src="build/example.bundle.js"></script>
<script>{$script}</script>
</body>
</html>
EOT;
39 changes: 39 additions & 0 deletions ui-skeleton/redux/var/www/Index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use BEAR\ReactJsModule\ReduxModule;
use Ray\Di\Injector;
use BEAR\Resource\RenderInterface;
use BEAR\Resource\ResourceObject;
use Ray\Di\Di\Inject;
use Ray\Di\Di\Named;

require dirname(__DIR__, 4) . '/vendor/autoload.php';

class Index extends ResourceObject
{
/**
* @Inject
* @Named("ssr_example")
*/
public function setRenderer(RenderInterface $renderer)
{
parent::setRenderer($renderer);
}

public $body = [
'title' => 'Greeting',
'hello' => ['message' => 'Hello BEAR.Sunday']
];

public function onGet()
{
return $this;
}
}


$injector = new Injector(new ReduxModule(__DIR__ . '/dist', 'ssr_example'));
$index = $injector->getInstance(Index::class);
/* @var $index Index */

echo $index;
Loading

0 comments on commit 896bbc0

Please sign in to comment.