import { useHovering } from 'mastodon/hooks/useHovering'; import { autoPlayGif } from 'mastodon/initial_state'; import type { Account } from 'mastodon/models/account'; interface Props { 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 size?: number; baseSize?: number; overlaySize?: number; } const handleImgLoadError = (error: { currentTarget: HTMLElement }) => { // // When the img tag fails to load the image, set the img tag to display: none. This prevents the // alt-text from overrunning the containing div. // error.currentTarget.style.display = 'none'; }; export const AvatarOverlay: React.FC = ({ account, friend, size = 46, baseSize = 36, overlaySize = 24, }) => { 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'); return (
{accountSrc && ( {account?.get('acct')} )}
{friendSrc && ( {friend?.get('acct')} )}
); };