Skip to content
Snippets Groups Projects
Commit 1e2240fa authored by Josiah Neuberger's avatar Josiah Neuberger
Browse files

fixed lint errors from stage zoom update

parent 65ab58d9
Branches
No related tags found
No related merge requests found
...@@ -11,26 +11,25 @@ import styles from './stage-header.css'; ...@@ -11,26 +11,25 @@ import styles from './stage-header.css';
const StageHeaderComponent = function (props) { const StageHeaderComponent = function (props) {
const { const {
isZoomed,
onZoom,
onUnzoom,
width,
height,
vm,
className, className,
title, height,
titleZoomIcon, isZoomed,
onUnzoom,
onZoom,
titleZoomIcon,
vm,
width,
...componentProps ...componentProps
} = props; } = props;
return isZoomed === false ? ( return isZoomed === false ? (
<Box className={styles.stageHeaderWrapper}> <Box className={styles.stageHeaderWrapper}>
<Box <Box
className={styles.stageMenuWrapper} className={styles.stageMenuWrapper}
height={height} height={height}
width={width} width={width}
> >
<Controls vm={vm} /> <Controls vm={vm} />
<img <img
className={classNames( className={classNames(
className, className,
styles.stageZoomIcon styles.stageZoomIcon
...@@ -44,11 +43,11 @@ const StageHeaderComponent = function (props) { ...@@ -44,11 +43,11 @@ const StageHeaderComponent = function (props) {
</Box> </Box>
) : ( ) : (
<Box className={styles.stageHeaderWrapperOverlay}> <Box className={styles.stageHeaderWrapperOverlay}>
<Box <Box
className={styles.stageMenuWrapper} className={styles.stageMenuWrapper}
height={"100%"} height={'100%'}
width={"100%"} width={'100%'}
> >
<Controls vm={vm} /> <Controls vm={vm} />
<img <img
className={classNames( className={classNames(
...@@ -65,19 +64,18 @@ const StageHeaderComponent = function (props) { ...@@ -65,19 +64,18 @@ const StageHeaderComponent = function (props) {
); );
}; };
StageHeaderComponent.propTypes = { StageHeaderComponent.propTypes = {
className: PropTypes.string,
height: PropTypes.number,
isZoomed: PropTypes.bool.isRequired, isZoomed: PropTypes.bool.isRequired,
onZoom: PropTypes.func.isRequired,
onUnzoom: PropTypes.func.isRequired, onUnzoom: PropTypes.func.isRequired,
height: PropTypes.number, onZoom: PropTypes.func.isRequired,
width: PropTypes.number, titleZoomIcon: PropTypes.string,
className: PropTypes.string, vm: PropTypes.instanceOf(VM).isRequired,
title: PropTypes.string, width: PropTypes.number
titleZoomIcon: PropTypes.string
}; };
StageHeaderComponent.defaultProps = { StageHeaderComponent.defaultProps = {
width: 480, width: 480,
height: 360, height: 360,
title: 'Stage Header',
titleZoomIcon: 'Zoom Control' titleZoomIcon: 'Zoom Control'
}; };
export default StageHeaderComponent; export default StageHeaderComponent;
...@@ -7,10 +7,10 @@ import styles from './stage.css'; ...@@ -7,10 +7,10 @@ import styles from './stage.css';
const StageComponent = props => { const StageComponent = props => {
const { const {
isZoomed,
canvasRef, canvasRef,
width,
height, height,
isZoomed,
width,
...boxProps ...boxProps
} = props; } = props;
return isZoomed === false ? ( return isZoomed === false ? (
...@@ -33,20 +33,20 @@ const StageComponent = props => { ...@@ -33,20 +33,20 @@ const StageComponent = props => {
className={styles.stage} className={styles.stage}
componentRef={canvasRef} componentRef={canvasRef}
element="canvas" element="canvas"
height={"100%"} height={'100%'}
width={"100%"} width={'100%'}
{...boxProps} {...boxProps}
/> />
<Box className={styles.monitorWrapper}> <Box className={styles.monitorWrapper}>
<MonitorList /> <MonitorList />
</Box> </Box>
</Box> </Box>
); );
}; };
StageComponent.propTypes = { StageComponent.propTypes = {
isZoomed: PropTypes.bool.isRequired,
canvasRef: PropTypes.func, canvasRef: PropTypes.func,
height: PropTypes.number, height: PropTypes.number,
isZoomed: PropTypes.bool.isRequired,
width: PropTypes.number width: PropTypes.number
}; };
StageComponent.defaultProps = { StageComponent.defaultProps = {
......
...@@ -19,16 +19,18 @@ class StageHeader extends React.Component { ...@@ -19,16 +19,18 @@ class StageHeader extends React.Component {
}; };
} }
shouldComponentUpdate (nextProps, nextState) { shouldComponentUpdate (nextProps, nextState) {
return this.props.width !== nextProps.width || this.props.height !== nextProps.height || this.state.isZoomed !== nextState.isZoomed; return this.props.width !== nextProps.width ||
this.props.height !== nextProps.height ||
this.state.isZoomed !== nextState.isZoomed;
} }
handleZoom () { handleZoom () {
this.setState({isZoomed: true}); this.setState({isZoomed: true});
this.props.dispatch({type: 'scratch-gui/Zoomed/SET_ZOOMED', isZoomed: true }); this.props.dispatch({type: 'scratch-gui/Zoomed/SET_ZOOMED', isZoomed: true});
} }
handleUnzoom () { handleUnzoom () {
this.setState({isZoomed: false}); this.setState({isZoomed: false});
this.props.dispatch({type: 'scratch-gui/Zoomed/SET_ZOOMED', isZoomed: false }); this.props.dispatch({type: 'scratch-gui/Zoomed/SET_ZOOMED', isZoomed: false});
} }
render () { render () {
const { const {
...@@ -38,9 +40,9 @@ class StageHeader extends React.Component { ...@@ -38,9 +40,9 @@ class StageHeader extends React.Component {
return ( return (
<StageHeaderComponent <StageHeaderComponent
isZoomed={this.state.isZoomed} isZoomed={this.state.isZoomed}
onZoom={this.handleZoom} vm={this.props.vm}
onUnzoom={this.handleUnzoom} onUnzoom={this.handleUnzoom}
vm={this.props.vm} onZoom={this.handleZoom}
{...props} {...props}
/> />
); );
...@@ -48,9 +50,10 @@ class StageHeader extends React.Component { ...@@ -48,9 +50,10 @@ class StageHeader extends React.Component {
} }
StageHeader.propTypes = { StageHeader.propTypes = {
dispatch: PropTypes.func.isRequired,
height: PropTypes.number, height: PropTypes.number,
width: PropTypes.number, vm: PropTypes.instanceOf(VM).isRequired,
vm: PropTypes.instanceOf(VM).isRequired width: PropTypes.number
}; };
const mapStateToProps = state => ({ const mapStateToProps = state => ({
...@@ -60,4 +63,3 @@ const mapStateToProps = state => ({ ...@@ -60,4 +63,3 @@ const mapStateToProps = state => ({
export default connect( export default connect(
mapStateToProps mapStateToProps
)(StageHeader); )(StageHeader);
...@@ -34,13 +34,6 @@ class Stage extends React.Component { ...@@ -34,13 +34,6 @@ class Stage extends React.Component {
isZoomed: false isZoomed: false
}; };
} }
componentWillReceiveProps(nextProps) {
const {
isZoomed
} = nextProps;
this.setState({isZoomed: isZoomed});
}
componentDidMount () { componentDidMount () {
this.attachRectEvents(); this.attachRectEvents();
this.attachMouseEvents(this.canvas); this.attachMouseEvents(this.canvas);
...@@ -48,12 +41,21 @@ class Stage extends React.Component { ...@@ -48,12 +41,21 @@ class Stage extends React.Component {
this.renderer = new Renderer(this.canvas); this.renderer = new Renderer(this.canvas);
this.props.vm.attachRenderer(this.renderer); this.props.vm.attachRenderer(this.renderer);
} }
componentWillReceiveProps (nextProps) {
const {
isZoomed
} = nextProps;
this.setState({isZoomed: isZoomed});
}
shouldComponentUpdate (nextProps, nextState) { shouldComponentUpdate (nextProps, nextState) {
return this.props.width !== nextProps.width || this.props.height !== nextProps.height || this.state.isZoomed !== nextState.isZoomed; return this.props.width !== nextProps.width ||
this.props.height !== nextProps.height ||
this.state.isZoomed !== nextState.isZoomed;
} }
componentDidUpdate() { componentDidUpdate () {
this.updateRect(); this.updateRect();
this.renderer.resize(this.rect.width, this.rect.height); this.renderer.resize(this.rect.width, this.rect.height);
} }
componentWillUnmount () { componentWillUnmount () {
this.detachMouseEvents(this.canvas); this.detachMouseEvents(this.canvas);
...@@ -209,8 +211,8 @@ class Stage extends React.Component { ...@@ -209,8 +211,8 @@ class Stage extends React.Component {
} = this.props; } = this.props;
return ( return (
<StageComponent <StageComponent
isZoomed={this.state.isZoomed}
canvasRef={this.setCanvas} canvasRef={this.setCanvas}
isZoomed={this.state.isZoomed}
onDoubleClick={this.handleDoubleClick} onDoubleClick={this.handleDoubleClick}
{...props} {...props}
/> />
...@@ -220,6 +222,7 @@ class Stage extends React.Component { ...@@ -220,6 +222,7 @@ class Stage extends React.Component {
Stage.propTypes = { Stage.propTypes = {
height: PropTypes.number, height: PropTypes.number,
isZoomed: PropTypes.bool,
vm: PropTypes.instanceOf(VM).isRequired, vm: PropTypes.instanceOf(VM).isRequired,
width: PropTypes.number width: PropTypes.number
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment