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.

69 lines
2.2 KiB

  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. import IconButton from './icon_button';
  4. import Dropdown, { DropdownTrigger, DropdownContent } from 'react-simple-dropdown';
  5. const StatusActionBar = React.createClass({
  6. propTypes: {
  7. status: ImmutablePropTypes.map.isRequired,
  8. onReply: React.PropTypes.func,
  9. onFavourite: React.PropTypes.func,
  10. onReblog: React.PropTypes.func,
  11. onDelete: React.PropTypes.func
  12. },
  13. mixins: [PureRenderMixin],
  14. handleReplyClick () {
  15. this.props.onReply(this.props.status);
  16. },
  17. handleFavouriteClick () {
  18. this.props.onFavourite(this.props.status);
  19. },
  20. handleReblogClick () {
  21. this.props.onReblog(this.props.status);
  22. },
  23. handleDeleteClick(e) {
  24. e.preventDefault();
  25. this.props.onDelete(this.props.status);
  26. },
  27. render () {
  28. const { status, me } = this.props;
  29. let menu = '';
  30. if (status.getIn(['account', 'id']) === me) {
  31. menu = (
  32. <ul>
  33. <li><a href='#' onClick={this.handleDeleteClick}>Delete</a></li>
  34. </ul>
  35. );
  36. } else {
  37. menu = <ul />;
  38. }
  39. return (
  40. <div style={{ marginTop: '10px', overflow: 'hidden' }}>
  41. <div style={{ float: 'left', marginRight: '18px'}}><IconButton title='Reply' icon='reply' onClick={this.handleReplyClick} /></div>
  42. <div style={{ float: 'left', marginRight: '18px'}}><IconButton active={status.get('reblogged')} title='Reblog' icon='retweet' onClick={this.handleReblogClick} /></div>
  43. <div style={{ float: 'left', marginRight: '18px'}}><IconButton active={status.get('favourited')} title='Favourite' icon='star' onClick={this.handleFavouriteClick} /></div>
  44. <div onClick={e => e.stopPropagation()} style={{ width: '18px', height: '18px', float: 'left' }}>
  45. <Dropdown>
  46. <DropdownTrigger className='icon-button' style={{ fontSize: '18px', lineHeight: '18px', width: '18px', height: '18px' }}>
  47. <i className='fa fa-fw fa-ellipsis-h' />
  48. </DropdownTrigger>
  49. <DropdownContent>{menu}</DropdownContent>
  50. </Dropdown>
  51. </div>
  52. </div>
  53. );
  54. }
  55. });
  56. export default StatusActionBar;