2019-07-02 08:10:25 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
2019-08-07 06:02:36 +01:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2019-07-02 08:10:25 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2019-08-07 06:02:36 +01:00
|
|
|
import { autoPlayGif, me } from '../../initial_state';
|
|
|
|
import { makeGetAccount } from '../../selectors';
|
|
|
|
import Avatar from '../avatar';
|
|
|
|
import { shortNumberFormat } from '../../utils/numbers';
|
2019-07-02 08:10:25 +01:00
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
import './user_panel.scss';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
gabs: { id:'account.posts', defaultMessage: 'Gabs' },
|
|
|
|
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
|
|
|
follows: { id: 'account.follows', defaultMessage: 'Follows' }
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
return {
|
|
|
|
account: getAccount(state, me),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
@injectIntl
|
2019-07-02 08:10:25 +01:00
|
|
|
class UserPanel extends ImmutablePureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-08-07 06:02:36 +01:00
|
|
|
const { account, intl } = this.props;
|
2019-07-02 08:10:25 +01:00
|
|
|
const displayNameHtml = { __html: account.get('display_name_html') };
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='user-panel'>
|
|
|
|
<div className='user-panel__container'>
|
|
|
|
|
|
|
|
<div className='user-panel__header'>
|
|
|
|
<img src={autoPlayGif ? account.get('header') : account.get('header_static')} alt='' />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='user-panel__profile'>
|
2019-08-07 06:02:36 +01:00
|
|
|
<Link to={`/${account.get('acct')}`} title={account.get('acct')}>
|
2019-07-03 04:42:28 +01:00
|
|
|
<Avatar account={account} />
|
2019-07-02 08:10:25 +01:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='user-panel__meta'>
|
|
|
|
|
|
|
|
<div className='user-panel__account'>
|
|
|
|
<h1>
|
|
|
|
<Link to={`/${account.get('acct')}`}>
|
|
|
|
<span className='user-panel__account__name' dangerouslySetInnerHTML={displayNameHtml} />
|
2019-08-07 06:02:36 +01:00
|
|
|
<small className='user-panel__account__username'>@{account.get('acct')}</small>
|
2019-07-02 08:10:25 +01:00
|
|
|
</Link>
|
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='user-panel__stats-block'>
|
|
|
|
|
|
|
|
<div className='user-panel-stats-item'>
|
|
|
|
<Link to={`/${account.get('acct')}`} title={intl.formatNumber(account.get('statuses_count'))}>
|
|
|
|
<strong className='user-panel-stats-item__value'>{shortNumberFormat(account.get('statuses_count'))}</strong>
|
2019-08-07 06:02:36 +01:00
|
|
|
<span className='user-panel-stats-item__label'>{intl.formatMessage(messages.gabs)}</span>
|
2019-07-02 08:10:25 +01:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='user-panel-stats-item'>
|
|
|
|
<Link to={`/${account.get('acct')}/followers`} title={intl.formatNumber(account.get('followers_count'))}>
|
|
|
|
<strong className='user-panel-stats-item__value'>{shortNumberFormat(account.get('followers_count'))}</strong>
|
2019-08-07 06:02:36 +01:00
|
|
|
<span className='user-panel-stats-item__label'>{intl.formatMessage(messages.followers)}</span>
|
2019-07-02 08:10:25 +01:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='user-panel-stats-item'>
|
|
|
|
<Link to={`/${account.get('acct')}/following`} title={intl.formatNumber(account.get('following_count'))}>
|
|
|
|
<strong className='user-panel-stats-item__value'>{shortNumberFormat(account.get('following_count'))}</strong>
|
2019-08-07 06:02:36 +01:00
|
|
|
<span className='user-panel-stats-item__label'>{intl.formatMessage(messages.follows)}</span>
|
2019-07-02 08:10:25 +01:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
};
|