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