mirror of https://github.com/msgbyte/tailchat
feat: 增加群组成员popover
parent
240bd72cb6
commit
ae3829628a
@ -0,0 +1,40 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Avatar, AvatarProps } from '../Avatar';
|
||||
import { Image } from '../Image';
|
||||
|
||||
export const AvatarWithPreview: React.FC<AvatarProps> = React.memo((props) => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const hasImage = typeof props.src === 'string';
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
style={{
|
||||
cursor: hasImage ? 'pointer' : 'auto',
|
||||
}}
|
||||
onClick={() => setVisible(!visible)}
|
||||
>
|
||||
<Avatar {...props} />
|
||||
</div>
|
||||
{hasImage && (
|
||||
<div
|
||||
style={{
|
||||
display: 'none',
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
preview={{
|
||||
visible,
|
||||
src: String(props.src),
|
||||
onVisibleChange: (value) => {
|
||||
setVisible(value);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
});
|
||||
AvatarWithPreview.displayName = 'AvatarWithPreview';
|
@ -0,0 +1,29 @@
|
||||
import { Tag } from 'antd';
|
||||
import React from 'react';
|
||||
import { AvatarWithPreview } from 'tailchat-design';
|
||||
import { t, UserBaseInfo } from 'tailchat-shared';
|
||||
|
||||
export const GroupUserPopover: React.FC<{
|
||||
userInfo: UserBaseInfo;
|
||||
}> = React.memo((props) => {
|
||||
const { userInfo } = props;
|
||||
|
||||
return (
|
||||
<div className="w-80">
|
||||
<AvatarWithPreview
|
||||
size={80}
|
||||
src={userInfo.avatar}
|
||||
name={userInfo.nickname}
|
||||
/>
|
||||
<div className="text-xl mt-2">
|
||||
<span className="font-semibold">{userInfo.nickname}</span>
|
||||
<span className="opacity-60 ml-1">#{userInfo.discriminator}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{userInfo.temporary && <Tag color="processing">{t('游客')}</Tag>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
GroupUserPopover.displayName = 'GroupUserPopover';
|
Loading…
Reference in New Issue