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

102 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';
2021-10-29 19:23:50 +08:00
import Settings from '/imports/ui/services/settings';
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,
2022-03-17 01:53:41 +08:00
isSkeleton: PropTypes.bool,
};
const defaultProps = {
2022-03-17 01:53:41 +08:00
children: <></>,
moderator: false,
2017-07-28 21:43:39 +08:00
presenter: false,
talking: false,
muted: false,
listenOnly: false,
voice: false,
noVoice: false,
2017-07-28 21:43:39 +08:00
color: '#000',
emoji: false,
avatar: '',
2022-03-17 01:53:41 +08:00
isSkeleton: false,
};
2021-10-29 19:23:50 +08:00
const { animations } = Settings.application;
const { isChrome, isFirefox, isEdge } = browserInfo;
2017-07-28 21:43:39 +08:00
const UserAvatar = ({
children,
moderator,
presenter,
talking,
muted,
listenOnly,
color,
voice,
emoji,
avatar,
noVoice,
whiteboardAccess,
2022-03-17 01:53:41 +08:00
isSkeleton,
2017-07-28 21:43:39 +08:00
}) => (
2022-03-17 01:53:41 +08:00
<>
{isSkeleton && (<Styled.Skeleton>{children}</Styled.Skeleton>)}
2018-08-04 00:31:58 +08:00
2022-03-17 01:53:41 +08:00
{!isSkeleton && (
<Styled.Avatar
aria-hidden="true"
data-test={moderator ? 'moderatorAvatar' : 'viewerAvatar'}
moderator={moderator}
presenter={presenter}
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
}}
>
2018-08-04 00:31:58 +08:00
2022-03-17 01:53:41 +08:00
<Styled.Talking talking={talking && !muted && avatar.length === 0} 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;
UserAvatar.defaultProps = defaultProps;
2017-07-28 21:43:39 +08:00
export default UserAvatar;