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.

JoinButton.web.tsx 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { translate } from '../../base/i18n/functions';
  4. import Icon from '../../base/icons/components/Icon';
  5. import { IconPlus } from '../../base/icons/svg';
  6. import Tooltip from '../../base/tooltip/components/Tooltip';
  7. /**
  8. * The type of the React {@code Component} props of {@link JoinButton}.
  9. */
  10. interface IProps extends WithTranslation {
  11. /**
  12. * The function called when the button is pressed.
  13. */
  14. onPress: Function;
  15. /**
  16. * The meeting URL associated with the {@link JoinButton} instance.
  17. */
  18. url: string;
  19. }
  20. /**
  21. * A React Component for joining an existing calendar meeting.
  22. *
  23. * @augments Component
  24. */
  25. class JoinButton extends Component<IProps> {
  26. /**
  27. * Initializes a new {@code JoinButton} instance.
  28. *
  29. * @param {*} props - The read-only properties with which the new instance
  30. * is to be initialized.
  31. */
  32. constructor(props: IProps) {
  33. super(props);
  34. // Bind event handler so it is only bound once for every instance.
  35. this._onClick = this._onClick.bind(this);
  36. this._onKeyPress = this._onKeyPress.bind(this);
  37. }
  38. /**
  39. * Implements React's {@link Component#render}.
  40. *
  41. * @inheritdoc
  42. */
  43. render() {
  44. const { t } = this.props;
  45. return (
  46. <Tooltip
  47. content = { t('calendarSync.joinTooltip') }>
  48. <div
  49. className = 'button join-button'
  50. onClick = { this._onClick }
  51. onKeyPress = { this._onKeyPress }
  52. role = 'button'>
  53. <Icon
  54. size = '14'
  55. src = { IconPlus } />
  56. </div>
  57. </Tooltip>
  58. );
  59. }
  60. /**
  61. * Callback invoked when the component is clicked.
  62. *
  63. * @param {Object} event - The DOM click event.
  64. * @private
  65. * @returns {void}
  66. */
  67. _onClick(event?: React.MouseEvent) {
  68. this.props.onPress(event, this.props.url);
  69. }
  70. /**
  71. * KeyPress handler for accessibility.
  72. *
  73. * @param {Object} e - The key event to handle.
  74. *
  75. * @returns {void}
  76. */
  77. _onKeyPress(e: React.KeyboardEvent) {
  78. if (e.key === ' ' || e.key === 'Enter') {
  79. e.preventDefault();
  80. this._onClick();
  81. }
  82. }
  83. }
  84. export default translate(JoinButton);