Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added logic to disable <ButtonForCounter>s when they're at either the…
… bottom or upper limit of their range.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent a02cce3 commit 0a28072
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webpack_in/entry.jsx
Expand Up @@ -240,7 +240,7 @@ class ButtonForCounter extends React.Component {
this._flagCount = true;

const doCount = () => {
if (!this._flagCount) {
if (!this._flagCount || this.props.isDisabled) {
return;
}

Expand All @@ -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 }
Expand All @@ -269,6 +270,7 @@ class ButtonForCounter extends React.Component {

ButtonForCounter.propTypes = {
caption: PropTypes.string.isRequired,
isDisabled: PropTypes.bool,
onCount: PropTypes.func.isRequired
};

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 0a28072

Please sign in to comment.