Skip to content

Instantly share code, notes, and snippets.

@gyver98
Created March 17, 2017 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyver98/5c7f4755023643a84dc7514209f22997 to your computer and use it in GitHub Desktop.
Save gyver98/5c7f4755023643a84dc7514209f22997 to your computer and use it in GitHub Desktop.
import React from 'react';
import './TeslaCounter.css';
const TeslaCounter = ({ initValues, currentValue, increment, decrement }) => (
<div className="tesla-counter">
<p className="tesla-counter__title">{initValues.title}</p>
<div className="tesla-counter__container cf">
<div className="tesla-counter__item">
<p className="tesla-counter__number">
{ currentValue }
<span>{ initValues.unit }</span>
</p>
<div className="tesla-counter__controls">
<button
onClick={(e) => {
e.preventDefault();
increment(currentValue)}}
disabled={currentValue >= initValues.max}
>
</button>
<button
onClick={(e) => {
e.preventDefault();
decrement(currentValue)}}
disabled={currentValue <= initValues.min}
>
</button>
</div>
</div>
</div>
</div>
);
TeslaCounter.propTypes = {
currentValue: React.PropTypes.number,
increment: React.PropTypes.func,
decrement: React.PropTypes.func,
initValues: React.PropTypes.object
}
export default TeslaCounter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment