Skip to content

Commit 0a28072

Browse files
committed
Added logic to disable <ButtonForCounter>s when they're at either the bottom or upper limit of their range.
1 parent a02cce3 commit 0a28072

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎webpack_in/entry.jsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class ButtonForCounter extends React.Component {
240240
this._flagCount = true;
241241

242242
const doCount = () => {
243-
if (!this._flagCount) {
243+
if (!this._flagCount || this.props.isDisabled) {
244244
return;
245245
}
246246

@@ -258,7 +258,8 @@ class ButtonForCounter extends React.Component {
258258
}
259259

260260
render() {
261-
return (<button onMouseDown={ this._onCountStart }
261+
return (<button disabled={ this.props.isDisabled }
262+
onMouseDown={ this._onCountStart }
262263
onMouseUp={ this._onCountStop }
263264
onMouseLeave={ this._onCountStop }
264265
onTouchStart={ this._onCountStart }
@@ -269,6 +270,7 @@ class ButtonForCounter extends React.Component {
269270

270271
ButtonForCounter.propTypes = {
271272
caption: PropTypes.string.isRequired,
273+
isDisabled: PropTypes.bool,
272274
onCount: PropTypes.func.isRequired
273275
};
274276

@@ -317,6 +319,7 @@ class ColorComponentEntry extends React.Component {
317319
this.props.onChangeValue(convertValue(strValueEntered));
318320
}} />
319321
<ButtonForCounter caption="&#9650;"
322+
isDisabled={ this.props.value === 255 }
320323
onCount={ () => {
321324
const valueNew = this.props.value + 1;
322325

@@ -327,6 +330,7 @@ class ColorComponentEntry extends React.Component {
327330
this.props.onChangeValue(valueNew);
328331
}} />
329332
<ButtonForCounter caption="&#9660;"
333+
isDisabled={ this.props.value === 0 }
330334
onCount={ () => {
331335
const valueNew = this.props.value - 1;
332336

0 commit comments

Comments
 (0)