Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

WhiteboardButton.tsx 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* eslint-disable lines-around-comment */
  2. import { IReduxState, IStore } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconHideWhiteboard, IconShowWhiteboard } from '../../../base/icons/svg';
  5. import { connect } from '../../../base/redux/functions';
  6. // @ts-ignore
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  8. // @ts-ignore
  9. import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
  10. import { setWhiteboardOpen } from '../../actions';
  11. import { isWhiteboardVisible } from '../../functions';
  12. type Props = AbstractButtonProps & {
  13. /**
  14. * Whether or not the button is toggled.
  15. */
  16. _toggled: boolean;
  17. /**
  18. * The redux {@code dispatch} function.
  19. */
  20. dispatch: IStore['dispatch'];
  21. };
  22. /**
  23. * Component that renders a toolbar button for the whiteboard.
  24. */
  25. class WhiteboardButton extends AbstractButton<Props, any, any> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.whiteboard';
  27. icon = IconShowWhiteboard;
  28. label = 'toolbar.showWhiteboard';
  29. toggledIcon = IconHideWhiteboard;
  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));