Skip to content

Commit

Permalink
[Add] 댓글 랜더링 기능 #140
Browse files Browse the repository at this point in the history
등록된 댓글들 보여지도록 댓글 컴포넌트를 분리하고 연결함
  • Loading branch information
WooYeonSeo committed Dec 4, 2019
1 parent 1a41b18 commit f8d7022
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 52 deletions.
50 changes: 0 additions & 50 deletions client/src/composition/Feed/Comment.tsx

This file was deleted.

14 changes: 12 additions & 2 deletions client/src/composition/Feed/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components';
import FeedHeader from './FeedHeader';
import FeedBody from './FeedBody';
import FeedFooter from './FeedFooter';
import Comment from './Comment';
import CommentContainer from './FeedComment';
import { IFeed } from 'react-components.d';

const FeedDiv = styled.div`
Expand Down Expand Up @@ -65,7 +65,17 @@ function Feed({ content, createdAt, feedinfo }: Iprops) {
feedId={feedinfo.feedId}
/>
</FeedContentDiv>
<Comment />
{feedinfo.comments && feedinfo.comments.length > 0 ? (
feedinfo.comments.map(comment => {
if (comment) {
return <CommentContainer comment={comment} />;
} else {
return <></>;
}
})
) : (
<></>
)}
</FeedDiv>
</>
);
Expand Down
40 changes: 40 additions & 0 deletions client/src/composition/Feed/FeedComment/CommentPresentor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import styled from 'styled-components';
import Profile from 'components/Profile';
import { Comment } from 'react-components.d';

const CommentBubble = styled.div`
background-color: #f2f3f5;
border-radius: 18px;
box-sizing: border-box;
color: #1c1e21;
display: inline-block;
line-height: 16px;
margin: 0;
max-width: 100%;
word-wrap: break-word;
white-space: normal;
word-break: break-word;
`;

const CommentText = styled.p`
padding: 8px 10px;
`;

// 역할 :
const CommentPresentor = ({ content }: Comment) => {
return (
<>
<Profile
imageUrl={process.env.PUBLIC_URL + '/images/profile.jpg'}
alt={'profile image'}
size="32px"
/>
<CommentBubble>
<CommentText>댓글 : {content}</CommentText>
</CommentBubble>
</>
);
};

export default CommentPresentor;
35 changes: 35 additions & 0 deletions client/src/composition/Feed/FeedComment/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import styled from 'styled-components';
import Profile from 'components/Profile';
import CommentPresentor from './CommentPresentor';
import { Comment, Maybe } from 'react-components.d';

// comment
const CommentDiv = styled.div`
border-top: 1px solid #dadde1;
padding: 4px 12px;
`;

// 역할 :
const CommentContainer = ({ comment }: { comment: Comment }) => {
return (
<>
<CommentDiv>
<div>
<CommentPresentor content={comment.content} />
<div>
<Profile
imageUrl={process.env.PUBLIC_URL + '/images/profile.jpg'}
alt={'profile image'}
size="32px"
/>
<input type="text"></input>
<input type="button" value="입력"></input>
</div>
</div>
</CommentDiv>
</>
);
};

export default CommentContainer;

0 comments on commit f8d7022

Please sign in to comment.