2023-04-17 15:07:27 +10:00
|
|
|
import { useHovering } from '../../hooks/useHovering';
|
2023-05-10 20:59:29 +10:00
|
|
|
import type { Account } from '../../types/resources';
|
2023-04-17 15:07:27 +10:00
|
|
|
import { autoPlayGif } from '../initial_state';
|
|
|
|
|
2023-05-10 20:59:29 +10:00
|
|
|
interface Props {
|
2023-07-13 19:49:16 +10: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 15:07:27 +10:00
|
|
|
size?: number;
|
|
|
|
baseSize?: number;
|
|
|
|
overlaySize?: number;
|
2023-05-10 20:59:29 +10:00
|
|
|
}
|
2023-04-17 15:07:27 +10:00
|
|
|
|
|
|
|
export const AvatarOverlay: React.FC<Props> = ({
|
|
|
|
account,
|
|
|
|
friend,
|
|
|
|
size = 46,
|
|
|
|
baseSize = 36,
|
|
|
|
overlaySize = 24,
|
|
|
|
}) => {
|
2023-05-10 03:02:12 +10: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 15:07:27 +10:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-05-10 03:02:12 +10:00
|
|
|
className='account__avatar-overlay'
|
|
|
|
style={{ width: size, height: size }}
|
2023-04-17 15:07:27 +10: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>
|
|
|
|
);
|
|
|
|
};
|