Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary container reducer and make <Subdivide> potentially controllable #6

Merged
merged 3 commits into from
Oct 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions/LayoutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SET_CORNER_DOWN,
SET_DIVIDER_DOWN,
SET_STATE
} from '../constants/BlenderLayoutConstants';
} from '../constants';

export function setState(state) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CornerOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
JOIN_UP_ARROW,
JOIN_LEFT_ARROW,
JOIN_DOWN_ARROW
} from '../constants/BlenderLayoutConstants';
} from '../constants';

export default class CornerOverlay extends Component {

Expand Down
2 changes: 1 addition & 1 deletion src/components/DividerTouch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import {
COL
} from '../constants/BlenderLayoutConstants';
} from '../constants';

export default class Divider extends Component {
constructor(props, context) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dividers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {
COL
} from '../constants/BlenderLayoutConstants';
} from '../constants';
import DividerTouch from './DividerTouch';

var Rect = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
NE,
SE,
NW
} from '../constants/BlenderLayoutConstants';
} from '../constants';

export default class Layout extends Component {
constructor(props, context) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SW,
SE,
NW
} from '../constants/BlenderLayoutConstants';
} from '../constants';

function getStyles({
width,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Triangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
NE,
SE,
NW
} from '../constants/BlenderLayoutConstants';
} from '../constants';

@Radium
export default class Triangle extends Component {
Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions src/containers/LayoutContainer.js

This file was deleted.

27 changes: 20 additions & 7 deletions src/containers/Subdivide.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { Component } from 'react';
import { createStore } from 'redux';
import { createStore, bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import reducer from '../reducers';
import LayoutContainer from './LayoutContainer';
import Layout from '../components/Layout';
import * as LayoutActions from '../actions/LayoutActions';

function configureStore(initialState) {
let store = createStore(reducer, initialState);
Expand All @@ -16,16 +18,27 @@ function configureStore(initialState) {
return store;
}

const ConnectedLayout = connect(
state => ({ layout: state })
)(Layout);

export default class Subdivide extends Component {
constructor(props) {
super(props);
this.store = configureStore();

const {dispatch} = props;
if (dispatch) {
this.actions = bindActionCreators(LayoutActions, dispatch);
} else {
this.store = configureStore();
this.actions = bindActionCreators(LayoutActions, this.store.dispatch);
}
}

render() {
const {DefaultComponent} = this.props;
return (
<LayoutContainer DefaultComponent={DefaultComponent} store={this.store} />
);
const {store, actions} = this;
return store ?
<ConnectedLayout {...this.props} store={store} actions={actions} /> :
<Layout {...this.props} actions={actions} />;
}
}
10 changes: 6 additions & 4 deletions src/dev-index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//import 'babel-core/polyfill';
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import Subdivide from './containers/Subdivide';
import Subdivide from './index';

class IframeComponent extends Component {
render() {
return (
<iframe src="index2.html" frameBorder={'0'} style={{
width: '100%',
height: '100%'
}}></iframe>
}} />
);
}
}

ReactDOM.render(<Subdivide DefaultComponent={IframeComponent}/>, document.getElementById('root'));
ReactDOM.render(
<Subdivide DefaultComponent={IframeComponent} />,
document.getElementById('root')
);

4 changes: 2 additions & 2 deletions src/helpers/LayoutHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
CHILD_RIGHT,
ROW,
COL
} from '../constants/BlenderLayoutConstants';
} from '../constants';

import {List, Map} from 'immutable';
import {Pane, Layout, Divider} from '../reducers/LayoutReducer';
import {Pane, Layout, Divider} from '../reducers';
import secondPass from './secondPass';

function getNextId(state) {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/secondPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
JOIN_UP_ARROW,
JOIN_LEFT_ARROW,
JOIN_DOWN_ARROW,
} from '../constants/BlenderLayoutConstants';
} from '../constants';

import {Divider} from '../reducers/LayoutReducer';
import {Divider} from '../reducers';
import {Map} from 'immutable';

function getJoinDirection({layout, pane}) {
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
//import 'babel-core/polyfill';

module.exports = require('./containers/Subdivide');
export default from './containers/Subdivide';
export { default as reducer } from './reducers';
110 changes: 0 additions & 110 deletions src/reducers/LayoutReducer.js

This file was deleted.

Loading