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.

ChatButton.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { IconMessage } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. import ChatCounter from './ChatCounter';
  8. /**
  9. * The type of the React {@code Component} props of {@link ChatButton}.
  10. */
  11. type Props = 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<Props, *> {
  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(): React$Node {
  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 => {
  63. return {
  64. _chatOpen: state['features/chat'].isOpen
  65. };
  66. };
  67. export default translate(connect(mapStateToProps)(ChatButton));