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.

59 lines
2.1 KiB

7 years ago
  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import Avatar from '../../../components/avatar';
  4. import IconButton from '../../../components/icon_button';
  5. import DisplayName from '../../../components/display_name';
  6. import emojify from '../../../emoji';
  7. import { defineMessages, injectIntl } from 'react-intl';
  8. const messages = defineMessages({
  9. cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' }
  10. });
  11. const ReplyIndicator = React.createClass({
  12. contextTypes: {
  13. router: React.PropTypes.object
  14. },
  15. propTypes: {
  16. status: ImmutablePropTypes.map.isRequired,
  17. onCancel: React.PropTypes.func.isRequired
  18. },
  19. mixins: [PureRenderMixin],
  20. handleClick () {
  21. this.props.onCancel();
  22. },
  23. handleAccountClick (e) {
  24. if (e.button === 0) {
  25. e.preventDefault();
  26. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  27. }
  28. },
  29. render () {
  30. const { intl } = this.props;
  31. const content = { __html: emojify(this.props.status.get('content')) };
  32. return (
  33. <div style={{ background: '#9baec8', padding: '10px' }}>
  34. <div style={{ overflow: 'hidden', marginBottom: '5px' }}>
  35. <div style={{ float: 'right', lineHeight: '24px' }}><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} /></div>
  36. <a href={this.props.status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name' style={{ display: 'block', maxWidth: '100%', paddingRight: '25px', color: '#282c37', textDecoration: 'none', overflow: 'hidden', lineHeight: '24px' }}>
  37. <div style={{ float: 'left', marginRight: '5px' }}><Avatar size={24} src={this.props.status.getIn(['account', 'avatar'])} /></div>
  38. <DisplayName account={this.props.status.get('account')} />
  39. </a>
  40. </div>
  41. <div className='reply-indicator__content' dangerouslySetInnerHTML={content} />
  42. </div>
  43. );
  44. }
  45. });
  46. export default injectIntl(ReplyIndicator);