2017-05-03 05:43:37 -04:00
|
|
|
import React from 'react';
|
2017-12-13 06:14:03 -05:00
|
|
|
import PropTypes from 'prop-types';
|
2017-08-07 13:44:55 -04:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-12-13 06:14:03 -05:00
|
|
|
import { autoPlayGif } from '../initial_state';
|
2022-10-27 18:48:45 -04:00
|
|
|
import Avatar from './avatar';
|
2017-05-03 05:43:37 -04:00
|
|
|
|
2017-06-23 13:36:54 -04:00
|
|
|
export default class AvatarOverlay extends React.PureComponent {
|
2017-05-20 11:31:47 -04:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static propTypes = {
|
2017-08-07 13:44:55 -04:00
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
friend: ImmutablePropTypes.map.isRequired,
|
2017-12-13 06:14:03 -05:00
|
|
|
animate: PropTypes.bool,
|
2022-10-27 18:48:45 -04:00
|
|
|
size: PropTypes.number,
|
|
|
|
baseSize: PropTypes.number,
|
|
|
|
overlaySize: PropTypes.number,
|
2017-12-13 06:14:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
animate: autoPlayGif,
|
2022-10-27 18:48:45 -04:00
|
|
|
size: 46,
|
|
|
|
baseSize: 36,
|
|
|
|
overlaySize: 24,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
2022-10-27 18:48:45 -04:00
|
|
|
state = {
|
|
|
|
hovering: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleMouseEnter = () => {
|
|
|
|
if (this.props.animate) return;
|
|
|
|
this.setState({ hovering: true });
|
2023-01-29 19:45:35 -05:00
|
|
|
};
|
2017-05-03 05:43:37 -04:00
|
|
|
|
2022-10-27 18:48:45 -04:00
|
|
|
handleMouseLeave = () => {
|
|
|
|
if (this.props.animate) return;
|
|
|
|
this.setState({ hovering: false });
|
2023-01-29 19:45:35 -05:00
|
|
|
};
|
2017-05-03 05:43:37 -04:00
|
|
|
|
2022-10-27 18:48:45 -04:00
|
|
|
render() {
|
|
|
|
const { account, friend, animate, size, baseSize, overlaySize } = this.props;
|
|
|
|
const { hovering } = this.state;
|
2017-05-03 05:43:37 -04:00
|
|
|
|
|
|
|
return (
|
2022-10-27 18:48:45 -04:00
|
|
|
<div className='account__avatar-overlay' style={{ width: size, height: size }}>
|
|
|
|
<div className='account__avatar-overlay-base'><Avatar animate={hovering || animate} account={account} size={baseSize} /></div>
|
|
|
|
<div className='account__avatar-overlay-overlay'><Avatar animate={hovering || animate} account={friend} size={overlaySize} /></div>
|
2017-05-03 05:43:37 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
}
|