|
|
@ -1,8 +1,10 @@
|
|
|
|
import { getMessageRender } from '@capital/common';
|
|
|
|
import { getMessageRender } from '@capital/common';
|
|
|
|
import { UserAvatar, UserName } from '@capital/component';
|
|
|
|
import { UserAvatar, UserName } from '@capital/component';
|
|
|
|
import React from 'react';
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import type { GroupTopicComment } from '../types';
|
|
|
|
import type { GroupTopicComment } from '../types';
|
|
|
|
|
|
|
|
import _takeRight from 'lodash/takeRight';
|
|
|
|
|
|
|
|
import { Translate } from '../translate';
|
|
|
|
|
|
|
|
|
|
|
|
const Root = styled.div`
|
|
|
|
const Root = styled.div`
|
|
|
|
padding: 10px;
|
|
|
|
padding: 10px;
|
|
|
@ -14,6 +16,16 @@ const Root = styled.div`
|
|
|
|
background-color: rgba(0, 0, 0, 0.25);
|
|
|
|
background-color: rgba(0, 0, 0, 0.25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.show-more {
|
|
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
|
|
color: #40a9ff;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.comment-item {
|
|
|
|
.comment-item {
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
margin-bottom: 10px;
|
|
|
@ -37,9 +49,21 @@ const Root = styled.div`
|
|
|
|
export const TopicComments: React.FC<{
|
|
|
|
export const TopicComments: React.FC<{
|
|
|
|
comments: GroupTopicComment[];
|
|
|
|
comments: GroupTopicComment[];
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
|
|
|
|
const [showAllComment, setShowAllComment] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const comments = showAllComment
|
|
|
|
|
|
|
|
? props.comments
|
|
|
|
|
|
|
|
: _takeRight(props.comments, 2);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Root>
|
|
|
|
<Root>
|
|
|
|
{props.comments.map((comment) => (
|
|
|
|
{props.comments.length > 2 && !showAllComment && (
|
|
|
|
|
|
|
|
<div className="show-more" onClick={() => setShowAllComment(true)}>
|
|
|
|
|
|
|
|
{Translate.loadMore}...
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{comments.map((comment) => (
|
|
|
|
<div key={comment.id} className="comment-item">
|
|
|
|
<div key={comment.id} className="comment-item">
|
|
|
|
<div className="left">
|
|
|
|
<div className="left">
|
|
|
|
<UserAvatar userId={comment.author} size={24} />
|
|
|
|
<UserAvatar userId={comment.author} size={24} />
|
|
|
|