Skip to content
Snippets Groups Projects
Commit 2677e221 authored by Tim Mickel's avatar Tim Mickel Committed by GitHub
Browse files

Merge pull request #3 from tmickel/feature/toolbox-default

Use default toolbox from scratch-blocks
parents edd09fa4 ea8dc56a
No related branches found
No related tags found
No related merge requests found
...@@ -3,12 +3,13 @@ const React = require('react'); ...@@ -3,12 +3,13 @@ const React = require('react');
const ScratchBlocks = require('scratch-blocks'); const ScratchBlocks = require('scratch-blocks');
class Blocks extends React.Component { class Blocks extends React.Component {
componentDidUpdate (prevProps) { componentDidMount () {
if (!prevProps.options.toolbox && this.props.options.toolbox) { let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options);
let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options); this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig);
this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig); this.props.onReceiveWorkspace(this.workspace);
this.props.onReceiveWorkspace(this.workspace); }
} componentWillUnmount () {
this.workspace.dispose();
} }
render () { render () {
return ( return (
......
...@@ -6,7 +6,6 @@ const Renderer = require('scratch-render'); ...@@ -6,7 +6,6 @@ const Renderer = require('scratch-render');
const SpriteSelector = require('./sprite-selector'); const SpriteSelector = require('./sprite-selector');
const Stage = require('./stage'); const Stage = require('./stage');
const StopAll = require('./stop-all'); const StopAll = require('./stop-all');
const Toolbox = require('./toolbox');
const VM = require('scratch-vm'); const VM = require('scratch-vm');
const VMManager = require('../lib/vm-manager'); const VMManager = require('../lib/vm-manager');
...@@ -17,11 +16,6 @@ class GUI extends React.Component { ...@@ -17,11 +16,6 @@ class GUI extends React.Component {
this.onReceiveWorkspace = this.onReceiveWorkspace.bind(this); this.onReceiveWorkspace = this.onReceiveWorkspace.bind(this);
this.state = {}; this.state = {};
} }
componentDidMount () {
this.setState({
toolbox: this.toolbox
});
}
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {
if (this.props.projectData !== nextProps.projectData) { if (this.props.projectData !== nextProps.projectData) {
this.props.vm.loadProject(nextProps.projectData); this.props.vm.loadProject(nextProps.projectData);
...@@ -58,11 +52,9 @@ class GUI extends React.Component { ...@@ -58,11 +52,9 @@ class GUI extends React.Component {
<StopAll vm={this.props.vm} /> <StopAll vm={this.props.vm} />
<Stage stageRef={stage => this.stage = stage} /> <Stage stageRef={stage => this.stage = stage} />
<SpriteSelector vm={this.props.vm} /> <SpriteSelector vm={this.props.vm} />
<Toolbox toolboxRef={toolbox => this.toolbox = toolbox} />
<Blocks <Blocks
options={{ options={{
media: this.props.basePath + 'static/blocks-media/', media: this.props.basePath + 'static/blocks-media/'
toolbox: this.state.toolbox
}} }}
vm={this.props.vm} vm={this.props.vm}
onReceiveWorkspace={this.onReceiveWorkspace} onReceiveWorkspace={this.onReceiveWorkspace}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment