2022-09-13 07:36:00 +00:00
|
|
|
import { Theme } from '@mui/material';
|
2019-03-27 10:23:41 +00:00
|
|
|
import React from 'react';
|
2021-12-15 13:18:41 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2019-03-27 10:23:41 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
2022-09-06 17:32:20 +00:00
|
|
|
import { IconRaisedHand } from '../../../base/icons/svg';
|
2022-08-26 09:54:03 +00:00
|
|
|
import { getParticipantById, hasRaisedHand } from '../../../base/participants/functions';
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IParticipant } from '../../../base/participants/types';
|
2022-08-26 09:54:03 +00:00
|
|
|
import BaseIndicator from '../../../base/react/components/web/BaseIndicator';
|
2017-07-10 22:29:44 +00:00
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link RaisedHandIndicator}.
|
2017-07-10 22:29:44 +00:00
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
type Props = {
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2017-07-10 22:29:44 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The font-size for the icon.
|
2017-07-10 22:29:44 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
iconSize: number;
|
2017-08-15 22:14:49 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
/**
|
|
|
|
* The participant id who we want to render the raised hand indicator
|
|
|
|
* for.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantId: string;
|
2021-12-15 13:18:41 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* From which side of the indicator the tooltip should appear from.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
tooltipPosition: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
};
|
2017-07-10 22:29:44 +00:00
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()((theme: Theme) => {
|
2021-12-15 13:18:41 +00:00
|
|
|
return {
|
|
|
|
raisedHandIndicator: {
|
2021-12-20 08:44:22 +00:00
|
|
|
backgroundColor: theme.palette.warning02,
|
2021-12-15 13:18:41 +00:00
|
|
|
padding: '2px',
|
|
|
|
zIndex: 3,
|
|
|
|
display: 'inline-block',
|
|
|
|
borderRadius: '4px',
|
|
|
|
boxSizing: 'border-box'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Thumbnail badge showing that the participant would like to speak.
|
|
|
|
*
|
2021-12-15 13:18:41 +00:00
|
|
|
* @returns {ReactElement}
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
const RaisedHandIndicator = ({
|
|
|
|
iconSize,
|
|
|
|
participantId,
|
|
|
|
tooltipPosition
|
|
|
|
}: Props) => {
|
2022-10-20 09:11:27 +00:00
|
|
|
const participant: IParticipant | undefined = useSelector((state: IReduxState) =>
|
2022-08-26 09:54:03 +00:00
|
|
|
getParticipantById(state, participantId));
|
|
|
|
const _raisedHand = hasRaisedHand(participant);
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes: styles, theme } = useStyles();
|
2021-12-15 13:18:41 +00:00
|
|
|
|
|
|
|
if (!_raisedHand) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = { styles.raisedHandIndicator }>
|
2017-07-10 22:29:44 +00:00
|
|
|
<BaseIndicator
|
2019-08-30 16:39:06 +00:00
|
|
|
icon = { IconRaisedHand }
|
2022-09-13 07:36:00 +00:00
|
|
|
iconColor = { theme.palette.uiBackground }
|
2021-12-15 13:18:41 +00:00
|
|
|
iconSize = { `${iconSize}px` }
|
2017-08-15 22:14:49 +00:00
|
|
|
tooltipKey = 'raisedHand'
|
2021-12-15 13:18:41 +00:00
|
|
|
tooltipPosition = { tooltipPosition } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2017-07-10 22:29:44 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
export default RaisedHandIndicator;
|