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