Skip to content

Commit

Permalink
Merge pull request #3 from tmickel/feature/toolbox-default
Browse files Browse the repository at this point in the history
Use default toolbox from scratch-blocks
  • Loading branch information
tmickel authored Oct 13, 2016
2 parents edd09fa + ea8dc56 commit 2677e22
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 715 deletions.
13 changes: 7 additions & 6 deletions src/components/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ const React = require('react');
const ScratchBlocks = require('scratch-blocks');

class Blocks extends React.Component {
componentDidUpdate (prevProps) {
if (!prevProps.options.toolbox && this.props.options.toolbox) {
let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options);
this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig);
this.props.onReceiveWorkspace(this.workspace);
}
componentDidMount () {
let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options);
this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig);
this.props.onReceiveWorkspace(this.workspace);
}
componentWillUnmount () {
this.workspace.dispose();
}
render () {
return (
Expand Down
10 changes: 1 addition & 9 deletions src/components/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const Renderer = require('scratch-render');
const SpriteSelector = require('./sprite-selector');
const Stage = require('./stage');
const StopAll = require('./stop-all');
const Toolbox = require('./toolbox');
const VM = require('scratch-vm');
const VMManager = require('../lib/vm-manager');

Expand All @@ -17,11 +16,6 @@ class GUI extends React.Component {
this.onReceiveWorkspace = this.onReceiveWorkspace.bind(this);
this.state = {};
}
componentDidMount () {
this.setState({
toolbox: this.toolbox
});
}
componentWillReceiveProps (nextProps) {
if (this.props.projectData !== nextProps.projectData) {
this.props.vm.loadProject(nextProps.projectData);
Expand Down Expand Up @@ -58,11 +52,9 @@ class GUI extends React.Component {
<StopAll vm={this.props.vm} />
<Stage stageRef={stage => this.stage = stage} />
<SpriteSelector vm={this.props.vm} />
<Toolbox toolboxRef={toolbox => this.toolbox = toolbox} />
<Blocks
options={{
media: this.props.basePath + 'static/blocks-media/',
toolbox: this.state.toolbox
media: this.props.basePath + 'static/blocks-media/'
}}
vm={this.props.vm}
onReceiveWorkspace={this.onReceiveWorkspace}
Expand Down
Loading

0 comments on commit 2677e22

Please # to comment.