decidim-comments/app/frontend/comments/vote_button.component.jsx in decidim-0.0.2 vs decidim-comments/app/frontend/comments/vote_button.component.jsx in decidim-0.0.3

- old
+ new

@@ -1,19 +1,27 @@ -import { PropTypes } from 'react'; +import { Component, PropTypes } from 'react'; import Icon from '../application/icon.component'; -const VoteButton = ({ buttonClassName, iconName, votes, voteAction, disabled }) => ( - <button className={buttonClassName} onClick={() => voteAction()} disabled={disabled}> - <Icon name={iconName} iconExtraClassName="icon--small" /> - { ` ${votes}` } - </button> -); +class VoteButton extends Component { + render() { + const { buttonClassName, iconName, votes, voteAction, disabled, selectedClass } = this.props; + let voteClasses = `${buttonClassName} ${selectedClass}`; + return ( + <button className={voteClasses} onClick={() => voteAction()} disabled={disabled}> + <Icon name={iconName} iconExtraClassName="icon--small" /> + { ` ${votes}` } + </button> + ); + } +} + VoteButton.propTypes = { buttonClassName: PropTypes.string.isRequired, iconName: PropTypes.string.isRequired, votes: PropTypes.number.isRequired, voteAction: PropTypes.func.isRequired, + selectedClass: PropTypes.string, disabled: PropTypes.bool }; export default VoteButton;