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

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