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.

ParticipantCounter.web.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { getParticipantCount } from '../../base/participants';
  5. /**
  6. * React component for showing a badge with the current count of conference
  7. * participants.
  8. *
  9. * @extends Component
  10. */
  11. class ParticipantCounter extends Component {
  12. /**
  13. * {@code ParticipantCounter} component's property types.
  14. *
  15. * @static
  16. */
  17. static propTypes = {
  18. /**
  19. * The number of participants in the conference.
  20. */
  21. _count: PropTypes.number
  22. };
  23. /**
  24. * Implements React's {@link Component#render()}.
  25. *
  26. * @inheritdoc
  27. * @returns {ReactElement}
  28. */
  29. render() {
  30. return (
  31. <span className = 'badge-round'>
  32. <span id = 'numberOfParticipants'>
  33. { this.props._count }
  34. </span>
  35. </span>
  36. );
  37. }
  38. }
  39. /**
  40. * Maps (parts of) the Redux state to the associated
  41. * {@code ParticipantCounter}'s props.
  42. *
  43. * @param {Object} state - The Redux state.
  44. * @private
  45. * @returns {{
  46. * _count: number
  47. * }}
  48. */
  49. function _mapStateToProps(state) {
  50. return {
  51. _count: getParticipantCount(state)
  52. };
  53. }
  54. export default connect(_mapStateToProps)(ParticipantCounter);