/// import * as React from 'react'; import { connect } from 'react-redux'; import { isDark } from './ColorPicker'; import { reduxify } from './core'; @reduxify( (state) => ({ width: state.width, height: state.height, color: state.color, top: state.nextShapeId * 10, left: state.nextShapeId * 10 }), (dispatch) => ({ addShape: (color, height, width, top, left) => { dispatch({ type: 'SHAPE_ADD', height, width, color, top, left }); } }) ) export default class ShapeMaker extends React.Component { constructor(props?, context?) { super(props, context); this.state = { top: props.top, left: props.left }; } render() { var width = this.props.width, height = this.props.height, background = this.props.color; const color = isDark(background) ? '#fff' : '#000'; return (

{height}x{width}

({this.state.top}, {this.state.left})

,

); } handleTop = (e) => { var top = parseInt(e.target.value); if (!isNaN(top)) this.setState({ top }); } handleLeft = (e) => { var left = parseInt(e.target.value); if (!isNaN(left)) this.setState({ left }); } }