mirror of https://github.com/msgbyte/tailchat
feat: topic 内容与回复渲染
parent
5db553aa7c
commit
2db0b07f29
@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import { Avatar } from 'tailchat-design';
|
||||
import { useCachedUserInfo } from 'tailchat-shared';
|
||||
|
||||
/**
|
||||
* 用户头像组件
|
||||
*/
|
||||
export const UserAvatar: React.FC<{
|
||||
userId: string;
|
||||
className?: string;
|
||||
}> = React.memo((props) => {
|
||||
const { userId, className } = props;
|
||||
const cachedUserInfo = useCachedUserInfo(userId);
|
||||
|
||||
return (
|
||||
<Avatar
|
||||
className={className}
|
||||
src={cachedUserInfo.avatar}
|
||||
name={cachedUserInfo.nickname}
|
||||
/>
|
||||
);
|
||||
});
|
||||
UserAvatar.displayName = 'UserAvatar';
|
@ -0,0 +1,30 @@
|
||||
import { UserName } from '@capital/component';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import type { GroupTopicComment } from '../types';
|
||||
|
||||
const Root = styled.div`
|
||||
padding: 10px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 3px;
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
|
||||
> div {
|
||||
display: flex;
|
||||
}
|
||||
`;
|
||||
|
||||
export const TopicComments: React.FC<{
|
||||
comments: GroupTopicComment[];
|
||||
}> = React.memo((props) => {
|
||||
return (
|
||||
<Root>
|
||||
{props.comments.map((comment) => (
|
||||
<div key={comment.id}>
|
||||
<UserName userId={comment.author} />: <div>{comment.content}</div>
|
||||
</div>
|
||||
))}
|
||||
</Root>
|
||||
);
|
||||
});
|
||||
TopicComments.displayName = 'TopicComments';
|
@ -0,0 +1,16 @@
|
||||
export interface GroupTopicComment {
|
||||
author: string;
|
||||
content: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface GroupTopic {
|
||||
_id: string;
|
||||
author: string;
|
||||
comments: GroupTopicComment[];
|
||||
content: string;
|
||||
createdAt: string;
|
||||
groupId: string;
|
||||
panelId: string;
|
||||
updatedAt: string;
|
||||
}
|
Loading…
Reference in New Issue