2023-04-17 08:07:27 +03:00
|
|
|
import { useHovering } from '../../hooks/useHovering';
|
2023-05-10 13:59:29 +03:00
|
|
|
import type { Account } from '../../types/resources';
|
2023-04-17 08:07:27 +03:00
|
|
|
import { autoPlayGif } from '../initial_state';
|
|
|
|
|
2023-05-10 13:59:29 +03:00
|
|
|
interface Props {
|
2023-07-13 12:49:16 +03:00
|
|
|
account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
|
|
|
|
friend: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
|
2023-04-17 08:07:27 +03:00
|
|
|
size?: number;
|
|
|
|
baseSize?: number;
|
|
|
|
overlaySize?: number;
|
2023-05-10 13:59:29 +03:00
|
|
|
}
|
2023-04-17 08:07:27 +03:00
|
|
|
|
|
|
|
export const AvatarOverlay: React.FC<Props> = ({
|
|
|
|
account,
|
|
|
|
friend,
|
|
|
|
size = 46,
|
|
|
|
baseSize = 36,
|
|
|
|
overlaySize = 24,
|
|
|
|
}) => {
|
2023-05-09 20:02:12 +03:00
|
|
|
const { hovering, handleMouseEnter, handleMouseLeave } =
|
|
|
|
useHovering(autoPlayGif);
|
|
|
|
const accountSrc = hovering
|
|
|
|
? account?.get('avatar')
|
|
|
|
: account?.get('avatar_static');
|
|
|
|
const friendSrc = hovering
|
|
|
|
? friend?.get('avatar')
|
|
|
|
: friend?.get('avatar_static');
|
2023-04-17 08:07:27 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-05-09 20:02:12 +03:00
|
|
|
className='account__avatar-overlay'
|
|
|
|
style={{ width: size, height: size }}
|
2023-04-17 08:07:27 +03:00
|
|
|
onMouseEnter={handleMouseEnter}
|
|
|
|
onMouseLeave={handleMouseLeave}
|
|
|
|
>
|
|
|
|
<div className='account__avatar-overlay-base'>
|
|
|
|
<div
|
|
|
|
className='account__avatar'
|
|
|
|
style={{ width: `${baseSize}px`, height: `${baseSize}px` }}
|
|
|
|
>
|
|
|
|
{accountSrc && <img src={accountSrc} alt={account?.get('acct')} />}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='account__avatar-overlay-overlay'>
|
|
|
|
<div
|
|
|
|
className='account__avatar'
|
|
|
|
style={{ width: `${overlaySize}px`, height: `${overlaySize}px` }}
|
|
|
|
>
|
|
|
|
{friendSrc && <img src={friendSrc} alt={friend?.get('acct')} />}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|