2016-08-31 16:15:12 +02:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
|
2016-08-25 19:52:55 +02:00
|
|
|
const CharacterCounter = React.createClass({
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2016-08-25 19:52:55 +02:00
|
|
|
propTypes: {
|
2016-09-25 15:26:56 +02:00
|
|
|
text: React.PropTypes.string.isRequired,
|
|
|
|
max: React.PropTypes.number.isRequired
|
2016-08-25 19:52:55 +02:00
|
|
|
},
|
|
|
|
|
2016-08-31 16:15:12 +02:00
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
2016-08-25 19:52:55 +02:00
|
|
|
render () {
|
2016-09-25 15:26:56 +02:00
|
|
|
const diff = this.props.max - this.props.text.length;
|
|
|
|
|
2016-08-25 19:52:55 +02:00
|
|
|
return (
|
|
|
|
<span style={{ fontSize: '16px', cursor: 'default' }}>
|
2016-09-25 15:26:56 +02:00
|
|
|
{diff}
|
2016-08-25 19:52:55 +02:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default CharacterCounter;
|