커뮤니티 페이지에서 페이지네이션을 구현하기 위해서 react-paginate를 사용했는데, styled-component를 어떻게 적용해야할지 몰라서 좀 헤맸다.
https://github.com/AdeleD/react-paginate/issues/321
여기서 styled-component 적용 방법을 확인할 수 있다.
<MyPaginate
forcePage={page}
previousLabel={"〈"}
nextLabel={"〉"}
breakLabel={"..."}
pageCount={15}
marginPagesDisplayed={3}
pageRangeDisplayed={2}
onPageChange={handlePageClick}
containerClassName="pagination justify-content-center"
pageClassName="page-item"
pageLinkClassName="page-link"
previousClassName="page-item"
previousLinkClassName="page-link"
nextClassName="page-item"
nextLinkClassName="page-link"
activeClassName="active"
/>
const MyPaginate = styled(ReactPaginate).attrs({
activeClassName: "active",
})`
margin: 50px 16px;
display: flex;
justify-content: center;
list-style-type: none;
padding: 0 5rem;
li a {
border-radius: 7px;
padding: 0.1rem 1rem;
cursor: pointer;
}
li.previous a,
li.next a {
color: #62b6b7;
}
li.active a {
color: #91cccd;
font-weight: 700;
min-width: 32px;
}
li.disabled a {
color: ${({ theme }) => theme.colors.gray_03};
}
li.disable,
li.disabled a {
cursor: default;
}
@media (max-width: 600px) {
font-size: ${({ theme }) => theme.fontSizes.fs10};
}
`;