about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx
blob: 50229eb691488cffc70bd26d5230b77d3efad25c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import PureRenderMixin    from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Avatar             from '../../../components/avatar';
import DisplayName        from '../../../components/display_name';
import { Link }           from 'react-router';

const outerStyle = {
  marginBottom: '10px',
  borderTop: '1px solid #616b86'
};

const headerStyle = {
  fontSize: '14px',
  fontWeight: '500',
  display: 'block',
  padding: '10px',
  color: '#9baec8',
  background: '#454b5e',
  width: '120px',
  marginTop: '-18px'
};

const itemStyle = {
  display: 'block',
  padding: '10px',
  color: '#9baec8',
  overflow: 'hidden',
  textDecoration: 'none'
};

const displayNameStyle = {
  display: 'block',
  fontWeight: '500',
  overflow: 'hidden',
  textOverflow: 'ellipsis'
};

const acctStyle = {
  display: 'block',
  overflow: 'hidden',
  textOverflow: 'ellipsis'
};

const SuggestionsBox = React.createClass({

  propTypes: {
    accounts: ImmutablePropTypes.list.isRequired
  },

  mixins: [PureRenderMixin],

  render () {
    const accounts = this.props.accounts.take(3);

    if (accounts.size === 0) {
      return <div />;
    }

    return (
      <div style={outerStyle}>
        <strong style={headerStyle}>Who to follow</strong>

        {accounts.map(account => {
          let displayName = account.get('display_name');

          if (displayName.length === 0) {
            displayName = account.get('username');
          }

          return (
            <Link key={account.get('id')} style={itemStyle} to={`/accounts/${account.get('id')}`}>
              <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={36} /></div>
              <strong style={displayNameStyle}>{displayName}</strong>
              <span style={acctStyle}>{account.get('acct')}</span>
            </Link>
          )
        })}
      </div>
    );
  }

});

export default SuggestionsBox;