mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-14 19:05:27 +00:00
1948f9e767
* Remove deprecated features at React v15.5
- [x] React.PropTypes
- [x] react-addons-pure-render-mixin
- [x] react-addons-test-utils
* Uncommented out & Add browserify_rails options
* re-add react-addons-shallow
* Fix syntax error from resolve conflicts
* follow up 59a77923b3
26 lines
643 B
JavaScript
26 lines
643 B
JavaScript
import PropTypes from 'prop-types';
|
|
|
|
class CharacterCounter extends React.PureComponent {
|
|
|
|
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 this.checkRemainingText(diff);
|
|
}
|
|
|
|
}
|
|
|
|
CharacterCounter.propTypes = {
|
|
text: PropTypes.string.isRequired,
|
|
max: PropTypes.number.isRequired
|
|
}
|
|
|
|
export default CharacterCounter;
|