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.
 
 
 
 

80 lines
2.7 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 { Link } from 'react-router';
  7. const messageStyle = {
  8. padding: '8px 10px',
  9. paddingBottom: '0',
  10. cursor: 'default',
  11. color: '#d9e1e8',
  12. fontSize: '15px'
  13. };
  14. const linkStyle = {
  15. fontWeight: '500'
  16. };
  17. const Notification = React.createClass({
  18. propTypes: {
  19. notification: ImmutablePropTypes.map.isRequired
  20. },
  21. mixins: [PureRenderMixin],
  22. renderFollow (account, link) {
  23. return (
  24. <div className='notification'>
  25. <div style={messageStyle}><i className='fa fa-fw fa-user-plus' style={{ color: '#2b90d9' }} /> <FormattedMessage id='notification.follow' defaultMessage='{name} followed you' values={{ name: link }} /></div>
  26. <AccountContainer id={account.get('id')} withNote={false} />
  27. </div>
  28. );
  29. },
  30. renderMention (notification) {
  31. return <StatusContainer id={notification.get('status')} />;
  32. },
  33. renderFavourite (notification, link) {
  34. return (
  35. <div className='notification'>
  36. <div style={messageStyle}><i className='fa fa-fw fa-star' style={{ color: '#ca8f04' }} /> <FormattedMessage id='notification.favourite' defaultMessage='{name} favourited your status' values={{ name: link }} /></div>
  37. <StatusContainer id={notification.get('status')} muted={true} />
  38. </div>
  39. );
  40. },
  41. renderReblog (notification, link) {
  42. return (
  43. <div className='notification'>
  44. <div style={messageStyle}><i className='fa fa-fw fa-retweet' style={{ color: '#2b90d9' }} /> <FormattedMessage id='notification.reblog' defaultMessage='{name} reblogged your status' values={{ name: link }} /></div>
  45. <StatusContainer id={notification.get('status')} muted={true} />
  46. </div>
  47. );
  48. },
  49. render () {
  50. const { notification } = this.props;
  51. const account = notification.get('account');
  52. const displayName = account.get('display_name').length > 0 ? account.get('display_name') : account.get('username');
  53. const link = <Link className='notification__display-name' style={linkStyle} to={`/accounts/${account.get('id')}`}>{displayName}</Link>;
  54. switch(notification.get('type')) {
  55. case 'follow':
  56. return this.renderFollow(account, link);
  57. case 'mention':
  58. return this.renderMention(notification);
  59. case 'favourite':
  60. return this.renderFavourite(notification, link);
  61. case 'reblog':
  62. return this.renderReblog(notification, link);
  63. }
  64. }
  65. });
  66. export default Notification;