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.
 
 
 
 

100 lines
2.3 KiB

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