Permalink
Browse files

Added logic to disable <ButtonForCounter>s when they're at either the…

… bottom or upper limit of their range.
  • Loading branch information...
maratbn committed Jul 23, 2018
1 parent a02cce3 commit 0a280725033e9254f4fa33dbb3b89e9b1b0db1c8
Showing with 6 additions and 2 deletions.
  1. +6 −2 webpack_in/entry.jsx
@@ -240,7 +240,7 @@ class ButtonForCounter extends React.Component {
this._flagCount = true;
const doCount = () => {
if (!this._flagCount) {
if (!this._flagCount || this.props.isDisabled) {
return;
}
@@ -258,7 +258,8 @@ class ButtonForCounter extends React.Component {
}
render() {
return (<button onMouseDown={ this._onCountStart }
return (<button disabled={ this.props.isDisabled }
onMouseDown={ this._onCountStart }
onMouseUp={ this._onCountStop }
onMouseLeave={ this._onCountStop }
onTouchStart={ this._onCountStart }
@@ -269,6 +270,7 @@ class ButtonForCounter extends React.Component {
ButtonForCounter.propTypes = {
caption: PropTypes.string.isRequired,
isDisabled: PropTypes.bool,
onCount: PropTypes.func.isRequired
};
@@ -317,6 +319,7 @@ class ColorComponentEntry extends React.Component {
this.props.onChangeValue(convertValue(strValueEntered));
}} />
<ButtonForCounter caption="&#9650;"
isDisabled={ this.props.value === 255 }
onCount={ () => {
const valueNew = this.props.value + 1;
@@ -327,6 +330,7 @@ class ColorComponentEntry extends React.Component {
this.props.onChangeValue(valueNew);
}} />
<ButtonForCounter caption="&#9660;"
isDisabled={ this.props.value === 0 }
onCount={ () => {
const valueNew = this.props.value - 1;

0 comments on commit 0a28072

Please sign in to comment.