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

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