123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import React, { ReactElement, useCallback } from 'react';
- import { WithTranslation } from 'react-i18next';
- import { makeStyles } from 'tss-react/mui';
-
- // @ts-ignore
- import { Avatar } from '../../../base/avatar';
- import ListItem from '../../../base/components/participants-pane-list/ListItem';
- import { translate } from '../../../base/i18n/functions';
- import { withPixelLineHeight } from '../../../base/styles/functions.web';
- import {
- ACTION_TRIGGER,
- type ActionTrigger,
- AudioStateIcons,
- MEDIA_STATE,
- MediaState,
- VideoStateIcons
- } from '../../constants';
-
- import { RaisedHandIndicator } from './RaisedHandIndicator';
-
- interface IProps extends WithTranslation {
-
- /**
- * Type of trigger for the participant actions.
- */
- actionsTrigger?: ActionTrigger;
-
- /**
- * Media state for audio.
- */
- audioMediaState?: MediaState;
-
- /**
- * React children.
- */
- children?: ReactElement | boolean;
-
- /**
- * Whether or not to disable the moderator indicator.
- */
- disableModeratorIndicator?: boolean;
-
- /**
- * The name of the participant. Used for showing lobby names.
- */
- displayName?: string;
-
- /**
- * Is this item highlighted/raised.
- */
- isHighlighted?: boolean;
-
- /**
- * Whether or not the participant is a moderator.
- */
- isModerator?: boolean;
-
- /**
- * True if the participant is local.
- */
- local?: boolean;
-
- /**
- * Callback for when the mouse leaves this component.
- */
- onLeave?: (e?: React.MouseEvent) => void;
-
- /**
- * Opens a drawer with participant actions.
- */
- openDrawerForParticipant?: Function;
-
- /**
- * If an overflow drawer can be opened.
- */
- overflowDrawer?: boolean;
-
- /**
- * The ID of the participant.
- */
- participantID: string;
-
- /**
- * True if the participant have raised hand.
- */
- raisedHand?: boolean;
-
- /**
- * Media state for video.
- */
- videoMediaState?: MediaState;
-
- /**
- * The translated "you" text.
- */
- youText?: string;
- }
-
- const useStyles = makeStyles()(theme => {
- return {
- nameContainer: {
- display: 'flex',
- flex: 1,
- overflow: 'hidden'
- },
-
- name: {
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap'
- },
-
- moderatorLabel: {
- ...withPixelLineHeight(theme.typography.labelRegular),
- color: theme.palette.text03
- }
- };
- });
-
- /**
- * A component representing a participant entry in ParticipantPane and Lobby.
- *
- * @param {IProps} props - The props of the component.
- * @returns {ReactNode}
- */
- function ParticipantItem({
- actionsTrigger = ACTION_TRIGGER.HOVER,
- audioMediaState = MEDIA_STATE.NONE,
- children,
- disableModeratorIndicator,
- displayName,
- isHighlighted,
- isModerator,
- local,
- onLeave,
- openDrawerForParticipant,
- overflowDrawer,
- participantID,
- raisedHand,
- t,
- videoMediaState = MEDIA_STATE.NONE,
- youText
- }: IProps) {
- const onClick = useCallback(
- () => openDrawerForParticipant?.({
- participantID,
- displayName
- }), []);
-
- const { classes: styles } = useStyles();
-
- const icon = (
- <Avatar
- className = 'participant-avatar'
- displayName = { displayName }
- participantId = { participantID }
- size = { 32 } />
- );
-
- const text = (
- <>
- <div className = { styles.nameContainer }>
- <div className = { styles.name }>
- {displayName}
- </div>
- {local ? <span> ({youText})</span> : null}
- </div>
- {isModerator && !disableModeratorIndicator && <div className = { styles.moderatorLabel }>
- {t('videothumbnail.moderator')}
- </div>}
- </>
- );
-
- const indicators = (
- <>
- {raisedHand && <RaisedHandIndicator />}
- {VideoStateIcons[videoMediaState]}
- {AudioStateIcons[audioMediaState]}
- </>
- );
-
- return (
- <ListItem
- actions = { children }
- hideActions = { local }
- icon = { icon }
- id = { `participant-item-${participantID}` }
- indicators = { indicators }
- isHighlighted = { isHighlighted }
- onClick = { !local && overflowDrawer ? onClick : undefined }
- onMouseLeave = { onLeave }
- textChildren = { text }
- trigger = { actionsTrigger } />
- );
- }
-
- export default translate(ParticipantItem);
|