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.
 
 
 
 

86 lines
2.8 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  5. import Button from '../../../components/button';
  6. import StatusContent from '../../../components/status_content';
  7. import Avatar from '../../../components/avatar';
  8. import RelativeTimestamp from '../../../components/relative_timestamp';
  9. import DisplayName from '../../../components/display_name';
  10. import ImmutablePureComponent from 'react-immutable-pure-component';
  11. const messages = defineMessages({
  12. reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
  13. });
  14. class BoostModal extends ImmutablePureComponent {
  15. static contextTypes = {
  16. router: PropTypes.object,
  17. };
  18. static propTypes = {
  19. status: ImmutablePropTypes.map.isRequired,
  20. onReblog: PropTypes.func.isRequired,
  21. onClose: PropTypes.func.isRequired,
  22. intl: PropTypes.object.isRequired,
  23. };
  24. componentDidMount() {
  25. this.button.focus();
  26. }
  27. handleReblog = () => {
  28. this.props.onReblog(this.props.status);
  29. this.props.onClose();
  30. }
  31. handleAccountClick = (e) => {
  32. if (e.button === 0) {
  33. e.preventDefault();
  34. this.props.onClose();
  35. this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  36. }
  37. }
  38. setRef = (c) => {
  39. this.button = c;
  40. }
  41. render () {
  42. const { status, intl } = this.props;
  43. return (
  44. <div className='modal-root__modal boost-modal'>
  45. <div className='boost-modal__container'>
  46. <div className='status light'>
  47. <div className='boost-modal__status-header'>
  48. <div className='boost-modal__status-time'>
  49. <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  50. </div>
  51. <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
  52. <div className='status__avatar'>
  53. <Avatar src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} size={48} />
  54. </div>
  55. <DisplayName account={status.get('account')} />
  56. </a>
  57. </div>
  58. <StatusContent status={status} />
  59. </div>
  60. </div>
  61. <div className='boost-modal__action-bar'>
  62. <div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div>
  63. <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
  64. </div>
  65. </div>
  66. );
  67. }
  68. }
  69. export default injectIntl(BoostModal);