-
Notifications
You must be signed in to change notification settings - Fork 26
[김참솔] Sprint 10 #134
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
Merged
kiJu2
merged 18 commits into
codeit-bootcamp-frontend:Next-김참솔
from
cskime:Next-김참솔-sprint10
Sep 23, 2025
The head ref may contain hidden characters: "Next-\uAE40\uCC38\uC194-sprint10"
Merged
[김참솔] Sprint 10 #134
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9cd0a05
refactor(Sprint9): HttpClient 이름 변경
cskime aaed2ee
refactor(Sprint9): TodoLabel을 todo status에 따라 style을 설정하는 범용 componen…
cskime 75e0a94
config(Sprint10): TypeScript 설정
cskime 5f93068
config(Sprint10): TypeScript 전환
cskime 7ac053a
refactor(Sprint10): jsconfig 파일 삭제
cskime e75109a
feat(Sprint10): Todo 클릭 시 상세 페이지 이동
cskime 689edba
feat(Sprint10): GNB를 공통 layout으로 분리
cskime e887d9e
feat(Sprint10): 배경색 설정
cskime 6cef4fe
feat(Sprint10): Todo detail page 틀 구현
cskime 0c4e021
feat(Sprint10): Todo detail page UI 구현
cskime 63b5db8
refactor(Sprint10): Button 컴포넌트 style을 disabled 상태 기준으로 설정하도록 변경
cskime c32a992
feat(Sprint10): Memo 수정 기능 개발, 404 page 구현
cskime d3591a9
feat(Sprint10): Todo 삭제 기능 구현
cskime 54b52a0
feat(Sprint10): Todo title 및 완료 상태 수정
cskime 2075c82
feat(Sprint10): File input으로 image 업로드한 뒤 Preview 표시
cskime 2d2fb15
feat(Sprint10): 이미지 업로드 및 수정 기능 구현
cskime f5288aa
feat(Sprint10): 5MB 용량을 초과하는 이미지를 선택할 수 없도록 제한
cskime b725211
refactor(Sprint10): 불필요한 주석 삭제
cskime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export enum ButtonType { | ||
| add = "add", | ||
| edit = "edit", | ||
| delete = "delete", | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { ButtonHTMLAttributes, ReactNode } from "react"; | ||
| import { ButtonType } from "./button-type"; | ||
| import styles from "./button.module.css"; | ||
|
|
||
| const className: { | ||
| [key in keyof typeof ButtonType]: string; | ||
| } = { | ||
| [ButtonType.add]: `${styles.button} ${styles.add}`, | ||
| [ButtonType.edit]: `${styles.button} ${styles.edit}`, | ||
| [ButtonType.delete]: `${styles.button} ${styles.delete}`, | ||
| }; | ||
|
|
||
| const leadingIcon: { | ||
| [key in keyof typeof ButtonType]: string; | ||
| } = { | ||
| [ButtonType.add]: "/icons/ic-plus.svg", | ||
| [ButtonType.edit]: "/icons/ic-check.svg", | ||
| [ButtonType.delete]: "/icons/ic-xmark-white.svg", | ||
| }; | ||
|
|
||
| interface Props extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
| children: ReactNode; | ||
| buttonType: keyof typeof ButtonType; | ||
| } | ||
|
|
||
| function Button({ children, buttonType = ButtonType.add, ...props }: Props) { | ||
| return ( | ||
| <button className={className[buttonType]} {...props}> | ||
| <div className={styles.trailingIcon}> | ||
| <img src={leadingIcon[buttonType]} alt={buttonType} /> | ||
| </div> | ||
| {children} | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| export default Button; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export enum ColorName { | ||
| state = "state", | ||
| violet = "violet", | ||
| rose = "rose", | ||
| lime = "lime", | ||
| amber = "amber", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
my-app/components/input/search-input.jsx → my-app/components/input/search-input.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 7 additions & 3 deletions
10
my-app/components/portal/portal.jsx → my-app/components/portal/portal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
my-app/components/todo/todo-detail-image-button.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| .editButton { | ||
| right: 16px; | ||
| bottom: 16px; | ||
| width: 64px; | ||
| height: 64px; | ||
| border-radius: 32px; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .editButtonImg { | ||
| width: 24px; | ||
| height: 24px; | ||
| } | ||
|
|
||
| .editButton.add { | ||
| background-color: var(--color-state-200); | ||
| } | ||
|
|
||
| .editButton.edit { | ||
| border: 2px solid var(--color-state-900); | ||
| background-color: #0f172a80; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { ChangeEvent } from "react"; | ||
| import styles from "./todo-detail-image-button.module.css"; | ||
|
|
||
| interface Props { | ||
| className?: string; | ||
| buttonType: "add" | "edit"; | ||
| onChange: (file: File | null, reset: () => void) => void; | ||
| } | ||
|
|
||
| const icon = { | ||
| add: "/icons/ic-plus-gray.svg", | ||
| edit: "/icons/ic-pencil.svg", | ||
| }; | ||
|
|
||
| const typeClassName = { | ||
| add: styles.add, | ||
| edit: styles.edit, | ||
| }; | ||
|
|
||
| export default function TodoDetailImageButton({ | ||
| className, | ||
| buttonType, | ||
| onChange, | ||
| }: Props) { | ||
| const classNames = `${styles.editButton} ${typeClassName[buttonType]} ${className}`; | ||
|
|
||
| const handleImageChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
| onChange(event.target.files?.[0] ?? null, () => { | ||
| event.target.value = ""; | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <label htmlFor="image-input" className={classNames}> | ||
| <img | ||
| className={styles.editButtonImg} | ||
| src={icon[buttonType]} | ||
| alt={buttonType} | ||
| /> | ||
| <input | ||
| id="image-input" | ||
| type="file" | ||
| accept="image/*" | ||
| hidden | ||
| onChange={handleImageChange} | ||
| /> | ||
| </label> | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
my-app/components/todo/todo-detail-image-preview.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| .preview { | ||
| border-radius: 24px; | ||
| overflow: hidden; | ||
| height: 100%; | ||
| position: relative; | ||
| } | ||
|
|
||
| .previewImageContainer { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .previewImage { | ||
| width: 100%; | ||
| height: 100%; | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| .previewEmptyIcon { | ||
| position: absolute; | ||
| top: 50%; | ||
| left: 50%; | ||
| width: 64px; | ||
| height: 64px; | ||
| transform: translate(-50%, -50%); | ||
| } | ||
|
|
||
| .button { | ||
| position: absolute; | ||
| right: 16px; | ||
| bottom: 16px; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { useEffect, useMemo, useState } from "react"; | ||
| import TodoDetailImageButton from "./todo-detail-image-button"; | ||
| import styles from "./todo-detail-image-preview.module.css"; | ||
|
|
||
| export default function TodoDetailImagePreview({ | ||
| imageUrl, | ||
| onChange, | ||
| }: { | ||
| imageUrl?: string; | ||
| onChange: (file: File) => void; | ||
| }) { | ||
| const [previewUrl, setPreviewUrl] = useState<string | undefined | null>( | ||
| imageUrl | ||
| ); | ||
|
|
||
| const hasPreview = useMemo(() => { | ||
| return previewUrl !== "" && previewUrl != null; | ||
| }, [previewUrl]); | ||
|
|
||
| const handlePreviewChanged = (file: File | null, reset: () => void) => { | ||
| if (!file) return; | ||
|
|
||
| const maxSize = 5 * 1024 * 1024; | ||
| if (file.size > maxSize) { | ||
| alert("파일 크기는 5MB 이하여야 합니다."); | ||
| reset(); | ||
| return; | ||
| } | ||
|
|
||
| if (previewUrl) { | ||
| URL.revokeObjectURL(previewUrl); | ||
| } | ||
|
|
||
| const newPreviewUrl = URL.createObjectURL(file); | ||
| setPreviewUrl(newPreviewUrl); | ||
| onChange(file); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| if (previewUrl) { | ||
| URL.revokeObjectURL(previewUrl); | ||
| } | ||
| }; | ||
| }, [previewUrl]); | ||
|
|
||
| return ( | ||
| <div className={styles.preview}> | ||
| <div className={styles.previewImageContainer}> | ||
| <img | ||
| className={styles.previewImage} | ||
| src={ | ||
| hasPreview ? previewUrl! : "/images/image-preview-background.svg" | ||
| } | ||
| alt="Preview image" | ||
| /> | ||
| {hasPreview || ( | ||
| <img | ||
| className={styles.previewEmptyIcon} | ||
| src="/icons/ic-image.svg" | ||
| alt="empty preview logo" | ||
| /> | ||
| )} | ||
| </div> | ||
| <TodoDetailImageButton | ||
| className={styles.button} | ||
| buttonType={previewUrl ? "edit" : "add"} | ||
| onChange={handlePreviewChanged} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
상수는 컴포넌트 바깥에 선언해볼 수 있습니다 😉
핸들러가 실행될 때 마다 재선언이 될 것이며, 컴포넌트의 상태나
props를 참조하고 있지 않으므로(= 컴포넌트 내의 값을 참조하지 않으므로) 바깥에 선언해볼 수 있습니다 😊