Skip to content

Commit

Permalink
Refactor: Retain filter #1024 (#1026)
Browse files Browse the repository at this point in the history
* Refactor to change the Router

* Fix Theme change bug

* Show Splash Screen

* refactor: retain filter

* Update src/components/ProjectList.jsx

Co-authored-by: Priyankar Pal  <[email protected]>
Signed-off-by: Kailash Choudhary <[email protected]>

* Update ProjectList.jsx

---------

Signed-off-by: Kailash Choudhary <[email protected]>
Co-authored-by: Priyankar Pal <[email protected]>
  • Loading branch information
kailashchoudhary11 and priyankarpal authored May 31, 2023
1 parent 3e41f74 commit 71f90f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/ProjectCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useContext } from 'react';
import { ThemeContext } from '../context/Theme';
import { Link } from 'react-router-dom';

const ProjectCard = ({ github_username, listOfProjects }) => {
const ProjectCard = ({ github_username, listOfProjects, filter }) => {
const { theme } = useContext(ThemeContext);

return (
Expand Down Expand Up @@ -46,6 +46,7 @@ const ProjectCard = ({ github_username, listOfProjects }) => {
<Link
to={`/projects/${github_username.toLowerCase()}`}
className="w-full px-4 items-center group flex gap-2 justify-center text-center text-white from-indigo-500 via-purple-500 to-pink-500 bg-gradient-to-r xl:text-[1rem] md:text-[0.8rem] rounded-md py-[0.35rem]"
state={{ filter: filter }}
>
More
<span className="group-hover:translate-x-1 duration-300 block" aria-hidden="true">
Expand Down
8 changes: 5 additions & 3 deletions src/components/ProjectList.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { useContext } from 'react';
import { useParams } from 'react-router-dom';
import { useParams, useLocation } from 'react-router-dom';
import { ThemeContext } from '../context/Theme';
import projects from '../DB/projects.json';
import { FaGithub, FaTwitter, FaLinkedinIn, FaInstagram, FaYoutube } from 'react-icons/fa';
Expand All @@ -10,6 +10,8 @@ import { Link } from 'react-router-dom';
const ProjectList = () => {
const { theme } = useContext(ThemeContext);
const { username } = useParams();
const data = useLocation();
const filter = data.state.filter;

const [userObj, setObject] = useState({});

Expand Down Expand Up @@ -40,8 +42,8 @@ const ProjectList = () => {
{/* Beack to projects link */}
<div className="m-4 hover:text-purple-500 transition-all duration-300 ease-in-out">
<span>{'<'}</span>
<Link to="/projects" className="font-mono ml-2">
Back to Projects
<Link to={`/projects${filter?`?filter=${filter}`:''}`} className="ml-2">{`Back to ${filter?filter.charAt(0).toUpperCase()+filter.slice(1):'All'} Projects`}

</Link>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/pages/ProjectsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const ProjectsPage = () => {
listOfProjects={item['Projects']}
socaialMedia={item['Social_media']}
key={i}
filter={currentFilter}
/>
))
) : (
Expand Down

1 comment on commit 71f90f6

@vercel
Copy link

@vercel vercel bot commented on 71f90f6 May 31, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

projectshut – ./

projectshut-priyankarpal.vercel.app
projectshut.vercel.app
projectshut-git-main-priyankarpal.vercel.app

Please sign in to comment.