-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assignment: 한슬희 #1
base: main
Are you sure you want to change the base?
Changes from 1 commit
3d8326e
13fc08c
4799a1b
4a2f474
1368179
1d182fc
feeab8b
bc162b2
8801337
ec9bac9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,81 @@ | ||||||
/** @jsxImportSource @emotion/react */ | ||||||
|
||||||
import { css } from "@emotion/react"; | ||||||
import { ChangeEvent, FormEvent, useState } from "react"; | ||||||
|
||||||
interface IComment { | ||||||
name: string; | ||||||
summary: string; | ||||||
} | ||||||
|
||||||
function Comment() { | ||||||
const [comment, setComment] = useState<IComment[]>([]); | ||||||
const [messageState, setMessageState] = useState("댓글이 아직 없어요"); | ||||||
const [nameState, setNameState] = useState<string>(""); | ||||||
const [summaryState, setSummaryState] = useState<string>(""); | ||||||
|
||||||
function onSubmitForm(event: FormEvent<HTMLFormElement>) { | ||||||
event?.preventDefault(); | ||||||
setComment((prev) => [...prev, { name: nameState, summary: summaryState }]) | ||||||
setMessageState("댓글들") | ||||||
setNameState("") | ||||||
setSummaryState(""); | ||||||
} | ||||||
|
||||||
function onNameInput(event: ChangeEvent<HTMLInputElement>) { | ||||||
setNameState(event.target.value) | ||||||
} | ||||||
|
||||||
function onSummaryInput(event: ChangeEvent<HTMLInputElement>) { | ||||||
setSummaryState(event.target.value); | ||||||
} | ||||||
|
||||||
return ( | ||||||
<div> | ||||||
<span css={text}>{messageState}</span> | ||||||
<form css={inputWrapper} onSubmit={onSubmitForm}> | ||||||
<input placeholder="닉네임" css={eachInput} value={nameState} onChange={onNameInput} /> | ||||||
<input placeholder="내용" css={eachInput} value={summaryState} onChange={onSummaryInput} /> | ||||||
<button css={buttonWrapper}>확인</button> | ||||||
</form> | ||||||
<div css={commentSort}> | ||||||
{comment.map((todo: IComment) => ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
여기서는 type을 따로 지정해주지 않으셔도 타입 추론이 되는데, 따로 지정해주신 이유가 있으실까요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그리고 댓글들이 리스트 렌더링되는 것인데, |
||||||
<span><b>{todo.name}</b>: {todo.summary}</span> | ||||||
))}</div> | ||||||
</div> | ||||||
); | ||||||
} | ||||||
|
||||||
export default Comment; | ||||||
|
||||||
const text = css` | ||||||
font-size: 1.1rem; | ||||||
font-weight: 700; | ||||||
`; | ||||||
Comment on lines
+51
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. emotion 사용이 나중에 관리할 때 더 쉬울 것 같다는 생각이 들었어요. |
||||||
|
||||||
const inputWrapper = css` | ||||||
margin: 0.6rem 0; | ||||||
` | ||||||
|
||||||
const eachInput = css` | ||||||
all: unset; | ||||||
border-bottom: 1px solid black; | ||||||
font-size: 0.9rem; | ||||||
font-weight: 300; | ||||||
margin-right: 1rem; | ||||||
`; | ||||||
|
||||||
const buttonWrapper = css` | ||||||
all: unset; | ||||||
font-size: 0.8rem; | ||||||
font-weight: 800; | ||||||
cursor: pointer; | ||||||
`; | ||||||
|
||||||
const commentSort = css` | ||||||
display: flex; | ||||||
flex-direction: column; | ||||||
height: 9rem; | ||||||
overflow-y: auto; | ||||||
margin: 0.7rem 0; | ||||||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
댓글들
이 저장되어 있는 상태라, 이름을 복수형으로 짓는 것이 좋지 않을까요?