您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

JoinButton.web.js 2.4KB

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