Fix core reducer destroying other reducers

This commit is contained in:
Samy Pesse
2016-09-25 17:44:08 +02:00
parent fab88bb47e
commit e46cd78f80
10 changed files with 75 additions and 17 deletions
+2 -2
View File
@@ -6,8 +6,8 @@ const ReactRedux = require('react-redux');
* @param {Function} mapStateToProps
* @return {ReactComponent}
*/
function connect(Component, mapStateToProps) {
return ReactRedux.connect(mapStateToProps)(Component);
function connect(Component, mapStateToProps, mapDispatchToProps) {
return ReactRedux.connect(mapStateToProps, mapDispatchToProps)(Component);
}
module.exports = connect;
+9 -8
View File
@@ -1,10 +1,11 @@
const Redux = require('redux');
const composeReducer = require('../composeReducer');
const createReducer = require('../createReducer');
module.exports = Redux.combineReducers({
components: require('./components'),
navigation: require('./navigation'),
module.exports = composeReducer(
createReducer('components', require('./components')),
createReducer('navigation', require('./navigation')),
// GitBook JSON
page: require('./page'),
summary: require('./summary'),
readme: require('./readme')
});
createReducer('page', require('./page')),
createReducer('summary', require('./summary')),
createReducer('readme', require('./readme'))
);
@@ -1,3 +1,6 @@
.Sidebar {
width: @sidebar-width;
height: 100%;
background: @sidebar-background;
background: rgb(250, 250, 250);
border-right: 1px solid @sidebar-border-color;
}
@@ -0,0 +1,37 @@
.Summary {
}
.SummaryPart {
> h1 {
padding: @summary-article-padding-v @summary-article-padding-h;
padding-top: 20px;
text-transform: uppercase;
color: @summary-header-color;
}
}
.SummaryArticles {
list-style: none;
margin: 0px;
padding: 0px;
}
.SummaryArticle {
list-style: none;
a, span {
display: block;
padding: @summary-article-padding-v @summary-article-padding-h;
border-bottom: none;
color: @summary-article-color;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
position: relative;
}
a:hover {
text-decoration: underline;
}
}
@@ -2,3 +2,10 @@
@import "reset.less";
@import "variables.less";
@import "Sidebar.less";
@import "Summary.less";
body, html {
margin: 0px;
}
@@ -1,2 +1,8 @@
// Sidebar
@sidebar-width: 200px;
@sidebar-background: rgb(250, 250, 250);
@sidebar-border-color: rgba(0, 0, 0, 0.0666667);
// Summary
@summary-header-color: #939da3;
@summary-article-padding-v: 10px;
@summary-article-padding-h: 15px;
@summary-article-color: hsl(207, 15%, 25%);
@@ -16,6 +16,7 @@
"gitbook-markdown-css": "^1.0.1",
"gitbook-plugin": "*",
"less": "^2.7.1",
"less-plugin-clean-css": "^1.5.1",
"preboot": "git+https://github.com/mdo/preboot.git#4aab4edd85f076d50609cbe28e4fe66cc0771701"
},
"scripts": {
@@ -46,10 +46,12 @@ const SummaryPart = React.createClass({
const { part } = this.props;
const { title, articles } = part;
const titleEL = title ? <h2>{title}</h2> : null;
return (
<GitBook.InjectedComponent matching={{ role: 'summary:part' }} props={this.props}>
<div className="SummaryPart">
{title}
{titleEL}
<SummaryArticles articles={articles} />
</div>
</GitBook.InjectedComponent>
@@ -24,7 +24,7 @@ let ThemeBody = React.createClass({
<GitBook.Head
title={page.title}
titleTemplate="%s - GitBook" />
<GitBook.ImportCSS href="gitbook/gitbook-plugin-theme-default/theme.css" />
<GitBook.ImportCSS href="gitbook/theme.css" />
<GitBook.FlexBox>
<GitBook.FlexLayout>
@@ -45,7 +45,7 @@ let ThemeBody = React.createClass({
});
ThemeBody = GitBook.connect(ThemeBody, ({page, summary, sidebar}) => {
console.log('connect', sidebar.toJS())
console.log('connect!');
return { page, summary, sidebar };
});
+3 -2
View File
@@ -22,7 +22,7 @@ function HTML({head, innerHTML, payload, scripts}) {
{scripts.map(script => {
return <script key={script} src={script} />;
})}
<script type="application/payload+json" dangerouslySetInnerHTML={{__html: JSON.stringify(payload)}} />
<script type="application/payload+json" dangerouslySetInnerHTML={{__html: payload}} />
<script type="application/javascript" dangerouslySetInnerHTML={{__html: BOOTSTRAP_CODE}} />
{head.script.toComponent()}
</body>
@@ -45,6 +45,7 @@ HTML.propTypes = {
function render(plugins, initialState) {
// Load the plugins
const browserPlugins = loadPlugins(plugins);
const payload = JSON.stringify(initialState);
const store = GitBook.createStore(browserPlugins, initialState);
const scripts = plugins.toList()
@@ -64,7 +65,7 @@ function render(plugins, initialState) {
const htmlEl = <HTML
head={head}
innerHTML={innerHTML}
payload={initialState}
payload={payload}
scripts={['gitbook/core.js'].concat(scripts)}
/>;