mirror of https://github.com/jitsi/jitsi-meet
parent
b7ab3ea052
commit
7263829763
@ -0,0 +1,45 @@ |
||||
// @flow
|
||||
|
||||
import { makeStyles } from '@material-ui/core/styles'; |
||||
import React from 'react'; |
||||
|
||||
type Props = { |
||||
|
||||
/** |
||||
* The name to be displayed within the badge. |
||||
*/ |
||||
name: string |
||||
} |
||||
|
||||
const useStyles = makeStyles(theme => { |
||||
return { |
||||
badge: { |
||||
background: 'rgba(0, 0, 0, 0.6)', |
||||
borderRadius: '3px', |
||||
color: theme.palette.text01, |
||||
maxWidth: '50%', |
||||
overflow: 'hidden', |
||||
padding: '2px 16px', |
||||
textOverflow: 'ellipsis', |
||||
whiteSpace: 'nowrap' |
||||
} |
||||
}; |
||||
}); |
||||
|
||||
/** |
||||
* Component that displays a name badge. |
||||
* |
||||
* @param {Props} props - The props of the component. |
||||
* @returns {ReactElement} |
||||
*/ |
||||
const DisplayNameBadge = ({ name }: Props) => { |
||||
const classes = useStyles(); |
||||
|
||||
return ( |
||||
<div className = { classes.badge }> |
||||
{name} |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
export default DisplayNameBadge; |
||||
@ -0,0 +1,60 @@ |
||||
// @flow
|
||||
|
||||
import { makeStyles } from '@material-ui/core/styles'; |
||||
import React from 'react'; |
||||
import { useSelector } from 'react-redux'; |
||||
|
||||
import { getLocalParticipant } from '../../../base/participants'; |
||||
import { withPixelLineHeight } from '../../../base/styles/functions.web'; |
||||
import { getLargeVideoParticipant } from '../../../large-video/functions'; |
||||
import { isToolboxVisible } from '../../../toolbox/functions.web'; |
||||
import { isLayoutTileView } from '../../../video-layout'; |
||||
|
||||
import DisplayNameBadge from './DisplayNameBadge'; |
||||
|
||||
const useStyles = makeStyles(theme => { |
||||
return { |
||||
badgeContainer: { |
||||
...withPixelLineHeight(theme.typography.bodyShortRegularLarge), |
||||
alignItems: 'center', |
||||
display: 'flex', |
||||
justifyContent: 'center', |
||||
marginBottom: theme.spacing(2), |
||||
transition: 'margin-bottom 0.3s' |
||||
}, |
||||
containerElevated: { |
||||
marginBottom: theme.spacing(7) |
||||
} |
||||
}; |
||||
}); |
||||
|
||||
/** |
||||
* Component that renders the dominant speaker's name as a badge above the toolbar in stage view. |
||||
* |
||||
* @returns {ReactElement|null} |
||||
*/ |
||||
const DominantSpeakerName = () => { |
||||
const classes = useStyles(); |
||||
const largeVideoParticipant = useSelector(getLargeVideoParticipant); |
||||
const nameToDisplay = largeVideoParticipant?.name; |
||||
const selectedId = largeVideoParticipant?.id; |
||||
|
||||
const localParticipant = useSelector(getLocalParticipant); |
||||
const localId = localParticipant?.id; |
||||
|
||||
const isTileView = useSelector(isLayoutTileView); |
||||
const toolboxVisible = useSelector(isToolboxVisible); |
||||
|
||||
if (nameToDisplay && selectedId !== localId && !isTileView) { |
||||
return ( |
||||
<div |
||||
className = { `${classes.badgeContainer}${toolboxVisible ? '' : ` ${classes.containerElevated}`}` }> |
||||
<DisplayNameBadge name = { nameToDisplay } /> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
return null; |
||||
}; |
||||
|
||||
export default DominantSpeakerName; |
||||
@ -0,0 +1,15 @@ |
||||
// @flow
|
||||
|
||||
import { getParticipantById } from '../base/participants'; |
||||
|
||||
/** |
||||
* Selector for the participant currently displaying on the large video. |
||||
* |
||||
* @param {Object} state - The redux state. |
||||
* @returns {Object} |
||||
*/ |
||||
export function getLargeVideoParticipant(state: Object) { |
||||
const { participantId } = state['features/large-video']; |
||||
|
||||
return getParticipantById(state, participantId); |
||||
} |
||||
Loading…
Reference in new issue