Add function color remaining text (#1980)
This commit is contained in:
parent
be6cabb315
commit
b87a08e160
3 changed files with 29 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue