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.

57 lines
1.6 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. const messages = defineMessages({
  11. markForDeletion: { id: 'notification.markForDeletion', defaultMessage: 'Mark for deletion' },
  12. });
  13. @injectIntl
  14. export default class NotificationOverlay extends ImmutablePureComponent {
  15. static propTypes = {
  16. notification : ImmutablePropTypes.map.isRequired,
  17. onMarkForDelete : PropTypes.func.isRequired,
  18. show : PropTypes.bool.isRequired,
  19. intl : PropTypes.object.isRequired,
  20. };
  21. onToggleMark = () => {
  22. const mark = !this.props.notification.get('markedForDelete');
  23. const id = this.props.notification.get('id');
  24. this.props.onMarkForDelete(id, mark);
  25. }
  26. render () {
  27. const { notification, show, intl } = this.props;
  28. const active = notification.get('markedForDelete');
  29. const label = intl.formatMessage(messages.markForDeletion);
  30. return show ? (
  31. <div
  32. aria-label={label}
  33. role='checkbox'
  34. aria-checked={active}
  35. tabIndex={0}
  36. className={`notification__dismiss-overlay ${active ? 'active' : ''}`}
  37. onClick={this.onToggleMark}
  38. >
  39. <div className='wrappy'>
  40. <div className='ckbox' aria-hidden='true' title={label}>
  41. {active ? (<i className='fa fa-check' />) : ''}
  42. </div>
  43. </div>
  44. </div>
  45. ) : null;
  46. }
  47. }