The code powering m.abunchtell.com https://m.abunchtell.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

76 行
2.3 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import Avatar from '../../../components/avatar';
  5. import IconButton from '../../../components/icon_button';
  6. import DisplayName from '../../../components/display_name';
  7. import { defineMessages, injectIntl } from 'react-intl';
  8. import ImmutablePureComponent from 'react-immutable-pure-component';
  9. import { isRtl } from '../../../rtl';
  10. import AttachmentList from 'mastodon/components/attachment_list';
  11. const messages = defineMessages({
  12. cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
  13. });
  14. export default @injectIntl
  15. class ReplyIndicator extends ImmutablePureComponent {
  16. static contextTypes = {
  17. router: PropTypes.object,
  18. };
  19. static propTypes = {
  20. status: ImmutablePropTypes.map,
  21. onCancel: PropTypes.func.isRequired,
  22. intl: PropTypes.object.isRequired,
  23. };
  24. handleClick = () => {
  25. this.props.onCancel();
  26. }
  27. handleAccountClick = (e) => {
  28. if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
  29. e.preventDefault();
  30. this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  31. }
  32. }
  33. render () {
  34. const { status, intl } = this.props;
  35. if (!status) {
  36. return null;
  37. }
  38. const content = { __html: status.get('contentHtml') };
  39. const style = {
  40. direction: isRtl(status.get('search_index')) ? 'rtl' : 'ltr',
  41. };
  42. return (
  43. <div className='reply-indicator'>
  44. <div className='reply-indicator__header'>
  45. <div className='reply-indicator__cancel'><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} inverted /></div>
  46. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name'>
  47. <div className='reply-indicator__display-avatar'><Avatar account={status.get('account')} size={24} /></div>
  48. <DisplayName account={status.get('account')} />
  49. </a>
  50. </div>
  51. <div className='reply-indicator__content' style={style} dangerouslySetInnerHTML={content} />
  52. {status.get('media_attachments').size > 0 && (
  53. <AttachmentList
  54. compact
  55. media={status.get('media_attachments')}
  56. />
  57. )}
  58. </div>
  59. );
  60. }
  61. }