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.

WhiteboardButton.tsx 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { IReduxState, IStore } from '../../../app/types';
  2. import { translate } from '../../../base/i18n/functions';
  3. import { IconWhiteboard, IconWhiteboardHide } from '../../../base/icons/svg';
  4. import { connect } from '../../../base/redux/functions';
  5. // eslint-disable-next-line lines-around-comment
  6. // @ts-ignore
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  8. import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
  9. import { setWhiteboardOpen } from '../../actions';
  10. import { isWhiteboardVisible } from '../../functions';
  11. type Props = AbstractButtonProps & {
  12. /**
  13. * Whether or not the button is toggled.
  14. */
  15. _toggled: boolean;
  16. /**
  17. * The redux {@code dispatch} function.
  18. */
  19. dispatch: IStore['dispatch'];
  20. };
  21. /**
  22. * Component that renders a toolbar button for the whiteboard.
  23. */
  24. class WhiteboardButton extends AbstractButton<Props, any, any> {
  25. accessibilityLabel = 'toolbar.accessibilityLabel.showWhiteboard';
  26. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.hideWhiteboard';
  27. icon = IconWhiteboard;
  28. label = 'toolbar.showWhiteboard';
  29. toggledIcon = IconWhiteboardHide;
  30. toggledLabel = 'toolbar.hideWhiteboard';
  31. toggledTooltip = 'toolbar.hideWhiteboard';
  32. tooltip = 'toolbar.showWhiteboard';
  33. /**
  34. * Handles clicking / pressing the button, and opens / closes the whiteboard view.
  35. *
  36. * @private
  37. * @returns {void}
  38. */
  39. _handleClick() {
  40. // @ts-ignore
  41. const { dispatch, _toggled } = this.props;
  42. dispatch(setWhiteboardOpen(!_toggled));
  43. dispatch(setOverflowMenuVisible(false));
  44. }
  45. /**
  46. * Indicates whether this button is in toggled state or not.
  47. *
  48. * @override
  49. * @protected
  50. * @returns {boolean}
  51. */
  52. _isToggled() {
  53. // @ts-ignore
  54. return this.props._toggled;
  55. }
  56. }
  57. /**
  58. * Maps part of the Redux state to the props of this component.
  59. *
  60. * @param {Object} state - The Redux state.
  61. * @private
  62. * @returns {Props}
  63. */
  64. function _mapStateToProps(state: IReduxState) {
  65. return {
  66. _toggled: isWhiteboardVisible(state)
  67. };
  68. }
  69. // @ts-ignore
  70. export default translate(connect(_mapStateToProps)(WhiteboardButton));