Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

VideoBlurButton.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @flow
  2. import { createVideoBlurEvent, sendAnalytics } from '../../analytics';
  3. import { translate } from '../../base/i18n';
  4. import { connect } from '../../base/redux';
  5. import { AbstractButton } from '../../base/toolbox';
  6. import type { AbstractButtonProps } from '../../base/toolbox';
  7. import { toggleBlurEffect } from '../actions';
  8. /**
  9. * The type of the React {@code Component} props of {@link VideoBlurButton}.
  10. */
  11. type Props = AbstractButtonProps & {
  12. /**
  13. * True if the video background is blurred or false if it is not.
  14. */
  15. _isVideoBlurred: boolean,
  16. /**
  17. * The redux {@code dispatch} function.
  18. */
  19. dispatch: Function
  20. };
  21. /**
  22. * An abstract implementation of a button that toggles the video blur effect.
  23. */
  24. class VideoBlurButton extends AbstractButton<Props, *> {
  25. accessibilityLabel = 'toolbar.accessibilityLabel.videoblur';
  26. iconName = 'icon-blur-background';
  27. label = 'toolbar.startvideoblur';
  28. tooltip = 'toolbar.startvideoblur';
  29. toggledLabel = 'toolbar.stopvideoblur';
  30. /**
  31. * Handles clicking / pressing the button, and toggles the blur effect
  32. * state accordingly.
  33. *
  34. * @protected
  35. * @returns {void}
  36. */
  37. _handleClick() {
  38. const { _isVideoBlurred, dispatch } = this.props;
  39. const value = !_isVideoBlurred;
  40. sendAnalytics(createVideoBlurEvent(value ? 'started' : 'stopped'));
  41. dispatch(toggleBlurEffect(value));
  42. }
  43. /**
  44. * Returns {@code boolean} value indicating if the blur effect is
  45. * enabled or not.
  46. *
  47. * @protected
  48. * @returns {boolean}
  49. */
  50. _isToggled() {
  51. return this.props._isVideoBlurred;
  52. }
  53. }
  54. /**
  55. * Maps (parts of) the redux state to the associated props for the
  56. * {@code VideoBlurButton} component.
  57. *
  58. * @param {Object} state - The Redux state.
  59. * @private
  60. * @returns {{
  61. * _isVideoBlurred: boolean
  62. * }}
  63. */
  64. function _mapStateToProps(state): Object {
  65. return {
  66. _isVideoBlurred: Boolean(state['features/blur'].blurEnabled)
  67. };
  68. }
  69. export default translate(connect(_mapStateToProps)(VideoBlurButton));