Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9cd0a05
refactor(Sprint9): HttpClient 이름 변경
cskime Sep 12, 2025
aaed2ee
refactor(Sprint9): TodoLabel을 todo status에 따라 style을 설정하는 범용 componen…
cskime Sep 12, 2025
75e0a94
config(Sprint10): TypeScript 설정
cskime Sep 19, 2025
5f93068
config(Sprint10): TypeScript 전환
cskime Sep 19, 2025
7ac053a
refactor(Sprint10): jsconfig 파일 삭제
cskime Sep 19, 2025
e75109a
feat(Sprint10): Todo 클릭 시 상세 페이지 이동
cskime Sep 20, 2025
689edba
feat(Sprint10): GNB를 공통 layout으로 분리
cskime Sep 20, 2025
e887d9e
feat(Sprint10): 배경색 설정
cskime Sep 20, 2025
6cef4fe
feat(Sprint10): Todo detail page 틀 구현
cskime Sep 20, 2025
0c4e021
feat(Sprint10): Todo detail page UI 구현
cskime Sep 20, 2025
63b5db8
refactor(Sprint10): Button 컴포넌트 style을 disabled 상태 기준으로 설정하도록 변경
cskime Sep 20, 2025
c32a992
feat(Sprint10): Memo 수정 기능 개발, 404 page 구현
cskime Sep 20, 2025
d3591a9
feat(Sprint10): Todo 삭제 기능 구현
cskime Sep 20, 2025
54b52a0
feat(Sprint10): Todo title 및 완료 상태 수정
cskime Sep 20, 2025
2075c82
feat(Sprint10): File input으로 image 업로드한 뒤 Preview 표시
cskime Sep 21, 2025
2d2fb15
feat(Sprint10): 이미지 업로드 및 수정 기능 구현
cskime Sep 21, 2025
f5288aa
feat(Sprint10): 5MB 용량을 초과하는 이미지를 선택할 수 없도록 제한
cskime Sep 21, 2025
b725211
refactor(Sprint10): 불필요한 주석 삭제
cskime Sep 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions my-app/components/button/button-type.js

This file was deleted.

5 changes: 5 additions & 0 deletions my-app/components/button/button-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ButtonType {
add = "add",
edit = "edit",
delete = "delete",
}
27 changes: 0 additions & 27 deletions my-app/components/button/button.jsx

This file was deleted.

10 changes: 6 additions & 4 deletions my-app/components/button/button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
font-size: 16px;
font-weight: 700;
line-height: 100%;
cursor: pointer;
display: flex;
align-items: center;
gap: 4px;
Expand All @@ -22,17 +21,20 @@
width: 100%;
height: 100%;
}
.button:not(:disabled) {
cursor: pointer;
}

.button.add:active {
.button.add:not(:disabled) {
color: white;
background-color: var(--color-violet-600);
}
.button.add:active img {
.button.add:not(:disabled) img {
filter: invert(100%) sepia(14%) saturate(1801%) hue-rotate(190deg)
brightness(116%) contrast(101%);
}

.button.edit:active {
.button.edit:not(:disabled) {
background-color: var(--color-lime-300);
}

Expand Down
37 changes: 37 additions & 0 deletions my-app/components/button/button.tsx
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;
7 changes: 7 additions & 0 deletions my-app/components/color/color-name.ts
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",
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
function colorVariable(name, shade) {
import { ColorName } from "./color-name";

function colorVariable(name: string, shade: number) {
return `var(--color-${name}-${Math.max(100, Math.min(900, shade))})`;
}

const Colors = {
state: {
const Colors: {
[key in keyof typeof ColorName]: { [key: number]: string };
} = {
[ColorName.state]: {
100: colorVariable("state", 100),
200: colorVariable("state", 200),
300: colorVariable("state", 300),
Expand All @@ -12,17 +16,17 @@ const Colors = {
800: colorVariable("state", 800),
900: colorVariable("state", 900),
},
violet: {
[ColorName.violet]: {
100: colorVariable("violet", 100),
600: colorVariable("violet", 600),
},
rose: {
[ColorName.rose]: {
500: colorVariable("rose", 500),
},
lime: {
[ColorName.lime]: {
300: colorVariable("lime", 300),
},
amber: {
[ColorName.amber]: {
800: colorVariable("amber", 800),
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { InputHTMLAttributes } from "react";
import styles from "./search-input.module.css";

function SearchInput({ ...props }) {
interface Props extends InputHTMLAttributes<HTMLInputElement> {}

function SearchInput({ ...props }: Props) {
return (
<div className={styles.searchInput}>
<input type="text" {...props} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useEffect, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { createPortal } from "react-dom";

function Portal({ children }) {
const [container, setContainer] = useState(null);
interface Props {
children: ReactNode;
}

function Portal({ children }: Props) {
const [container, setContainer] = useState<HTMLElement | null>(null);

useEffect(() => {
// setContainer(document.getElementById("portal"));
Expand Down
25 changes: 25 additions & 0 deletions my-app/components/todo/todo-detail-image-button.module.css
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;
}
49 changes: 49 additions & 0 deletions my-app/components/todo/todo-detail-image-button.tsx
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 my-app/components/todo/todo-detail-image-preview.module.css
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;
}
72 changes: 72 additions & 0 deletions my-app/components/todo/todo-detail-image-preview.tsx
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;
Comment on lines +4 to +23
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상수는 컴포넌트 바깥에 선언해볼 수 있습니다 😉

Suggested change
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;
const MAX_FILE_SIZE = 5 * 1024 * 1024;
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;

핸들러가 실행될 때 마다 재선언이 될 것이며, 컴포넌트의 상태나 props를 참조하고 있지 않으므로(= 컴포넌트 내의 값을 참조하지 않으므로) 바깥에 선언해볼 수 있습니다 😊

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>
);
}
Loading
Loading