-
Notifications
You must be signed in to change notification settings - Fork 128
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
This pr fixes #164. screenshots: ![Screenshot 2024-05-17 093744](https://github.com/HimanshuNarware/CareerZunction_Intern/assets/139672976/3f430484-3814-483d-b601-22f5dee81006) ![Screenshot 2024-05-17 093803](https://github.com/HimanshuNarware/CareerZunction_Intern/assets/139672976/2ae05cbf-d1d1-49a4-9d68-fcd87591d57e) video link for my demonstration: https://drive.google.com/file/d/18jspsXz9p51kh5shfldUN8_YlWuyF4G3/view?usp=sharing
- Loading branch information
Showing
7 changed files
with
188 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
|
@@ -205,6 +205,11 @@ font-weight:500; | |
} | ||
} | ||
|
||
.page-summary { | ||
color: blueviolet; | ||
padding: 15px 10%; | ||
} | ||
|
||
/* @mediaQwery */ | ||
|
||
|
||
|
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,56 @@ | ||
.pagination-wrapper { | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
margin-top:35px; | ||
} | ||
.pagination-container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
gap: 10px; | ||
box-shadow: 0 0 10px blueviolet; | ||
border: 2px solid blueviolet; | ||
padding: 10px 20px; | ||
border-radius: 30px; | ||
} | ||
.page-btn { | ||
list-style-type: none; | ||
} | ||
.page-btn-link { | ||
padding: 10px; | ||
display: inline-block; | ||
height: 35px; | ||
width: 35px; | ||
border-radius: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
transition: 0.5s; | ||
color: blueviolet; | ||
} | ||
.page-btn-link:not(.active):hover { | ||
background-color: rgb(222, 186, 255); | ||
} | ||
.active { | ||
background-color: blueviolet; | ||
color: white; | ||
font-weight: 600; | ||
border-radius: 50%; | ||
} | ||
.prev, .next { | ||
width: max-content; | ||
border-radius: 5px; | ||
} | ||
.disabled{ | ||
pointer-events: none; | ||
opacity: 0.5; | ||
} | ||
.break { | ||
color: blueviolet; | ||
pointer-events: none; | ||
border: none; | ||
font-weight: 600; | ||
} |
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,60 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import ReactPaginate from 'react-paginate'; | ||
import './pagination.css' | ||
import DataDB from '../DB/DataBase.json' | ||
|
||
function PaginatedItems({ setCurrentData, setPageSummary }) { | ||
const itemsPerPage = 12; | ||
|
||
const pageCount = Math.ceil(DataDB.length / itemsPerPage); | ||
|
||
const handlePageClick = (event) => { | ||
const newOffset = (event.selected * itemsPerPage) % DataDB.length; | ||
const endOffset = newOffset + itemsPerPage > DataDB.length ? DataDB.length : newOffset + itemsPerPage; | ||
|
||
setCurrentData(DataDB.slice(newOffset, endOffset)) | ||
setPageSummary(`Showing ${newOffset+1} to ${endOffset} results out of ${DataDB.length}`) | ||
|
||
window.scroll(0, 0); | ||
}; | ||
|
||
useEffect(() => { | ||
const pageBtns = document.querySelectorAll(".page-btn"); | ||
console.log(pageBtns[1]) | ||
handlePageClick({selected: 0}) | ||
pageBtns[1].classList.add("active"); | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<div className="pagination-wrapper"> | ||
<ReactPaginate | ||
breakLabel="..." | ||
nextLabel="| Next" | ||
onPageChange={handlePageClick} | ||
pageRangeDisplayed={3} | ||
marginPagesDisplayed={2} | ||
pageCount={pageCount} | ||
previousLabel="Prev |" | ||
renderOnZeroPageCount={null} | ||
activeClassName="page-btn" | ||
activeLinkClassName='active' | ||
containerClassName='pagination-container' | ||
pageClassName='page-btn' | ||
pageLinkClassName='page-btn-link' | ||
previousClassName='page-btn' | ||
previousLinkClassName='prev page-btn-link' | ||
nextClassName='page-btn' | ||
nextLinkClassName='next page-btn-link' | ||
disabledClassName='page-btn' | ||
disabledLinkClassName='disabled page-btn-link' | ||
breakClassName='page-btn' | ||
breakLinkClassName='break page-btn-link' | ||
/> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
|
||
export default PaginatedItems; |