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.

83 lines
2.2 KiB

  1. // Package imports.
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import { defineMessages, injectIntl } from 'react-intl';
  6. // Mastodon imports.
  7. import IconButton from './icon_button';
  8. import VisibilityIcon from './status_visibility_icon';
  9. // Messages for use with internationalization stuff.
  10. const messages = defineMessages({
  11. collapse: { id: 'status.collapse', defaultMessage: 'Collapse' },
  12. uncollapse: { id: 'status.uncollapse', defaultMessage: 'Uncollapse' },
  13. });
  14. @injectIntl
  15. export default class StatusIcons extends React.PureComponent {
  16. static propTypes = {
  17. status: ImmutablePropTypes.map.isRequired,
  18. mediaIcon: PropTypes.string,
  19. collapsible: PropTypes.bool,
  20. collapsed: PropTypes.bool,
  21. setCollapsed: PropTypes.func.isRequired,
  22. intl: PropTypes.object.isRequired,
  23. };
  24. // Handles clicks on collapsed button
  25. handleCollapsedClick = (e) => {
  26. const { collapsed, setCollapsed } = this.props;
  27. if (e.button === 0) {
  28. setCollapsed(!collapsed);
  29. e.preventDefault();
  30. }
  31. }
  32. // Rendering.
  33. render () {
  34. const {
  35. status,
  36. mediaIcon,
  37. collapsible,
  38. collapsed,
  39. intl,
  40. } = this.props;
  41. return (
  42. <div className='status__info__icons'>
  43. {status.get('in_reply_to_id', null) !== null ? (
  44. <i
  45. className={`fa fa-fw fa-comment status__reply-icon`}
  46. aria-hidden='true'
  47. />
  48. ) : null}
  49. {mediaIcon ? (
  50. <i
  51. className={`fa fa-fw fa-${mediaIcon} status__media-icon`}
  52. aria-hidden='true'
  53. />
  54. ) : null}
  55. {(
  56. <VisibilityIcon visibility={status.get('visibility')} />
  57. )}
  58. {collapsible ? (
  59. <IconButton
  60. className='status__collapse-button'
  61. animate flip
  62. active={collapsed}
  63. title={
  64. collapsed ?
  65. intl.formatMessage(messages.uncollapse) :
  66. intl.formatMessage(messages.collapse)
  67. }
  68. icon='angle-double-up'
  69. onClick={this.handleCollapsedClick}
  70. />
  71. ) : null}
  72. </div>
  73. );
  74. }
  75. }