refactor: redesign projects page with full navigation functionallity

This commit is contained in:
sanjidaRimi023
2026-05-06 20:17:29 +06:00
parent 6f74ae9da8
commit 5e188baeff
3 changed files with 226 additions and 156 deletions
+3 -4
View File
@@ -1,19 +1,17 @@
import { Toaster as Sonner } from "@/components/ui/sonner"; import { Toaster as Sonner } from "@/components/ui/sonner";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip"; import { TooltipProvider } from "@/components/ui/tooltip";
import { ThemeProvider } from "@/contexts/ThemeContext"; import { ThemeProvider } from "@/contexts/ThemeContext";
import { AnimatePresence } from "framer-motion"; import { AnimatePresence } from "framer-motion";
import { BrowserRouter, Route, Routes, useLocation } from "react-router-dom"; import { BrowserRouter, Route, Routes, useLocation } from "react-router-dom";
import Footer from "./components/Footer"; import Footer from "./components/Footer";
import Navbar from "./components/Navbar"; import Navbar from "./components/Navbar";
import Blog from "./pages/Blog";
import BlogArticle from "./pages/BlogArticle";
import Index from "./pages/Index"; import Index from "./pages/Index";
import NotFound from "./pages/NotFound"; import NotFound from "./pages/NotFound";
import ProjectDetails from "./pages/ProjectDetails"; import ProjectDetails from "./pages/ProjectDetails";
import Projects from "./pages/Projects"; import Projects from "./pages/Projects";
import { QueryProvider } from "./provider/QueryProvider"; import { QueryProvider } from "./provider/QueryProvider";
import { PrivacyPolicy } from "./pages/PrivacyPolicy"; import { PrivacyPolicy } from "./pages/PrivacyPolicy";
import ScrollToTop from "./components/ScrollToTop";
function AnimatedRoutes() { function AnimatedRoutes() {
const location = useLocation(); const location = useLocation();
@@ -38,9 +36,10 @@ const App = () => (
<QueryProvider> <QueryProvider>
<ThemeProvider> <ThemeProvider>
<TooltipProvider> <TooltipProvider>
<Toaster />
<Sonner /> <Sonner />
<BrowserRouter> <BrowserRouter>
<ScrollToTop/>
<Navbar /> <Navbar />
<AnimatedRoutes /> <AnimatedRoutes />
<Footer /> <Footer />
+1 -3
View File
@@ -1,5 +1,3 @@
import Footer from "@/components/Footer";
import Navbar from "@/components/Navbar";
import PageTransition from "@/components/PageTransition"; import PageTransition from "@/components/PageTransition";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { useProjectById } from "@/hooks/queires/useProjects"; import { useProjectById } from "@/hooks/queires/useProjects";
@@ -98,7 +96,7 @@ export default function ProjectDetails() {
return ( return (
<PageTransition> <PageTransition>
<div className="min-h-screen bg-background text-foreground overflow-x-hidden selection:bg-primary/30 selection:text-primary"> <div className="min-h-screen bg-background text-foreground overflow-x-hidden selection:bg-primary/30 selection:text-primary">
<Navbar />
{/* Hero Section */} {/* Hero Section */}
<section className="pt-36 pb-20 relative overflow-hidden"> <section className="pt-36 pb-20 relative overflow-hidden">
+222 -149
View File
@@ -9,10 +9,12 @@ import {
ExternalLink, ExternalLink,
Github, Github,
Globe, Globe,
Loader2,
Search,
Smartphone, Smartphone,
Workflow, Workflow,
} from "lucide-react"; } from "lucide-react";
import { useState } from "react"; import { useMemo, useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
const categories = [ const categories = [
@@ -29,39 +31,44 @@ const containerVariants = {
visible: { visible: {
opacity: 1, opacity: 1,
transition: { transition: {
staggerChildren: 0.1, staggerChildren: 0.08,
}, },
}, },
}; };
const itemVariants = {
hidden: { opacity: 0, y: 30 },
visible: {
opacity: 1,
y: 0,
transition: { duration: 0.5, ease: "easeOut" as const },
},
};
export default function Projects() { export default function Projects() {
const { data: projectsData } = useProjects(); const { data: projectsData, isLoading, isError } = useProjects();
const projects = projectsData?.data.data.result;
const [activeCategory, setActiveCategory] = useState("all"); const [activeCategory, setActiveCategory] = useState("all");
const [searchQuery, setSearchQuery] = useState("");
const filteredProjects = const filteredProjects = useMemo(() => {
activeCategory === "all" const projects = projectsData?.data?.data?.result || [];
? projects if (!projects) return [];
: projects?.filter((project) => project.category === activeCategory); return projects.filter((project) => {
const matchesCategory =
activeCategory === "all" || project.category === activeCategory;
const matchesSearch =
searchQuery.trim() === "" ||
project.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
project.description.toLowerCase().includes(searchQuery.toLowerCase()) ||
project.technologies.some((tech: string) =>
tech.toLowerCase().includes(searchQuery.toLowerCase()),
);
return matchesCategory && matchesSearch;
});
}, [projectsData, activeCategory, searchQuery]);
return ( return (
<PageTransition> <PageTransition>
<div className="min-h-screen bg-background overflow-x-hidden"> <div className="min-h-screen bg-background overflow-x-hidden text-foreground antialiased">
{/* Hero Section */} {/* Hero Section */}
<section className="pt-32 pb-16 relative overflow-hidden"> <section className="pt-32 pb-16 relative overflow-hidden border-b border-primary/10">
<div className="absolute inset-0"> <div className="absolute inset-0 pointer-events-none select-none">
<div className="absolute top-1/4 left-1/4 w-96 h-96 bg-primary/20 rounded-full blur-3xl" /> <div className="absolute top-1/4 left-1/4 w-96 h-96 bg-primary/10 rounded-full blur-3xl" />
<div className="absolute bottom-0 right-1/4 w-64 h-64 bg-neon-purple/20 rounded-full blur-3xl" /> <div className="absolute bottom-0 right-1/4 w-64 h-64 bg-accent/20 rounded-full blur-3xl" />
</div> </div>
<div className="container mx-auto px-4 relative z-10"> <div className="container mx-auto px-4 relative z-10">
@@ -69,10 +76,10 @@ export default function Projects() {
<motion.div <motion.div
initial={{ opacity: 0, x: -20 }} initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }} animate={{ opacity: 1, x: 0 }}
transition={{ duration: 0.5 }} transition={{ duration: 0.4 }}
> >
<Link to="/"> <Link to="/">
<Button variant="ghost" className="mb-8 group"> <Button variant="ghost" className="mb-8 group h-10 px-4">
<ArrowLeft className="w-4 h-4 mr-2 transition-transform group-hover:-translate-x-1" /> <ArrowLeft className="w-4 h-4 mr-2 transition-transform group-hover:-translate-x-1" />
Back to Home Back to Home
</Button> </Button>
@@ -81,156 +88,222 @@ export default function Projects() {
{/* Header */} {/* Header */}
<motion.div <motion.div
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 15 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6 }} transition={{ duration: 0.5 }}
className="text-center mb-12" className="text-center mb-10 max-w-3xl mx-auto"
> >
<h1 className="text-5xl md:text-6xl font-bold mb-6"> <h1 className="text-4xl md:text-6xl font-extrabold tracking-tight mb-4 bg-gradient-to-r from-primary via-primary/80 to-accent bg-clip-text text-transparent">
Our{" "} Our Projects
<span className="text-primary neon-text-glow">Projects</span>
</h1> </h1>
<p className="text-muted-foreground max-w-2xl mx-auto text-lg"> <p className="text-muted-foreground text-lg md:text-xl leading-relaxed max-w-2xl mx-auto">
Explore our portfolio of innovative solutions that have Explore our portfolio of innovative solutions designed to scale
transformed businesses across industries. and transform businesses across industries.
</p> </p>
</motion.div> </motion.div>
{/* Filter Tabs */} {/* Interactive Search and Filter Section */}
<motion.div <motion.div
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 15 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, delay: 0.2 }} transition={{ duration: 0.5, delay: 0.1 }}
className="flex flex-wrap justify-center gap-3 mb-16" className="flex flex-col items-center gap-6 mb-12"
> >
{categories?.map((category) => { {/* Search Bar */}
const Icon = category.icon; <div className="relative w-full max-w-md">
return ( <Search className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground" />
<Button <input
key={category.id} type="text"
variant={ placeholder="Search projects, tech, or keywords..."
activeCategory === category.id ? "default" : "outline" value={searchQuery}
} onChange={(e) => setSearchQuery(e.target.value)}
onClick={() => setActiveCategory(category.id)} className="w-full pl-10 pr-4 py-2.5 rounded-full border border-border/50 bg-background/50 backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-primary/40 transition-all text-sm shadow-sm"
className={`rounded-full px-6 transition-all duration-300 ${ aria-label="Search projects"
activeCategory === category.id />
? "neon-glow bg-primary text-primary-foreground" </div>
: "glass border-primary/30 hover:border-primary"
}`} {/* Filter Tabs */}
> <div className="flex flex-wrap justify-center gap-2 max-w-4xl">
{Icon && <Icon className="w-4 h-4 mr-2" />} {categories.map((category) => {
{category.name} const Icon = category.icon;
</Button> const isActive = activeCategory === category.id;
);
})} return (
<Button
key={category.id}
variant={isActive ? "default" : "outline"}
onClick={() => setActiveCategory(category.id)}
aria-pressed={isActive}
className={`rounded-full px-5 py-2 text-sm font-medium transition-all duration-300 ${
isActive
? "bg-primary text-primary-foreground shadow-sm shadow-primary/20"
: "border-border/60 hover:bg-muted/50"
}`}
>
{Icon && <Icon className="w-4 h-4 mr-2" />}
{category.name}
</Button>
);
})}
</div>
</motion.div> </motion.div>
</div> </div>
</section> </section>
{/* Projects Grid */} {/* Projects Grid */}
<section className="pb-24"> <section className="py-20 bg-background/50">
<div className="container mx-auto px-4"> <div className="container mx-auto px-4">
<AnimatePresence mode="wait"> {/* Loading / Error State */}
<motion.div {isLoading && (
key={activeCategory} <div className="flex flex-col items-center justify-center py-24 gap-4 text-muted-foreground animate-pulse">
variants={containerVariants} <Loader2 className="w-8 h-8 animate-spin text-primary" />
initial="hidden" <span className="text-sm font-medium">Loading projects...</span>
animate="visible" </div>
exit="hidden" )}
className="grid md:grid-cols-2 gap-8"
>
{filteredProjects?.map((project) => (
<motion.article
key={project._id}
variants={itemVariants}
layout
className="group glass rounded-3xl overflow-hidden hover:neon-glow transition-all duration-500"
>
{/* Image */}
<div className="relative h-64 overflow-hidden">
<img
src={project.image}
alt={project.title}
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
/>
<div className="absolute inset-0 bg-gradient-to-t from-background via-background/50 to-transparent opacity-60" />
{/* Category Badge */} {isError && (
<div className="absolute top-4 left-4"> <div className="text-center py-20 text-destructive">
<span className="px-3 py-1 rounded-full bg-primary/20 text-primary text-sm font-medium backdrop-blur-sm border border-primary/30"> <p className="text-lg font-semibold mb-2">
{ Failed to load projects.
categories.find((c) => c.id === project.category) </p>
?.name <p className="text-sm text-muted-foreground">
} Please check your network connection or try again later.
</span> </p>
</div>
)}
{!isLoading && !isError && (
<AnimatePresence mode="wait">
<motion.div
key={`${activeCategory}-${searchQuery}`}
variants={containerVariants}
initial="hidden"
animate="visible"
exit="hidden"
className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"
>
{filteredProjects.map((project) => (
<motion.article
key={project._id}
layout
className="group flex flex-col justify-between bg-card/40 border border-border/50 backdrop-blur-sm rounded-3xl overflow-hidden hover:border-primary/50 transition-all duration-500 hover:shadow-xl hover:shadow-accent/5 p-4"
>
<div>
{/* Project Image */}
<div className="relative h-56 rounded-2xl overflow-hidden mb-6">
<img
src={project.image}
alt={project.title}
loading="lazy"
className="w-full h-full object-cover transition-transform duration-700 ease-out group-hover:scale-105"
/>
<div className="absolute inset-0 bg-gradient-to-t from-background/90 via-background/20 to-transparent opacity-80" />
{/* Category Badge */}
<div className="absolute top-4 left-4">
<span className="px-3 py-1 rounded-full bg-primary/20 text-primary text-xs font-semibold backdrop-blur-md border border-primary/20">
{
categories.find(
(c) => c.id === project.category,
)?.name
}
</span>
</div>
{/* Quick External Links */}
<div className="absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
{project.liveUrl && (
<a
href={project.liveUrl}
target="_blank"
rel="noopener noreferrer"
className="p-2 rounded-full bg-background/80 backdrop-blur-sm border border-border/40 hover:bg-primary/20 transition-colors"
aria-label={`View live project: ${project.title}`}
>
<ExternalLink className="w-4 h-4" />
</a>
)}
{project.githubUrl && (
<a
href={project.githubUrl}
target="_blank"
rel="noopener noreferrer"
className="p-2 rounded-full bg-background/80 backdrop-blur-sm border border-border/40 hover:bg-primary/20 transition-colors"
aria-label={`View GitHub repository for: ${project.title}`}
>
<Github className="w-4 h-4" />
</a>
)}
</div>
</div>
{/* Title & Description */}
<div className="px-2">
<div className="flex items-center gap-3 text-xs font-medium text-muted-foreground mb-3">
<span>{project.client}</span>
<span className="w-1.5 h-1.5 rounded-full bg-muted-foreground/40" />
<span>{project.year}</span>
</div>
<h3 className="text-xl font-bold tracking-tight mb-3 group-hover:text-primary transition-colors line-clamp-1">
<Link to={`/projects/${project._id}`}>
{project.title}
</Link>
</h3>
<p className="text-muted-foreground text-sm leading-relaxed mb-6 line-clamp-3">
{project.description}
</p>
</div>
</div> </div>
{/* Quick Links */} {/* Technologies and Detail Navigation */}
<div className="absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity duration-300"> <div className="px-2">
<Link <div className="flex flex-wrap gap-1.5 max-h-16 overflow-hidden mb-4">
target="_blank" {project.technologies
to={project.liveUrl} .slice(0, 5)
className="p-2 rounded-full glass hover:bg-primary/20 transition-colors" .map((tech: string) => (
aria-label="View live project" <span
> key={tech}
<ExternalLink className="w-4 h-4" /> className="px-2.5 py-0.5 rounded-md bg-primary text-primary-foreground text-xs font-semibold tracking-wide"
</Link> >
<Link {tech}
target="_blank" </span>
to={project.githubUrl} ))}
className="p-2 rounded-full glass hover:bg-primary/20 transition-colors" {project.technologies.length > 5 && (
aria-label="View on GitHub" <span className="px-2.5 py-0.5 rounded-md bg-secondary text-secondary-foreground text-xs font-semibold tracking-wide">
> +{project.technologies.length - 5}
<Github className="w-4 h-4" /> </span>
</Link> )}
</div>
<div className="flex justify-end pt-2 border-t border-border/30">
<Link to={`/projects/${project._id}`}>
<Button
variant="link"
size="sm"
className="text-xs text-primary p-0 h-auto font-semibold group/btn"
>
View Details
</Button>
</Link>
</div>
</div> </div>
</div> </motion.article>
))}
{/* Content */} </motion.div>
<div className="p-8"> </AnimatePresence>
{/* Meta */} )}
<div className="flex items-center gap-4 text-sm text-muted-foreground mb-4">
<span>{project.client}</span>
<span className="w-1 h-1 rounded-full bg-muted-foreground" />
<span>{project.year}</span>
</div>
{/* Title */}
<h3 className="text-2xl font-bold mb-4 group-hover:text-primary transition-colors">
{project.title}
</h3>
{/* Description */}
<p className="text-muted-foreground mb-6 leading-relaxed">
{project.description}
</p>
{/* Technologies */}
<div className="flex flex-wrap gap-2">
{project?.technologies.map((tech) => (
<span
key={tech}
className="px-3 py-1 rounded-full bg-muted text-muted-foreground text-xs font-medium"
>
{tech}
</span>
))}
</div>
</div>
</motion.article>
))}
</motion.div>
</AnimatePresence>
{/* Empty State */} {/* Empty State */}
{filteredProjects?.length === 0 && ( {!isLoading && !isError && filteredProjects.length === 0 && (
<motion.div <motion.div
initial={{ opacity: 0 }} initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1 }} animate={{ opacity: 1, y: 0 }}
className="text-center py-20" className="text-center py-20"
> >
<p className="text-muted-foreground text-lg"> <p className="text-muted-foreground text-lg">
No projects found in this category. No projects match your current search or category.
</p> </p>
</motion.div> </motion.div>
)} )}