mastodon/app/assets/javascripts/components/components/status.jsx

66 lines
2.7 KiB
React
Raw Normal View History

import ImmutablePropTypes from 'react-immutable-proptypes';
2016-08-24 19:08:00 +00:00
import Avatar from './avatar';
import RelativeTimestamp from './relative_timestamp';
import PureRenderMixin from 'react-addons-pure-render-mixin';
2016-08-31 20:58:10 +00:00
import IconButton from './icon_button';
const Status = React.createClass({
propTypes: {
2016-08-31 20:58:10 +00:00
status: ImmutablePropTypes.map.isRequired,
onReply: React.PropTypes.func,
onFavourite: React.PropTypes.func,
onReblog: React.PropTypes.func
},
mixins: [PureRenderMixin],
2016-08-31 20:58:10 +00:00
handleReplyClick () {
this.props.onReply(this.props.status);
},
handleFavouriteClick () {
this.props.onFavourite(this.props.status);
},
handleReblogClick () {
this.props.onReblog(this.props.status);
},
2016-08-24 19:08:00 +00:00
render () {
var content = { __html: this.props.status.get('content') };
2016-08-24 19:08:00 +00:00
var status = this.props.status;
return (
2016-08-31 20:58:10 +00:00
<div style={{ padding: '8px 10px', paddingLeft: '68px', position: 'relative', minHeight: '48px', borderBottom: '1px solid #363c4b', cursor: 'pointer' }}>
<div style={{ fontSize: '15px' }}>
2016-09-01 10:13:41 +00:00
<div style={{ float: 'right', fontSize: '14px' }}>
2016-08-31 20:58:10 +00:00
<a href={status.get('url')} className='status__relative-time' style={{ color: '#616b86' }}><RelativeTimestamp timestamp={status.get('created_at')} /></a>
</div>
2016-08-24 19:08:00 +00:00
2016-08-31 20:58:10 +00:00
<a href={status.getIn(['account', 'url'])} className='status__display-name' style={{ display: 'block', maxWidth: '100%', paddingRight: '25px', color: '#616b86' }}>
<div style={{ position: 'absolute', left: '10px', top: '10px', width: '48px', height: '48px' }}>
<Avatar src={status.getIn(['account', 'avatar'])} size={48} />
2016-08-24 19:08:00 +00:00
</div>
2016-09-01 10:13:41 +00:00
<span style={{ display: 'block', maxWidth: '100%', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
<strong style={{ fontWeight: 'bold', color: '#fff' }}>{status.getIn(['account', 'display_name'])}</strong> <span style={{ fontSize: '14px' }}>@{status.getIn(['account', 'acct'])}</span>
2016-08-31 20:58:10 +00:00
</span>
</a>
</div>
<div className='status__content' dangerouslySetInnerHTML={content} />
2016-08-24 19:08:00 +00:00
2016-08-31 20:58:10 +00:00
<div style={{ marginTop: '10px', overflow: 'hidden' }}>
<div style={{ float: 'left', marginRight: '10px'}}><IconButton title='Reply' icon='reply' onClick={this.handleReplyClick} /></div>
<div style={{ float: 'left', marginRight: '10px'}}><IconButton active={status.get('reblogged')} title='Reblog' icon='retweet' onClick={this.handleReblogClick} /></div>
<div style={{ float: 'left'}}><IconButton active={status.get('favourited')} title='Favourite' icon='star' onClick={this.handleFavouriteClick} /></div>
2016-08-24 19:08:00 +00:00
</div>
</div>
);
}
});
export default Status;