import React, { useState } from 'react'; import { Avatar, Box, Icon, Icons, Modal, Overlay, OverlayBackdrop, OverlayCenter, Text, } 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 { extendedProfileFields } from '../../hooks/useExtendedProfile'; type UserHeroProps = { userId: string; avatarUrl?: string; presence?: UserPresence; }; export function UserHero({ userId, avatarUrl, presence }: UserHeroProps) { const [viewAvatar, setViewAvatar] = useState(); return (
{avatarUrl && ( {userId} )}
} > setViewAvatar(avatarUrl) : undefined} className={css.UserHeroAvatar} size="500" > } /> {viewAvatar && ( }> setViewAvatar(undefined), clickOutsideDeactivates: true, escapeDeactivates: stopPropagation, }} > evt.stopPropagation()}> setViewAvatar(undefined)} /> )}
); } type UserHeroNameProps = { displayName?: string; userId: string; extendedProfile?: extendedProfileFields; }; export function UserHeroName({ displayName, userId, extendedProfile }: UserHeroNameProps) { const username = getMxIdLocalPart(userId); const pronouns = extendedProfile?.["io.fsky.nyx.pronouns"]; return ( {displayName ?? username ?? userId} @{username} {pronouns && ยท {pronouns.map(({ summary }) => summary).join(", ")}} ); }