bigbuffet-rw/app/soapbox/components/more_follows.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2020-05-27 17:36:23 -07:00
import { defineMessages, injectIntl } from 'react-intl';
2020-05-27 17:36:23 -07:00
const messages = defineMessages({
2020-06-06 12:06:45 -07:00
following: {
id: 'morefollows.following_label',
defaultMessage: '…and {count} more {count, plural, one {follow} other {follows}} on remote sites.',
2020-05-27 17:36:23 -07:00
},
2020-06-06 12:06:45 -07:00
followers: {
id: 'morefollows.followers_label',
defaultMessage: '…and {count} more {count, plural, one {follower} other {followers}} on remote sites.',
2020-05-27 17:36:23 -07:00
},
});
export default @injectIntl
class MoreFollows extends React.PureComponent {
static propTypes = {
visible: PropTypes.bool,
2020-05-27 17:36:23 -07:00
count: PropTypes.number,
type: PropTypes.string,
intl: PropTypes.object.isRequired,
}
static defaultProps = {
visible: true,
}
2020-05-27 17:36:23 -07:00
getMessage = () => {
const { type, count, intl } = this.props;
2020-06-06 12:06:45 -07:00
return intl.formatMessage(messages[type], { count });
2020-05-27 17:36:23 -07:00
}
2020-05-27 17:36:23 -07:00
render() {
return (
<div className='morefollows-indicator'>
<div>
<div className='morefollows-indicator__label' style={{ visibility: this.props.visible ? 'visible' : 'hidden' }}>
{this.getMessage()}
</div>
</div>
2020-05-27 17:36:23 -07:00
</div>
);
}
}