Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Captions.web.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import React from 'react';
  3. import { connect } from '../../base/redux';
  4. import {
  5. _abstractMapStateToProps,
  6. AbstractCaptions,
  7. type AbstractCaptionsProps
  8. } from './AbstractCaptions';
  9. type Props = {
  10. /**
  11. * Whether the subtitles container is lifted above the invite box.
  12. */
  13. _isLifted: boolean
  14. } & AbstractCaptionsProps;
  15. /**
  16. * React {@code Component} which can display speech-to-text results from
  17. * Jigasi as subtitles.
  18. */
  19. class Captions
  20. extends AbstractCaptions<Props> {
  21. /**
  22. * Renders the transcription text.
  23. *
  24. * @param {string} id - The ID of the transcript message from which the
  25. * {@code text} has been created.
  26. * @param {string} text - Subtitles text formatted with the participant's
  27. * name.
  28. * @protected
  29. * @returns {React$Element} - The React element which displays the text.
  30. */
  31. _renderParagraph(id: string, text: string): React$Element<*> {
  32. return (
  33. <p key = { id }>
  34. <span>{ text }</span>
  35. </p>
  36. );
  37. }
  38. /**
  39. * Renders the subtitles container.
  40. *
  41. * @param {Array<React$Element>} paragraphs - An array of elements created
  42. * for each subtitle using the {@link _renderParagraph} method.
  43. * @protected
  44. * @returns {React$Element} - The subtitles container.
  45. */
  46. _renderSubtitlesContainer(
  47. paragraphs: Array<React$Element<*>>): React$Element<*> {
  48. const className = this.props._isLifted ? 'transcription-subtitles lifted' : 'transcription-subtitles';
  49. return (
  50. <div className = { className } >
  51. { paragraphs }
  52. </div>
  53. );
  54. }
  55. }
  56. /**
  57. * Maps (parts of) the redux state to the associated {@code }'s
  58. * props.
  59. *
  60. * @param {Object} state - The redux state.
  61. * @private
  62. * @returns {Object}
  63. */
  64. function mapStateToProps(state) {
  65. return {
  66. ..._abstractMapStateToProps(state),
  67. _isLifted: state['features/base/participants'].length < 2
  68. };
  69. }
  70. export default connect(mapStateToProps)(Captions);