Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aac7d4c
🐛 fix(mentor): tag logic 및 form validity 확인 수정
Moon-ju-young May 20, 2025
ac49ea2
✨ feat(mentor): price input type number로 변경
Moon-ju-young May 20, 2025
6afbd9a
✨ feat(mentor): tag component 구조 및 prop 수정
Moon-ju-young May 20, 2025
4122464
✨ feat(mentor): tag 삭제 기능 추가
Moon-ju-young May 20, 2025
48483b7
♻️ refactor(mentor): Button component to prop 삭제
Moon-ju-young May 20, 2025
fb05c81
✨ feat: item 클릭 시 page 이동 기능 추가
Moon-ju-young May 21, 2025
3c92e8f
✨ feat: ItemProduct page 추가
Moon-ju-young May 21, 2025
1e24ebe
✨ feat: getProduct, getProductComment api 함수 추가
Moon-ju-young May 21, 2025
5e1f2c2
✨ feat: data response 추가
Moon-ju-young May 21, 2025
83b161f
💄 style: pagenation 버튼 디자인 수정
Moon-ju-young May 21, 2025
91f10e5
♻️ refactor: dropdown 파일 이름 변경
Moon-ju-young May 21, 2025
32cac9c
♻️ refactor: assets 폴더 분할 및 경로 수정
Moon-ju-young May 21, 2025
2c17cb2
✨ feat: 새로운 icon 파일 추가
Moon-ju-young May 21, 2025
423213a
💄 style: favoriteCount 색상 미적용 수정
Moon-ju-young May 21, 2025
3c1e798
♻️ refactor: disabled button 내부 icon으로 수정
Moon-ju-young May 21, 2025
6824aa5
🐛 fix: Pagenation button disabled 조건 변경
Moon-ju-young May 21, 2025
e84ea6d
✨ feat: Dropdown component 추가
Moon-ju-young May 21, 2025
43b8291
✨ feat: ButtonHeart component 추가
Moon-ju-young May 21, 2025
0dda2f9
✨ feat: image 추가
Moon-ju-young May 22, 2025
2c7834c
✨ feat: tag component 다른 형태 추가 및 내부 수정
Moon-ju-young May 22, 2025
b107dc0
♻️ refactor: Nav component 시맨틱 태그 변경
Moon-ju-young May 22, 2025
b1f3a78
♻️ refactor: Button padding 스타일 추가 및 그에 따른 수정
Moon-ju-young May 22, 2025
4d711a6
🐛 fix: z-index 수정
Moon-ju-young May 22, 2025
80869b0
✨ feat: getDurationString tutil 함수 추가
Moon-ju-young May 22, 2025
fe371e2
✨ feat: inputRef prop 추가
Moon-ju-young May 23, 2025
9221a0c
✨ feat: Dropdown 내부 button type=button 추가
Moon-ju-young May 23, 2025
bf79c70
✨ feat: back icon 추가
Moon-ju-young May 24, 2025
1244e2e
✨ feat: api 함수 Error throw 추가
Moon-ju-young May 24, 2025
9ae50ee
✨ feat: ItemProduct (개별 아이템) 페이지 구현
Moon-ju-young May 24, 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
6 changes: 5 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { HelmetProvider } from 'react-helmet-async';
import Index from './pages/Index.jsx';
import Items from './pages/Items.jsx';
import ItemProduct from './pages/ItemProduct.jsx';
import AddItem from './pages/AddItem.jsx';
import Auth from './pages/Auth.jsx';
import Login from './pages/Login.jsx';
Expand All @@ -16,7 +17,10 @@ function App() {
<Routes>
<Route index element={<Index />} />

<Route path="items" element={<Items />} />
<Route path="items">
<Route index element={<Items />} />
<Route path=":productId" element={<ItemProduct />} />
</Route>

<Route path="additem" element={<AddItem />} />

Expand Down
19 changes: 16 additions & 3 deletions src/api/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
const BASE_URL = "https://panda-market-api.vercel.app";

export async function getProducts( { page=1, pageSize=10, orderBy="recent", keyword } ) {
export async function getProducts({ page=1, pageSize=10, orderBy="recent", keyword }) {
const query = new URLSearchParams({ page, pageSize, orderBy }).toString();
const products = await fetch(`${BASE_URL}/products?${query}${keyword ? "&keyword="+keyword : ''}`);
return (await products.json());
const response = await fetch(`${BASE_URL}/products?${query}${keyword ? "&keyword="+keyword : ''}`);
if (!response.ok) { throw Error("Request Error"); }
return (await response.json());
}

export async function getProduct({ productId }) {
const response = await fetch(`${BASE_URL}/products/${productId}`);
if (!response.ok) { throw Error("Request Error"); }
return (await response.json());
}

export async function getProductComments({ productId, limit }) {
const response = await fetch(`${BASE_URL}/products/${productId}/comments?limit=${limit}`);
if (!response.ok) { throw Error("Request Error"); }
return (await response.json());
}
3 changes: 3 additions & 0 deletions src/assets/arrow/ic_arrow_left_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/arrow/ic_arrow_left_inactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/arrow/ic_arrow_right_inactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/default_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_large_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_large_inactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_medium_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_medium_inactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_small_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/heart/ic_heart_small_inactive.svg
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
동일한 이미지를 사이즈별로 저장해서 사용하셔야할 필요가 있을까요? 제가 보기엔 하나로 충분해보입니다~

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/ic_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/ic_kebab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/inquiry_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
11 changes: 2 additions & 9 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { useNavigate } from "react-router-dom";
import styles from "./Button.module.css";

//styleType은 small, medium, large로 나뉜다
function Button ({ styleType="small", className, onClick, to, children, ...props }) {
const navigate = useNavigate();
const handleClick = (e) => {
if (onClick) onClick(e);
if (to) setTimeout(() => navigate(to), 0);
}

function Button ({ styleType="small", className='', children, ...props }) {
return (
<button className={`${styles.btn} ${styles[styleType]} ${className}`} onClick={handleClick} {...props}>
<button className={`${styles.btn} ${styles[styleType]} ${className}`} {...props}>
{children}
</button>
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
}

.btn.small {
padding: 8px 23px;
border-radius: 8px;
font-size: 16px;
line-height: 26px;
}

.btn.medium {
width: 240px;
padding: 11px 0;
border-radius: 9999px;
font-size: 18px;
line-height: 26px;
}

.btn.large {
padding: 12px 0;
border-radius: 9999px;
font-size: 20px;
line-height: 32px;
Expand Down
17 changes: 17 additions & 0 deletions src/components/ButtonHeart.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import icHeartLargeActive from "../assets/heart/ic_heart_large_active.svg";
import icHeartLargeInactive from "../assets/heart/ic_heart_large_inactive.svg";
import icHeartMediumActive from "../assets/heart/ic_heart_medium_active.svg";
import icHeartMediumInactive from "../assets/heart/ic_heart_medium_inactive.svg";
import styles from "./ButtonHeart.module.css";

function ButtonHeart({ isActive=false, className='', children, ...props }) {
return (<button className={styles.btn+' '+className} {...props}>
<img className={styles.large+' '+styles[isActive]} src={icHeartLargeActive} />
<img className={styles.large+' '+styles[!isActive]} src={icHeartLargeInactive} />
<img className={styles.medium+' '+styles[isActive]} src={icHeartMediumActive} />
<img className={styles.medium+' '+styles[!isActive]} src={icHeartMediumInactive} />
{children}
</button>);
}

export default ButtonHeart;
29 changes: 29 additions & 0 deletions src/components/ButtonHeart.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.btn {
display: flex;
align-items: center;
gap: 4px;
padding: 3px 11px;
border: 1px solid var(--gray200);
border-radius: 9999px;
background-color: white;
color: var(--gray500);
font-weight: 500;
font-size: 16px;
line-height: 26px;
}

.btn img.medium,
.btn img.false {
display: none;
}

@media (max-width: 1199px) {
.btn img.medium {
display: block;
}

.btn img.large,
.btn img.false {
display: none;
}
}
37 changes: 12 additions & 25 deletions src/components/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { useEffect, useRef, useState } from 'react';
import icArrowDown from '../assets/ic_arrow_down.svg';
import icSort from '../assets/ic_sort.svg';
import styles from './Dropdown.module.css';
import { useEffect, useRef, useState } from "react";
import icKebab from "../assets/ic_kebab.svg";
import styles from "./Dropdown.module.css";

const option = { recent: "최신순", favorite: "좋아요순", }

function Dropdown({ state, setState, mode }) {
function Dropdown({ className='', onClickEdit, onClickDelete, ...props }) {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef(null);

useEffect(() => {
const handleClickOutside = (e) => {
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) setIsOpen(false);
Expand All @@ -17,23 +14,13 @@ function Dropdown({ state, setState, mode }) {
return () => document.removeEventListener("click", handleClickOutside);;
}, []);

return (
<button
className={`${styles.dropdown} ${(mode === "Mobile" && styles.small)}`}
onClick={() => setIsOpen((prev) => !prev)}
ref={dropdownRef}
>
{ mode !== "Mobile"
? <> <div>{option[state]}</div> <img src={icArrowDown} /> </>
: <img src={icSort} /> }
{ isOpen &&
<ul className={styles.dropdownList}>
{Object.entries(option).map(([key, value]) => (<li key={key}>
<input type="button" value={value} onClick={() => setState(key)} />
</li>))}
</ul>}
</button>
);
return (<button type="button" className={styles.dropdown+' '+className} ref={dropdownRef} onClick={() => setIsOpen((prev) => !prev)} {...props}>
<img src={icKebab} />
{isOpen && <div className={styles.list}>
<input type="button" value="수정하기" onClick={onClickEdit} />
<input type="button" value="삭제하기" onClick={onClickDelete}/>
</div>}
</button>);
}

export default Dropdown;
74 changes: 39 additions & 35 deletions src/components/Dropdown.module.css
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
.dropdown {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
gap: 0;
width: 130px;
padding: 0 19px;
border: 1px solid var(--gray200);
border-radius: 12px;
color: var(--gray800);
font-weight: 400;
font-size: 16px;
line-height: 26px;
}

.dropdown.small {
justify-content: center;
width: 42px;
padding: 0;
border: none;
}

.dropdownList {
.dropdown .list {
z-index: 1;
position: absolute;
top: calc(100% + 8px);
top: calc(100% + 10px);
right: 0;
width: 130px;
margin: 0;
padding: 0;
border: 1px solid var(--gray200);
border-radius: 12px;
background-color: white;
width: 139px;
}

.dropdownList li input {
display: block;
.dropdown .list input {
cursor: pointer;
width: 100%;
height: 41px;
padding: 8px 0 6px;
border: none;
border-bottom: 1px solid var(--gray200);
background-color: transparent;
color: var(--gray800);
border: 1px solid #D1D5DB;
background-color: white;
color: var(--gray500);
font-weight: 400;
font-size: 16px;
line-height: 26px;
}

.dropdownList li:last-child input {
border: none;
.dropdown .list input:first-child {
padding: 11px 0 8px;
border-bottom: none;
border-radius: 8px 8px 0 0;
}

.dropdown .list input:last-child {
padding: 8px 0 11px;
border-top: none;
border-radius: 0 0 8px 8px;
}

@media (max-width: 767px) {
.dropdown .list {
width: 102px;
}

.dropdown .list input {
font-size: 14px;
line-height: 17px;
}

.dropdown .list input:first-child {
padding: 15px 0 12px;
}

.dropdown .list input:last-child {
padding: 12px 0 15px;
}
}
40 changes: 40 additions & 0 deletions src/components/DropdownSort.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect, useRef, useState } from 'react';
import icArrowDown from '../assets/ic_arrow_down.svg';
import icSort from '../assets/ic_sort.svg';
import styles from './DropdownSort.module.css';

const option = { recent: "최신순", favorite: "좋아요순", }

function Dropdown({ state, setState, mode }) {
const [isOpen, setIsOpen] = useState(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 여담
reducer 를 사용해 아래처럼 간단하게도 작성 가능합니다~

Suggested change
const [isOpen, setIsOpen] = useState(false);
const [isOpen, toggleIsOpen] = useReducer((prev) => !prev, false);

const dropdownRef = useRef(null);

useEffect(() => {
const handleClickOutside = (e) => {
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) setIsOpen(false);
};
document.addEventListener("click", handleClickOutside);
return () => document.removeEventListener("click", handleClickOutside);;
}, []);

return (
<button
type="button"
className={`${styles.dropdown} ${(mode === "Mobile" && styles.small)}`}
onClick={() => setIsOpen((prev) => !prev)}
ref={dropdownRef}
>
{ mode !== "Mobile"
? <> <div>{option[state]}</div> <img src={icArrowDown} /> </>
: <img src={icSort} /> }
{ isOpen &&
<ul className={styles.dropdownList}>
{Object.entries(option).map(([key, value]) => (<li key={key}>
<input type="button" value={value} onClick={() => setState(key)} />
</li>))}
</ul>}
</button>
);
}

export default Dropdown;
Loading
Loading