forked from EFUB/efub4-first-react-study
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PostViewPage.jsx
88 lines (82 loc) Β· 2.03 KB
/
PostViewPage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React, { useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import styled from "styled-components";
import CommentList from "../list/CommentList";
import TextInput from "../UI/TextInput";
import Button from "../UI/Button";
import data from "../../data.json";
const Wrapper = styled.div`
width: calc(100%-32px);
padding: 16px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
`;
const Container = styled.div`
width: 100$;
max-width: 720px;
& > * {
:not(:last-child) {
margin-bottom: 16px;
}
}
`;
const PostContainer = styled.div`
padding: 8px 16px;
border: 1px solid grey;
border-radius: 8px;
`;
const TitleText = styled.p`
font-size:28px;
font-weight;500;
`;
const ContentText = styled.p`
font-size: 20px;
line-height: 32px;
white-space: pre-wrap;
`;
const CommentLabel = styled.p`
font-size: 16px;
font-weight: 500;
`;
function PostViewPage(props) {
const navigate = useNavigate();
const { postId } = useParams();
const post = data.find((item) => {
return item.id == postId;
});
const [comment, setComment] = useState("");
return (
<Wrapper>
<Container>
<Button
title="λ€λ‘κ°κΈ°"
onClick={() => {
navigate("/");
}}
></Button>
<PostContainer>
<TitleText>{post.title}</TitleText>
<ContentText>{post.content}</ContentText>
</PostContainer>
<CommentLabel>λκΈ</CommentLabel>
<CommentList comments={post.comments}></CommentList>
<TextInput
height={40}
value={comment}
onChange={(event) => {
setComment(event.target.value);
}}
></TextInput>
<Button
title="λκΈ μμ±νκΈ°"
onClick={() => {
navigate("/");
}}
></Button>
</Container>
</Wrapper>
);
}
export default PostViewPage;