2016-10-28 04:59:56 +09:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import Avatar from '../../../components/avatar';
|
2016-10-29 03:05:44 +09:00
|
|
|
import DisplayName from '../../../components/display_name';
|
2016-10-28 04:59:56 +09:00
|
|
|
import { Link } from 'react-router';
|
2016-10-29 03:05:44 +09:00
|
|
|
import IconButton from '../../../components/icon_button';
|
2016-10-28 04:59:56 +09:00
|
|
|
|
|
|
|
const outerStyle = {
|
2016-10-29 03:05:44 +09:00
|
|
|
padding: '10px',
|
|
|
|
borderBottom: '1px solid #363c4b'
|
2016-10-28 04:59:56 +09:00
|
|
|
};
|
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
const itemStyle = {
|
|
|
|
flex: '1 1 auto',
|
2016-10-28 04:59:56 +09:00
|
|
|
display: 'block',
|
2016-10-29 03:05:44 +09:00
|
|
|
color: '#9baec8',
|
2016-10-28 04:59:56 +09:00
|
|
|
overflow: 'hidden',
|
2016-10-29 03:05:44 +09:00
|
|
|
textDecoration: 'none',
|
|
|
|
fontSize: '14px'
|
2016-10-28 04:59:56 +09:00
|
|
|
};
|
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
const noteStyle = {
|
|
|
|
paddingTop: '5px',
|
|
|
|
fontSize: '12px',
|
|
|
|
color: '#616b86'
|
2016-10-28 04:59:56 +09:00
|
|
|
};
|
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
const buttonsStyle = {
|
|
|
|
padding: '10px'
|
2016-10-28 04:59:56 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
const Account = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
2016-10-29 03:05:44 +09:00
|
|
|
me: React.PropTypes.number.isRequired,
|
|
|
|
onFollow: React.PropTypes.func.isRequired,
|
|
|
|
withNote: React.PropTypes.bool
|
2016-10-28 04:59:56 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
handleFollow () {
|
|
|
|
this.props.onFollow(this.props.account);
|
|
|
|
},
|
|
|
|
|
2016-10-28 04:59:56 +09:00
|
|
|
render () {
|
2016-10-29 03:05:44 +09:00
|
|
|
const { account, me } = this.props;
|
2016-10-28 04:59:56 +09:00
|
|
|
|
|
|
|
if (!account) {
|
|
|
|
return <div />;
|
|
|
|
}
|
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
let note, buttons;
|
2016-10-28 04:59:56 +09:00
|
|
|
|
2016-10-29 03:05:44 +09:00
|
|
|
if (account.get('note').length > 0) {
|
|
|
|
note = <div style={noteStyle}>{account.get('note')}</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (account.get('id') !== me) {
|
|
|
|
buttons = (
|
|
|
|
<div style={buttonsStyle}>
|
|
|
|
<IconButton icon='user-plus' title='Follow' onClick={this.handleFollow} active={account.getIn(['relationship', 'following'])} />
|
|
|
|
</div>
|
|
|
|
);
|
2016-10-28 04:59:56 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={outerStyle}>
|
2016-10-29 03:05:44 +09:00
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
|
<Link key={account.get('id')} style={itemStyle} className='account__display-name' to={`/accounts/${account.get('id')}`}>
|
|
|
|
<div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={36} /></div>
|
|
|
|
<DisplayName account={account} />
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
{buttons}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{note}
|
2016-10-28 04:59:56 +09:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Account;
|