-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 프로젝트 생성, 파일 정리, 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
Showing
31 changed files
with
6,678 additions
and
4,783 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.