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.

DominantSpeakerName.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // @flow
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import React from 'react';
  4. import { useSelector } from 'react-redux';
  5. import { getLocalParticipant } from '../../../base/participants';
  6. import { withPixelLineHeight } from '../../../base/styles/functions.web';
  7. import { getLargeVideoParticipant } from '../../../large-video/functions';
  8. import { isToolboxVisible } from '../../../toolbox/functions.web';
  9. import { isLayoutTileView } from '../../../video-layout';
  10. import DisplayNameBadge from './DisplayNameBadge';
  11. const useStyles = makeStyles(theme => {
  12. return {
  13. badgeContainer: {
  14. ...withPixelLineHeight(theme.typography.bodyShortRegularLarge),
  15. alignItems: 'center',
  16. display: 'flex',
  17. justifyContent: 'center',
  18. marginBottom: theme.spacing(2),
  19. transition: 'margin-bottom 0.3s'
  20. },
  21. containerElevated: {
  22. marginBottom: theme.spacing(7)
  23. }
  24. };
  25. });
  26. /**
  27. * Component that renders the dominant speaker's name as a badge above the toolbar in stage view.
  28. *
  29. * @returns {ReactElement|null}
  30. */
  31. const DominantSpeakerName = () => {
  32. const classes = useStyles();
  33. const largeVideoParticipant = useSelector(getLargeVideoParticipant);
  34. const nameToDisplay = largeVideoParticipant?.name;
  35. const selectedId = largeVideoParticipant?.id;
  36. const localParticipant = useSelector(getLocalParticipant);
  37. const localId = localParticipant?.id;
  38. const isTileView = useSelector(isLayoutTileView);
  39. const toolboxVisible = useSelector(isToolboxVisible);
  40. if (nameToDisplay && selectedId !== localId && !isTileView) {
  41. return (
  42. <div
  43. className = { `${classes.badgeContainer}${toolboxVisible ? '' : ` ${classes.containerElevated}`}` }>
  44. <DisplayNameBadge name = { nameToDisplay } />
  45. </div>
  46. );
  47. }
  48. return null;
  49. };
  50. export default DominantSpeakerName;