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

Fixes #1072 by adding a Scroll-To-Top Button. #1119

Open
wants to merge 1 commit 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
23 changes: 11 additions & 12 deletions public/data/Om-pawarr.json
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i only made changes in App.js..why 4 files are changed?

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "Om pawar",
"location": "Maharashtra",
"bio": "A Web Developer specializing in HTML5,css, JavaScript, and front-end frameworks",
"avatar": "https://avatars.githubusercontent.com/u/124502159?s=400&u=3691e22cc07794bb421cee5c655dca4d8da244c9&v=4",
"portfolio": "",
"skills": ["Front end frameworks expertise", "AWS associate level certified", "..."],
"social": {
"GitHub": "https://github.com/Om-pawarr",
"Twitter": "https://twitter.com/@_Parth_Dwivedi_",
"LinkedIn": ""
}
"name": "Om pawar",
"location": "Maharashtra",
"bio": "A Web Developer specializing in HTML5,css, JavaScript, and front-end frameworks",
"avatar": "https://avatars.githubusercontent.com/u/124502159?s=400&u=3691e22cc07794bb421cee5c655dca4d8da244c9&v=4",
"portfolio": "",
"skills": ["Front end frameworks expertise", "AWS associate level certified", "..."],
"social": {
"GitHub": "https://github.com/Om-pawarr",
"Twitter": "https://twitter.com/@_Parth_Dwivedi_",
"LinkedIn": ""
}
}
22 changes: 11 additions & 11 deletions public/data/giuliarappo.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Giulia",
"location": "Italy",
"bio": "Junior fullstack delevoper searching a project to collaborate for improve skills",
"avatar": "https://github.com/giuliarappo.png",
"portfolio": "https://github.com/giuliarappo",
"skills": ["Java", "Spring boot", "Angular", "React"],
"social": {
"GitHub": "https://github.com/<giuliarappo>",
"LinkedIn": "https://www.linkedin.com/in/<giulia-rappo>"
}
}
"name": "Giulia",
"location": "Italy",
"bio": "Junior fullstack delevoper searching a project to collaborate for improve skills",
"avatar": "https://github.com/giuliarappo.png",
"portfolio": "https://github.com/giuliarappo",
"skills": ["Java", "Spring boot", "Angular", "React"],
"social": {
"GitHub": "https://github.com/<giuliarappo>",
"LinkedIn": "https://www.linkedin.com/in/<giulia-rappo>"
}
}
44 changes: 43 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import NoResultFound from './components/NoResultFound/NoResultFound';
import Pagination from './components/Pagination/Pagination';
import './App.css';
import filenames from './ProfilesList.json';

import { FaArrowUpLong } from 'react-icons/fa6';
function App() {
const profilesRef = useRef();
const [profiles, setProfiles] = useState([]);
Expand Down Expand Up @@ -126,12 +126,54 @@ function App() {
return paginatedData.map((currentRecord, index) => <Profile data={currentRecord} key={index} />);
};

const [showScrollTop, setShowScrollTop] = useState(false);
const handleScroll = () => {
if (profilesRef.current.scrollTop > 100 || window.pageYOffset > 100) {
setShowScrollTop(true);
} else {
setShowScrollTop(false);
}
};
useEffect(() => {
const ref = profilesRef.current;
ref.addEventListener('scroll', handleScroll);

return () => {
ref.removeEventListener('scroll', handleScroll);
};
}, []);
useEffect(() => {
window.addEventListener('scroll', handleScroll);

return () => {
window.removeEventListener('scroll', handleScroll);
};
}, []);

const scrollTop = () => {
profilesRef.current.scrollTo({
top: 0,
behavior: 'smooth',
});
window.scrollTo({
top: 0,
behavior: 'smooth',
});
};
return currentUrl === '/' ? (
<div className="App flex flex-col bg-primaryColor dark:bg-secondaryColor md:flex-row">
<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()}
{showScrollTop && (
<div
onClick={scrollTop}
className="fixed bottom-4 right-12 flex h-12 w-12 cursor-pointer items-center justify-center rounded-full bg-[#00A6FB] text-xl"
>
<FaArrowUpLong />
</div>
)}
{combinedData.length > 0 && (
<Pagination
currentPage={currentPage}
Expand Down
2 changes: 1 addition & 1 deletion src/ProfilesList.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,4 @@
"Om-pawarr.json",
"boytur.json",
"giuliarappo.json"
]
]