Skip to content

Commit 2c98427

Browse files
committed
Implements subcomments loading
1 parent 217a99e commit 2c98427

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

src/components/post/PostCommentItem.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Typography from '../common/Typography';
77
import { PlusBoxIcon, MinusBoxIcon } from '../../static/svg';
88
import { userThumbnail } from '../../static/images';
99
import useBoolean from '../../lib/hooks/useBoolean';
10+
import PostRepliesContainer from '../../containers/post/PostRepliesContainer';
1011

1112
const PostCommentItemBlock = styled.div`
1213
padding-top: 1.5rem;
@@ -125,6 +126,7 @@ const PostCommentItem: React.FC<PostCommentItemProps> = ({ comment }) => {
125126
</Typography>
126127
<CommentFoot>
127128
<Toggler open={open} onToggle={onToggle} count={replies_count} />
129+
{open && <PostRepliesContainer commentId={id} />}
128130
</CommentFoot>
129131
</PostCommentItemBlock>
130132
);

src/components/post/PostCommentsList.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import styled from 'styled-components';
33
import { Comment } from '../../lib/graphql/post';
44
import PostCommentItem from './PostCommentItem';
55

6-
const PostCommentsListBlock = styled.div`
7-
margin-top: 2.5rem;
8-
`;
6+
const PostCommentsListBlock = styled.div``;
97

108
export interface PostCommentsListProps {
119
comments: Comment[];

src/components/post/PostReplies.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import styled from 'styled-components';
33
import { Comment } from '../../lib/graphql/post';
44
import PostCommentsList from './PostCommentsList';
55

6-
const PostRepliesBlock = styled.div``;
6+
const PostRepliesBlock = styled.div`
7+
border: solid 1px rgba(0, 0, 0, 0.02);
8+
background-color: rgba(0, 0, 0, 0.015);
9+
padding-left: 1.5rem;
10+
padding-right: 1.5rem;
11+
border-radius: 4px;
12+
margin-top: 1.3125rem;
13+
`;
714

815
export interface PostRepliesProps {
916
comments: Comment[];

src/containers/post/PostComments.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ import PostCommentsWriteContainer from './PostCommentsWriteContainer';
44
import { Comment, WRITE_COMMENT } from '../../lib/graphql/post';
55
import PostCommentsList from '../../components/post/PostCommentsList';
66
import { MutationResult, Mutation } from 'react-apollo';
7+
import styled from 'styled-components';
78

89
export interface PostCommentsProps {
910
comments: Comment[];
1011
postId: string;
1112
}
1213

14+
const MarginTop = styled.div`
15+
margin-top: 2.5rem;
16+
`;
17+
1318
const PostComments: React.FC<PostCommentsProps> = ({ comments, postId }) => {
1419
return (
1520
<PostCommentsTemplate count={comments.length}>
1621
<PostCommentsWriteContainer postId={postId} />
17-
<PostCommentsList comments={comments} />;
22+
<MarginTop>
23+
<PostCommentsList comments={comments} />
24+
</MarginTop>
1825
</PostCommentsTemplate>
1926
);
2027
};

src/containers/post/PostRepliesContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PostRepliesContainer: React.FC<PostRepliesProps> = ({ commentId }) => {
1818
error,
1919
data,
2020
}: QueryResult<{ comment: CommentWithReplies }>) => {
21+
console.log(loading, error, data);
2122
if (loading || !data) return null;
2223
return <PostReplies comments={data.comment.replies} />;
2324
}}

0 commit comments

Comments
 (0)