Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9,678 changes: 4,874 additions & 4,804 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "1-weekly-mission",
"name": "react_mission",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.0",
"react-scripts": "5.0.1",
"styled-components": "^6.1.13",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand All @@ -34,5 +36,9 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"eslint-config-prettier": "^9.1.0"
}
}
Binary file removed public/favicon.ico
Binary file not shown.
38 changes: 3 additions & 35 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
<!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>
<link rel="shortcut icon" href="../src/img/panda.png" type="image/x-icon" />
<title>판다마켓</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`.
-->
</body>
</html>
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/App.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/Main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BrowserRouter, Route, Routes } from "react-router-dom";
import App from "./components/App";
import ItemsPage from "./pages/ItemsPage";
import AddItem from "./pages/AddItem";
import BoardsPage from "./pages/BoardsPage";

function Main() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<App />}>
<Route path="/items" element={<ItemsPage />} />
<Route path="/boards" element={<BoardsPage />} />
<Route path="/additem" element={<AddItem />} />
</Route>
</Routes>
</BrowserRouter>
);
}

export default Main;
13 changes: 13 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export async function getList({
orderby = "recent",
page = 1,
pageSize = 10,
keyword = "",
}) {
const query = `orderBy=${orderby}&page=${page}&pageSize=${pageSize}&keyword=${keyword}`;
const response = await fetch(
`https://panda-market-api.vercel.app/products?${query}`
);
const body = await response.json();
return body;
}
16 changes: 16 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Nav from "./Nav";
import styles from "./App.module.css";
import { Outlet } from "react-router-dom";

function App() {
return (
<>
<Nav className={styles.nav} />
<div className={styles.body}>
<Outlet />
</div>
</>
);
}

export default App;
39 changes: 39 additions & 0 deletions src/components/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@font-face {
font-family: "Pretendard-Regular";
src: url
(
"https://fastly-jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Regular.woff"
)
format ("woff");
font-weight: 400;
font-style: normal;
}

body {
font-family: "Pretendard-Regular";
}

* {
box-sizing: border-box;
word-break: keep-all;
}

body {
margin: 0;
}

.nav {
flex: none;
}

@media (max-width: 1199px) {
.body {
padding: 0 24px 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

0 24px 과 결과가 동일해서 확인하면 좋을 것 같아요.

}
}

@media (min-width: 375px) and (max-width: 767px) {
.body {
padding: 0 16px 0;
}
}
43 changes: 43 additions & 0 deletions src/components/BestProductList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import styled from "styled-components";
import { ProductListItem } from "./ProductList";

const Container = styled.ul`
width: 100%;
max-width: 1040px;
margin: 0 auto;
padding: 0;
display: grid;
grid-template:
1fr /
repeat(4, 1fr);
gap: 24px;
list-style: none;

@media (max-width: 1199px) {
grid-template:
1fr /
repeat(2, 1fr);
}

@media (min-width: 375px) and (max-width: 767px) {
grid-template:
1fr /
1fr;
}
`;

function BestProduct({ items }) {
return (
<Container>
{items.map((item) => {
return (
<li key={item.id}>
<ProductListItem item={item} />
</li>
);
})}
</Container>
);
}

export default BestProduct;
43 changes: 43 additions & 0 deletions src/components/Dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useState } from "react";
import styles from "./Dropdown.module.css";

function Dropdown({ options, selectedValue, onChange }) {
const [isOpen, setIsOpen] = useState(false);

const handleToggle = () => {
setIsOpen((prev) => !prev);
Copy link
Contributor

Choose a reason for hiding this comment

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

prev 활용 좋아요~👍

};

const handleOptionClick = (value) => {
onChange(value); // 부모 컴포넌트로 선택 값 전달
setIsOpen(false);
};

return (
<div className={styles.dropdown}>
<button
className={styles.dropdown_button}
onClick={handleToggle}
type="button"
>
{options.find((option) => option.value === selectedValue)?.label ||
"선택"}
</button>
{isOpen && (
<ul className={styles.dropdown_menu}>
{options.map((option) => (
<li
key={option.value}
className={styles.dropdown_item}
onClick={() => handleOptionClick(option.value)}
>
{option.label}
</li>
))}
</ul>
)}
</div>
);
}

export default Dropdown;
Copy link
Contributor

Choose a reason for hiding this comment

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

Dropdown은 만들고 사용하는 곳은 없나요?

Loading
Loading