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.

92 lines
3.6 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import Avatar from './avatar';
  3. import RelativeTimestamp from './relative_timestamp';
  4. import PureRenderMixin from 'react-addons-pure-render-mixin';
  5. import IconButton from './icon_button';
  6. import DisplayName from './display_name';
  7. import MediaGallery from './media_gallery';
  8. import { hashHistory } from 'react-router';
  9. const Status = React.createClass({
  10. propTypes: {
  11. status: ImmutablePropTypes.map.isRequired,
  12. wrapped: React.PropTypes.bool,
  13. onReply: React.PropTypes.func,
  14. onFavourite: React.PropTypes.func,
  15. onReblog: React.PropTypes.func
  16. },
  17. mixins: [PureRenderMixin],
  18. handleReplyClick () {
  19. this.props.onReply(this.props.status);
  20. },
  21. handleFavouriteClick () {
  22. this.props.onFavourite(this.props.status);
  23. },
  24. handleReblogClick () {
  25. this.props.onReblog(this.props.status);
  26. },
  27. handleClick () {
  28. hashHistory.push(`/statuses/${this.props.status.get('id')}`);
  29. },
  30. render () {
  31. var content = { __html: this.props.status.get('content') };
  32. var media = '';
  33. var { status, ...other } = this.props;
  34. if (status.get('reblog') !== null) {
  35. return (
  36. <div style={{ cursor: 'pointer' }} onClick={this.handleClick}>
  37. <div style={{ marginLeft: '68px', color: '#616b86', padding: '8px 0', paddingBottom: '2px', fontSize: '14px', position: 'relative' }}>
  38. <div style={{ position: 'absolute', 'left': '-26px'}}><i className='fa fa-fw fa-retweet'></i></div>
  39. <a href={status.getIn(['account', 'url'])} className='status__display-name'><strong style={{ color: '#616b86'}}>{status.getIn(['account', 'display_name'])}</strong></a> reblogged
  40. </div>
  41. <Status {...other} wrapped={true} status={status.get('reblog')} />
  42. </div>
  43. );
  44. }
  45. if (status.get('media_attachments').size > 0) {
  46. media = <MediaGallery media={status.get('media_attachments')} />;
  47. }
  48. return (
  49. <div style={{ padding: '8px 10px', paddingLeft: '68px', position: 'relative', minHeight: '48px', borderBottom: '1px solid #363c4b', cursor: 'pointer' }} onClick={this.handleClick}>
  50. <div style={{ fontSize: '15px' }}>
  51. <div style={{ float: 'right', fontSize: '14px' }}>
  52. <a href={status.get('url')} className='status__relative-time' style={{ color: '#616b86' }}><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  53. </div>
  54. <a href={status.getIn(['account', 'url'])} className='status__display-name' style={{ display: 'block', maxWidth: '100%', paddingRight: '25px', color: '#616b86' }}>
  55. <div style={{ position: 'absolute', left: '10px', top: '10px', width: '48px', height: '48px' }}>
  56. <Avatar src={status.getIn(['account', 'avatar'])} size={48} />
  57. </div>
  58. <DisplayName account={status.get('account')} />
  59. </a>
  60. </div>
  61. <div className='status__content' dangerouslySetInnerHTML={content} />
  62. {media}
  63. <div style={{ marginTop: '10px', overflow: 'hidden' }}>
  64. <div style={{ float: 'left', marginRight: '10px'}}><IconButton title='Reply' icon='reply' onClick={this.handleReplyClick} /></div>
  65. <div style={{ float: 'left', marginRight: '10px'}}><IconButton active={status.get('reblogged')} title='Reblog' icon='retweet' onClick={this.handleReblogClick} /></div>
  66. <div style={{ float: 'left'}}><IconButton active={status.get('favourited')} title='Favourite' icon='star' onClick={this.handleFavouriteClick} /></div>
  67. </div>
  68. </div>
  69. );
  70. }
  71. });
  72. export default Status;