Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
93a0e93
chore: 머지 후 브랜치 삭제 github action 추가
withyj-codeit Sep 3, 2023
17be37c
Initial commit from Create Next App
withyj-codeit Sep 8, 2023
b2e37bd
reset
hanseulhee Oct 10, 2023
6f8bbb0
Merge branch 'codeit-bootcamp-frontend:main' into main
hanseulhee Oct 10, 2023
e11e25f
fix: 머지 후 브랜치 삭제 github action 수정
hanseulhee Oct 10, 2023
212e864
env: workflows 폴더로 이동
hanseulhee Oct 10, 2023
4dc5dd0
Merge pull request #237 from hanseulhee/fix-github-actions
withyj-codeit Nov 6, 2023
7df9c2b
fix: 머지 후 브랜치 삭제 github action 수정
hanseulhee Oct 10, 2023
66f3ba6
env: workflows 폴더로 이동
hanseulhee Oct 10, 2023
b986c4a
스프린트미션1제출 -유선향
Dec 3, 2024
7001bec
Merge pull request #2 from grimza99/part1-유선향-sprint1
kiJu2 Dec 5, 2024
08482b9
코드리뷰 보완 - 로그인,구경하러가기버튼 button 태그로 변경
Dec 23, 2024
e118a16
코드리뷰보완 -png파일 svg파일로 변경
Dec 23, 2024
95c1bbd
alt내용 좀더 자세하게 수정
Dec 23, 2024
e433f0a
css선택자이름 통일
Dec 23, 2024
242d427
nav 영역 fixed
Dec 23, 2024
1e66de8
로그인페이지와 회원가입 페이지를 함께 스타일링할signup _login. css 파일 생성
Dec 23, 2024
5e40a3f
login페이지 작성, 카카오,구글링크 연결
Dec 24, 2024
5c70501
회원가입페이지 작성
Dec 24, 2024
ba9ff3d
signup_login.css파일 컬러파레트변수 설정 & header부분 스타일링하면서 컬러파레트 적용확인
Dec 24, 2024
370ecd0
css 작성중 요소끼리의 간격 맞추기 위해 label태그로 Input 태그 감싸는 걸로 변경
Dec 24, 2024
f28513f
공통 css 작성완료
Dec 24, 2024
18a18b6
카카오,구글 아이콘 새창에서 열리게 변경
Dec 24, 2024
2fc219a
화면너비기준 미디어 쿼리기준 작성
Dec 24, 2024
7e9cb3b
데스크탑 기준으로 시작해야 할것 같고, 375px 이하는 고려하지 않는다 해서 @media 기준점 다시 수정
Dec 24, 2024
2526685
반응형디자인을위해 index.html 수정
Dec 24, 2024
349af48
반응형웹사이트 위해 index.html, index.css 수정
Dec 24, 2024
a5f8d13
로그인, 회원가입 페이지 모바일 반응형 작성
Dec 25, 2024
d732d0f
태블릿 환경 css 작성
Dec 25, 2024
8ccea71
모바일환경 반응형 css 작성
Dec 25, 2024
30cf7b2
페이스북 오픈그래프 메타 데이터 작성
Dec 25, 2024
f6f2ce1
type: style
Dec 26, 2024
4da25fd
Docs : creacte color.css
Dec 26, 2024
cb664e8
style: code look nice
Dec 26, 2024
95bf2ff
Docs : 모듈파일인 login_signup.js 파일생성과 함수 계획작성
Dec 27, 2024
e2acf9c
Docs : 모듈 설계
Dec 27, 2024
2e65279
Docs : fuc Password_focus_out 함수 작성
Dec 27, 2024
6bf93ef
Docs: function Email_focus_out 함수 작성 ,
Dec 27, 2024
d630e4d
docs: button_inactive 함수 작성, 원하는 대로 동작하지 않아 수정필요, 일단 회원가입 페이지 함수 작성후 …
Dec 27, 2024
d9c4ff6
Docs: signup.js 파일내핸들러 작성과 등록 완료 이제 작동이 안되는 함수 수정 예정
Dec 27, 2024
22f3069
fix: login.js
Dec 27, 2024
b416887
Fix : login.js
Dec 27, 2024
9cb5029
fix : signup.js
Dec 28, 2024
195c9d1
[Test] create Test.js file
Dec 30, 2024
92066d1
[Docs] create gitMessage.txt file
Jan 4, 2025
b068f48
[Docs] Merge branch 'React-유선향' into React-유선향
Jan 4, 2025
8c22bae
[Feat] create handleLoad
Jan 12, 2025
0fa7d30
[Feat] 최신순, 좋아요 순에 따른 정렬 기능 추가
Jan 13, 2025
bbc8b6a
[Feat] create bestItems state
Jan 13, 2025
b3877f0
[Feat] create PageCount.js
Jan 15, 2025
4dd938f
[Design] 정렬버튼, 검색창과 검색버튼 스타일
Jan 15, 2025
88ea6af
[Feat] 스크린 사이즈에 따른 가변적인 api 요청
Jan 17, 2025
79b5023
[Feat]ItemList 반응형 그리드 설정
Jan 17, 2025
ca5c72b
[Design] 미디어 쿼리에 따라 사용자 ui 변화
Jan 20, 2025
cc886e2
[Design] input form 반응형ui로 스타일링
Jan 20, 2025
196fa2b
[Design] sort Select button media ui
Jan 21, 2025
301a870
[Fix] 'items' DOM nvalid attribute name: $items
Jan 21, 2025
8dfe0fb
Merge pull request #56 from grimza99/React-유선향-sprint5
kiJu2 Jan 23, 2025
24cf0a9
[Chore] 이전 스프린트 미션 정리중
Feb 8, 2025
016b300
[Refactor]폴더 구조 변경
Feb 8, 2025
1fc463b
[Feat] create input , button common components
Feb 8, 2025
a01d1a9
[Feat] create TagComponent, create AddItem.jsx
Feb 8, 2025
3a71f40
[Feat] create Tag handler
Feb 9, 2025
acf9f02
[Feat] createTag enterkeyup event
Feb 9, 2025
e0d440a
[Feat] imgPreview
Feb 9, 2025
91d5048
[Style] edit NavStyle
Feb 9, 2025
36aecd8
[Feat] 각 input에서 데이터 입력시 data state에 들어가게함
Feb 10, 2025
02e4bfc
[Feat] Delete img preview
Feb 11, 2025
85ec238
[Feat] 데이터 입력시 리퀘스트에 보낼 data 객체에 담김
Feb 11, 2025
b0f0cfb
[Feat] button disabled
Feb 11, 2025
fe30e18
[Style] placeholder rearrange
Feb 11, 2025
82d21fa
[Refactor] npm install lodash.throttle and use throttle in useWindowSize
Feb 11, 2025
07fc7a9
[Style] header 반응형 수정
Feb 13, 2025
00a142c
[Style] additem 반응형
Feb 13, 2025
07b07af
[Refactor] addItem리팩토링
Feb 13, 2025
79f18bf
[Style] edit style.file
Feb 13, 2025
f5642a5
[Refactor] edit input onChange
Feb 13, 2025
486bc5f
[Chore] delete console.log
Feb 13, 2025
65157fa
[Refactor] 코드 리뷰에 따른 windowSize 리팩토링
Feb 13, 2025
58b0981
[Refactor] HomePage 스타일 분리
Feb 13, 2025
fe73546
[Chore] create Product.jsx
Feb 13, 2025
c089e18
[Feat] getComments, getProductInfo api created
Feb 14, 2025
ff9c75d
[Chore] productpage 전체 ui 구성
Feb 14, 2025
f85bdfd
[Feat] comment.jsx 구조 구성
Feb 14, 2025
91fb7c5
[Feat]get comment
Feb 14, 2025
e931d2c
[Chore] create common compoenet BtnHeart
Feb 14, 2025
0f56568
[Chore] Btn Heart border
Feb 14, 2025
38081d0
[Feat] create kebab component
Feb 14, 2025
2a9d87d
[Refactor] edit tag component 태그에 배열을 넘기면 tag 컴포넌트 안에서 자동을 뿌려줌
Feb 15, 2025
ec72e73
[Feat] create useFormatPrice
Feb 15, 2025
b1efb18
[Style] border-bottom edit
Feb 15, 2025
9ca3d66
[Refactor] edit input style and commentInput onchange handler
Feb 15, 2025
683ab87
[Feat] kebab select
Feb 15, 2025
22a1e07
[Feat] useNavigate로 목록으로 돌아가기 버튼
Feb 15, 2025
74144e9
[Chore] prop 넘길시 tag의 delete 버튼 안보이게 수정
Feb 15, 2025
af11121
[Style] edit style
Feb 15, 2025
a29ce2b
[Style]반응형
Feb 16, 2025
d6fba06
[Chore] theme.font 적용
Feb 16, 2025
a1ef393
[Feat] 수정하기 버튼시 입력 폼에 이전내용
Feb 16, 2025
e589fe6
[Feat] 타임 스탬프로 부터 몇시간이 지났는지 알려주는 커스텀 훅 적용
Feb 16, 2025
f4be2c5
[Feat] review 수정시 수정 반영됨
Feb 16, 2025
f0036d4
[Feat] 수정버튼 클릭시 kebab 사라짐
Feb 16, 2025
d6c5f1a
[Refactor] edit input props
Feb 16, 2025
31176dd
[Refactor] imgInput props edited
Feb 16, 2025
2d1a980
[Refactor] create constant required_input
Feb 16, 2025
5c0d686
[Chore] delete console.log
Feb 16, 2025
bda17f4
[Feat] add useNavigate itemList to items/{product.id}
Feb 18, 2025
d86c63d
[Refactor]문의 코멘트에 프로필 이미지 있을경우 사이즈
Feb 18, 2025
12d3a0a
[Refactor] edit ProductInfo style
Feb 18, 2025
8d73d8c
[Refactor] ItemsList style 분리
Feb 18, 2025
409ee54
[Chore] ItemsList 폴더 이동, HomePage->ItemsPage로 이름변경
Feb 18, 2025
78c3078
[Chore] globalstyles 분리
Feb 18, 2025
86e69a5
[Refactor] ItemsPage mobile 반응형 수정
Feb 19, 2025
930dba9
[Style] 이전 작업 style.jsx font 적용
Feb 19, 2025
addb51f
[Refactor] edit heartBtn
Feb 19, 2025
fecbd64
[Refactor]edit pageCount
Feb 19, 2025
f8d651c
[Style]ItemList style edit
Feb 20, 2025
b87b91b
[Chore]i typescript and edit tsconfig.json options
Feb 20, 2025
46d3ce6
[Chore] i types/styled-compoenents
Feb 20, 2025
1cb5a08
[Types] add declaration file for SVG imports and select componenet type
Feb 20, 2025
167dcc0
[Type] button componente type
Feb 22, 2025
212edd8
[Type] input component type
Feb 22, 2025
a04e631
[Type] BtnHeart type
Feb 22, 2025
3210bd4
[Type] Convert JSX to TSX and add type for AddItem
Feb 23, 2025
9dac8e0
[Type]Convert JSX to TSX and add type for Tag
Feb 23, 2025
8f838ca
[Type] edit type AddItem and Tag
Feb 23, 2025
b960234
[Type]Convert JSX to TSX ItemsList and ItemsList.style and edit type …
Feb 23, 2025
7bb8e24
[Type] add type for ItemsPage and ItemsPage.style
Feb 23, 2025
3f77bf3
[Type]Convert JSX to TSX CommentCard , Comment, Product
Feb 23, 2025
ef38e4e
[Type] add type for Comments
Feb 23, 2025
a1639f6
[Type] add type for Product
Feb 23, 2025
3731caa
[Type] add type for CommentCard
Feb 23, 2025
5fdcc0e
[Type]Convert JSX to TSX ProductInfo
Feb 24, 2025
0c34f84
[Chore] global.d.ts created
Feb 24, 2025
a8fd50d
[Type] global.d.ts에 타입이랑 interface 싹다 모음
Feb 24, 2025
8186da1
[Type] create global type Params and ProductInfo
Feb 24, 2025
c5fea26
[Type] add type for pageCount
Feb 24, 2025
de53246
[Type] create Item type with Omit
Feb 24, 2025
6352933
[Type] Comment interface 전역 타입 설정
Feb 24, 2025
d0b343e
[Type] onClick type 생성
Feb 24, 2025
7e56e15
[Refactor] fetch ->axios
Feb 24, 2025
a4011fe
[Type] product.api interface
Feb 24, 2025
3ee9850
[Chore] 단순 오타 에러 수정
Feb 24, 2025
6dc1fab
[Chore] type items -> item 으로 이름 변경
Feb 24, 2025
b4c2a29
[Chore] 잘 모르겠는 부분 주석 남김
Feb 24, 2025
b562007
[Chore] npm run start 에러 경로문제 수정
Feb 24, 2025
cd7f584
[Fix] 개발 환경 실행시 이벤트 핸들러 동작 오류 수정
Feb 24, 2025
0caf94e
[Chore] Next 프로젝트로 변경
Mar 2, 2025
694ca44
[Chore] e] next 초기 세팅
Mar 2, 2025
b67a4a7
[Chore] create boards.tsx
Mar 2, 2025
7d316ea
[Refactor] 이전 리액트 공용컴포넌트 불러옴, 수정
Mar 2, 2025
7379f38
[Chore] Ignore .next folder
Mar 2, 2025
3f67611
[Style] boards ui 구현 and 전역 스타일 지정
Mar 2, 2025
c01f0f0
[Feat] create Card com and boards page
Mar 2, 2025
4e66879
[Feat] created ArticleCard and ui
Mar 3, 2025
cb94373
[Style] create Btn Heart and edit style
Mar 3, 2025
505d385
[Style] edit style BtnHeart
Mar 3, 2025
9917f06
[Style] Articles Card style
Mar 3, 2025
ed1e149
[Feat] create handleSortChange and add select
Mar 3, 2025
e463029
[Feat] 검색 기능
Mar 7, 2025
0c4bb84
[Chore] npm install tailwind
Mar 7, 2025
c0b2bf1
[Chore] setting tailwind.config.js
Mar 7, 2025
ec3bd64
[Refactor] layout components -> tailwind로 변경
Mar 8, 2025
9783a4c
[Chore] delete layout.style.tsx
Mar 8, 2025
5cabe04
[Refactor] Nav style changed tailwind
Mar 8, 2025
94a21ad
[Refactor] btnHeart changed style tailwind
Mar 8, 2025
d985185
[Refactor] board tailwind 반응형
Mar 8, 2025
fdabf1f
[Refactor] select changed tailwind
Mar 8, 2025
190b179
[Refactor] input changed tailwind
Mar 8, 2025
2b4d1c3
[Refactor] axios instance created
Mar 12, 2025
df36031
[Refactor] search 기능 코드 리팩토링
Mar 12, 2025
5ce8207
[Fix] 검색어 입력후 정렬 변경시 검색어가 풀리는 오류 부분 수정
Mar 12, 2025
0cc0d4a
[Style] 스타일 브레이크 포인트 오류 수정
Mar 12, 2025
4060082
[Feat] 좋아요 숫자가 9999이상일 경우 9999+
Mar 12, 2025
cb861f5
[Style] style 오류 수정
Mar 12, 2025
dc410b2
Merge branch 'Next-유선향' into Next-유선향-sprint9
grimza99 Mar 13, 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
20 changes: 6 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,20 @@
# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem
.env.local
.env.development.local
.env.test.local
.env.production.local
Comment on lines +17 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

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

굿굿 ! 환경변수를 잘 작성하셨군요 ! 👍

.gitignore에도 추가하셨네요 잘하셨습니다 ! 👍👍


# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.next
.env.local

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
25 changes: 25 additions & 0 deletions .gitmessage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Type] title

# [Type] 입력 목록
# 1. Feat: 새로운 기능 추가
# 2. Fix: 오류 해결
# 3. Rename: 파일 혹은 폴더명을 수정만 한 경우
# 4. Remove: 파일을 삭제만 한 경우
# 5. Style: 기능 수정 없이 코드 스타일만 변경한 경우 (코드 포매팅, 세미콜론 누락 등)
# 6. Design: 사용자 UI 디자인 변경 (CSS 등)
# 7. Refactor: 코드 베이스의 특정 부분을 재정렬 (Refactoring)
# 8. Test: 테스트와 관련된 모든 것
# 9. Docs: 문서화에 관한 모든 것
# 10. Chore: 빌드 업무 수정, 패키지 매니저 수정 (gitignore 수정 등)
# 11. Perf: 성능 개선
#
# [Title] 규칙
# 1. 50자 이내 짧은 요약 (영어의 경우 첫글자는 대문자로)
# 2. 명령형으로 작성 (과거형X)
# 3. 제목 끝에 .(마침표) 금지
#
# [Body] 작성 규칙
# 1. 제목과 본문 사이 빈 칸 한줄 필수 (제목과 본문 분리)
# 2. 생략 가능, 필요 시 자세한 설명 작성 (72자 내외로 마무리)
# 3. 적용한 변경사항과 그것을 만든 이유에 대해 설명
# - 어떻게보다는 "무엇을", "왜"
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["inputwidth"]
}
40 changes: 40 additions & 0 deletions components/BtnHeart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import activeHeart from "@/public/assets/icons/active.heart.icon.svg";
import inactiveHeart from "@/public/assets/icons/inactive.heart.icon.svg";
import Image from "next/image";

//
interface Props {
value: number;
active?: boolean;
}
export default function BtnHeart({ value, ...props }: Props) {
const { active, ...rest } = props;
const count = value > 9999 ? "9999+" : value;
return (
<>
{active ? (
<div className="flex items-center justify-between gap-[6px] w-16 h-6 border-none font-Pretendard text-H7Regular bg-gray-50 text-gray-500 ">
<Image
width={16}
height={16}
src={activeHeart}
{...rest}
alt="좋아요"
/>
{value}
</div>
) : (
<div className="flex items-center justify-between gap-[6px] w-16 h-6 border-none font-Pretendard text-H7Regular bg-white text-gray-500 ">
<Image
width={16}
height={16}
src={inactiveHeart}
{...rest}
alt="좋아요"
/>
{count}
</div>
)}
</>
);
}
19 changes: 19 additions & 0 deletions components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ReactNode } from "react";
//
interface Props {
onClick: onClick;
children: ReactNode;
disabled?: boolean;
}
export default function Button({ onClick, children, ...props }: Props) {
return (
<>
<button
onClick={onClick}
className="flex bg-blue-500 justify-center items-center w-full h-full rounded-[8px] border-none font-Pretendard text-H5Bold text-gray-100 bg-light-blue cursor-pointer"
>
{children}
</button>
</>
);
}
69 changes: 69 additions & 0 deletions components/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import BestImage from "@/public/assets/icons/best.icon.svg";
import Image from "next/image";
import ProfileImg from "@/public/assets/icons/default.profile.icon.svg";
import { useFormatDate } from "@/hooks/useFormatting";

import BtnHeart from "./BtnHeart";
//
interface Props {
article: Article;
}
export function BestArticle({ article }: Props) {
const formattedDate = useFormatDate(article.createdAt);
const articleImg = article.image || "";
return (
<div className=" flex flex-col gap-4 w-[384px]tablet:w-full mobile:w-full h-[169px] tablet:h-[198px] border-none bg-gray-50 px-6 rounded-lg">
<Image
className="w-[102px] h-[30px] "
src={BestImage}
width={102}
height={30}
alt="베스트"
/>
<div className="flex justify-between gap-2 tablet:gap-10 font-Pretendard text-H3Bold">
<p>{article.content}</p>
<Image
className="w-[72px] h-[72px] "
width={72}
height={72}
src={articleImg}
alt="상품이미지"
/>
</div>
<div className="flex justify-between text-gray-500 font-Pretendard text-H7Regular ">
<div className="flex gap-2">
{article.writer.nickname}
<BtnHeart value={article.likeCount} />
</div>
<div>{formattedDate}</div>
</div>
</div>
);
}

export function Articles({ article }: Props) {
const formattedDate = useFormatDate(article.createdAt);
const articleImg = article.image || ProfileImg;

return (
<div className=" flex flex-col gap-4 w-full h-[138px] bg-light-gray px-6 border-b border-gray-200">
Comment on lines +44 to +49
Copy link
Collaborator

Choose a reason for hiding this comment

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

(의견) variant라는 props를 추가해보는건 어떨까요? BestArticlesArticles의 차이는 "스타일"로 보여서요 !

레이아웃이 전반적으로 달라지는게 아니라 일부 스타일이 달라지는 것 같아서 조심스레 제안드려봅니다 !😉:

Suggested change
export function Articles({ article }: Props) {
const formattedDate = useFormatDate(article.createdAt);
const articleImg = article.image || ProfileImg;
return (
<div className=" flex flex-col gap-4 w-full h-[138px] bg-light-gray px-6 border-b border-gray-200">
export default function ArticleCard({ article, variant = "normal" }: Props) {
const formattedDate = useFormatDate(article.createdAt);
const articleImg = article.image || DEFAULT_IMAGE;
return (
<div
className={`flex flex-col gap-4 px-6 rounded-lg ${
variant === "best"
? "w-[384px] h-[169px] tablet:w-full tablet:h-[198px] bg-gray-50"
: "w-full h-[138px] bg-light-gray border-b border-gray-200"
}`}
>
{variant === "best" && (
<Image className="w-[102px] h-[30px]" src={BestImage} width={102} height={30} alt="베스트" />
)}

<div className="flex justify-between font-Pretendard text-H3Bold">
<p>{article.content}</p>
<img
className="w-[72px] h-[72px] text-H8"
src={articleImg}
alt="상품이미지"
/>
</div>
<div className="flex justify-between text-gray-500 font-Pretendard text-H7Regular ">
<div className="flex gap-2">
<Image src={ProfileImg} width={24} height={24} alt="프로필" />

<div>{article.writer.nickname}</div>
{formattedDate}
</div>
<BtnHeart value={article.likeCount} />
</div>
</div>
);
}
136 changes: 136 additions & 0 deletions components/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import PlusIcon from "@/public/assets/icons/plusIcon.svg";
import DeleteIcon from "@/public/assets/icons/DeleteIcon.svg";
import SearchIcon from "@/public/assets/icons/search.icon.svg";
import Image from "next/image";
import { ChangeEvent, useRef, useState } from "react";
//

interface Props {
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
label?: string;
placeholder?: string;
name: string;
tag?: boolean;
value?: string;
$comment?: boolean;
$textArea?: boolean;
$edit?: boolean;
onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
type?: "text" | "number";
}
export function Input({ onChange, type = "text", ...props }: Props) {
const { label, onKeyUp, $edit, $textArea, $comment } = props;

return (
<div className="flex flex-col justify-start w-full gap-4">
<div
className={`${label ? "block" : "none"} ${
$comment && "text-H5Bold"
} w-full h-[26px] font-Pretendard text-gray-800 text-H4Bold`}
>
{label}
</div>
<input
className={`${$textArea && "h-[282px]"} ${
$comment && "text-H7Regular h-[104px] mobile:h-[129px] "
} ${
$edit && "text-H7Regular h-[80px]"
}relative w-full h-[56px] bg-gray-100 font-Pretendard text-H6Regular border-none rounded-xl text-gray-800 px-4 py-6 placeholder-gray-400 placeholder:text-H5Regular placeholder:absolute focus:outline-none`}
type={type}
onChange={onChange}
onKeyUp={onKeyUp || undefined}
/>
</div>
);
}
//
interface ImgProps extends Omit<Props, "onChange"> {
onChange: (value: File | string) => void;
}
export function ImgInput({ onChange, ...props }: ImgProps) {
const imgRef = useRef<HTMLInputElement>(null);
const [imgPreview, setImgPreview] = useState<string>("");

const handlePreviewImg = () => {
if (!imgRef.current || !imgRef.current.files?.length) return;
const file = imgRef.current.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onloadend = () => {
if (typeof reader.result === "string") {
setImgPreview(reader.result);
onChange(file);
}
};
};
//
const handleClickImgDelete = () => {
setImgPreview("");
onChange("");
};
return (
<div className="flex gap-6 mobile:gap-[10px] ">
<div className="mobile:w-[168px] w-[282px] h-[282px] bg-gray-100 rounded-xl border-none text-gray-800">
<input
className="relative w-full h-full bg-gray-100 font-Pretendard text-H6Regular border-none rounded-xl text-gray-800 px-4 py-6
placeholder-gray-400 placeholder:text-H5Regular placeholder:top-[10px] placeholder:text-left placeholder:absolute focus:outline-none"
type="file"
id="fileUpload"
accept="image/*"
ref={imgRef}
onChange={handlePreviewImg}
{...props}
/>
<label
htmlFor="fileUpload"
className="absolute text-center text-gray-400 -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2 text-H5Regular"
>
<Image width={48} height={48} src={PlusIcon} alt="추가" />
<p>{props.placeholder}</p>
</label>
</div>

{imgPreview && (
<div className="relative">
<Image
className=" aspect-square w-[282px] h-[282px] mobile:w-[168px] "
src={imgPreview}
width={282}
height={282}
alt="이미지 미리보기"
/>
<Image
className="absolute top-[15px] right-[15px]"
src={DeleteIcon}
width={22}
height={24}
alt="x"
onClick={handleClickImgDelete}
/>
</div>
)}
</div>
);
}

export function SearchInput({ onChange, ...props }: Props) {
return (
<div className="relative w-full">
<input
onChange={onChange}
className="
rounded-xl border-none px-[44px] py-[16px] w-full h-[42px] bg-gray-100
font-Pretendard text-gray-800 text-H5Regular
placeholder:text-H5Regular placeholder:text-gray-400
"
/>
<Image
className="absolute translate-x-0 left-4 top-1/2 -translate-y-2/4"
src={SearchIcon}
alt="검색"
width={15}
height={15}
/>
</div>
);
}
Comment on lines +116 to +136
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 컴포넌트에 맞는 새로운 PropType을 작성하는건 어떨까요?:

Suggested change
export function SearchInput({ onChange, ...props }: Props) {
return (
<div className="relative w-full">
<input
onChange={onChange}
className="
rounded-xl border-none px-[44px] py-[16px] w-full h-[42px] bg-gray-100
font-Pretendard text-gray-800 text-H5Regular
placeholder:text-H5Regular placeholder:text-gray-400
"
/>
<Image
className="absolute translate-x-0 left-4 top-1/2 -translate-y-2/4"
src={SearchIcon}
alt="검색"
width={15}
height={15}
/>
</div>
);
}
export function SearchInput({ onChange }: { onChange: (e: ChangeEvent<HTMLInputElement>) => void }) {
return (
<div className="relative w-full">
<input
onChange={onChange}
className="
rounded-xl border-none px-[44px] py-[16px] w-full h-[42px] bg-gray-100
font-Pretendard text-gray-800 text-H5Regular
placeholder:text-H5Regular placeholder:text-gray-400
"
/>
<Image
className="absolute translate-x-0 left-4 top-1/2 -translate-y-2/4"
src={SearchIcon}
alt="검색"
width={15}
height={15}
/>
</div>
);
}

현재 나머지 props도(...props) 사용하지 않는 것 같고 onChange만 사용하는 것으로 보여요. 별개의 프롭 타입을 정의하는게 어떨까요?

46 changes: 46 additions & 0 deletions components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Link from "next/link";
import pandaLogo from "@/public/assets/Logo/pandaLogo.svg";
import textLogo from "@/public/assets/Logo/textLogo.svg";
import myLogo from "@/public/assets/icons/default.profile.icon.svg";
import Image from "next/image";
import useWindowSize from "@/hooks/useWindowSize";
export default function Nav() {
const device: string = useWindowSize();
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
const device: string = useWindowSize();
const device: 'mobile' | 'tablet' | 'desktop' = useWindowSize();

return (
<div className="fixed top-0 left-0 w-screen h-[70px] bg-white py-[10px] px-[200px] NavPadding:px-[24px] NavPadding:py-[10px] mobile:px-[15px] mobile:py-[15px] z-50">
<div className="flex justify-between w-screen max-w-full ">
<div className="flex items-center w-screen gap-8 mobile:gap-2">
<div className="flex w-auto gap-2">
<Image
className="block w-10 h-10 mobile:hidden"
src={pandaLogo}
alt="판다로고"
width={40}
height={40}
/>
<Image
className="w-[103px] h-[51px] cursor-pointer mobile:w-20"
src={textLogo}
alt="판다마켓"
width={103}
height={51}
/>
</div>
<div className="flex w-auto gap-7 mobile:gap-2 font-Pretendard text-H4Bold">
<Link href="/docs">자유게시판</Link>
<Link href="/items">중고마켓</Link>
</div>
</div>
<Link href="/mypage">
<Image
className="w-10 h-10"
src={myLogo}
alt="프로필 이미지"
width={40}
height={40}
/>
</Link>
</div>
</div>
);
}
Loading
Loading