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