bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/user-avatar/component.jsx

93 lines
2.3 KiB
React
Raw Normal View History

2017-07-28 21:43:39 +08:00
import React from 'react';
import PropTypes from 'prop-types';
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
2021-10-29 19:23:50 +08:00
import Styled from './styles';
import browserInfo from '/imports/utils/browserInfo';
const propTypes = {
2022-03-17 01:53:41 +08:00
children: PropTypes.node,
moderator: PropTypes.bool,
presenter: PropTypes.bool,
talking: PropTypes.bool,
muted: PropTypes.bool,
listenOnly: PropTypes.bool,
voice: PropTypes.bool,
noVoice: PropTypes.bool,
2017-07-28 21:43:39 +08:00
color: PropTypes.string,
emoji: PropTypes.bool,
avatar: PropTypes.string,
className: PropTypes.string,
2022-03-17 01:53:41 +08:00
isSkeleton: PropTypes.bool,
};
2021-10-29 19:23:50 +08:00
const { isChrome, isFirefox, isEdge } = browserInfo;
2017-07-28 21:43:39 +08:00
const UserAvatar = ({
2024-06-11 21:05:08 +08:00
children = <></>,
moderator = false,
presenter = false,
className = '',
talking = false,
muted = false,
listenOnly = false,
color = '#000',
voice = false,
emoji = false,
avatar = '',
noVoice = false,
whiteboardAccess = false,
isSkeleton = false,
}) => {
const Settings = getSettingsSingletonInstance();
const { animations } = Settings.application;
2018-08-04 00:31:58 +08:00
return (
<>
{isSkeleton && (<Styled.Skeleton>{children}</Styled.Skeleton>)}
2018-08-04 00:31:58 +08:00
{!isSkeleton && (
<Styled.Avatar
aria-hidden="true"
data-test={moderator ? 'moderatorAvatar' : 'viewerAvatar'}
moderator={moderator}
presenter={presenter}
className={className}
whiteboardAccess={whiteboardAccess && !presenter}
muted={muted}
listenOnly={listenOnly}
voice={voice}
noVoice={noVoice && !listenOnly}
isChrome={isChrome}
isFirefox={isFirefox}
isEdge={isEdge}
style={{
backgroundColor: color,
color, // We need the same color on both for the border
}}
>
2022-03-17 01:53:41 +08:00
<Styled.Talking talking={talking && !muted} animations={animations} />
{avatar.length !== 0 && !emoji
? (
<Styled.Image>
<Styled.Img
moderator={moderator}
src={avatar}
/>
</Styled.Image>
) : (
<Styled.Content>
{children}
</Styled.Content>
)}
</Styled.Avatar>
)}
</>
)
};
UserAvatar.propTypes = propTypes;
2017-07-28 21:43:39 +08:00
export default UserAvatar;