Skip to content

Commit

Permalink
Merge pull request #2689 from DevGajjar28/scrolltop
Browse files Browse the repository at this point in the history
page scroll to top
  • Loading branch information
panwar8279 authored Aug 7, 2024
2 parents ad0155b + 9db4f14 commit 18ed5f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 16 additions & 7 deletions frontend/src/Component/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ function Home(props) {

const filteredData = !!props.searchQuery
? allvalue.filter((datalist) => {
return datalist.productName
.toLowerCase()
.includes(props.searchQuery.toLowerCase());
})
return datalist.productName
.toLowerCase()
.includes(props.searchQuery.toLowerCase());
})
: allvalue;

const currentPost =
Expand All @@ -128,17 +128,20 @@ function Home(props) {
const prePage = () => {
if (currentPage > 1) {
setCurrentPage(currentPage - 1);
window.scrollTo({ top: document.body.scrollHeight * 0.2, behavior: "smooth" });
}
};

const nextPage = () => {
if (currentPage < npage) {
setCurrentPage(currentPage + 1);
window.scrollTo({ top: document.body.scrollHeight * 0.2, behavior: "smooth" });
}
};

const changeCPage = (id) => {
setCurrentPage(id);
window.scrollTo({ top: document.body.scrollHeight * 0.2, behavior: "smooth" });
};

const handleBookmark = (datalist) => {
Expand Down Expand Up @@ -303,10 +306,13 @@ function Home(props) {
</h1>
</h1>


<div className="hero-button-container" style={{ display: "flex", justifyContent: "center" }}>
<div
className="hero-button-container"
style={{ display: "flex", justifyContent: "center" }}
>

<button className="hero-button">
<NavbarItem description="Get Started" to="/open-source" />
</button>
Expand Down Expand Up @@ -334,13 +340,17 @@ function Home(props) {
<br />
{searchQuery && searchResults.length === 0 && (
<div className="no-results">

<img src="./empty-state.png" height={"300px"} width={"300px"} style={{ background: "none" }} alt="empty_state_img" />

<img
src="./empty-state.png"
height={"300px"}
width={"300px"}
style={{ background: "none" }}
alt="empty_state_img"
/>

<h1>No matching tools found.</h1>
</div>
)}
Expand All @@ -360,9 +370,8 @@ function Home(props) {
{filters.map((category) => (
<button
key={category}
className={`filter-button ${
selectedFilters.includes(category) ? "active_filter" : ""
}`}
className={`filter-button ${selectedFilters.includes(category) ? "active_filter" : ""
}`}
onClick={() => handleFilterButtonClick(category)}
>
{category}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/Component/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const Pagination = ({
handlePageChange,
scrollPosition
}) => {


return (
<nav>
<div className="page-index">
Expand Down

0 comments on commit 18ed5f5

Please sign in to comment.