Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ParticipantName.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. type Props = {
  5. /**
  6. * Flag signaling if the name is ediable or not.
  7. */
  8. isEditable: boolean,
  9. /**
  10. * Sets the name for the joining user.
  11. */
  12. setName: Function,
  13. /**
  14. * Used to obtain translations.
  15. */
  16. t: Function,
  17. /**
  18. * The text to be displayed.
  19. */
  20. value: string,
  21. };
  22. /**
  23. * Participant name - can be an editable input or just the text name.
  24. *
  25. * @returns {ReactElement}
  26. */
  27. class ParticipantName extends Component<Props> {
  28. /**
  29. * Initializes a new {@code ParticipantName} instance.
  30. *
  31. * @param {Props} props - The props of the component.
  32. * @inheritdoc
  33. */
  34. constructor(props) {
  35. super(props);
  36. this._onNameChange = this._onNameChange.bind(this);
  37. }
  38. _onNameChange: () => void;
  39. /**
  40. * Handler used for changing the guest user name.
  41. *
  42. * @returns {undefined}
  43. */
  44. _onNameChange({ target: { value } }) {
  45. this.props.setName(value);
  46. }
  47. /**
  48. * Implements React's {@link Component#render()}.
  49. *
  50. * @inheritdoc
  51. * @returns {ReactElement}
  52. */
  53. render() {
  54. const { value, isEditable, t } = this.props;
  55. return isEditable ? (
  56. <input
  57. className = 'prejoin-preview-name prejoin-preview-name--editable'
  58. onChange = { this._onNameChange }
  59. placeholder = { t('dialog.enterDisplayName') }
  60. value = { value } />
  61. )
  62. : <div className = 'prejoin-preview-name'>{value}</div>
  63. ;
  64. }
  65. }
  66. export default translate(ParticipantName);