mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-14 00:19:46 -05:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import bindAll from 'lodash.bindall';
|
|
import React from 'react';
|
|
import PaperCanvas from '../containers/paper-canvas.jsx';
|
|
import BrushMode from '../containers/brush-mode.jsx';
|
|
import EraserMode from '../containers/eraser-mode.jsx';
|
|
|
|
class PaintEditorComponent extends React.Component {
|
|
constructor (props) {
|
|
super(props);
|
|
bindAll(this, [
|
|
'setCanvas'
|
|
]);
|
|
this.state = {};
|
|
}
|
|
setCanvas (canvas) {
|
|
this.setState({canvas: canvas});
|
|
}
|
|
render () {
|
|
// Modes can't work without a canvas, so we don't render them until we have it
|
|
if (this.state.canvas) {
|
|
return (
|
|
<div>
|
|
<PaperCanvas canvasRef={this.setCanvas} />
|
|
<BrushMode canvas={this.state.canvas} />
|
|
<EraserMode canvas={this.state.canvas} />
|
|
</div>
|
|
);
|
|
}
|
|
return (
|
|
<div>
|
|
<PaperCanvas canvasRef={this.setCanvas} />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default PaintEditorComponent;
|