import React, { useState } from 'react'; import { Avatar, Box, Icon, Icons, Modal, Overlay, OverlayBackdrop, OverlayCenter, Text, toRem, } from 'folds'; import classNames from 'classnames'; import FocusTrap from 'focus-trap-react'; import * as css from './styles.css'; import { UserAvatar } from '../user-avatar'; import colorMXID from '../../../util/colorMXID'; import { getMxIdLocalPart } from '../../utils/matrix'; import { BreakWord, LineClamp3 } from '../../styles/Text.css'; import { UserPresence } from '../../hooks/useUserPresence'; import { AvatarPresence, PresenceBadge } from '../presence'; import { ImageViewer } from '../image-viewer'; import { stopPropagation } from '../../utils/keyboard'; import { useOtherUserColor } from '../../hooks/useUserColor'; import { useOtherUserBanner } from '../../hooks/useUserBanner'; import { useOtherUserProfileStyle } from '../../hooks/useUserProfileStyle'; type UserHeroProps = { userId: string; avatarUrl?: string; avatarMxc?: string; presence?: UserPresence; }; export function UserHero({ userId, avatarUrl, avatarMxc, presence }: UserHeroProps) { const [viewAvatar, setViewAvatar] = useState(); const bannerUrl = useOtherUserBanner(userId, avatarMxc); // Now returns blob URL directly const profileStyle = useOtherUserProfileStyle(userId, avatarMxc); return (
{bannerUrl ? ( {userId} ) : ( avatarUrl && ( {userId} ) )}
} > setViewAvatar(avatarUrl) : undefined} className={css.UserHeroAvatar} size="500" style={profileStyle.avatarBorderColor ? { outline: `${toRem(4)} solid ${profileStyle.avatarBorderColor}`, outlineOffset: toRem(-1), } : undefined} > } /> {viewAvatar && ( }> setViewAvatar(undefined), clickOutsideDeactivates: true, escapeDeactivates: stopPropagation, }} > evt.stopPropagation()}> setViewAvatar(undefined)} /> )}
); } type UserHeroNameProps = { displayName?: string; userId: string; avatarMxc?: string; }; export function UserHeroName({ displayName, userId, avatarMxc }: UserHeroNameProps) { const username = getMxIdLocalPart(userId); const userColor = useOtherUserColor(userId, avatarMxc); return ( {displayName ?? username ?? userId} {userId} ); }