gab-social/app/javascript/gabsocial/components/panel/profile_stats_panel.js

76 lines
2.4 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
2020-02-28 15:20:47 +00:00
import { defineMessages, injectIntl } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
2020-11-15 18:48:32 +00:00
import { me } from '../../initial_state'
2020-02-28 15:20:47 +00:00
import { shortNumberFormat } from '../../utils/numbers'
import PanelLayout from './panel_layout'
import UserStat from '../user_stat'
2020-05-09 03:17:19 +01:00
import Dummy from '../dummy'
import ProfileStatsPanelPlaceholder from '../placeholder/profile_stats_panel_placeholder'
2020-05-09 03:17:19 +01:00
import ResponsiveClassesComponent from '../../features/ui/util/responsive_classes_component'
2020-02-28 15:20:47 +00:00
class ProfileStatsPanel extends ImmutablePureComponent {
render() {
2020-05-09 03:17:19 +01:00
const {
intl,
account,
noPanel
} = this.props
2020-02-28 15:20:47 +00:00
2020-05-09 03:17:19 +01:00
const Wrapper = noPanel ? Dummy : PanelLayout
2020-02-28 15:20:47 +00:00
return (
2020-05-09 03:17:19 +01:00
<Wrapper>
{
!account && !noPanel &&
<ProfileStatsPanelPlaceholder />
}
2020-02-28 15:20:47 +00:00
{
!!account &&
2020-05-09 03:17:19 +01:00
<ResponsiveClassesComponent
classNames={[_s.d, _s.flexRow].join(' ')}
2020-12-16 07:39:07 +00:00
classNamesXS={[_s.d, _s.flexRow, _s.mt15, _s.flexWrap].join(' ')}
2020-05-09 03:17:19 +01:00
>
2020-02-28 15:20:47 +00:00
<UserStat
title={intl.formatMessage(messages.gabs)}
value={shortNumberFormat(account.get('statuses_count'))}
to={`/${account.get('acct')}`}
2020-12-16 07:39:07 +00:00
isInline={noPanel}
2020-02-28 15:20:47 +00:00
/>
<UserStat
title={intl.formatMessage(messages.followers)}
value={shortNumberFormat(account.get('followers_count'))}
to={`/${account.get('acct')}/followers`}
2020-12-16 07:39:07 +00:00
isInline={noPanel}
2020-02-28 15:20:47 +00:00
/>
<UserStat
2020-12-16 07:39:07 +00:00
isLast
title={intl.formatMessage(messages.follows)}
value={shortNumberFormat(account.get('following_count'))}
to={`/${account.get('acct')}/following`}
2020-12-16 07:39:07 +00:00
isInline={noPanel}
/>
2020-05-09 03:17:19 +01:00
</ResponsiveClassesComponent>
2020-02-28 15:20:47 +00:00
}
2020-05-09 03:17:19 +01:00
</Wrapper>
2020-02-28 15:20:47 +00:00
)
}
}
const messages = defineMessages({
gabs: { id: 'account.gabs', defaultMessage: 'Gabs' },
followers: { id: 'account.followers', defaultMessage: 'Followers' },
follows: { id: 'account.follows', defaultMessage: 'Following' },
likes: { id: 'likes', defaultMessage: 'Likes' },
})
ProfileStatsPanel.propTypes = {
account: ImmutablePropTypes.map,
intl: PropTypes.object.isRequired,
noPanel: PropTypes.bool,
}
export default injectIntl(ProfileStatsPanel)