-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[ View Product ] 페이지네이션 및 가격 정렬 구현
- Loading branch information
Showing
58 changed files
with
17,524 additions
and
3,637 deletions.
There are no files selected for viewing
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
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
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
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,88 @@ | ||
import styled from '@emotion/styled'; | ||
import { css } from '@emotion/react'; | ||
import { | ||
IcLeftArrow, | ||
IcLeftArrowFill, | ||
IcRightArrow, | ||
IcRightArrowFill, | ||
} from '../../public/assets/icons'; | ||
|
||
interface PageNavigationProps { | ||
currentPage: number; | ||
lastPage: number; | ||
handleCurrentPage: (nextPage: number) => void; | ||
} | ||
|
||
export default function PageNavigation(props: PageNavigationProps) { | ||
const { currentPage, lastPage, handleCurrentPage } = props; | ||
|
||
const pageArray = | ||
currentPage % 5 === 0 | ||
? new Array(5) | ||
.fill(0) | ||
.map((_, idx) => (Math.floor(currentPage / 5) - 1) * 5 + idx + 1) | ||
: lastPage > Math.ceil(currentPage / 5) * 5 | ||
? new Array(5) | ||
.fill(0) | ||
.map((_, idx) => Math.floor(currentPage / 5) * 5 + idx + 1) | ||
: new Array(lastPage - Math.floor(currentPage / 5) * 5) | ||
.fill(0) | ||
.map((_, idx) => Math.floor(currentPage / 5) * 5 + idx + 1); | ||
|
||
const handlePreviousGroupPage = () => { | ||
handleCurrentPage(pageArray[0] - 1); | ||
}; | ||
const handleNextGroupPage = () => { | ||
handleCurrentPage(pageArray[pageArray.length - 1] + 1); | ||
}; | ||
|
||
const handlePageNumber = (e: React.MouseEvent<HTMLAnchorElement>) => { | ||
const target = e.target as HTMLAnchorElement; | ||
handleCurrentPage(Number(target.innerHTML)); | ||
}; | ||
return ( | ||
<StNavigationWrapper> | ||
{Math.floor(currentPage / 5) >= 1 && currentPage !== 5 ? ( | ||
<IcLeftArrowFill onClick={handlePreviousGroupPage} /> | ||
) : ( | ||
<IcLeftArrow /> | ||
)} | ||
{pageArray.map((page) => ( | ||
<StPageNumberA | ||
key={page} | ||
isCurrent={page === currentPage} | ||
onClick={() => handleCurrentPage(page)} | ||
> | ||
{page} | ||
</StPageNumberA> | ||
))} | ||
{lastPage > Math.ceil(currentPage / 5) * 5 ? ( | ||
<IcRightArrowFill onClick={handleNextGroupPage} /> | ||
) : ( | ||
<IcRightArrow /> | ||
)} | ||
</StNavigationWrapper> | ||
); | ||
} | ||
|
||
const StNavigationWrapper = styled.nav` | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
width: 22.2rem; | ||
margin-bottom: 12rem; | ||
cursor: pointer; | ||
`; | ||
const StPageNumberA = styled.a<{ isCurrent: boolean }>` | ||
${({ isCurrent }) => | ||
isCurrent | ||
? css` | ||
color: #1db981; | ||
` | ||
: css` | ||
color: #787878; | ||
`}; | ||
${({ theme }) => theme.fonts.b3_16_medium_140} | ||
`; |
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,45 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export interface PriceFilterProps { | ||
priceDesc: boolean; | ||
handleClickPrice: (clickPrice: string) => void; | ||
} | ||
|
||
export default function PriceFilter(props: PriceFilterProps) { | ||
const { priceDesc, handleClickPrice } = props; | ||
|
||
return ( | ||
<StPriceSection> | ||
<StPriceTitle | ||
onClick={() => handleClickPrice('price-desc')} | ||
priceDesc={priceDesc} | ||
> | ||
낮은 가격순 | ||
</StPriceTitle> | ||
<span>|</span> | ||
<StPriceTitle | ||
onClick={() => handleClickPrice('price-asc')} | ||
priceDesc={!priceDesc} | ||
> | ||
높은 가격순 | ||
</StPriceTitle> | ||
</StPriceSection> | ||
); | ||
} | ||
|
||
const StPriceSection = styled.section` | ||
display: flex; | ||
align-items: center; | ||
column-gap: 1.4rem; | ||
height: 2rem; | ||
margin-top: 2rem; | ||
color: ${({ theme }) => theme.colors.gray005}; | ||
${({ theme }) => theme.fonts.b5_14_medium_140}; | ||
`; | ||
const StPriceTitle = styled.span<{ priceDesc: boolean }>` | ||
color: ${({ priceDesc, theme: { colors } }) => | ||
priceDesc ? colors.black : colors.gray005}; | ||
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
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
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,45 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
interface CommunityCategoryProps { | ||
category: string; | ||
} | ||
|
||
export default function CommunityCategory(props: CommunityCategoryProps) { | ||
const { category } = props; | ||
|
||
return ( | ||
<> | ||
{category === '후기' ? ( | ||
<StCategoryReview>{category}</StCategoryReview> | ||
) : category === '질문' ? ( | ||
<StCategoryQuestion>{category}</StCategoryQuestion> | ||
) : ( | ||
<StCategoryInfo>{category}</StCategoryInfo> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
const StCategory = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 7.6rem; | ||
height: 2.6rem; | ||
border-radius: 1.9rem; | ||
color: ${({ theme }) => theme.colors.white}; | ||
${({ theme }) => theme.fonts.b5_14_medium_140} | ||
`; | ||
const StCategoryReview = styled(StCategory)` | ||
background-color: ${({ theme }) => theme.colors.mainDarkgreen}; | ||
`; | ||
const StCategoryQuestion = styled(StCategory)` | ||
color: ${({ theme }) => theme.colors.gray009}; | ||
background-color: ${({ theme }) => theme.colors.subYellow}; | ||
`; | ||
const StCategoryInfo = styled(StCategory)` | ||
background-color: ${({ theme }) => theme.colors.mainGreen}; | ||
`; |
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
Oops, something went wrong.