Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ChatButton.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import { translate } from '../../../base/i18n/functions';
  5. import { IconMessage } from '../../../base/icons/svg';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import ChatCounter from './ChatCounter';
  8. /**
  9. * The type of the React {@code Component} props of {@link ChatButton}.
  10. */
  11. interface IProps extends AbstractButtonProps {
  12. /**
  13. * Whether or not the chat feature is currently displayed.
  14. */
  15. _chatOpen: boolean;
  16. }
  17. /**
  18. * Implementation of a button for accessing chat pane.
  19. */
  20. class ChatButton extends AbstractButton<IProps> {
  21. accessibilityLabel = 'toolbar.accessibilityLabel.openChat';
  22. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.closeChat';
  23. icon = IconMessage;
  24. label = 'toolbar.openChat';
  25. toggledLabel = 'toolbar.closeChat';
  26. tooltip = 'toolbar.openChat';
  27. toggledTooltip = 'toolbar.closeChat';
  28. /**
  29. * Indicates whether this button is in toggled state or not.
  30. *
  31. * @override
  32. * @protected
  33. * @returns {boolean}
  34. */
  35. _isToggled() {
  36. return this.props._chatOpen;
  37. }
  38. /**
  39. * Overrides AbstractButton's {@link Component#render()}.
  40. *
  41. * @override
  42. * @protected
  43. * @returns {boReact$Nodeolean}
  44. */
  45. render() {
  46. return (
  47. <div
  48. className = 'toolbar-button-with-badge'
  49. key = 'chatcontainer'>
  50. {super.render()}
  51. <ChatCounter />
  52. </div>
  53. );
  54. }
  55. }
  56. /**
  57. * Function that maps parts of Redux state tree into component props.
  58. *
  59. * @param {Object} state - Redux state.
  60. * @returns {Object}
  61. */
  62. const mapStateToProps = (state: IReduxState) => {
  63. return {
  64. _chatOpen: state['features/chat'].isOpen
  65. };
  66. };
  67. export default translate(connect(mapStateToProps)(ChatButton));