The code powering m.abunchtell.com https://m.abunchtell.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

26 rindas
643 B

  1. import PropTypes from 'prop-types';
  2. class CharacterCounter extends React.PureComponent {
  3. checkRemainingText (diff) {
  4. if (diff <= 0) {
  5. return <span style={{ fontSize: '16px', cursor: 'default', color: '#ff5050' }}>{diff}</span>;
  6. }
  7. return <span style={{ fontSize: '16px', cursor: 'default' }}>{diff}</span>;
  8. }
  9. render () {
  10. const diff = this.props.max - this.props.text.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
  11. return this.checkRemainingText(diff);
  12. }
  13. }
  14. CharacterCounter.propTypes = {
  15. text: PropTypes.string.isRequired,
  16. max: PropTypes.number.isRequired
  17. }
  18. export default CharacterCounter;