bigbuffet-rw/app/soapbox/features/ui/components/profile_stats.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

import classNames from 'classnames';
2021-09-13 11:09:11 -07:00
import PropTypes from 'prop-types';
import React from 'react';
2021-09-13 11:09:11 -07:00
import ImmutablePropTypes from 'react-immutable-proptypes';
import { injectIntl, defineMessages } from 'react-intl';
import { NavLink } from 'react-router-dom';
2022-01-10 14:01:24 -08:00
import { shortNumberFormat } from 'soapbox/utils/numbers';
2021-09-13 11:09:11 -07:00
const messages = defineMessages({
followers: { id: 'account.followers', defaultMessage: 'Followers' },
follows: { id: 'account.follows', defaultMessage: 'Follows' },
});
export default @injectIntl
class ProfileStats extends React.PureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
account: ImmutablePropTypes.map.isRequired,
className: PropTypes.string,
2021-09-13 11:09:11 -07:00
}
render() {
const { intl, className } = this.props;
2021-09-13 11:09:11 -07:00
const { account } = this.props;
if (!account) {
return null;
}
const acct = account.get('acct');
return (
<div className={classNames('profile-stats', className)}>
2021-09-13 11:14:15 -07:00
<NavLink className='profile-stat' to={`/@${acct}/followers`} onClick={this.handleClose} title={intl.formatNumber(account.get('followers_count'))}>
<strong className='profile-stat__value'>
{shortNumberFormat(account.get('followers_count'))}
</strong>
<span className='profile-stat__label'>
{intl.formatMessage(messages.followers)}
</span>
2021-09-13 11:09:11 -07:00
</NavLink>
2021-09-13 11:14:15 -07:00
<NavLink className='profile-stat' to={`/@${acct}/following`} onClick={this.handleClose} title={intl.formatNumber(account.get('following_count'))}>
<strong className='profile-stat__value'>
{shortNumberFormat(account.get('following_count'))}
</strong>
<span className='profile-stat__label'>
{intl.formatMessage(messages.follows)}
</span>
2021-09-13 11:09:11 -07:00
</NavLink>
</div>
);
}
}