File tree Expand file tree Collapse file tree 8 files changed +166
-0
lines changed Expand file tree Collapse file tree 8 files changed +166
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import styled from 'styled-components' ;
3
+ import VelogResponsive from '../velog/VelogResponsive' ;
4
+ import palette from '../../lib/styles/palette' ;
5
+
6
+ const PostCommentsTemplateBlock = styled ( VelogResponsive ) `
7
+ margin-top: 7.5rem;
8
+ color: ${ palette . gray8 } ;
9
+ h4 {
10
+ font-size: 1.125rem;
11
+ line-height: 1.5;
12
+ font-weight: 600;
13
+ margin-bottom: 1rem;
14
+ }
15
+ ` ;
16
+
17
+ const Contents = styled . div `` ;
18
+
19
+ export interface PostCommentsTemplateProps {
20
+ count : number ;
21
+ }
22
+
23
+ const PostCommentsTemplate : React . FC < PostCommentsTemplateProps > = ( {
24
+ count,
25
+ children,
26
+ } ) => {
27
+ return (
28
+ < PostCommentsTemplateBlock >
29
+ < h4 > { count } 개의 댓글</ h4 >
30
+ < Contents > { children } </ Contents >
31
+ </ PostCommentsTemplateBlock >
32
+ ) ;
33
+ } ;
34
+
35
+ export default PostCommentsTemplate ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import styled from 'styled-components' ;
3
+ import TextareaAutosize from 'react-textarea-autosize' ;
4
+ import Button from '../common/Button' ;
5
+
6
+ const PostCommentsWriteBlock = styled . div `
7
+ > .buttons-wrapper {
8
+ display: flex;
9
+ justify-content: flex-end;
10
+ }
11
+ ` ;
12
+ const StyledTextarea = styled ( TextareaAutosize ) `` ;
13
+
14
+ export interface PostCommentsWriteProps { }
15
+
16
+ const PostCommentsWrite : React . FC < PostCommentsWriteProps > = props => {
17
+ return (
18
+ < PostCommentsWriteBlock >
19
+ < StyledTextarea placeholder = "댓글을 작성하세요" />
20
+ < div className = "buttons-wrapper" >
21
+ < Button > 댓글 작성</ Button >
22
+ </ div >
23
+ </ PostCommentsWriteBlock >
24
+ ) ;
25
+ } ;
26
+
27
+ export default PostCommentsWrite ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { render } from 'react-testing-library' ;
3
+ import PostCommentsTemplate , {
4
+ PostCommentsTemplateProps ,
5
+ } from '../PostCommentsTemplate' ;
6
+
7
+ describe ( 'PostCommentsTemplate' , ( ) => {
8
+ const setup = ( props : Partial < PostCommentsTemplateProps > = { } ) => {
9
+ const initialProps : PostCommentsTemplateProps = {
10
+ count : 9 ,
11
+ } ;
12
+ const utils = render (
13
+ < PostCommentsTemplate { ...initialProps } { ...props } >
14
+ contents
15
+ </ PostCommentsTemplate > ,
16
+ ) ;
17
+ return {
18
+ ...utils ,
19
+ } ;
20
+ } ;
21
+ it ( 'shows comments count and children' , ( ) => {
22
+ const { getByText } = setup ( ) ;
23
+ getByText ( '9개의 댓글' ) ;
24
+ getByText ( 'contents' ) ;
25
+ } ) ;
26
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { render } from 'react-testing-library' ;
3
+ import PostCommentsWrite , {
4
+ PostCommentsWriteProps ,
5
+ } from '../PostCommentsWrite' ;
6
+
7
+ describe ( 'PostCommentsWrite' , ( ) => {
8
+ const setup = ( props : Partial < PostCommentsWriteProps > = { } ) => {
9
+ const initialProps : PostCommentsWriteProps = { } ;
10
+ const utils = render ( < PostCommentsWrite { ...initialProps } { ...props } /> ) ;
11
+
12
+ const textarea = utils . getByPlaceholderText ( '댓글을 작성하세요' ) ;
13
+ const writeButton = utils . getByText ( '댓글 작성' ) ;
14
+ return {
15
+ textarea,
16
+ writeButton,
17
+ ...utils ,
18
+ } ;
19
+ } ;
20
+ it ( 'renders textarea and a button' , ( ) => {
21
+ const { textarea, writeButton } = setup ( ) ;
22
+ expect ( textarea ) . toBeVisible ( ) ;
23
+ expect ( writeButton ) . toBeVisible ( ) ;
24
+ } ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { render } from 'react-testing-library' ;
3
+ import PostCommentsWrite , {
4
+ PostCommentsWriteProps ,
5
+ } from '../PostCommentsWrite' ;
6
+
7
+ describe ( 'PostCommentsWrite' , ( ) => {
8
+ const setup = ( props : Partial < PostCommentsWriteProps > = { } ) => {
9
+ const initialProps : PostCommentsWriteProps = { } ;
10
+ const utils = render ( < PostCommentsWrite { ...initialProps } { ...props } /> ) ;
11
+
12
+ const textarea = utils . getByPlaceholderText ( '댓글을 작성하세요' ) ;
13
+ const writeButton = utils . getByText ( '댓글 작성' ) ;
14
+ return {
15
+ textarea,
16
+ writeButton,
17
+ ...utils ,
18
+ } ;
19
+ } ;
20
+ it ( 'renders textarea and a button' , ( ) => {
21
+ const { textarea, writeButton } = setup ( ) ;
22
+ expect ( textarea ) . toBeVisible ( ) ;
23
+ expect ( writeButton ) . toBeVisible ( ) ;
24
+ } ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import PostCommentsTemplate from '../../components/post/PostCommentsTemplate' ;
3
+ import PostCommentsWriteContainer from './PostCommentsWriteContainer' ;
4
+
5
+ export interface PostCommentsProps { }
6
+
7
+ const PostComments : React . FC < PostCommentsProps > = props => {
8
+ return (
9
+ < PostCommentsTemplate count = { 9 } >
10
+ < PostCommentsWriteContainer />
11
+ </ PostCommentsTemplate >
12
+ ) ;
13
+ } ;
14
+
15
+ export default PostComments ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import PostCommentsWrite from '../../components/post/PostCommentsWrite' ;
3
+ export interface PostCommentWriteContainerProps { }
4
+
5
+ const PostCommentsWriteContainer : React . FC <
6
+ PostCommentWriteContainerProps
7
+ > = props => {
8
+ return < PostCommentsWrite /> ;
9
+ } ;
10
+
11
+ export default PostCommentsWriteContainer ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Query, QueryResult } from 'react-apollo';
3
3
import { READ_POST , SinglePost } from '../../lib/graphql/post' ;
4
4
import PostHead from '../../components/post/PostHead' ;
5
5
import PostContent from '../../components/post/PostContent' ;
6
+ import PostComments from './PostComments' ;
6
7
7
8
export interface PostViewerProps {
8
9
username : string ;
@@ -39,6 +40,7 @@ const PostViewer: React.FC<PostViewerProps> = ({ username, urlSlug }) => {
39
40
}
40
41
/>
41
42
< PostContent isMarkdown = { post . is_markdown } body = { post . body } />
43
+ < PostComments />
42
44
</ >
43
45
) ;
44
46
} }
You can’t perform that action at this time.
0 commit comments