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