]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/compose/components/character_counter.js
Improve eslint rules (#3147)
[mastodon.git] / app / javascript / mastodon / features / compose / components / character_counter.js
1 import React from 'react';
2 import PropTypes from 'prop-types';
3 import { length } from 'stringz';
4
5 class CharacterCounter extends React.PureComponent {
6
7 static propTypes = {
8 text: PropTypes.string.isRequired,
9 max: PropTypes.number.isRequired,
10 };
11
12 checkRemainingText (diff) {
13 if (diff < 0) {
14 return <span className='character-counter character-counter--over'>{diff}</span>;
15 }
16 return <span className='character-counter'>{diff}</span>;
17 }
18
19 render () {
20 const diff = this.props.max - length(this.props.text);
21
22 return this.checkRemainingText(diff);
23 }
24
25 }
26
27 export default CharacterCounter;
This page took 0.081945 seconds and 4 git commands to generate.