forked from github/cinny
* WIP - new profile view * render common rooms in user profile * add presence component * WIP - room user profile * temp hide profile button * show mutual rooms in spaces, rooms and direct messages categories * add message button * add option to change user powers in profile * improve ban info and option to unban * add share user button in user profile * add option to block user in user profile * improve blocked user alert body * add moderation tool in user profile * open profile view on left side in member drawer * open new user profile in all places
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import React from 'react';
|
|
import { Avatar, Box, Icon, Icons, Text } from 'folds';
|
|
import classNames from 'classnames';
|
|
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';
|
|
|
|
type UserHeroProps = {
|
|
userId: string;
|
|
avatarUrl?: string;
|
|
presence?: UserPresence;
|
|
};
|
|
export function UserHero({ userId, avatarUrl, presence }: UserHeroProps) {
|
|
return (
|
|
<Box direction="Column" className={css.UserHero}>
|
|
<div
|
|
className={css.UserHeroCoverContainer}
|
|
style={{
|
|
backgroundColor: colorMXID(userId),
|
|
filter: avatarUrl ? undefined : 'brightness(50%)',
|
|
}}
|
|
>
|
|
{avatarUrl && <img className={css.UserHeroCover} src={avatarUrl} alt={userId} />}
|
|
</div>
|
|
<div className={css.UserHeroAvatarContainer}>
|
|
<AvatarPresence
|
|
className={css.UserAvatarContainer}
|
|
badge={
|
|
presence && <PresenceBadge presence={presence.presence} status={presence.status} />
|
|
}
|
|
>
|
|
<Avatar className={css.UserHeroAvatar} size="500">
|
|
<UserAvatar
|
|
userId={userId}
|
|
src={avatarUrl}
|
|
alt={userId}
|
|
renderFallback={() => <Icon size="500" src={Icons.User} filled />}
|
|
/>
|
|
</Avatar>
|
|
</AvatarPresence>
|
|
</div>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
type UserHeroNameProps = {
|
|
displayName?: string;
|
|
userId: string;
|
|
};
|
|
export function UserHeroName({ displayName, userId }: UserHeroNameProps) {
|
|
const username = getMxIdLocalPart(userId);
|
|
|
|
return (
|
|
<Box grow="Yes" direction="Column" gap="0">
|
|
<Box alignItems="Baseline" gap="200" wrap="Wrap">
|
|
<Text
|
|
size="H4"
|
|
className={classNames(BreakWord, LineClamp3)}
|
|
title={displayName ?? username}
|
|
>
|
|
{displayName ?? username ?? userId}
|
|
</Text>
|
|
</Box>
|
|
<Box alignItems="Center" gap="100" wrap="Wrap">
|
|
<Text size="T200" className={classNames(BreakWord, LineClamp3)} title={username}>
|
|
@{username}
|
|
</Text>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
}
|