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.

VideoBackgroundButton.js 2.1KB

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