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.

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