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.

62 lines
1.5 KiB

7 years ago
  1. // Package imports.
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. // Mastodon imports.
  6. import Avatar from './avatar';
  7. import AvatarOverlay from './avatar_overlay';
  8. import DisplayName from './display_name';
  9. export default class StatusHeader extends React.PureComponent {
  10. static propTypes = {
  11. status: ImmutablePropTypes.map.isRequired,
  12. friend: ImmutablePropTypes.map,
  13. parseClick: PropTypes.func.isRequired,
  14. };
  15. // Handles clicks on account name/image
  16. handleAccountClick = (e) => {
  17. const { status, parseClick } = this.props;
  18. parseClick(e, `/accounts/${+status.getIn(['account', 'id'])}`);
  19. }
  20. // Rendering.
  21. render () {
  22. const {
  23. status,
  24. friend,
  25. } = this.props;
  26. const account = status.get('account');
  27. return (
  28. <div className='status__info__account' >
  29. <a
  30. href={account.get('url')}
  31. target='_blank'
  32. className='status__avatar'
  33. onClick={this.handleAccountClick}
  34. >
  35. {
  36. friend ? (
  37. <AvatarOverlay account={account} friend={friend} />
  38. ) : (
  39. <Avatar account={account} size={48} />
  40. )
  41. }
  42. </a>
  43. <a
  44. href={account.get('url')}
  45. target='_blank'
  46. className='status__display-name'
  47. onClick={this.handleAccountClick}
  48. >
  49. <DisplayName account={account} />
  50. </a>
  51. </div>
  52. );
  53. }
  54. }