p5.js-web-editor/shared/containers/IDEView/IDEView.jsx

72 lines
2.2 KiB
React
Raw Normal View History

2016-05-18 19:37:59 +02:00
import React from 'react'
2016-05-06 01:01:31 +02:00
import Editor from '../../components/Editor/Editor'
2016-05-10 00:28:38 +02:00
import PreviewFrame from '../../components/Preview/PreviewFrame'
2016-05-11 19:19:37 +02:00
import Toolbar from '../../components/Toolbar/Toolbar'
2016-06-17 19:37:29 +02:00
import Preferences from '../../components/Preferences/Preferences'
2016-06-10 04:15:50 +02:00
import Nav from '../../components/Nav/Nav'
2016-05-06 01:01:31 +02:00
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
2016-06-20 19:29:32 +02:00
import * as IndexActions from '../../redux/actions'
import * as ProjectActions from '../../redux/actions/project'
2016-05-06 01:01:31 +02:00
2016-05-18 19:37:59 +02:00
class IDEView extends React.Component {
2016-06-20 19:29:32 +02:00
componentDidMount() {
if (this.props.params.project_id) {
const id = this.props.params.project_id
this.props.getProject(id);
}
}
2016-05-06 01:01:31 +02:00
render() {
return (
2016-05-18 19:37:59 +02:00
<div className="ide">
2016-06-17 20:11:52 +02:00
<Nav user={this.props.user}
createProject={this.props.createProject}
saveProject={this.props.saveProject}/>
2016-05-18 19:37:59 +02:00
<Toolbar
className="Toolbar"
2016-05-11 22:13:17 +02:00
isPlaying={this.props.ide.isPlaying}
2016-06-17 19:37:29 +02:00
startSketch={this.props.startSketch}
stopSketch={this.props.stopSketch}
projectName={this.props.project.name}
setProjectName={this.props.setProjectName}
2016-06-17 20:31:33 +02:00
openPreferences={this.props.openPreferences}
2016-06-17 19:37:29 +02:00
isPreferencesShowing = {this.props.preferences.isPreferencesShowing}
/>
<Preferences
isPreferencesShowing = {this.props.preferences.isPreferencesShowing}
2016-06-20 20:58:15 +02:00
closePreferences={this.props.closePreferences}
increaseFont={this.props.increaseFont}
decreaseFont={this.props.decreaseFont}
fontSize={this.props.preferences.fontSize}/>
2016-06-17 19:37:29 +02:00
<Editor
content={this.props.file.content}
2016-06-20 20:58:15 +02:00
updateFile={this.props.updateFile}
fontSize={this.props.preferences.fontSize} />
2016-06-17 19:37:29 +02:00
<PreviewFrame
content={this.props.file.content}
2016-05-11 04:22:32 +02:00
head={
<link type='text/css' rel='stylesheet' href='preview-styles.css' />
2016-05-11 22:13:17 +02:00
}
isPlaying={this.props.ide.isPlaying}/>
</div>
2016-05-18 19:37:59 +02:00
)
2016-05-06 01:01:31 +02:00
}
}
function mapStateToProps(state) {
return {
2016-05-11 22:13:17 +02:00
file: state.file,
2016-06-17 19:37:29 +02:00
ide: state.ide,
2016-06-14 20:46:40 +02:00
preferences: state.preferences,
user: state.user,
project: state.project
2016-05-06 01:01:31 +02:00
}
}
function mapDispatchToProps(dispatch) {
2016-06-20 19:29:32 +02:00
return bindActionCreators(Object.assign({}, IndexActions, ProjectActions), dispatch);
2016-05-06 01:01:31 +02:00
}
2016-05-18 19:37:59 +02:00
export default connect(mapStateToProps, mapDispatchToProps)(IDEView);