merge master 3.0.3, feature counter

Merge remote-tracking branch 'origin'

Signed-off-by: Baptiste Lemoine <contact@cipherbliss.com>

# Conflicts:
#	.ruby-version
#	app/javascript/mastodon/components/status.js
#	app/javascript/mastodon/features/direct_timeline/components/conversation.js
#	app/javascript/mastodon/features/getting_started/components/announcements.js
#	app/javascript/mastodon/locales/fr.json
#	config/locales/kab.yml
#	config/locales/ta.yml
#	yarn.lock
This commit is contained in:
tykayn 2021-01-13 14:25:58 +01:00 committed by Baptiste Lemoine
parent 4522b0c3a8
commit 6beaa79ab3

View File

@ -6,20 +6,22 @@ export default class CharacterCounter extends React.PureComponent {
static propTypes = { static propTypes = {
text: PropTypes.string.isRequired, text: PropTypes.string.isRequired,
max: PropTypes.number.isRequired, max : PropTypes.number.isRequired,
}; };
checkRemainingText (diff) { checkRemainingText(textlength, max) {
const diff = this.props.max - textlength;
if (diff < 0) { if (diff < 0) {
return <span className='character-counter character-counter--over'>{diff}</span>; return <span className='character-counter character-counter--over'>{diff}</span >;
} }
return <span className='character-counter'>{diff}</span>; return <span className='character-counter'>{textlength} / {max}</span >;
} }
render () { render() {
const diff = this.props.max - length(this.props.text);
return this.checkRemainingText(diff); const leng = length(this.props.text);
return this.checkRemainingText(leng, this.props.max);
} }
} }