From 5ad829032d9e4197d07d6ed373d9ad10f0a96eb0 Mon Sep 17 00:00:00 2001 From: Suhaibinator <42899065+Suhaibinator@users.noreply.github.com> Date: Fri, 16 May 2025 18:32:24 -0700 Subject: [PATCH 1/3] feat: add sidebar and category tabs --- .../[bookId]/[hadithId]/page.tsx | 4 +- .../[collectionId]/[bookId]/page.tsx | 2 + .../app/collections/[collectionId]/page.tsx | 4 +- fe/src/app/collections/layout.tsx | 44 +++++++++ fe/src/app/collections/page.tsx | 2 + fe/src/components/category-tabs.tsx | 32 +++++++ fe/src/components/hadith-sidebar.tsx | 90 +++++++++++++++++++ 7 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 fe/src/app/collections/layout.tsx create mode 100644 fe/src/components/category-tabs.tsx create mode 100644 fe/src/components/hadith-sidebar.tsx diff --git a/fe/src/app/collections/[collectionId]/[bookId]/[hadithId]/page.tsx b/fe/src/app/collections/[collectionId]/[bookId]/[hadithId]/page.tsx index cd06b7e..f9fe6d5 100644 --- a/fe/src/app/collections/[collectionId]/[bookId]/[hadithId]/page.tsx +++ b/fe/src/app/collections/[collectionId]/[bookId]/[hadithId]/page.tsx @@ -13,6 +13,7 @@ import { apiDetailedHadithToHadith, } from "fe/types"; import { HadithCard } from "fe/components/hadith-card"; +import { CategoryTabs } from "fe/components/category-tabs"; import { StructuredData } from "fe/components/structured-data"; import { generateHadithStructuredData, generateBreadcrumbStructuredData } from "fe/lib/seo-utils"; @@ -159,7 +160,8 @@ const HadithPage = async (props: HadithPageProps) => {
{/* JSON-LD structured data */} - + + {/* Breadcrumb structured data */} {/* JSON-LD structured data */} + {/* Breadcrumb structured data */} {/* JSON-LD structured data */} - + + {/* Breadcrumb structured data */} apiSimpleBookToBook(b, params.collectionId!)) || [] + } + + return ( + + {children} + + ) +} diff --git a/fe/src/app/collections/page.tsx b/fe/src/app/collections/page.tsx index e223fc3..b2037d1 100644 --- a/fe/src/app/collections/page.tsx +++ b/fe/src/app/collections/page.tsx @@ -4,6 +4,7 @@ import { CollectionWithoutBooks } from "fe/proto/business_models"; // Import the import { Collection } from "fe/types"; // Import the frontend type import { CollectionCard } from "fe/components/collection-card"; import { SearchBar } from "fe/components/search-bar"; +import { CategoryTabs } from "fe/components/category-tabs"; import { StructuredData } from "fe/components/structured-data"; import { generateCollectionsStructuredData } from "fe/lib/seo-utils"; @@ -59,6 +60,7 @@ export default async function CollectionsPage() {
{/* JSON-LD structured data */} +

Hadith Collections

diff --git a/fe/src/components/category-tabs.tsx b/fe/src/components/category-tabs.tsx new file mode 100644 index 0000000..6bffc5b --- /dev/null +++ b/fe/src/components/category-tabs.tsx @@ -0,0 +1,32 @@ +'use client' + +import Link from 'next/link' +import { Tabs, TabsList, TabsTrigger } from 'fe/components/ui/tabs' + +interface CategoryTabsProps { + active: 'collections' | 'books' | 'hadiths' + collectionId?: string + bookId?: string +} + +export function CategoryTabs({ active, collectionId, bookId }: CategoryTabsProps) { + return ( + + + + Collections + + {collectionId && ( + + Books + + )} + {bookId && ( + + Hadiths + + )} + + + ) +} diff --git a/fe/src/components/hadith-sidebar.tsx b/fe/src/components/hadith-sidebar.tsx new file mode 100644 index 0000000..5259b1f --- /dev/null +++ b/fe/src/components/hadith-sidebar.tsx @@ -0,0 +1,90 @@ +'use client' + +import Link from 'next/link' +import { + SidebarProvider, + Sidebar, + SidebarContent, + SidebarGroup, + SidebarGroupLabel, + SidebarMenu, + SidebarMenuItem, + SidebarMenuButton, + SidebarInset +} from 'fe/components/ui/sidebar' + +interface SidebarCollection { id: string; name: string } +interface SidebarBook { id: string; name: string } +interface SidebarHadith { id: string; number: number } + +interface HadithSidebarProps { + collections: SidebarCollection[] + books?: SidebarBook[] + hadiths?: SidebarHadith[] + activeCollectionId?: string + activeBookId?: string + activeHadithId?: string + children?: React.ReactNode +} + +export function HadithSidebar({ + collections, + books = [], + hadiths = [], + activeCollectionId, + activeBookId, + activeHadithId, + children +}: HadithSidebarProps) { + return ( + +

+ + + + Collections + + {collections.map(c => ( + + + {c.name} + + + ))} + + + {books.length > 0 && ( + + Books + + {books.map(b => ( + + + {b.name} + + + ))} + + + )} + {hadiths.length > 0 && ( + + Hadiths + + {hadiths.map(h => ( + + + Hadith {h.number} + + + ))} + + + )} + + + {children} +
+ + ) +} From 52e04bd02a69962759aa5107a0771cc91e7345c9 Mon Sep 17 00:00:00 2001 From: suhaibinator Date: Sat, 24 May 2025 03:18:11 -0400 Subject: [PATCH 2/3] Some fixes --- fe/src/components/hadith-sidebar.tsx | 36 ++++++++++++++++++++-------- fe/src/components/ui/sidebar.tsx | 4 ++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/fe/src/components/hadith-sidebar.tsx b/fe/src/components/hadith-sidebar.tsx index 5259b1f..2702a0a 100644 --- a/fe/src/components/hadith-sidebar.tsx +++ b/fe/src/components/hadith-sidebar.tsx @@ -1,6 +1,7 @@ 'use client' -import Link from 'next/link' +import Link from 'next/link'; +import { FileText } from 'lucide-react'; // Import an icon import { SidebarProvider, Sidebar, @@ -10,7 +11,8 @@ import { SidebarMenu, SidebarMenuItem, SidebarMenuButton, - SidebarInset + SidebarInset, + SidebarTrigger } from 'fe/components/ui/sidebar' interface SidebarCollection { id: string; name: string } @@ -39,15 +41,18 @@ export function HadithSidebar({ return (
- + Collections {collections.map(c => ( - - {c.name} + + + + {c.name} + ))} @@ -59,8 +64,11 @@ export function HadithSidebar({ {books.map(b => ( - - {b.name} + + + + {b.name} + ))} @@ -73,8 +81,11 @@ export function HadithSidebar({ {hadiths.map(h => ( - - Hadith {h.number} + + + + Hadith {h.number} + ))} @@ -83,7 +94,12 @@ export function HadithSidebar({ )} - {children} + +
{/* Added padding for the trigger */} + +
+ {children} +
) diff --git a/fe/src/components/ui/sidebar.tsx b/fe/src/components/ui/sidebar.tsx index 8c1d9c4..e8c91f3 100644 --- a/fe/src/components/ui/sidebar.tsx +++ b/fe/src/components/ui/sidebar.tsx @@ -251,7 +251,7 @@ function Sidebar({ />