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';
|
2016-06-01 04:25:42 +08:00
|
|
|
import cx from 'classnames';
|
2017-07-28 21:43:39 +08:00
|
|
|
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from './styles';
|
2016-06-01 04:25:42 +08:00
|
|
|
|
2016-06-02 21:00:57 +08:00
|
|
|
const propTypes = {
|
2017-07-28 21:43:39 +08:00
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
moderator: PropTypes.bool.isRequired,
|
|
|
|
presenter: PropTypes.bool.isRequired,
|
|
|
|
talking: PropTypes.bool.isRequired,
|
|
|
|
muted: PropTypes.bool.isRequired,
|
|
|
|
listenOnly: PropTypes.bool.isRequired,
|
|
|
|
voice: PropTypes.bool.isRequired,
|
|
|
|
color: PropTypes.string,
|
|
|
|
className: PropTypes.string,
|
2016-06-02 21:00:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
2017-07-28 21:43:39 +08:00
|
|
|
moderator: false,
|
|
|
|
presenter: false,
|
|
|
|
talking: false,
|
|
|
|
muted: false,
|
|
|
|
listenOnly: false,
|
|
|
|
voice: false,
|
|
|
|
color: '#000',
|
2017-10-11 06:08:51 +08:00
|
|
|
className: null,
|
2016-06-02 21:00:57 +08:00
|
|
|
};
|
|
|
|
|
2017-07-28 21:43:39 +08:00
|
|
|
const UserAvatar = ({
|
|
|
|
children,
|
|
|
|
moderator,
|
|
|
|
presenter,
|
|
|
|
talking,
|
|
|
|
muted,
|
|
|
|
listenOnly,
|
|
|
|
color,
|
|
|
|
voice,
|
|
|
|
className,
|
|
|
|
}) => (
|
|
|
|
<div
|
2018-03-06 23:32:13 +08:00
|
|
|
aria-hidden="true"
|
2018-01-09 10:43:34 +08:00
|
|
|
data-test="userAvatar"
|
2017-07-28 21:43:39 +08:00
|
|
|
className={cx(styles.avatar, {
|
|
|
|
[styles.moderator]: moderator,
|
|
|
|
[styles.presenter]: presenter,
|
|
|
|
[styles.muted]: muted,
|
|
|
|
[styles.listenOnly]: listenOnly,
|
2017-10-05 03:08:33 +08:00
|
|
|
[styles.talking]: (talking && !muted),
|
2017-07-28 21:43:39 +08:00
|
|
|
[styles.voice]: voice,
|
|
|
|
}, className)}
|
|
|
|
style={{
|
|
|
|
backgroundColor: color,
|
|
|
|
color, // We need the same color on both for the border
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className={styles.content}>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2016-06-02 21:00:57 +08:00
|
|
|
|
|
|
|
UserAvatar.propTypes = propTypes;
|
|
|
|
UserAvatar.defaultProps = defaultProps;
|
2017-07-28 21:43:39 +08:00
|
|
|
|
|
|
|
export default UserAvatar;
|