restructure react components

This commit is contained in:
catarak 2016-06-22 13:49:06 -04:00
parent 6b978abcdd
commit 3a26cdd491
26 changed files with 28 additions and 69 deletions

View file

@ -2,8 +2,8 @@ import React from 'react'
import { render } from 'react-dom' import { render } from 'react-dom'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { Router, browserHistory } from 'react-router' import { Router, browserHistory } from 'react-router'
import configureStore from '../shared/redux/store/configureStore' import configureStore from './store'
import routes from '../shared/routes' import routes from './routes'
require('../styles/main.scss'); require('../styles/main.scss');

View file

@ -1,8 +1,8 @@
import React from 'react' import React from 'react'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import {reduxForm} from 'redux-form' import {reduxForm} from 'redux-form'
import * as UserActions from '../../redux/actions/user' import * as UserActions from '../../../redux/actions/user'
import LoginForm from '../../components/LoginForm/LoginForm' import LoginForm from '../components/LoginForm'
class LoginView extends React.Component { class LoginView extends React.Component {
render() { render() {

View file

@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as UserActions from '../../redux/actions/user' import * as UserActions from '../../../redux/actions/user'
import { reduxForm } from 'redux-form' import { reduxForm } from 'redux-form'
import SignupForm from '../../components/SignupForm/SignupForm' import SignupForm from '../components/SignupForm'
class SignupView extends React.Component { class SignupView extends React.Component {
render() { render() {

View file

@ -1,9 +1,9 @@
import React from 'react'; import React from 'react';
var Isvg = require('react-inlinesvg'); var Isvg = require('react-inlinesvg');
var exitUrl = require('../../../images/exit.svg'); var exitUrl = require('../../../../images/exit.svg');
var plusUrl = require('../../../images/plus.svg'); var plusUrl = require('../../../../images/plus.svg');
var minusUrl = require('../../../images/minus.svg'); var minusUrl = require('../../../../images/minus.svg');
var classNames = require('classnames'); var classNames = require('classnames');
class Preferences extends React.Component { class Preferences extends React.Component {

View file

@ -1,10 +1,10 @@
import React from 'react'; import React from 'react';
var Isvg = require('react-inlinesvg'); var Isvg = require('react-inlinesvg');
var playUrl = require('../../../images/play.svg'); var playUrl = require('../../../../images/play.svg');
var logoUrl = require('../../../images/p5js-logo.svg'); var logoUrl = require('../../../../images/p5js-logo.svg');
var stopUrl = require('../../../images/stop.svg'); var stopUrl = require('../../../../images/stop.svg');
var preferencesUrl = require('../../../images/preferences.svg'); var preferencesUrl = require('../../../../images/preferences.svg');
var classNames = require('classnames'); var classNames = require('classnames');
class Toolbar extends React.Component { class Toolbar extends React.Component {

View file

@ -1,13 +1,13 @@
import React from 'react' import React from 'react'
import Editor from '../../components/Editor/Editor' import Editor from '../components/Editor'
import PreviewFrame from '../../components/Preview/PreviewFrame' import PreviewFrame from '../components/PreviewFrame'
import Toolbar from '../../components/Toolbar/Toolbar' import Toolbar from '../components/Toolbar'
import Preferences from '../../components/Preferences/Preferences' import Preferences from '../components/Preferences'
import Nav from '../../components/Nav/Nav' import Nav from '../../../components/Nav'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as IndexActions from '../../redux/actions' import * as IndexActions from '../../../redux/actions'
import * as ProjectActions from '../../redux/actions/project' import * as ProjectActions from '../../../redux/actions/project'
class IDEView extends React.Component { class IDEView extends React.Component {
componentDidMount() { componentDidMount() {

View file

@ -1,11 +1,10 @@
import { Route, IndexRoute } from 'react-router' import { Route, IndexRoute } from 'react-router'
import React from 'react' import React from 'react'
import App from './containers/App' import App from './modules/App/App'
import IDEView from './containers/IDEView/IDEView' import IDEView from './modules/IDE/pages/IDEView'
import LoginView from './containers/LoginView/LoginView' import LoginView from './modules/Auth/pages/LoginView'
import SignupView from './containers/SignupView/SignupView' import SignupView from './modules/Auth/pages/SignupView'
import ProjectView from './containers/ProjectView/ProjectView' import { getUser } from './redux/actions/user'
import { getUser } from './redux/actions/user';
const routes = (store) => { const routes = (store) => {
return ( return (

View file

@ -1,6 +1,6 @@
import { createStore, applyMiddleware, compose } from 'redux' import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk' import thunk from 'redux-thunk'
import rootReducer from '../reducers' import rootReducer from './redux/reducers'
export default function configureStore(initialState) { export default function configureStore(initialState) {
const store = createStore( const store = createStore(
@ -11,8 +11,8 @@ export default function configureStore(initialState) {
if (module.hot) { if (module.hot) {
// Enable Webpack hot module replacement for reducers // Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => { module.hot.accept('./redux/reducers', () => {
const nextRootReducer = require('../reducers').default const nextRootReducer = require('./redux/reducers').default
store.replaceReducer(nextRootReducer) store.replaceReducer(nextRootReducer)
}) })
} }

View file

@ -1,40 +0,0 @@
import React from 'react'
import * as ProjectActions from '../../redux/actions/project'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
class ProjectView extends React.Component {
render() {
return (
<div className="project">
<h1>{this.props.project.name}</h1>
<p>
{this.props.file.content}
</p>
</div>
);
}
componentDidMount() {
const id = this.props.params.project_id
this.props.getProject(id);
}
}
function mapStateToProps(state) {
return {
file: state.file,
ide: state.ide,
user: state.user,
project: state.project
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(ProjectActions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(ProjectView);