|
1 | 1 | <script lang="ts"> |
2 | | - import { Calendar, ChevronRight } from 'lucide-svelte'; |
3 | | - import Button from '$lib/components/ui/button/button.svelte'; |
4 | | - import { |
5 | | - Pagination, |
6 | | - PaginationContent, |
7 | | - PaginationItem, |
8 | | - PaginationLink, |
9 | | - PaginationNextButton as PaginationNext, |
10 | | - PaginationPrevButton as PaginationPrevious, |
11 | | - PaginationEllipsis |
12 | | - } from '$lib/components/ui/pagination'; |
| 2 | + import * as Pagination from '$lib/components/ui/pagination'; |
| 3 | + import { goto } from '$app/navigation'; |
| 4 | + import { page } from '$app/stores'; |
13 | 5 |
|
14 | 6 | let { data } = $props(); |
15 | 7 |
|
|
34 | 26 | return new Date(b).getTime() - new Date(a).getTime(); |
35 | 27 | }) |
36 | 28 | ); |
| 29 | +
|
| 30 | + function handlePageChange(newPage: number) { |
| 31 | + const url = new URL($page.url); |
| 32 | + url.searchParams.set('page', newPage.toString()); |
| 33 | + goto(url.toString()); |
| 34 | + } |
37 | 35 | </script> |
38 | 36 |
|
39 | 37 | <div class="mx-auto w-full max-w-4xl"> |
40 | 38 | <!-- Header Section --> |
41 | | - <div class="grain-effect mb-6"> |
42 | | - <div class="space-y-3 py-6"> |
43 | | - <h1 |
44 | | - class="font-gothic flex items-center gap-3 text-4xl font-bold tracking-tight text-black md:text-5xl" |
45 | | - > |
46 | | - <Calendar class="h-8 w-8 md:h-10 md:w-10" /> |
47 | | - Certification Log |
48 | | - </h1> |
49 | | - <p class="font-atkinson text-base leading-relaxed text-gray-700 md:text-lg"> |
50 | | - Complete chronological history of CBFC certifications |
51 | | - </p> |
52 | | - </div> |
| 39 | + <div class="mb-6"> |
| 40 | + <h1 class="font-gothic text-sepia-brown mb-3 text-6xl font-bold tracking-tight"> |
| 41 | + Archival Log |
| 42 | + </h1> |
| 43 | + <p class="text-sepia-brown/70 text-lg font-medium">Changelog of movies added to the database</p> |
53 | 44 | </div> |
54 | 45 |
|
55 | 46 | {#if data.error} |
|
61 | 52 | <p class="font-atkinson text-sepia-brown">No records found.</p> |
62 | 53 | </div> |
63 | 54 | {:else} |
64 | | - <div class="space-y-8"> |
| 55 | + <div class="space-y-10"> |
65 | 56 | {#each sortedGroupKeys as month} |
66 | 57 | <section> |
67 | | - <!-- Simple month heading --> |
68 | | - <h2 class="font-gothic mb-3 text-2xl font-medium tracking-tight text-black"> |
| 58 | + <!-- Month heading with better visual hierarchy --> |
| 59 | + <h2 |
| 60 | + class="font-gothic border-sepia-dark/80 text-sepia-brown mb-4 border-b pb-2 text-4xl font-semibold tracking-tight" |
| 61 | + > |
69 | 62 | {month} |
70 | 63 | </h2> |
71 | 64 |
|
72 | | - <!-- Simple list of films --> |
73 | | - <ul class="space-y-2 pl-4"> |
| 65 | + <!-- Film list with improved spacing and hierarchy --> |
| 66 | + <ul class="space-y-5"> |
74 | 67 | {#each groupedFilms[month] as film} |
75 | | - <li class="font-atkinson text-sm leading-relaxed"> |
76 | | - <a |
77 | | - href="/film/{film.slug}" |
78 | | - class="text-sepia-brown inline transition-colors hover:text-black" |
79 | | - > |
80 | | - <span class="font-medium">{film.name}</span> |
81 | | - <span class="text-gray-500"> ({film.year})</span> |
| 68 | + <li class="transition-colors"> |
| 69 | + <a href="/film/{film.slug}" class="group block transition-colors"> |
| 70 | + <div class="flex flex-wrap items-baseline gap-x-2 gap-y-1"> |
| 71 | + <span |
| 72 | + class="font-atkinson text-sepia-brown group-hover:text-sepia-dark text-base font-semibold transition-colors" |
| 73 | + > |
| 74 | + {film.name} |
| 75 | + </span> |
| 76 | + <span class="font-atkinson text-sm text-gray-500">({film.year})</span> |
| 77 | + </div> |
| 78 | + <div |
| 79 | + class="font-atkinson mt-1 flex flex-wrap items-center gap-x-3 text-xs text-gray-600" |
| 80 | + > |
| 81 | + <span class="font-medium">{film.language}</span> |
| 82 | + {#if film.cert_date} |
| 83 | + <span class="flex items-center gap-1"> |
| 84 | + <span class="text-gray-400">• </span> |
| 85 | + <span class="text-gray-500"> |
| 86 | + {new Date(film.cert_date).toLocaleDateString('en-US', { |
| 87 | + month: 'short', |
| 88 | + day: 'numeric', |
| 89 | + year: 'numeric' |
| 90 | + })} |
| 91 | + </span> |
| 92 | + </span> |
| 93 | + {/if} |
| 94 | + </div> |
82 | 95 | </a> |
83 | | - <span class="text-gray-500"> · </span> |
84 | | - <span class="text-gray-600">{film.language}</span> |
85 | | - {#if film.rating} |
86 | | - <span class="text-gray-500"> · </span> |
87 | | - <span class="text-gray-600">{film.rating}</span> |
88 | | - {/if} |
89 | 96 | </li> |
90 | 97 | {/each} |
91 | 98 | </ul> |
|
94 | 101 | </div> |
95 | 102 |
|
96 | 103 | <!-- Pagination --> |
97 | | - {#if data.page > 1 || data.hasNext} |
98 | | - <div class="border-sepia-dark mt-8 flex items-center justify-between border-t pt-6"> |
99 | | - {#if data.page > 1} |
100 | | - <Button href="/changelog?page={data.page - 1}" variant="secondary" size="sm"> |
101 | | - ← Previous |
102 | | - </Button> |
103 | | - {:else} |
104 | | - <div></div> |
105 | | - {/if} |
| 104 | + {#if data.pagination && data.pagination.totalPages > 1} |
| 105 | + <div class="mt-8 flex justify-center"> |
| 106 | + <Pagination.Root |
| 107 | + count={data.totalCount} |
| 108 | + perPage={data.pagination.perPage} |
| 109 | + page={data.pagination.currentPage} |
| 110 | + onPageChange={handlePageChange} |
| 111 | + > |
| 112 | + <Pagination.Content> |
| 113 | + <Pagination.Item> |
| 114 | + <Pagination.PrevButton size="compact" variant="secondary" /> |
| 115 | + </Pagination.Item> |
106 | 116 |
|
107 | | - <span class="font-atkinson text-sepia-brown text-sm font-medium">Page {data.page}</span> |
| 117 | + {#each Array.from({ length: data.pagination.totalPages }, (_, i) => i + 1) as pageNum} |
| 118 | + {#if pageNum === 1 || pageNum === data.pagination.totalPages || (pageNum >= data.pagination.currentPage - 2 && pageNum <= data.pagination.currentPage + 2)} |
| 119 | + <Pagination.Item> |
| 120 | + <Pagination.Link |
| 121 | + page={{ value: pageNum, type: 'page' }} |
| 122 | + isActive={pageNum === data.pagination.currentPage} |
| 123 | + inactiveVariant="secondary" |
| 124 | + > |
| 125 | + {pageNum} |
| 126 | + </Pagination.Link> |
| 127 | + </Pagination.Item> |
| 128 | + {:else if (pageNum === data.pagination.currentPage - 3 && data.pagination.currentPage > 4) || (pageNum === data.pagination.currentPage + 3 && data.pagination.currentPage < data.pagination.totalPages - 3)} |
| 129 | + <Pagination.Item> |
| 130 | + <Pagination.Ellipsis /> |
| 131 | + </Pagination.Item> |
| 132 | + {/if} |
| 133 | + {/each} |
108 | 134 |
|
109 | | - {#if data.hasNext} |
110 | | - <Button href="/changelog?page={data.page + 1}" variant="secondary" size="sm"> |
111 | | - Next → |
112 | | - </Button> |
113 | | - {:else} |
114 | | - <div></div> |
115 | | - {/if} |
| 135 | + <Pagination.Item> |
| 136 | + <Pagination.NextButton size="compact" variant="secondary" /> |
| 137 | + </Pagination.Item> |
| 138 | + </Pagination.Content> |
| 139 | + </Pagination.Root> |
116 | 140 | </div> |
117 | 141 | {/if} |
118 | 142 | {/if} |
|
0 commit comments