0
0
Fork 0

Add function color remaining text (#1980)

This commit is contained in:
usagi-f 2017-04-17 17:34:33 +09:00 committed by Eugen
parent be6cabb315
commit b87a08e160
3 changed files with 29 additions and 5 deletions

View file

@ -9,14 +9,17 @@ const CharacterCounter = React.createClass({
mixins: [PureRenderMixin],
checkRemainingText (diff) {
if (diff <= 0) {
return <span style={{ fontSize: '16px', cursor: 'default', color: '#ff5050' }}>{diff}</span>;
}
return <span style={{ fontSize: '16px', cursor: 'default' }}>{diff}</span>;
},
render () {
const diff = this.props.max - this.props.text.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
return (
<span style={{ fontSize: '16px', cursor: 'default' }}>
{diff}
</span>
);
return this.checkRemainingText(diff);
}
});