Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll-to-Top button #1132

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions public/data/elijahlowe77.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Elijah",
"location": "University of Florida",
"bio": "I love everything about digital visualization, currently learning react, ruby on rails, but most proficient in C# with unity",
"avatar": "https://github.com/elijahlowe77.png",
"portfolio": "https://github.com/elijahlowe77",
"skills": ["Unity", "REACT"],
"social": {
"GitHub": "https://github.com/elijahlowe77",
"Twitter": "https://twitter.com/REDACTED",
"LinkedIn": "https://www.linkedin.com/in/elijah-lowe-54105821a/"
}
}
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NoResultFound from './components/NoResultFound/NoResultFound';
import Pagination from './components/Pagination/Pagination';
import './App.css';
import filenames from './ProfilesList.json';
import PageUp from "./components/PageUp/PageUp.jsx";

function App() {
const profilesRef = useRef();
Expand Down Expand Up @@ -133,7 +134,8 @@ function App() {
<Sidebar />
<div className="w-full pl-5 pr-4 md:h-screen md:w-[77%] md:overflow-y-scroll md:py-7" ref={profilesRef}>
<Search onSearch={handleSearch} />
{profiles.length === 0 && searching ? <NoResultFound /> : renderProfiles()}
{profiles.length === 0 && searching ? <NoResultFound /> : renderProfiles()}
<PageUp />
{(searching ? profiles.length : shuffledProfiles.length) > 0 && (
<Pagination
currentPage={currentPage}
Expand Down
3 changes: 2 additions & 1 deletion src/ProfilesList.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,6 @@
"Sanket176.json",
"Om-pawarr.json",
"boytur.json",
"giuliarappo.json"
"giuliarappo.json",
"elijahlowe77.json"
]
18 changes: 18 additions & 0 deletions src/components/PageUp/PageUp.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import react from "react";

function PageUp() {
//creating function outside of return to keep code readibility
const top = () => {
window.scrollTo(0, 0);
};
return (
//using same classNames as buttons from Pagination component to maintain formatting
<div className="flex items-center justify-center gap-12">
<button className="focus:outline-none disabled:opacity-30" onClick={top}>
Top
</button>
</div>
);
}

export default PageUp;