You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.4 KiB
121 lines
3.4 KiB
7 years ago
|
// Package imports.
|
||
8 years ago
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||
|
|
||
7 years ago
|
// Mastodon imports.
|
||
7 years ago
|
import Avatar from './avatar';
|
||
|
import AvatarOverlay from './avatar_overlay';
|
||
|
import DisplayName from './display_name';
|
||
|
import IconButton from './icon_button';
|
||
|
import VisibilityIcon from './status_visibility_icon';
|
||
8 years ago
|
|
||
7 years ago
|
// Messages for use with internationalization stuff.
|
||
8 years ago
|
const messages = defineMessages({
|
||
|
collapse: { id: 'status.collapse', defaultMessage: 'Collapse' },
|
||
|
uncollapse: { id: 'status.uncollapse', defaultMessage: 'Uncollapse' },
|
||
8 years ago
|
public: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
||
|
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
|
||
|
private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
||
|
direct: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
||
8 years ago
|
});
|
||
|
|
||
|
@injectIntl
|
||
|
export default class StatusHeader extends React.PureComponent {
|
||
|
|
||
|
static propTypes = {
|
||
7 years ago
|
status: ImmutablePropTypes.map.isRequired,
|
||
8 years ago
|
friend: ImmutablePropTypes.map,
|
||
|
mediaIcon: PropTypes.string,
|
||
|
collapsible: PropTypes.bool,
|
||
|
collapsed: PropTypes.bool,
|
||
|
parseClick: PropTypes.func.isRequired,
|
||
|
setExpansion: PropTypes.func.isRequired,
|
||
|
intl: PropTypes.object.isRequired,
|
||
|
};
|
||
|
|
||
7 years ago
|
// Handles clicks on collapsed button
|
||
8 years ago
|
handleCollapsedClick = (e) => {
|
||
|
const { collapsed, setExpansion } = this.props;
|
||
|
if (e.button === 0) {
|
||
|
setExpansion(collapsed ? null : false);
|
||
|
e.preventDefault();
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
// Handles clicks on account name/image
|
||
8 years ago
|
handleAccountClick = (e) => {
|
||
7 years ago
|
const { status, parseClick } = this.props;
|
||
|
parseClick(e, `/accounts/${+status.getIn(['account', 'id'])}`);
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
// Rendering.
|
||
8 years ago
|
render () {
|
||
|
const {
|
||
7 years ago
|
status,
|
||
8 years ago
|
friend,
|
||
|
mediaIcon,
|
||
|
collapsible,
|
||
|
collapsed,
|
||
|
intl,
|
||
|
} = this.props;
|
||
|
|
||
7 years ago
|
const account = status.get('account');
|
||
8 years ago
|
|
||
8 years ago
|
return (
|
||
|
<header className='status__info'>
|
||
7 years ago
|
<a
|
||
|
href={account.get('url')}
|
||
|
target='_blank'
|
||
|
className='status__avatar'
|
||
|
onClick={this.handleAccountClick}
|
||
|
>
|
||
7 years ago
|
{
|
||
|
friend ? (
|
||
|
<AvatarOverlay account={account} friend={friend} />
|
||
|
) : (
|
||
|
<Avatar account={account} size={48} />
|
||
|
)
|
||
|
}
|
||
7 years ago
|
</a>
|
||
|
<a
|
||
|
href={account.get('url')}
|
||
|
target='_blank'
|
||
|
className='status__display-name'
|
||
|
onClick={this.handleAccountClick}
|
||
|
>
|
||
|
<DisplayName account={account} />
|
||
|
</a>
|
||
8 years ago
|
<div className='status__info__icons'>
|
||
|
{mediaIcon ? (
|
||
|
<i
|
||
|
className={`fa fa-fw fa-${mediaIcon}`}
|
||
|
aria-hidden='true'
|
||
|
/>
|
||
|
) : null}
|
||
8 years ago
|
{(
|
||
7 years ago
|
<VisibilityIcon visibility={status.get('visibility')} />
|
||
8 years ago
|
)}
|
||
8 years ago
|
{collapsible ? (
|
||
|
<IconButton
|
||
|
className='status__collapse-button'
|
||
|
animate flip
|
||
|
active={collapsed}
|
||
|
title={
|
||
|
collapsed ?
|
||
|
intl.formatMessage(messages.uncollapse) :
|
||
|
intl.formatMessage(messages.collapse)
|
||
|
}
|
||
|
icon='angle-double-up'
|
||
|
onClick={this.handleCollapsedClick}
|
||
|
/>
|
||
|
) : null}
|
||
|
</div>
|
||
|
|
||
|
</header>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|