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.3KB

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