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.

102 lines
3.1 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import StatusContainer from '../../../containers/status_container';
  4. import AccountContainer from '../../../containers/account_container';
  5. import { FormattedMessage } from 'react-intl';
  6. import Permalink from '../../../components/permalink';
  7. const messageStyle = {
  8. marginLeft: '68px',
  9. padding: '8px 0',
  10. paddingBottom: '0',
  11. cursor: 'default',
  12. color: '#d9e1e8',
  13. fontSize: '15px',
  14. position: 'relative'
  15. };
  16. const linkStyle = {
  17. fontWeight: '500'
  18. };
  19. const Notification = React.createClass({
  20. propTypes: {
  21. notification: ImmutablePropTypes.map.isRequired
  22. },
  23. mixins: [PureRenderMixin],
  24. renderFollow (account, link) {
  25. return (
  26. <div className='notification'>
  27. <div style={messageStyle}>
  28. <div style={{ position: 'absolute', 'left': '-26px'}}>
  29. <i className='fa fa-fw fa-user-plus' style={{ color: '#2b90d9' }} />
  30. </div>
  31. <FormattedMessage id='notification.follow' defaultMessage='{name} followed you' values={{ name: link }} />
  32. </div>
  33. <AccountContainer id={account.get('id')} withNote={false} />
  34. </div>
  35. );
  36. },
  37. renderMention (notification) {
  38. return <StatusContainer id={notification.get('status')} />;
  39. },
  40. renderFavourite (notification, link) {
  41. return (
  42. <div className='notification'>
  43. <div style={messageStyle}>
  44. <div style={{ position: 'absolute', 'left': '-26px'}}>
  45. <i className='fa fa-fw fa-star' style={{ color: '#ca8f04' }} />
  46. </div>
  47. <FormattedMessage id='notification.favourite' defaultMessage='{name} favourited your status' values={{ name: link }} />
  48. </div>
  49. <StatusContainer id={notification.get('status')} muted={true} />
  50. </div>
  51. );
  52. },
  53. renderReblog (notification, link) {
  54. return (
  55. <div className='notification'>
  56. <div style={messageStyle}>
  57. <div style={{ position: 'absolute', 'left': '-26px'}}>
  58. <i className='fa fa-fw fa-retweet' style={{ color: '#2b90d9' }} />
  59. </div>
  60. <FormattedMessage id='notification.reblog' defaultMessage='{name} boosted your status' values={{ name: link }} />
  61. </div>
  62. <StatusContainer id={notification.get('status')} muted={true} />
  63. </div>
  64. );
  65. },
  66. render () {
  67. const { notification } = this.props;
  68. const account = notification.get('account');
  69. const displayName = account.get('display_name').length > 0 ? account.get('display_name') : account.get('username');
  70. const link = <Permalink className='notification__display-name' style={linkStyle} href={account.get('url')} to={`/accounts/${account.get('id')}`}>{displayName}</Permalink>;
  71. switch(notification.get('type')) {
  72. case 'follow':
  73. return this.renderFollow(account, link);
  74. case 'mention':
  75. return this.renderMention(notification);
  76. case 'favourite':
  77. return this.renderFavourite(notification, link);
  78. case 'reblog':
  79. return this.renderReblog(notification, link);
  80. }
  81. }
  82. });
  83. export default Notification;