2017-07-27 16:41:41 -04:00
|
|
|
import bindAll from 'lodash.bindall';
|
2017-07-13 14:03:48 -04:00
|
|
|
import React from 'react';
|
2017-07-17 18:39:50 -04:00
|
|
|
import PaperCanvas from '../containers/paper-canvas.jsx';
|
2017-08-15 18:11:02 -04:00
|
|
|
import BrushMode from '../containers/brush-mode.jsx';
|
|
|
|
import EraserMode from '../containers/eraser-mode.jsx';
|
2017-07-13 14:03:48 -04:00
|
|
|
|
2017-07-27 11:45:41 -04:00
|
|
|
class PaintEditorComponent extends React.Component {
|
2017-07-27 16:41:41 -04:00
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
bindAll(this, [
|
|
|
|
'setCanvas'
|
|
|
|
]);
|
|
|
|
this.state = {};
|
|
|
|
}
|
|
|
|
setCanvas (canvas) {
|
|
|
|
this.setState({canvas: canvas});
|
|
|
|
}
|
2017-07-27 11:45:41 -04:00
|
|
|
render () {
|
2017-08-15 18:11:02 -04:00
|
|
|
// Modes can't work without a canvas, so we don't render them until we have it
|
2017-07-27 16:41:41 -04:00
|
|
|
if (this.state.canvas) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<PaperCanvas canvasRef={this.setCanvas} />
|
2017-08-15 18:11:02 -04:00
|
|
|
<BrushMode canvas={this.state.canvas} />
|
|
|
|
<EraserMode canvas={this.state.canvas} />
|
2017-07-27 16:41:41 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-07-27 11:45:41 -04:00
|
|
|
return (
|
|
|
|
<div>
|
2017-07-27 16:41:41 -04:00
|
|
|
<PaperCanvas canvasRef={this.setCanvas} />
|
2017-07-27 11:45:41 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-07-13 14:03:48 -04:00
|
|
|
|
2017-07-26 20:39:12 -04:00
|
|
|
export default PaintEditorComponent;
|