Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ChatDialogHeader.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { Icon, IconClose } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import { toggleChat } from '../../actions.web';
  7. type Props = {
  8. /**
  9. * Function to be called when pressing the close button.
  10. */
  11. onCancel: Function,
  12. /**
  13. * An optional class name.
  14. */
  15. className: string,
  16. /**
  17. * Whether the polls feature is enabled or not.
  18. */
  19. isPollsEnabled: boolean,
  20. /**
  21. * Invoked to obtain translated strings.
  22. */
  23. t: Function
  24. };
  25. /**
  26. * Custom header of the {@code ChatDialog}.
  27. *
  28. * @returns {React$Element<any>}
  29. */
  30. function Header({ onCancel, className, isPollsEnabled, t }: Props) {
  31. const onKeyPressHandler = useCallback(e => {
  32. if (onCancel && (e.key === ' ' || e.key === 'Enter')) {
  33. e.preventDefault();
  34. onCancel();
  35. }
  36. }, [ onCancel ]);
  37. return (
  38. <div
  39. className = { className || 'chat-dialog-header' }
  40. role = 'heading'>
  41. { t(isPollsEnabled ? 'chat.titleWithPolls' : 'chat.title') }
  42. <Icon
  43. ariaLabel = { t('toolbar.closeChat') }
  44. onClick = { onCancel }
  45. onKeyPress = { onKeyPressHandler }
  46. role = 'button'
  47. src = { IconClose }
  48. tabIndex = { 0 } />
  49. </div>
  50. );
  51. }
  52. const mapDispatchToProps = { onCancel: toggleChat };
  53. export default translate(connect(null, mapDispatchToProps)(Header));