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