The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

75 lines
3.6 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 { Link } from 'react-router';
  9. import { FormattedDate, FormattedNumber } from 'react-intl';
  10. import CardContainer from '../containers/card_container';
  11. const DetailedStatus = React.createClass({
  12. contextTypes: {
  13. router: React.PropTypes.object
  14. },
  15. propTypes: {
  16. status: ImmutablePropTypes.map.isRequired,
  17. onOpenMedia: React.PropTypes.func.isRequired
  18. },
  19. mixins: [PureRenderMixin],
  20. handleAccountClick (e) {
  21. if (e.button === 0) {
  22. e.preventDefault();
  23. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  24. }
  25. e.stopPropagation();
  26. },
  27. render () {
  28. const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
  29. let media = '';
  30. let applicationLink = '';
  31. if (status.get('media_attachments').size > 0) {
  32. if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  33. media = <VideoPlayer sensitive={status.get('sensitive')} media={status.getIn(['media_attachments', 0])} width={317} height={178} />;
  34. } else {
  35. media = <MediaGallery sensitive={status.get('sensitive')} media={status.get('media_attachments')} height={300} onOpenMedia={this.props.onOpenMedia} />;
  36. }
  37. } else {
  38. media = <CardContainer statusId={status.get('id')} />;
  39. }
  40. if (status.get('application')) {
  41. applicationLink = <span> · <a className='detailed-status__application' style={{ color: 'inherit' }} href={status.getIn(['application', 'website'])} target='_blank' rel='nooopener'>{status.getIn(['application', 'name'])}</a></span>;
  42. }
  43. return (
  44. <div style={{ background: '#2f3441', padding: '14px 10px' }} className='detailed-status'>
  45. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='detailed-status__display-name' style={{ display: 'block', overflow: 'hidden', marginBottom: '15px' }}>
  46. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={status.getIn(['account', 'avatar'])} size={48} /></div>
  47. <DisplayName account={status.get('account')} />
  48. </a>
  49. <StatusContent status={status} />
  50. {media}
  51. <div style={{ marginTop: '15px', color: '#616b86', fontSize: '14px', lineHeight: '18px' }}>
  52. <a className='detailed-status__datetime' style={{ color: 'inherit' }} href={status.get('url')} target='_blank' rel='noopener'><FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' /></a>{applicationLink} · <Link to={`/statuses/${status.get('id')}/reblogs`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-retweet' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('reblogs_count')} /></span></Link> · <Link to={`/statuses/${status.get('id')}/favourites`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-star' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('favourites_count')} /></span></Link>
  53. </div>
  54. </div>
  55. );
  56. }
  57. });
  58. export default DetailedStatus;