bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/user-avatar/component.jsx
Arthurk12 f92d3a1ca5 fix(user-list): center icons on safari
Centers icons indicating presenter, audio state and whiteboard access in the
user list.
2023-09-12 17:06:32 -03:00

104 lines
2.3 KiB
JavaScript
Executable File

import React from 'react';
import PropTypes from 'prop-types';
import Settings from '/imports/ui/services/settings';
import Styled from './styles';
import browserInfo from '/imports/utils/browserInfo';
const propTypes = {
children: PropTypes.node,
moderator: PropTypes.bool,
presenter: PropTypes.bool,
talking: PropTypes.bool,
muted: PropTypes.bool,
listenOnly: PropTypes.bool,
voice: PropTypes.bool,
noVoice: PropTypes.bool,
color: PropTypes.string,
emoji: PropTypes.bool,
avatar: PropTypes.string,
className: PropTypes.string,
isSkeleton: PropTypes.bool,
};
const defaultProps = {
children: <></>,
moderator: false,
presenter: false,
talking: false,
muted: false,
listenOnly: false,
voice: false,
noVoice: false,
color: '#000',
emoji: false,
avatar: '',
className: '',
isSkeleton: false,
};
const { animations } = Settings.application;
const { isSafari } = browserInfo;
const UserAvatar = ({
children,
moderator,
presenter,
className,
talking,
muted,
listenOnly,
color,
voice,
emoji,
avatar,
noVoice,
whiteboardAccess,
isSkeleton,
}) => (
<>
{isSkeleton && (<Styled.Skeleton>{children}</Styled.Skeleton>)}
{!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}
isSafari={isSafari}
style={{
backgroundColor: color,
color, // We need the same color on both for the border
}}
>
<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;
UserAvatar.defaultProps = defaultProps;
export default UserAvatar;