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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.whiteboard';
  26. icon = IconWhiteboard;
  27. label = 'toolbar.showWhiteboard';
  28. toggledIcon = IconWhiteboardHide;
  29. toggledLabel = 'toolbar.hideWhiteboard';
  30. toggledTooltip = 'toolbar.hideWhiteboard';
  31. tooltip = 'toolbar.showWhiteboard';
  32. /**
  33. * Handles clicking / pressing the button, and opens / closes the whiteboard view.
  34. *
  35. * @private
  36. * @returns {void}
  37. */
  38. _handleClick() {
  39. // @ts-ignore
  40. const { dispatch, _toggled } = this.props;
  41. dispatch(setWhiteboardOpen(!_toggled));
  42. dispatch(setOverflowMenuVisible(false));
  43. }
  44. /**
  45. * Indicates whether this button is in toggled state or not.
  46. *
  47. * @override
  48. * @protected
  49. * @returns {boolean}
  50. */
  51. _isToggled() {
  52. // @ts-ignore
  53. return this.props._toggled;
  54. }
  55. }
  56. /**
  57. * Maps part of the Redux state to the props of this component.
  58. *
  59. * @param {Object} state - The Redux state.
  60. * @private
  61. * @returns {Props}
  62. */
  63. function _mapStateToProps(state: IReduxState) {
  64. return {
  65. _toggled: isWhiteboardVisible(state)
  66. };
  67. }
  68. // @ts-ignore
  69. export default translate(connect(_mapStateToProps)(WhiteboardButton));