-
Notifications
You must be signed in to change notification settings - Fork 21
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
[김가희] sprint6 #92
The head ref may contain hidden characters: "React-\uAE40\uAC00\uD76C-week6"
[김가희] sprint6 #92
Changes from all commits
cefe7b6
7588fa8
cd50a99
766ec54
9dad834
b06158d
37ca496
e1dcf29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
|
||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
|
||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
|
||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
<div id="root"> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* api 호출 await 필요 | ||
* @param {*} page 페이지 번호 | default 1 | ||
* @param {*} pageSize 페이지 당 상품 수 | default 10 | ||
* @param {*} orderBy 정렬 기준 favorite, recent | default recent | ||
* @param {*} keyword 검색 키워드 | ||
* @returns | ||
*/ | ||
export async function getItems( | ||
page = 1, | ||
pageSize = 10, | ||
orderBy = "recent", | ||
keyword | ||
) { | ||
const searchQuery = keyword ? `keyword=${keyword}` : ""; | ||
const response = await fetch( | ||
`https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}&${searchQuery}` | ||
); | ||
const body = await response.json(); | ||
return body; | ||
} | ||
|
||
// // 1페이지 10개 최신순 줘 | ||
// const 1페이지10개 = getItems(1,10,"recent") | ||
// const 2페이지10개 = getItems(2,10,"recent") | ||
// const 3페이지10개 = getItems(3,10,"recent") | ||
|
||
// // 최신순으로 1페이지 1개 줘 | ||
// const 1페이지10개 = getItems(1,10,"favorite") | ||
// const 2페이지10개 = getItems(2,10,"favorite") | ||
// const 3페이지10개 = getItems(3,10,"favorite") | ||
Comment on lines
+23
to
+31
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. P3: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Nav from "./Nav"; | ||
|
||
function App({ children }) { | ||
return ( | ||
<div> | ||
<Nav></Nav> | ||
<div>{children}</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||||||||||
import { useEffect, useState } from "react"; | ||||||||||||||
import { getItems } from "../api"; | ||||||||||||||
import Card from "./Card"; | ||||||||||||||
import style from "./BestList.module.css"; | ||||||||||||||
|
||||||||||||||
function BestList() { | ||||||||||||||
const [cardList, setCardList] = useState([]); | ||||||||||||||
|
||||||||||||||
const fetchData = async function () { | ||||||||||||||
const data = await getItems(1, 4, "favorite"); | ||||||||||||||
setCardList(data.list); | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
useEffect(() => { | ||||||||||||||
fetchData(); | ||||||||||||||
}, []); | ||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<div className={style.wrapper}> | ||||||||||||||
<div className={style.bestListBlock}> | ||||||||||||||
<div className={style.label}>베스트 상품</div> | ||||||||||||||
<div className={style.bestList}> | ||||||||||||||
{cardList.map((item) => { | ||||||||||||||
return <Card key={item.id} item={item} imgSize={"282px"}></Card>; | ||||||||||||||
})} | ||||||||||||||
Comment on lines
+23
to
+25
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. P3:
Suggested change
|
||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export default BestList; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@font-face { | ||
font-family: "Pretendard Variable"; | ||
src: url("../../public/Pretendard-Regular.ttf"); | ||
} | ||
|
||
.label { | ||
font-family: "Pretendard Variable"; | ||
font-size: 20px; | ||
font-weight: 700; | ||
line-height: 32px; | ||
text-align: left; | ||
color: #111827; | ||
} | ||
|
||
.bestList { | ||
display: flex; | ||
justify-content: center; | ||
gap: 24px; | ||
} | ||
|
||
.bestListBlock { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
width: fit-content; | ||
} | ||
|
||
.wrapper { | ||
display: flex; | ||
justify-content: center; | ||
} |
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.
P2:
모든 파람의 경우 default값이 설정되어 있는데, 이런 방식으로는 default값을 설정해두신 장점을 살리기 어렵습니다.
아래처럼 obj로 받으시면 필요한 값만 넘길 수 있으므로 아래와 같은 방식도 고려해보세요~