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

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