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.

59 lines
1.7 KiB

  1. /**
  2. * Notification overlay
  3. */
  4. // Package imports //
  5. import React from 'react';
  6. import ImmutablePropTypes from 'react-immutable-proptypes';
  7. import PropTypes from 'prop-types';
  8. import ImmutablePureComponent from 'react-immutable-pure-component';
  9. import { defineMessages, injectIntl } from 'react-intl';
  10. // Mastodon imports //
  11. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  12. const messages = defineMessages({
  13. markForDeletion: { id: 'notification.markForDeletion', defaultMessage: 'Mark for deletion' },
  14. });
  15. @injectIntl
  16. export default class NotificationOverlay extends ImmutablePureComponent {
  17. static propTypes = {
  18. notification : ImmutablePropTypes.map.isRequired,
  19. onMarkForDelete : PropTypes.func.isRequired,
  20. revealed : PropTypes.bool.isRequired,
  21. intl : PropTypes.object.isRequired,
  22. };
  23. onToggleMark = () => {
  24. const mark = !this.props.notification.get('markedForDelete');
  25. const id = this.props.notification.get('id');
  26. this.props.onMarkForDelete(id, mark);
  27. }
  28. render () {
  29. const { notification, revealed, intl } = this.props;
  30. const active = notification.get('markedForDelete');
  31. const label = intl.formatMessage(messages.markForDeletion);
  32. return (
  33. <div
  34. aria-label={label}
  35. role='checkbox'
  36. aria-checked={active}
  37. tabIndex={0}
  38. className={`notification__dismiss-overlay ${active ? 'active' : ''} ${revealed ? 'show' : ''}`}
  39. onClick={this.onToggleMark}
  40. >
  41. <div className='notification__dismiss-overlay__ckbox' aria-hidden='true' title={label}>
  42. {active ? (<i className='fa fa-check' />) : ''}
  43. </div>
  44. </div>
  45. );
  46. }
  47. }