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.
 
 
 
 

96 regels
2.3 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import Avatar from '../../../components/avatar';
  4. import DisplayName from '../../../components/display_name';
  5. import { Link } from 'react-router';
  6. import IconButton from '../../../components/icon_button';
  7. import { injectIntl } from 'react-intl';
  8. const outerStyle = {
  9. padding: '10px',
  10. borderBottom: '1px solid #363c4b'
  11. };
  12. const itemStyle = {
  13. flex: '1 1 auto',
  14. display: 'block',
  15. color: '#9baec8',
  16. overflow: 'hidden',
  17. textDecoration: 'none',
  18. fontSize: '14px'
  19. };
  20. const noteStyle = {
  21. paddingTop: '5px',
  22. fontSize: '12px',
  23. color: '#616b86'
  24. };
  25. const buttonsStyle = {
  26. padding: '10px'
  27. };
  28. const Account = React.createClass({
  29. propTypes: {
  30. account: ImmutablePropTypes.map.isRequired,
  31. me: React.PropTypes.number.isRequired,
  32. onFollow: React.PropTypes.func.isRequired,
  33. withNote: React.PropTypes.bool
  34. },
  35. getDefaultProps () {
  36. return {
  37. withNote: true
  38. };
  39. },
  40. mixins: [PureRenderMixin],
  41. handleFollow () {
  42. this.props.onFollow(this.props.account);
  43. },
  44. render () {
  45. const { account, me, withNote, intl } = this.props;
  46. if (!account) {
  47. return <div />;
  48. }
  49. let note, buttons;
  50. if (account.get('note').length > 0 && withNote) {
  51. note = <div style={noteStyle}>{account.get('note')}</div>;
  52. }
  53. if (account.get('id') !== me) {
  54. const following = account.getIn(['relationship', 'following']);
  55. buttons = (
  56. <div style={buttonsStyle}>
  57. <IconButton icon={following ? 'user-times' : 'user-plus'} title={intl.formatMessage({ id: 'account.follow', defaultMessage: 'Follow' })} onClick={this.handleFollow} active={following} />
  58. </div>
  59. );
  60. }
  61. return (
  62. <div style={outerStyle}>
  63. <div style={{ display: 'flex' }}>
  64. <Link key={account.get('id')} style={itemStyle} className='account__display-name' to={`/accounts/${account.get('id')}`}>
  65. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={36} /></div>
  66. <DisplayName account={account} />
  67. </Link>
  68. {buttons}
  69. </div>
  70. {note}
  71. </div>
  72. );
  73. }
  74. });
  75. export default injectIntl(Account);