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

64 lines
2 KiB
JavaScript
Raw Normal View History

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
2022-03-21 11:09:01 -07:00
import { HStack, Text } from '../../../components/ui';
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,
2022-03-21 11:09:01 -07:00
onClickHandler: PropTypes.func,
2021-09-13 11:09:11 -07:00
}
render() {
2022-03-21 11:09:01 -07:00
const { intl } = this.props;
const { account, onClickHandler } = this.props;
2021-09-13 11:09:11 -07:00
if (!account) {
return null;
}
const acct = account.get('acct');
return (
2022-03-21 11:09:01 -07:00
<HStack alignItems='center' space={3}>
<NavLink to={`/@${acct}/followers`} onClick={onClickHandler} title={intl.formatNumber(account.get('followers_count'))}>
<HStack alignItems='center' space={1}>
<Text theme='primary' weight='bold' size='sm'>
{shortNumberFormat(account.get('followers_count'))}
</Text>
<Text weight='bold' size='sm'>
{intl.formatMessage(messages.followers)}
</Text>
</HStack>
2021-09-13 11:09:11 -07:00
</NavLink>
2021-09-13 11:14:15 -07:00
2022-03-21 11:09:01 -07:00
<NavLink to={`/@${acct}/following`} onClick={onClickHandler} title={intl.formatNumber(account.get('following_count'))}>
<HStack alignItems='center' space={1}>
<Text theme='primary' weight='bold' size='sm'>
{shortNumberFormat(account.get('following_count'))}
</Text>
<Text weight='bold' size='sm'>
{intl.formatMessage(messages.follows)}
</Text>
</HStack>
2021-09-13 11:09:11 -07:00
</NavLink>
2022-03-21 11:09:01 -07:00
</HStack>
2021-09-13 11:09:11 -07:00
);
}
}