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.

64 lines
2.7 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import Avatar from '../../../components/avatar';
  4. import DisplayName from '../../../components/display_name';
  5. import StatusContent from '../../../components/status_content';
  6. import MediaGallery from '../../../components/media_gallery';
  7. import VideoPlayer from '../../../components/video_player';
  8. import moment from 'moment';
  9. const DetailedStatus = React.createClass({
  10. contextTypes: {
  11. router: React.PropTypes.object
  12. },
  13. propTypes: {
  14. status: ImmutablePropTypes.map.isRequired,
  15. onOpenMedia: React.PropTypes.func.isRequired
  16. },
  17. mixins: [PureRenderMixin],
  18. handleAccountClick (e) {
  19. if (e.button === 0) {
  20. e.preventDefault();
  21. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  22. }
  23. e.stopPropagation();
  24. },
  25. render () {
  26. const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
  27. let media = '';
  28. if (status.get('media_attachments').size > 0) {
  29. if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  30. media = <VideoPlayer media={status.getIn(['media_attachments', 0])} width={317} height={178} />;
  31. } else {
  32. media = <MediaGallery media={status.get('media_attachments')} height={300} onOpenMedia={this.props.onOpenMedia} />;
  33. }
  34. }
  35. return (
  36. <div style={{ background: '#2f3441', padding: '14px 10px' }} className='detailed-status'>
  37. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='detailed-status__display-name' style={{ display: 'block', overflow: 'hidden', marginBottom: '15px' }}>
  38. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={status.getIn(['account', 'avatar'])} size={48} /></div>
  39. <DisplayName account={status.get('account')} />
  40. </a>
  41. <StatusContent status={status} />
  42. {media}
  43. <div style={{ marginTop: '15px', color: '#616b86', fontSize: '14px', lineHeight: '18px' }}>
  44. <a className='detailed-status__datetime' style={{ color: 'inherit' }} href={status.get('url')} target='_blank' rel='noopener'>{moment(status.get('created_at')).format('HH:mm, DD MMM Y')}</a> · <i className='fa fa-retweet' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}>{status.get('reblogs_count')}</span> · <i className='fa fa-star' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}>{status.get('favourites_count')}</span>
  45. </div>
  46. </div>
  47. );
  48. }
  49. });
  50. export default DetailedStatus;