Skip to content

Commit

Permalink
[박형준] sprint5 (#255)
Browse files Browse the repository at this point in the history
* 프로젝트 생성, 파일 정리, App component 생성

* Add Header Component

* change image name

* change Header.css

* add media query to Header.css for Tablet

* change media query min-width for Tablet

* Add media query for Desktop and finish Header component

* Add Best Items section

* Add Best Item section Tablet size

* Add Best items desktop size

* Add All Item section

* Add All Items order change

* Add Basic Pagenation

---------

Co-authored-by: 박형준 <[email protected]>
  • Loading branch information
junAlexx and 박형준 authored Dec 9, 2024
1 parent 66f3ba6 commit eed5503
Show file tree
Hide file tree
Showing 31 changed files with 6,678 additions and 4,783 deletions.
10,461 changes: 5,854 additions & 4,607 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@noonnu/rokaf-sans-medium": "^0.1.0",
"@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-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
31 changes: 0 additions & 31 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,9 @@
<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`.
-->
</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.

38 changes: 38 additions & 0 deletions src/App/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@import url('https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=ROKAF+Sans:wght@400;700&display=swap');
@import url('~@noonnu/rokaf-sans-medium');

:root {
--blue100: #3692ff;
--grey200: #1f2937;
--grey100: #4b5563;
}

* {
margin: 0;
padding: 0;

font-family: 'Pretendard', sans-serif;
}

a {
text-decoration: none;
}

.loadChangeButton {
width: 100%;
display: flex;
justify-content: center;
}

.loadChange {
/* width: 100%; */
flex-grow: 1;
height: 50px;

font-size: 25px;
border-radius: 10px;

margin-bottom: 100px;
cursor: pointer;
}
57 changes: 57 additions & 0 deletions src/App/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useEffect, useState } from 'react';
import { getData } from '../api';
import AllItems from '../Components/AllItems/AllItems';
import BestItems from '../Components/BestItems/BestItems';
import Header from '../Components/Header/Header';
import './App.css';

const { list: bestItems } = await getData({ order: 'favorite' });

function App() {
const [allItems, setAllItems] = useState([]);
const [order, setOrder] = useState('recent');
const [page, setPage] = useState(1);

const handleChange = (orderBy) => {
setOrder(orderBy);
};

const handleLoadNext = () => {
if (allItems.length < 10) {
return;
} else {
setPage(page + 1);
}
};
const handleLoadPre = () => {
if (page === 1) {
return;
} else {
setPage(page - 1);
}
};

const itemLoad = async (orderQuery) => {
const { list: nextItems } = await getData(orderQuery);
setAllItems(nextItems);
};

useEffect(() => {
itemLoad({ order, page });
}, [order, page]);

return (
<>
<Header />
<BestItems items={bestItems} />
<AllItems
items={allItems}
onChange={handleChange}
onLoadNext={handleLoadNext}
onLoadPre={handleLoadPre}
/>
</>
);
}

export default App;
141 changes: 141 additions & 0 deletions src/App/backup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// App.js

import { useEffect, useState } from 'react';
import { getData } from '../api';
import AllItems from '../Components/AllItems/AllItems';
import BestItems from '../Components/BestItems/BestItems';
import Header from '../Components/Header/Header';
import './App.css';

const { list: bestItems } = await getData('favorite');

function App() {
const [allItems, setAllItems] = useState([]);
const [order, setOrder] = useState('recent');
const [preOrder, setPreOrder] = useState(order);
const [page, setPage] = useState(1);

const handleChange = (orderBy) => {
setOrder(orderBy);
};

const handLoadMore = () => {
setPage(page + 1);
};

const load = async (orderQuery) => {
const { list: nextItems } = await getData(orderQuery);
if (orderQuery.page === 1) {
setAllItems(nextItems);
} else {
setAllItems([...allItems, ...nextItems]);
}
};

useEffect(() => {
if (order !== preOrder) {
load({ order });
} else {
load({ order, page });
}
}, [order, page]);

return (
<>
<Header />
<BestItems items={bestItems} />
<AllItems
items={allItems}
onChange={handleChange}
onLoadMore={handLoadMore}
/>
</>
);
}

export default App;








































// AllItems.js

import AllItemList from './AllItemList/AllItemList';
import './AllItems.css';

function AllItems({ items, onChange, onLoadMore }) {
const allItemsChange = (e) => {
onChange(e.target.value);
};

const handLoadMore = () => {
onLoadMore();
};

return (
<div className="allItems">
<div className="container">
<h2>전체 상품</h2>
<div className="allItemsRight">
<input type="text" placeholder="검색할 상품을 입력해주세요"></input>
<button>상품 등록하기</button>
<select
className="orderSelect"
name="order"
onChange={allItemsChange}
>
<option value="recent">최신순</option>
<option value="favorite">베스트순</option>
</select>
</div>
</div>

<ul className="itemList">
{items.map((item, index) => {
return <AllItemList key={item.id} item={item} index={index} />;
})}
</ul>
<button className="loadMore" onClick={handLoadMore}>
더보기
</button>
</div>
);
}

export default AllItems;
Loading

0 comments on commit eed5503

Please sign in to comment.