From 13d72748dd199e3974e0779843d57c3021f5ae97 Mon Sep 17 00:00:00 2001 From: Farhan <144435177+toufiqfarhan0@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:52:39 +0530 Subject: [PATCH] added all button and minor UX changes --- apps/web/components/Blog.tsx | 4 +-- apps/web/components/BlogAppbar.tsx | 8 +++--- apps/web/components/CustomPagination.tsx | 33 +++++++++++++++++++----- apps/web/components/TrackTools.tsx | 13 +++++----- apps/web/components/Tracks.tsx | 26 ++++++++++++++++--- 5 files changed, 61 insertions(+), 23 deletions(-) diff --git a/apps/web/components/Blog.tsx b/apps/web/components/Blog.tsx index c652923f..f94b98c8 100644 --- a/apps/web/components/Blog.tsx +++ b/apps/web/components/Blog.tsx @@ -40,7 +40,7 @@ export const Blog = ({ {showAppBar && } {showPagination && ( -
+
)} @@ -51,7 +51,7 @@ export const Blog = ({
-
+
diff --git a/apps/web/components/BlogAppbar.tsx b/apps/web/components/BlogAppbar.tsx index defaa0d2..899f34ef 100644 --- a/apps/web/components/BlogAppbar.tsx +++ b/apps/web/components/BlogAppbar.tsx @@ -17,7 +17,6 @@ import { Button, Card, CardContent, Separator } from "@repo/ui"; import { ModeToggle } from "./ModeToggle"; import UserAccountDropDown from "./UserAccountDropDown"; -import CustomPagination from "./CustomPagination"; export const BlogAppbar = ({ track, @@ -119,7 +118,7 @@ export const BlogAppbar = ({ const renderUIModeToggleButton = () => ( ); @@ -140,17 +139,16 @@ export const BlogAppbar = ({ {track.title} ({problemIndex + 1} / {track.problems.length})

- diff --git a/apps/web/components/CustomPagination.tsx b/apps/web/components/CustomPagination.tsx index 88bbde35..382143bd 100644 --- a/apps/web/components/CustomPagination.tsx +++ b/apps/web/components/CustomPagination.tsx @@ -2,7 +2,8 @@ import { Track, Problem } from "@prisma/client"; import { PageToggle } from "./PageToggle"; import Link from "next/link"; import { Button } from "@repo/ui"; -import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons"; +import { ArrowUp, ChevronLeft, ChevronRight, HomeIcon } from "lucide-react"; +import { motion } from "framer-motion"; const CustomPagination = ({ isAtHeader = false, @@ -14,8 +15,18 @@ const CustomPagination = ({ problemIndex: number; track: Track & { problems: Problem[] }; }) => { + const scrollToTop = () => { + window.scrollTo({ top: 0, behavior: "smooth" }); + }; + return ( -
+
+ + + @@ -55,23 +68,29 @@ const CustomPagination = ({ +
); }; diff --git a/apps/web/components/TrackTools.tsx b/apps/web/components/TrackTools.tsx index 078271bb..b532c039 100644 --- a/apps/web/components/TrackTools.tsx +++ b/apps/web/components/TrackTools.tsx @@ -2,7 +2,7 @@ import { Track, Problem } from "@prisma/client"; import { PageToggle } from "./PageToggle"; import Link from "next/link"; import { Button } from "@repo/ui"; -import { ArrowUp, ChevronLeft, ChevronRight } from "lucide-react"; +import { ArrowUp, ChevronLeft, ChevronRight, HomeIcon } from "lucide-react"; import { motion } from "framer-motion"; const TrackTools = ({ @@ -25,9 +25,10 @@ const TrackTools = ({ className="flex w-full items-center justify-between gap-2 p-6" >
- + @@ -42,7 +43,7 @@ const TrackTools = ({ size={"lg"} > - Prev + Prev - Next + Next {/* To Top */}
diff --git a/apps/web/components/Tracks.tsx b/apps/web/components/Tracks.tsx index 3eebb117..1d834031 100644 --- a/apps/web/components/Tracks.tsx +++ b/apps/web/components/Tracks.tsx @@ -61,7 +61,9 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => { const filterTracks = () => { setLoading(true); - let newFilteredTracks = tracks; + let newFilteredTracks = [...tracks].sort( + (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() + ); if (selectedCohort) { newFilteredTracks = newFilteredTracks.filter((t) => t.cohort === selectedCohort); } @@ -95,6 +97,15 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => { setSelectedCohort((prevCohort) => (prevCohort === cohort ? null : cohort)); }; + const handleAllTracks = () => { + setLoading(true); + setFilteredTracks(tracks); + setSelectedCategory(""); + setSelectedCohort(null); + setCurrentPage(1); + setLoading(false); + }; + useEffect(() => { filterTracks(); }, [selectedCategory, selectedCohort, tracks]); @@ -131,8 +142,17 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => { className="flex max-w-5xl flex-col gap-4 w-full mx-auto p-4" id="tracks" > -
+
+ +
-
+
{/* Filter by Categories */}