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.

86 lines
3.3 KiB

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