2017-07-28 21:43:39 +08:00
|
|
|
import React from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2024-05-29 21:26:11 +08:00
|
|
|
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';
|
2016-06-01 04:25:42 +08:00
|
|
|
|
2016-06-02 21:00:57 +08:00
|
|
|
const propTypes = {
|
2022-03-17 01:53:41 +08:00
|
|
|
children: PropTypes.node,
|
|
|
|
moderator: PropTypes.bool,
|
2019-03-23 02:10:47 +08:00
|
|
|
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,
|
2020-09-15 07:13:47 +08:00
|
|
|
emoji: PropTypes.bool,
|
|
|
|
avatar: PropTypes.string,
|
2022-05-03 06:47:46 +08:00
|
|
|
className: PropTypes.string,
|
2022-03-17 01:53:41 +08:00
|
|
|
isSkeleton: PropTypes.bool,
|
2016-06-02 21:00:57 +08:00
|
|
|
};
|
|
|
|
|
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,
|
2024-05-29 21:26:11 +08:00
|
|
|
}) => {
|
|
|
|
const Settings = getSettingsSingletonInstance();
|
|
|
|
const { animations } = Settings.application;
|
2018-08-04 00:31:58 +08:00
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{isSkeleton && (<Styled.Skeleton>{children}</Styled.Skeleton>)}
|
2018-08-04 00:31:58 +08:00
|
|
|
|
2024-05-29 21:26:11 +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
|
|
|
|
2024-05-29 21:26:11 +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>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
};
|
2016-06-02 21:00:57 +08:00
|
|
|
|
|
|
|
UserAvatar.propTypes = propTypes;
|
2017-07-28 21:43:39 +08:00
|
|
|
|
|
|
|
export default UserAvatar;
|