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.

PinnedIndicator.tsx 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React from 'react';
  2. import { useSelector } from 'react-redux';
  3. import { makeStyles } from 'tss-react/mui';
  4. import { IReduxState } from '../../../app/types';
  5. import { IconPinParticipant } from '../../../base/icons/svg';
  6. import { getParticipantById } from '../../../base/participants/functions';
  7. import BaseIndicator from '../../../base/react/components/web/BaseIndicator';
  8. // eslint-disable-next-line lines-around-comment
  9. // @ts-ignore
  10. import { getPinnedActiveParticipants, isStageFilmstripAvailable } from '../../functions.web';
  11. /**
  12. * The type of the React {@code Component} props of {@link PinnedIndicator}.
  13. */
  14. type Props = {
  15. /**
  16. * The font-size for the icon.
  17. */
  18. iconSize: number;
  19. /**
  20. * The participant id who we want to render the raised hand indicator
  21. * for.
  22. */
  23. participantId: string;
  24. /**
  25. * From which side of the indicator the tooltip should appear from.
  26. */
  27. tooltipPosition: string;
  28. };
  29. const useStyles = makeStyles()(() => {
  30. return {
  31. pinnedIndicator: {
  32. backgroundColor: 'rgba(0, 0, 0, .7)',
  33. padding: '2px',
  34. zIndex: 3,
  35. display: 'inline-block',
  36. borderRadius: '4px',
  37. boxSizing: 'border-box'
  38. }
  39. };
  40. });
  41. /**
  42. * Thumbnail badge showing that the participant would like to speak.
  43. *
  44. * @returns {ReactElement}
  45. */
  46. const PinnedIndicator = ({
  47. iconSize,
  48. participantId,
  49. tooltipPosition
  50. }: Props) => {
  51. const stageFilmstrip = useSelector(isStageFilmstripAvailable);
  52. const pinned = useSelector((state: IReduxState) => getParticipantById(state, participantId))?.pinned;
  53. const activePinnedParticipants: Array<{ participantId: string; pinned: boolean; }>
  54. = useSelector(getPinnedActiveParticipants);
  55. const isPinned = activePinnedParticipants.find(p => p.participantId === participantId);
  56. const { classes: styles } = useStyles();
  57. if ((stageFilmstrip && !isPinned) || (!stageFilmstrip && !pinned)) {
  58. return null;
  59. }
  60. return (
  61. <div
  62. className = { styles.pinnedIndicator }
  63. id = { `pin-indicator-${participantId}` }>
  64. <BaseIndicator
  65. icon = { IconPinParticipant }
  66. iconSize = { `${iconSize}px` }
  67. tooltipKey = 'pinnedParticipant'
  68. tooltipPosition = { tooltipPosition } />
  69. </div>
  70. );
  71. };
  72. export default PinnedIndicator;