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.

84 lines
1.9 KiB

7 years ago
  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. const outerStyle = {
  7. marginBottom: '10px',
  8. borderTop: '1px solid #616b86'
  9. };
  10. const headerStyle = {
  11. fontSize: '14px',
  12. fontWeight: '500',
  13. display: 'block',
  14. padding: '10px',
  15. color: '#9baec8',
  16. background: '#454b5e',
  17. width: '120px',
  18. marginTop: '-18px'
  19. };
  20. const itemStyle = {
  21. display: 'block',
  22. padding: '10px',
  23. color: '#9baec8',
  24. overflow: 'hidden',
  25. textDecoration: 'none'
  26. };
  27. const displayNameStyle = {
  28. display: 'block',
  29. fontWeight: '500',
  30. overflow: 'hidden',
  31. textOverflow: 'ellipsis'
  32. };
  33. const acctStyle = {
  34. display: 'block',
  35. overflow: 'hidden',
  36. textOverflow: 'ellipsis'
  37. };
  38. const SuggestionsBox = React.createClass({
  39. propTypes: {
  40. accounts: ImmutablePropTypes.list.isRequired
  41. },
  42. mixins: [PureRenderMixin],
  43. render () {
  44. const accounts = this.props.accounts.take(3);
  45. if (accounts.size === 0) {
  46. return <div />;
  47. }
  48. return (
  49. <div style={outerStyle}>
  50. <strong style={headerStyle}>Who to follow</strong>
  51. {accounts.map(account => {
  52. let displayName = account.get('display_name');
  53. if (displayName.length === 0) {
  54. displayName = account.get('username');
  55. }
  56. return (
  57. <Link key={account.get('id')} style={itemStyle} to={`/accounts/${account.get('id')}`}>
  58. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={36} /></div>
  59. <strong style={displayNameStyle}>{displayName}</strong>
  60. <span style={acctStyle}>{account.get('acct')}</span>
  61. </Link>
  62. )
  63. })}
  64. </div>
  65. );
  66. }
  67. });
  68. export default SuggestionsBox;