|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import Container from "@/components/Common/Container/Container"; |
| 4 | +import SectionHero from "@/components/Common/SectionHero/SectionHero"; |
| 5 | +import SpacingDivider from "@/components/Common/SpacingDivider/SpacingDivider"; |
| 6 | +import { BookOpen, Bookmark, LibraryBig, NotebookPen } from "lucide-react"; |
| 7 | +import { useTranslations } from "next-intl"; |
| 8 | + |
| 9 | +type BookItem = { |
| 10 | + _id: string; |
| 11 | + title: string; |
| 12 | + authorName: string; |
| 13 | + authorEmail?: string; |
| 14 | + authorLink?: string; |
| 15 | + image?: string; |
| 16 | + link: string; |
| 17 | +}; |
| 18 | + |
| 19 | +type BooksPageClientProps = { |
| 20 | + books: BookItem[]; |
| 21 | +}; |
| 22 | + |
| 23 | +const BooksPageClient = ({ books }: BooksPageClientProps) => { |
| 24 | + const t = useTranslations("booksHero"); |
| 25 | + |
| 26 | + return ( |
| 27 | + <Container> |
| 28 | + <section className="py-16"> |
| 29 | + <SectionHero |
| 30 | + label={t("label")} |
| 31 | + title={t("title")} |
| 32 | + subtitle={t("subtitle")} |
| 33 | + labelIcon={NotebookPen} |
| 34 | + labelIconClassName="text-prism-violet" |
| 35 | + labelChipBackground="linear-gradient(135deg, #a78bfa12, #22d3ee08)" |
| 36 | + labelChipBorder="1px solid rgba(167,139,250,0.15)" |
| 37 | + shimmerBackground="linear-gradient(90deg, transparent 0%, rgba(167,139,250,0.1) 50%, transparent 100%)" |
| 38 | + myanmarTitleColorClass="text-prism-violet" |
| 39 | + floatingIcons={[ |
| 40 | + { |
| 41 | + Icon: BookOpen, |
| 42 | + className: "text-prism-violet/40", |
| 43 | + style: { top: "8%", right: "6%" }, |
| 44 | + delay: 0.25, |
| 45 | + sizeClass: "h-4 w-4", |
| 46 | + }, |
| 47 | + { |
| 48 | + Icon: LibraryBig, |
| 49 | + className: "text-prism-cyan/40", |
| 50 | + style: { top: "65%", right: "14%" }, |
| 51 | + delay: 0.35, |
| 52 | + sizeClass: "h-3.5 w-3.5", |
| 53 | + }, |
| 54 | + { |
| 55 | + Icon: Bookmark, |
| 56 | + className: "text-prism-rose/35", |
| 57 | + style: { top: "80%", left: "3%" }, |
| 58 | + delay: 0.45, |
| 59 | + sizeClass: "h-3.5 w-3.5", |
| 60 | + }, |
| 61 | + ]} |
| 62 | + /> |
| 63 | + |
| 64 | + {books.length === 0 ? ( |
| 65 | + <div className="mt-12 rounded-3xl border border-white/10 bg-surface/50 p-8 text-zinc-300"> |
| 66 | + <h2 className="font-display text-2xl font-semibold text-zinc-100"> |
| 67 | + No books yet |
| 68 | + </h2> |
| 69 | + <p className="mt-3 max-w-2xl text-sm leading-6 text-zinc-400"> |
| 70 | + Community recommendations will appear here once contributors add |
| 71 | + book entries to the repository. |
| 72 | + </p> |
| 73 | + </div> |
| 74 | + ) : ( |
| 75 | + <div className="mt-12 grid gap-4"> |
| 76 | + {books.map((book) => ( |
| 77 | + <article |
| 78 | + key={book._id} |
| 79 | + className="rounded-3xl border border-white/10 bg-surface/50 p-6 transition-colors hover:border-white/20" |
| 80 | + > |
| 81 | + <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"> |
| 82 | + <div className="flex flex-col gap-4 sm:flex-row sm:items-start"> |
| 83 | + {book.image && ( |
| 84 | + <img |
| 85 | + src={book.image} |
| 86 | + alt={`${book.title} cover`} |
| 87 | + className="h-32 w-24 rounded-xl border border-white/10 object-cover" |
| 88 | + /> |
| 89 | + )} |
| 90 | + |
| 91 | + <div> |
| 92 | + <h2 className="font-display text-2xl font-semibold text-zinc-100"> |
| 93 | + {book.title} |
| 94 | + </h2> |
| 95 | + <p className="mt-2 text-sm text-zinc-400"> |
| 96 | + by {book.authorName} |
| 97 | + </p> |
| 98 | + {(book.authorEmail || book.authorLink) && ( |
| 99 | + <div className="mt-3 flex flex-col gap-2 text-sm"> |
| 100 | + {book.authorEmail && ( |
| 101 | + <a |
| 102 | + href={`mailto:${book.authorEmail}`} |
| 103 | + className="text-zinc-400 transition-colors hover:text-prism-cyan" |
| 104 | + > |
| 105 | + {book.authorEmail} |
| 106 | + </a> |
| 107 | + )} |
| 108 | + {book.authorLink && ( |
| 109 | + <a |
| 110 | + href={book.authorLink} |
| 111 | + target="_blank" |
| 112 | + rel="noopener noreferrer" |
| 113 | + className="text-zinc-400 transition-colors hover:text-prism-cyan" |
| 114 | + > |
| 115 | + {book.authorLink} |
| 116 | + </a> |
| 117 | + )} |
| 118 | + </div> |
| 119 | + )} |
| 120 | + </div> |
| 121 | + </div> |
| 122 | + |
| 123 | + <a |
| 124 | + href={book.link} |
| 125 | + target="_blank" |
| 126 | + rel="noopener noreferrer" |
| 127 | + className="inline-flex items-center justify-center rounded-full border border-prism-cyan/40 px-4 py-2 text-sm font-medium text-prism-cyan transition-colors hover:border-prism-cyan hover:bg-prism-cyan/10" |
| 128 | + > |
| 129 | + Open Resource |
| 130 | + </a> |
| 131 | + </div> |
| 132 | + </article> |
| 133 | + ))} |
| 134 | + </div> |
| 135 | + )} |
| 136 | + </section> |
| 137 | + |
| 138 | + <SpacingDivider size="lg" /> |
| 139 | + </Container> |
| 140 | + ); |
| 141 | +}; |
| 142 | + |
| 143 | +export default BooksPageClient; |
0 commit comments