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

101 lines
2.2 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';
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,
};
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: '',
className: '',
2022-03-17 01:53:41 +08:00
isSkeleton: false,
};
2021-10-29 19:23:50 +08:00
const { animations } = Settings.application;
2017-07-28 21:43:39 +08:00
const UserAvatar = ({
children,
moderator,
presenter,
className,
2017-07-28 21:43:39 +08:00
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}
className={className}
2022-03-17 01:53:41 +08:00
whiteboardAccess={whiteboardAccess && !presenter}
muted={muted}
listenOnly={listenOnly}
voice={voice}
noVoice={noVoice && !listenOnly}
style={{
backgroundColor: color,
color, // We need the same color on both for the border
}}
>
2018-08-04 00:31:58 +08:00
<Styled.Talking talking={talking && !muted} animations={animations} />
2022-03-17 01:53:41 +08:00
{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;