📱 phone-sized tables, toolbars and AI pages
Browse files at this commitee4b86b0450cc95f4b9b4f73a6da53ca45b70f2cParent: ba7ff56- feat
- 📱 phone-sized tables, toolbars and AI pages
39 changed files +536 -259
- src/components/ai/note-studio-panel.tsx +24 -4
- src/components/ai/studio-output-library.test.tsx +21 -0
- src/components/ai/studio-output-library.tsx +32 -2
- src/components/courses/course-notes-panel.tsx +8 -5
- src/components/exams/bank-question-picker.tsx +10 -7
- src/components/layout/celebi-thread-list.tsx +2 -2
- src/components/notes/note-files-panel.tsx +2 -2
- src/components/notes/podcast-history.tsx +9 -6
- src/components/notes/podcast-panel.tsx +1 -1
- src/components/notes/rag-outputs-panel.tsx +6 -4
- src/components/rag/rag-composer.tsx +2 -1
- src/components/rag/rag-copy.ts +4 -0
- src/components/rag/rag-study-panel.tsx +89 -8
- src/components/rag/rag-thread-list.tsx +2 -2
- src/components/ui/coming-soon.tsx +3 -1
- src/components/ui/data-table-search.tsx +3 -1
- src/components/ui/data-table.test.tsx +27 -4
- src/components/ui/data-table.tsx +57 -42
- src/components/ui/data-toolbar.tsx +20 -14
- src/components/ui/pagination-controls.tsx +0 -40
- src/components/ui/table-pagination.tsx +58 -35
- src/components/ui/table-row-actions.tsx +3 -1
- src/components/users/profile-memberships.tsx +7 -7
- src/i18n/locales/en.ts +2 -2
- src/i18n/locales/tr.ts +2 -2
- src/i18n/messages.ts +2 -2
- src/lib/create-page-size.test.ts +15 -0
- src/lib/create-page-size.ts +25 -0
- src/pages/classes-page.tsx +2 -2
- src/pages/courses-page.tsx +7 -5
- src/pages/exam-detail-page.tsx +22 -10
- src/pages/meals-page.tsx +9 -6
- src/pages/messages-page.tsx +4 -4
- src/pages/notes-page.tsx +12 -9
- src/pages/payments-page.tsx +6 -3
- src/pages/question-bank-page.tsx +9 -5
- src/pages/staff-work-page.tsx +7 -4
- src/pages/students-roster-page.tsx +13 -9
- src/pages/whiteboards-page.tsx +9 -7
src/components/ai/note-studio-panel.tsxmodified+24 -4
| @@ -7,13 +7,16 @@ import { formatApiError, type CourseNote } from "@/api/client"; | ||
| 7 | 7 | import { PodcastPanel } from "@/components/notes/podcast-panel"; |
| 8 | 8 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; |
| 9 | 9 | import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; |
| 10 | +import { Button } from "@/components/ui/button"; | |
| 10 | 11 | import { EmptyState } from "@/components/ui/empty-state"; |
| 11 | 12 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 13 | +import { IconChevronLeft } from "@/components/ui/icons"; | |
| 12 | 14 | import { Label } from "@/components/ui/label"; |
| 13 | 15 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 14 | 16 | import { SearchableSelect } from "@/components/ui/searchable-select"; |
| 15 | 17 | import { useAuth } from "@/stores/auth-context"; |
| 16 | 18 | import { useT } from "@/stores/preferences-context"; |
| 19 | +import { cn } from "@/lib/cn"; | |
| 17 | 20 | import { courseNoteFiles } from "@/lib/note-source"; |
| 18 | 21 | import { hasMinRole } from "@/lib/roles"; |
| 19 | 22 | |
| @@ -74,7 +77,9 @@ export function NoteStudioPanel() { | ||
| 74 | 77 | everything produced so far. Flat hairline cards, no banner and no |
| 75 | 78 | shadow stack — the work is the content, not the chrome. */} |
| 76 | 79 | <div class="w-full space-y-8"> |
| 77 | - <header class="space-y-1.5"> | |
| 80 | + {/* On a phone an open note needs the screen more than the page | |
| 81 | + title does; the picker below still says where you are. */} | |
| 82 | + <header class={cn("space-y-1.5", selected() && "max-sm:hidden")}> | |
| 78 | 83 | <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("aiHub.tab.studio")}</h1> |
| 79 | 84 | <p class="text-sm text-muted-foreground">{t("aiStudio.heading")}</p> |
| 80 | 85 | </header> |
| @@ -102,9 +107,24 @@ export function NoteStudioPanel() { | ||
| 102 | 107 | > |
| 103 | 108 | {(note) => ( |
| 104 | 109 | <section ref={outputsSection} class="scroll-mt-20 space-y-4"> |
| 105 | - <div class="flex flex-wrap items-baseline justify-between gap-2"> | |
| 106 | - <h2 class="min-w-0 truncate text-base font-semibold text-text-strong">{note().title}</h2> | |
| 107 | - <span class="shrink-0 text-xs text-muted-foreground">{note().courseTitle}</span> | |
| 110 | + {/* The library steps aside while a note is open; this is the | |
| 111 | + way back to it without emptying the picker by hand. */} | |
| 112 | + <div class="flex items-center gap-3"> | |
| 113 | + <Button | |
| 114 | + type="button" | |
| 115 | + variant="outline" | |
| 116 | + size="sm" | |
| 117 | + class="h-8 shrink-0 gap-1 rounded-lg max-sm:h-10 max-sm:w-10 max-sm:px-0" | |
| 118 | + aria-label={t("aiStudio.backToLibrary")} | |
| 119 | + onClick={() => setSelectedId("")} | |
| 120 | + > | |
| 121 | + <IconChevronLeft class="h-4 w-4" /> | |
| 122 | + <span class="hidden sm:inline">{t("aiStudio.backToLibrary")}</span> | |
| 123 | + </Button> | |
| 124 | + <div class="min-w-0 flex-1"> | |
| 125 | + <h2 class="truncate text-base font-semibold text-text-strong">{note().title}</h2> | |
| 126 | + <p class="truncate text-xs text-muted-foreground">{note().courseTitle}</p> | |
| 127 | + </div> | |
| 108 | 128 | </div> |
| 109 | 129 | <div class="grid gap-4 xl:grid-cols-2"> |
| 110 | 130 | <RagOutputsPanel |
src/components/ai/studio-output-library.test.tsxmodified+21 -0
| @@ -99,6 +99,27 @@ describe("StudioOutputLibrary", () => { | ||
| 99 | 99 | expect(current.length).toBe(2); |
| 100 | 100 | }); |
| 101 | 101 | |
| 102 | + it("pages a long history ten rows at a time", async () => { | |
| 103 | + podcastApi.listPodcastJobs.mockResolvedValue(page( | |
| 104 | + Array.from({ length: 12 }, (_, index) => | |
| 105 | + podcast({ job_id: `job-${index}`, source_title: `Bölüm ${index + 1}`, source_id: `other-${index}`, created_at: Date.UTC(2026, 0, 1, index), finished_at: Date.UTC(2026, 0, 1, index) }), | |
| 106 | + ), | |
| 107 | + )); | |
| 108 | + courseNotesApi.getCourseNoteRag.mockResolvedValue(page([])); | |
| 109 | + renderLibrary(); | |
| 110 | + | |
| 111 | + // Newest first: episode 12 leads page one, episode 2 closes it. | |
| 112 | + await waitFor(() => expect(screen.getByText("Bölüm 12")).toBeTruthy()); | |
| 113 | + expect(screen.getByText("Bölüm 3")).toBeTruthy(); | |
| 114 | + expect(screen.queryByText("Bölüm 2")).toBeNull(); | |
| 115 | + expect(screen.getByText("1-10 / 12")).toBeTruthy(); | |
| 116 | + | |
| 117 | + fireEvent.click(screen.getByRole("button", { name: "Sonraki" })); | |
| 118 | + expect(screen.getByText("Bölüm 2")).toBeTruthy(); | |
| 119 | + expect(screen.getByText("Bölüm 1")).toBeTruthy(); | |
| 120 | + expect(screen.queryByText("Bölüm 12")).toBeNull(); | |
| 121 | + }); | |
| 122 | + | |
| 102 | 123 | it("opens the run inspector for an episode instead of selecting its note", async () => { |
| 103 | 124 | const onSelect = renderLibrary(); |
| 104 | 125 |
src/components/ai/studio-output-library.tsxmodified+32 -2
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; | |
| 1 | +import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | |
| 2 | 2 | import { createResource } from "@/lib/create-resource"; |
| 3 | 3 | import { getCourseNoteRag } from "@/api/course-notes"; |
| 4 | 4 | import { listPodcastJobs } from "@/api/podcast"; |
| @@ -8,7 +8,9 @@ import { Badge } from "@/components/ui/badge"; | ||
| 8 | 8 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 9 | 9 | import { IconSparkles, IconWaveform } from "@/components/ui/icons"; |
| 10 | 10 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 11 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 11 | 12 | import { cn } from "@/lib/cn"; |
| 13 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 12 | 14 | import { formatDateTime } from "@/lib/format"; |
| 13 | 15 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 14 | 16 | |
| @@ -34,6 +36,7 @@ type StudioArtifact = { | ||
| 34 | 36 | }; |
| 35 | 37 | |
| 36 | 38 | const LIBRARY_LIMIT = 100; |
| 39 | +const LIBRARY_PAGE_SIZE = 10; | |
| 37 | 40 | |
| 38 | 41 | export function StudioOutputLibrary(props: { |
| 39 | 42 | notes: StudioLibraryNote[]; |
| @@ -112,6 +115,21 @@ export function StudioOutputLibrary(props: { | ||
| 112 | 115 | return rows.sort((a, b) => b.at - a.at); |
| 113 | 116 | }); |
| 114 | 117 | |
| 118 | + // The history is merged here from two sources, so it pages in memory. | |
| 119 | + const [page, setPage] = createSignal(0); | |
| 120 | + const pageSize = createResponsivePageSize(LIBRARY_PAGE_SIZE); | |
| 121 | + const total = () => items()?.length ?? 0; | |
| 122 | + const pageCount = createMemo(() => Math.max(1, Math.ceil(total() / pageSize()))); | |
| 123 | + const pageItems = createMemo(() => (items() ?? []).slice(page() * pageSize(), (page() + 1) * pageSize())); | |
| 124 | + createEffect(() => { | |
| 125 | + source(); | |
| 126 | + pageSize(); | |
| 127 | + setPage(0); | |
| 128 | + }); | |
| 129 | + createEffect(() => { | |
| 130 | + if (page() > pageCount() - 1) setPage(pageCount() - 1); | |
| 131 | + }); | |
| 132 | + | |
| 115 | 133 | const open = (item: StudioArtifact) => { |
| 116 | 134 | // A produced episode has an artifact of its own to inspect; a summary is |
| 117 | 135 | // rendered by the note's own producer panel, so that row opens the note. |
| @@ -145,7 +163,7 @@ export function StudioOutputLibrary(props: { | ||
| 145 | 163 | {/* A run history, the way a studio lists one: hairline dividers, a |
| 146 | 164 | status dot, what was produced and when — no cards. */} |
| 147 | 165 | <ul class="divide-y divide-border-hairline"> |
| 148 | - <For each={items()}> | |
| 166 | + <For each={pageItems()}> | |
| 149 | 167 | {(item) => ( |
| 150 | 168 | <li> |
| 151 | 169 | <button |
| @@ -199,6 +217,18 @@ export function StudioOutputLibrary(props: { | ||
| 199 | 217 | )} |
| 200 | 218 | </For> |
| 201 | 219 | </ul> |
| 220 | + <Show when={pageCount() > 1}> | |
| 221 | + <div class="border-t border-border-hairline p-2"> | |
| 222 | + <TablePagination | |
| 223 | + pageIndex={page()} | |
| 224 | + pageCount={pageCount()} | |
| 225 | + pageSize={pageSize()} | |
| 226 | + total={total()} | |
| 227 | + onPageChange={setPage} | |
| 228 | + class="border-0 bg-transparent" | |
| 229 | + /> | |
| 230 | + </div> | |
| 231 | + </Show> | |
| 202 | 232 | </Show> |
| 203 | 233 | </Suspense> |
| 204 | 234 |
src/components/courses/course-notes-panel.tsxmodified+8 -5
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import { deleteCourseNoteById, getCourseNotes, patchCourseNoteById, postCourseNote, postCourseNoteFile } from "@/api/course-notes"; |
| 4 | 5 | import { formatApiError } from "@/api/client"; |
| @@ -9,7 +10,7 @@ import { Button } from "@/components/ui/button"; | ||
| 9 | 10 | import { DataToolbar } from "@/components/ui/data-toolbar"; |
| 10 | 11 | import { IconPlus } from "@/components/ui/icons"; |
| 11 | 12 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 12 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 13 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 13 | 14 | import { SidePanel } from "@/components/ui/side-panel"; |
| 14 | 15 | import { createFlash } from "@/lib/flash"; |
| 15 | 16 | import { courseNoteFiles } from "@/lib/note-source"; |
| @@ -29,6 +30,7 @@ export function CourseNotesPanel(props: { | ||
| 29 | 30 | const [error, setError] = createSignal(""); |
| 30 | 31 | const [flash, setFlash] = createFlash(); |
| 31 | 32 | const [page, setPage] = createSignal(0); |
| 33 | + const pageSize = createResponsivePageSize(NOTE_PAGE_SIZE); | |
| 32 | 34 | const [search, setSearch] = createSignal(""); |
| 33 | 35 | |
| 34 | 36 | const [list, { refetch }] = createResource( |
| @@ -42,12 +44,13 @@ export function CourseNotesPanel(props: { | ||
| 42 | 44 | return query ? allNotes().filter((note) => matchesSearch(query, note.title, note.content)) : allNotes(); |
| 43 | 45 | }); |
| 44 | 46 | const total = () => filteredNotes().length; |
| 45 | - const pageItems = createMemo(() => filteredNotes().slice(page() * NOTE_PAGE_SIZE, (page() + 1) * NOTE_PAGE_SIZE)); | |
| 46 | - const totalPages = createMemo(() => Math.max(1, Math.ceil(total() / NOTE_PAGE_SIZE))); | |
| 47 | + const pageItems = createMemo(() => filteredNotes().slice(page() * pageSize(), (page() + 1) * pageSize())); | |
| 48 | + const totalPages = createMemo(() => Math.max(1, Math.ceil(total() / pageSize()))); | |
| 47 | 49 | const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); |
| 48 | 50 | |
| 49 | 51 | createEffect(() => { |
| 50 | 52 | search(); |
| 53 | + pageSize(); | |
| 51 | 54 | setPage(0); |
| 52 | 55 | }); |
| 53 | 56 | |
| @@ -153,8 +156,8 @@ export function CourseNotesPanel(props: { | ||
| 153 | 156 | }, t("common.deleted")) |
| 154 | 157 | } |
| 155 | 158 | /> |
| 156 | - <Show when={total() > NOTE_PAGE_SIZE}> | |
| 157 | - <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 159 | + <Show when={total() > pageSize()}> | |
| 160 | + <TablePagination pageIndex={safePage()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 158 | 161 | </Show> |
| 159 | 162 | </Show> |
| 160 | 163 | </Suspense> |
src/components/exams/bank-question-picker.tsxmodified+10 -7
| @@ -1,4 +1,5 @@ | ||
| 1 | -import { For, Show, createSignal } from "solid-js"; | |
| 1 | +import { For, Show, createSignal, createEffect, on } from "solid-js"; | |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import type { BankQuestion, Subject } from "@/api/client"; |
| 4 | 5 | import { formatApiError } from "@/api/client"; |
| @@ -7,7 +8,7 @@ import { Badge } from "@/components/ui/badge"; | ||
| 7 | 8 | import { Button } from "@/components/ui/button"; |
| 8 | 9 | import { Input } from "@/components/ui/input"; |
| 9 | 10 | import { Label } from "@/components/ui/label"; |
| 10 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 11 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 11 | 12 | import { Select } from "@/components/ui/select"; |
| 12 | 13 | import { cn } from "@/lib/cn"; |
| 13 | 14 | import { createDebouncedSignal } from "@/lib/create-debounced-signal"; |
| @@ -25,16 +26,18 @@ export function BankQuestionPicker(props: { | ||
| 25 | 26 | const t = useT(); |
| 26 | 27 | const [query, setQuery, debouncedQuery] = createDebouncedSignal(); |
| 27 | 28 | const [page, setPage] = createSignal(0); |
| 29 | + const pageSize = createResponsivePageSize(PICKER_PAGE_SIZE); | |
| 30 | + createEffect(on(pageSize, () => setPage(0), { defer: true })); | |
| 28 | 31 | const [selected, setSelected] = createSignal<BankQuestion | null>(null); |
| 29 | 32 | const [subjectId, setSubjectId] = createSignal(""); |
| 30 | 33 | const [error, setError] = createSignal(""); |
| 31 | 34 | const [pending, setPending] = createSignal(false); |
| 32 | 35 | const [templates] = createResource( |
| 33 | - () => ({ page: page(), q: debouncedQuery().trim() }), | |
| 36 | + () => ({ page: page(), size: pageSize(), q: debouncedQuery().trim() }), | |
| 34 | 37 | (params) => |
| 35 | 38 | getBankQuestions({ |
| 36 | - limit: PICKER_PAGE_SIZE, | |
| 37 | - offset: params.page * PICKER_PAGE_SIZE, | |
| 39 | + limit: params.size, | |
| 40 | + offset: params.page * params.size, | |
| 38 | 41 | ...(params.q ? { q: params.q } : {}), |
| 39 | 42 | }), |
| 40 | 43 | ); |
| @@ -113,8 +116,8 @@ export function BankQuestionPicker(props: { | ||
| 113 | 116 | {t("bank.countShown", { shown: visible().length, total: total() })} |
| 114 | 117 | </p> |
| 115 | 118 | </Show> |
| 116 | - <Show when={pagesOf(total(), PICKER_PAGE_SIZE) > 1}> | |
| 117 | - <PaginationControls page={page()} totalPages={pagesOf(total(), PICKER_PAGE_SIZE)} onPageChange={setPage} /> | |
| 119 | + <Show when={pagesOf(total(), pageSize()) > 1}> | |
| 120 | + <TablePagination pageIndex={page()} pageCount={pagesOf(total(), pageSize())} onPageChange={setPage} /> | |
| 118 | 121 | </Show> |
| 119 | 122 | |
| 120 | 123 | <Show when={selected()}> |
src/components/layout/celebi-thread-list.tsxmodified+2 -2
| @@ -4,7 +4,7 @@ import { getChatbotThreads, type ChatbotThread } from "@/api/chatbot"; | ||
| 4 | 4 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 5 | 5 | import { IconEdit, IconTrash } from "@/components/ui/icons"; |
| 6 | 6 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 7 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 7 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 8 | 8 | import { cn } from "@/lib/cn"; |
| 9 | 9 | import { formatDateTime } from "@/lib/format"; |
| 10 | 10 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -71,7 +71,7 @@ export function CelebiThreadList(props: { | ||
| 71 | 71 | </div> |
| 72 | 72 | <Show when={totalPages() > 1}> |
| 73 | 73 | <div class="mt-3 shrink-0"> |
| 74 | - <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 74 | + <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 75 | 75 | </div> |
| 76 | 76 | </Show> |
| 77 | 77 | </div> |
src/components/notes/note-files-panel.tsxmodified+2 -2
| @@ -13,7 +13,7 @@ import { FormDialog } from "@/components/ui/form-dialog"; | ||
| 13 | 13 | import { createFlash } from "@/lib/flash"; |
| 14 | 14 | import { IconDownload, IconEdit, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; |
| 15 | 15 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 16 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 16 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 17 | 17 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 18 | 18 | import { cn } from "@/lib/cn"; |
| 19 | 19 | import { fileTypeMeta } from "@/lib/file-type"; |
| @@ -253,7 +253,7 @@ export function NoteFilesPanel(props: { | ||
| 253 | 253 | </For> |
| 254 | 254 | </ul> |
| 255 | 255 | <Show when={(files() ?? []).length > FILE_PAGE_SIZE}> |
| 256 | - <PaginationControls page={filePage()} totalPages={totalPages()} onPageChange={setFilePage} /> | |
| 256 | + <TablePagination pageIndex={filePage()} pageCount={totalPages()} onPageChange={setFilePage} /> | |
| 257 | 257 | </Show> |
| 258 | 258 | <NoteFilePreview noteId={props.noteId} source={props.source} file={previewFile()} onClose={() => setPreviewFile(null)} /> |
| 259 | 259 | </Show> |
src/components/notes/podcast-history.tsxmodified+9 -6
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import { formatApiError } from "@/api/client"; |
| 4 | 5 | import type { MessageKey } from "@/i18n/messages"; |
| @@ -8,7 +9,7 @@ import { Badge } from "@/components/ui/badge"; | ||
| 8 | 9 | import { Button, buttonVariants } from "@/components/ui/button"; |
| 9 | 10 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 10 | 11 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 11 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 12 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 12 | 13 | import { IconDownload, IconWaveform } from "@/components/ui/icons"; |
| 13 | 14 | import { cn } from "@/lib/cn"; |
| 14 | 15 | import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download"; |
| @@ -40,19 +41,21 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | ||
| 40 | 41 | const { locale } = usePreferences(); |
| 41 | 42 | const [playing, setPlaying] = createSignal(""); |
| 42 | 43 | const [page, setPage] = createSignal(0); |
| 44 | + const pageSize = createResponsivePageSize(HISTORY_PAGE_SIZE); | |
| 43 | 45 | const active = () => props.active !== false; |
| 44 | 46 | |
| 45 | 47 | createEffect(() => { |
| 46 | 48 | props.noteId; |
| 49 | + pageSize(); | |
| 47 | 50 | setPage(0); |
| 48 | 51 | }); |
| 49 | 52 | |
| 50 | 53 | // The source is the scope string, not a fresh object: an identity-stable |
| 51 | 54 | // value keeps the resource from refetching when nothing about it changed. |
| 52 | - const source = createMemo(() => (active() && props.noteId ? { noteId: props.noteId, page: page() } : null)); | |
| 55 | + const source = createMemo(() => (active() && props.noteId ? { noteId: props.noteId, page: page(), size: pageSize() } : null)); | |
| 53 | 56 | const [list, { refetch }] = createResource( |
| 54 | 57 | source, |
| 55 | - (scope) => listPodcastJobs({ limit: HISTORY_PAGE_SIZE, offset: scope.page * HISTORY_PAGE_SIZE, sourceId: scope.noteId }), | |
| 58 | + (scope) => listPodcastJobs({ limit: scope.size, offset: scope.page * scope.size, sourceId: scope.noteId }), | |
| 56 | 59 | ); |
| 57 | 60 | |
| 58 | 61 | // The panel bumps the key ("", then the job id) when a generation finishes; |
| @@ -63,7 +66,7 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | ||
| 63 | 66 | }); |
| 64 | 67 | |
| 65 | 68 | const jobs = () => list()?.items ?? []; |
| 66 | - const totalPages = createMemo(() => Math.max(1, Math.ceil((list()?.total ?? 0) / HISTORY_PAGE_SIZE))); | |
| 69 | + const totalPages = createMemo(() => Math.max(1, Math.ceil((list()?.total ?? 0) / pageSize()))); | |
| 67 | 70 | const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); |
| 68 | 71 | |
| 69 | 72 | createEffect(() => { |
| @@ -174,8 +177,8 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | ||
| 174 | 177 | </For> |
| 175 | 178 | </ul> |
| 176 | 179 | </Show> |
| 177 | - <Show when={(list()?.total ?? 0) > HISTORY_PAGE_SIZE}> | |
| 178 | - <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 180 | + <Show when={(list()?.total ?? 0) > pageSize()}> | |
| 181 | + <TablePagination pageIndex={safePage()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 179 | 182 | </Show> |
| 180 | 183 | </Suspense> |
| 181 | 184 | </Show> |
src/components/notes/podcast-panel.tsxmodified+1 -1
| @@ -176,7 +176,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | ||
| 176 | 176 | </section> |
| 177 | 177 | } |
| 178 | 178 | > |
| 179 | - <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-4"> | |
| 179 | + <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"> | |
| 180 | 180 | <div class="flex items-start gap-3"> |
| 181 | 181 | <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text"> |
| 182 | 182 | <IconWaveform class="h-5 w-5" /> |
src/components/notes/rag-outputs-panel.tsxmodified+6 -4
| @@ -199,19 +199,21 @@ export function RagOutputsPanel(props: { | ||
| 199 | 199 | }; |
| 200 | 200 | |
| 201 | 201 | return ( |
| 202 | - <section class="space-y-3 rounded-xl border border-border-line bg-surface-base p-4"> | |
| 202 | + <section class="space-y-3 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"> | |
| 203 | 203 | <div class="flex flex-wrap items-start justify-between gap-3"> |
| 204 | 204 | <div> |
| 205 | 205 | <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> |
| 206 | 206 | <p class="mt-0.5 text-xs text-muted-foreground">{t("courseNotes.ragHint")}</p> |
| 207 | 207 | </div> |
| 208 | - <div class="flex flex-wrap items-center justify-end gap-2"> | |
| 208 | + {/* Phones: the actions take the full row at touch size, the main one | |
| 209 | + stretching, instead of a cluster of 32px targets. */} | |
| 210 | + <div class="flex flex-wrap items-center justify-end gap-2 max-sm:w-full max-sm:[&_[data-row-actions-trigger]]:h-10 max-sm:[&_[data-row-actions-trigger]]:min-w-10"> | |
| 209 | 211 | <Show when={props.canManage !== false && props.source.reindexRag}> |
| 210 | 212 | <Button |
| 211 | 213 | type="button" |
| 212 | 214 | size="sm" |
| 213 | 215 | variant="ghost" |
| 214 | - class="topbar-ai-control h-8 min-w-[78px] rounded-lg px-2" | |
| 216 | + class="topbar-ai-control h-8 min-w-[78px] rounded-lg px-2 max-sm:h-10 max-sm:flex-1" | |
| 215 | 217 | disabled={!available() || generating()} |
| 216 | 218 | onClick={() => void generate()} |
| 217 | 219 | > |
| @@ -273,7 +275,7 @@ export function RagOutputsPanel(props: { | ||
| 273 | 275 | <span class="text-xs font-semibold uppercase tracking-wide text-muted-foreground">{t("courseNotes.markdownPreview")}</span> |
| 274 | 276 | <span class="text-xs text-muted-foreground">{formatDateTime(current().generated_at, locale())}</span> |
| 275 | 277 | </header> |
| 276 | - <div class="p-4"> | |
| 278 | + <div class="p-3 sm:p-4"> | |
| 277 | 279 | <RagOutputContent payload={current().payload} /> |
| 278 | 280 | </div> |
| 279 | 281 | </article> |
src/components/rag/rag-composer.tsxmodified+2 -1
| @@ -72,7 +72,8 @@ export function RagComposer(props: { | ||
| 72 | 72 | <IconSend class="h-4 w-4" /> |
| 73 | 73 | </Button> |
| 74 | 74 | </div> |
| 75 | - <p class="mx-auto mt-2 w-full max-w-3xl px-1 text-center text-[11px] leading-4 text-muted-foreground">{props.hint}</p> | |
| 75 | + {/* Enter / Shift+Enter means nothing on a touch keyboard. */} | |
| 76 | + <p class="mx-auto mt-2 w-full max-w-3xl px-1 text-center text-[11px] leading-4 text-muted-foreground [@media(pointer:coarse)]:hidden">{props.hint}</p> | |
| 76 | 77 | </form> |
| 77 | 78 | ); |
| 78 | 79 | } |
src/components/rag/rag-copy.tsmodified+4 -0
| @@ -19,6 +19,8 @@ const copy = { | ||
| 19 | 19 | title: "Ask your notes", |
| 20 | 20 | newThread: "New chat", |
| 21 | 21 | history: "Chat history", |
| 22 | + openHistory: "Open chat history", | |
| 23 | + closeHistory: "Close chat history", | |
| 22 | 24 | untitled: "Untitled chat", |
| 23 | 25 | emptyThreads: "No chats yet", |
| 24 | 26 | emptyThreadsHint: "Start a new chat to ask the course corpus a question.", |
| @@ -78,6 +80,8 @@ const copy = { | ||
| 78 | 80 | title: "Notlarına sor", |
| 79 | 81 | newThread: "Yeni sohbet", |
| 80 | 82 | history: "Sohbet geçmişi", |
| 83 | + openHistory: "Sohbet geçmişini aç", | |
| 84 | + closeHistory: "Sohbet geçmişini kapat", | |
| 81 | 85 | untitled: "Başlıksız sohbet", |
| 82 | 86 | emptyThreads: "Henüz sohbet yok", |
| 83 | 87 | emptyThreadsHint: "Ders arşivine soru sormak için yeni bir sohbet başlat.", |
src/components/rag/rag-study-panel.tsxmodified+89 -8
| @@ -19,7 +19,7 @@ import { RagThreadList } from "@/components/rag/rag-thread-list"; | ||
| 19 | 19 | import { Alert } from "@/components/ui/alert"; |
| 20 | 20 | import { Button } from "@/components/ui/button"; |
| 21 | 21 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 22 | -import { IconChevronDown, IconPlus } from "@/components/ui/icons"; | |
| 22 | +import { IconChevronDown, IconMenu, IconPlus, IconX } from "@/components/ui/icons"; | |
| 23 | 23 | import { cn } from "@/lib/cn"; |
| 24 | 24 | import { scopeFromCitations } from "@/lib/rag-study-scope"; |
| 25 | 25 | import { usePreferences } from "@/stores/preferences-context"; |
| @@ -45,6 +45,18 @@ export function RagStudyPanel() { | ||
| 45 | 45 | const [studyUnavailable, setStudyUnavailable] = createSignal(false); |
| 46 | 46 | const [renaming, setRenaming] = createSignal<RagThread | null>(null); |
| 47 | 47 | const [removing, setRemoving] = createSignal<RagThread | null>(null); |
| 48 | + // Below lg the history is a drawer from the left edge, the way a chat app | |
| 49 | + // on a phone keeps its conversations one tap away without spending the | |
| 50 | + // screen on them. From lg it is the fixed column beside the transcript. | |
| 51 | + const [historyOpen, setHistoryOpen] = createSignal(false); | |
| 52 | + createEffect(() => { | |
| 53 | + if (!historyOpen()) return; | |
| 54 | + const onKey = (event: KeyboardEvent) => { | |
| 55 | + if (event.key === "Escape") setHistoryOpen(false); | |
| 56 | + }; | |
| 57 | + window.addEventListener("keydown", onKey); | |
| 58 | + onCleanup(() => window.removeEventListener("keydown", onKey)); | |
| 59 | + }); | |
| 48 | 60 | |
| 49 | 61 | let pollTimer: number | undefined; |
| 50 | 62 | let stream: EventSource | undefined; |
| @@ -223,21 +235,65 @@ export function RagStudyPanel() { | ||
| 223 | 235 | }; |
| 224 | 236 | |
| 225 | 237 | return ( |
| 226 | - <div class="grid min-h-[calc(100dvh-10rem)] gap-4 lg:h-[calc(100dvh-10rem)] lg:grid-cols-[18rem_minmax(0,1fr)]"> | |
| 227 | - <aside class="flex h-full min-h-0 flex-col gap-3 rounded-xl border border-border-line bg-surface-base p-3 shadow-xs"> | |
| 238 | + // Phones: one screen-tall column — top bar, transcript, composer — so the | |
| 239 | + // composer sits above the tab bar instead of scrolling away with the page. | |
| 240 | + <div class="grid h-[calc(var(--app-viewport)-5.5rem-max(env(safe-area-inset-bottom),var(--android-nav-inset,0px)))] gap-4 max-lg:-mt-2 lg:h-[calc(100dvh-10rem)] lg:grid-cols-[18rem_minmax(0,1fr)]"> | |
| 241 | + <button | |
| 242 | + type="button" | |
| 243 | + tabIndex={-1} | |
| 244 | + aria-hidden="true" | |
| 245 | + class={cn( | |
| 246 | + "fixed inset-0 z-[55] bg-black/45 transition-opacity duration-300 lg:hidden", | |
| 247 | + historyOpen() ? "opacity-100" : "pointer-events-none opacity-0", | |
| 248 | + )} | |
| 249 | + onClick={() => setHistoryOpen(false)} | |
| 250 | + /> | |
| 251 | + <aside | |
| 252 | + aria-label={copy().history} | |
| 253 | + class={cn( | |
| 254 | + "flex min-h-0 flex-col gap-3 bg-surface-base", | |
| 255 | + // Phone drawer. `visibility` rides the transition so the panel | |
| 256 | + // slides out before it leaves the tab order. | |
| 257 | + "fixed inset-y-0 left-0 z-[60] w-[min(20rem,85vw)] border-r border-border-line px-3 pb-[calc(max(env(safe-area-inset-bottom),var(--android-nav-inset,0px))+0.75rem)] pt-[calc(env(safe-area-inset-top)+0.75rem)] shadow-xl transition-[transform,visibility] duration-300 ease-out", | |
| 258 | + historyOpen() ? "visible translate-x-0" : "invisible -translate-x-full", | |
| 259 | + "lg:visible lg:static lg:z-auto lg:h-full lg:w-auto lg:translate-x-0 lg:rounded-xl lg:border lg:p-3 lg:shadow-xs lg:transition-none", | |
| 260 | + )} | |
| 261 | + > | |
| 228 | 262 | <div class="flex items-center justify-between gap-2"> |
| 229 | 263 | <h2 class="text-sm font-semibold text-text-strong">{copy().history}</h2> |
| 230 | - <Button type="button" size="sm" class="h-8 rounded-lg" disabled={!threadId() && messages().length === 0} onClick={newThread}> | |
| 231 | - <IconPlus class="h-4 w-4" /> | |
| 232 | - {copy().newThread} | |
| 233 | - </Button> | |
| 264 | + <div class="flex items-center gap-1"> | |
| 265 | + <Button | |
| 266 | + type="button" | |
| 267 | + size="sm" | |
| 268 | + class="h-8 rounded-lg max-lg:h-10" | |
| 269 | + disabled={!threadId() && messages().length === 0} | |
| 270 | + onClick={() => { | |
| 271 | + setHistoryOpen(false); | |
| 272 | + newThread(); | |
| 273 | + }} | |
| 274 | + > | |
| 275 | + <IconPlus class="h-4 w-4" /> | |
| 276 | + {copy().newThread} | |
| 277 | + </Button> | |
| 278 | + <button | |
| 279 | + type="button" | |
| 280 | + class="inline-flex h-10 w-10 items-center justify-center rounded-lg text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring lg:hidden" | |
| 281 | + aria-label={copy().closeHistory} | |
| 282 | + onClick={() => setHistoryOpen(false)} | |
| 283 | + > | |
| 284 | + <IconX class="h-5 w-5" /> | |
| 285 | + </button> | |
| 286 | + </div> | |
| 234 | 287 | </div> |
| 235 | 288 | <RagThreadList |
| 236 | 289 | activeId={threadId()} |
| 237 | 290 | version={threadsVersion()} |
| 238 | 291 | locale={locale()} |
| 239 | 292 | labels={copy()} |
| 240 | - onOpen={(thread) => void openThread(thread)} | |
| 293 | + onOpen={(thread) => { | |
| 294 | + setHistoryOpen(false); | |
| 295 | + void openThread(thread); | |
| 296 | + }} | |
| 241 | 297 | onRename={setRenaming} |
| 242 | 298 | onRemove={setRemoving} |
| 243 | 299 | /> |
| @@ -247,6 +303,31 @@ export function RagStudyPanel() { | ||
| 247 | 303 | chat does. The conversation's own actions live on its row in the |
| 248 | 304 | sidebar, which is where they were already duplicated. */} |
| 249 | 305 | <section class="flex h-full min-h-0 flex-col" aria-label={copy().title}> |
| 306 | + {/* Phone top bar: the drawer on the left, the open chat's name in the | |
| 307 | + middle, a fresh chat on the right. */} | |
| 308 | + <div class="flex shrink-0 items-center gap-2 border-b border-border-hairline pb-2 lg:hidden"> | |
| 309 | + <button | |
| 310 | + type="button" | |
| 311 | + class="inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-foreground outline-hidden transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring" | |
| 312 | + aria-label={copy().openHistory} | |
| 313 | + aria-expanded={historyOpen()} | |
| 314 | + onClick={() => setHistoryOpen(true)} | |
| 315 | + > | |
| 316 | + <IconMenu class="h-5 w-5" /> | |
| 317 | + </button> | |
| 318 | + <h1 class="min-w-0 flex-1 truncate text-center text-sm font-semibold text-text-strong"> | |
| 319 | + {activeThread()?.title || (threadId() ? copy().untitled : copy().title)} | |
| 320 | + </h1> | |
| 321 | + <button | |
| 322 | + type="button" | |
| 323 | + class="inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-foreground outline-hidden transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40" | |
| 324 | + aria-label={copy().newThread} | |
| 325 | + disabled={!threadId() && messages().length === 0} | |
| 326 | + onClick={newThread} | |
| 327 | + > | |
| 328 | + <IconPlus class="h-5 w-5" /> | |
| 329 | + </button> | |
| 330 | + </div> | |
| 250 | 331 | <Show when={error()}> |
| 251 | 332 | <div class="mx-auto w-full max-w-3xl px-4 pt-1 sm:px-6"> |
| 252 | 333 | <Alert variant="destructive">{error()}</Alert> |
src/components/rag/rag-thread-list.tsxmodified+2 -2
| @@ -5,7 +5,7 @@ import type { RagThread } from "@/api/client"; | ||
| 5 | 5 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 6 | 6 | import { IconEdit, IconTrash } from "@/components/ui/icons"; |
| 7 | 7 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 8 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 8 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 9 | 9 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 10 | 10 | import { cn } from "@/lib/cn"; |
| 11 | 11 | import { formatDateTime } from "@/lib/format"; |
| @@ -126,7 +126,7 @@ export function RagThreadList(props: { | ||
| 126 | 126 | </div> |
| 127 | 127 | <Show when={totalPages() > 1}> |
| 128 | 128 | <div class="mt-3 shrink-0"> |
| 129 | - <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 129 | + <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 130 | 130 | </div> |
| 131 | 131 | </Show> |
| 132 | 132 | </div> |
src/components/ui/coming-soon.tsxmodified+3 -1
| @@ -6,7 +6,9 @@ import { useT } from "@/stores/preferences-context"; | ||
| 6 | 6 | export function ComingSoonBadge(props: { class?: string }) { |
| 7 | 7 | const t = useT(); |
| 8 | 8 | return ( |
| 9 | - <Badge variant="secondary" class={cn("bg-surface-tint text-text-subtle", props.class)}> | |
| 9 | + // `data-coming-soon` lets a toolbar find the control carrying it — phones | |
| 10 | + // drop a button that can only say "not yet" (see DataTable's toolbar). | |
| 11 | + <Badge variant="secondary" data-coming-soon class={cn("bg-surface-tint text-text-subtle", props.class)}> | |
| 10 | 12 | {t("comingSoon.title")} |
| 11 | 13 | </Badge> |
| 12 | 14 | ); |
src/components/ui/data-table-search.tsxmodified+3 -1
| @@ -49,7 +49,9 @@ export function DataTableSearch(props: DataTableSearchProps) { | ||
| 49 | 49 | }} |
| 50 | 50 | placeholder={props.placeholder ?? t("common.search")} |
| 51 | 51 | aria-describedby={props.hint ? hintId : undefined} |
| 52 | - class={cn("h-8 rounded-lg bg-muted/40 text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")} | |
| 52 | + // Phones get a touch-sized box at 16px: below that iOS Safari zooms | |
| 53 | + // the page into a focused field. Compact from `sm` up. | |
| 54 | + class={cn("h-10 rounded-lg bg-muted/40 text-base sm:h-8 sm:text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")} | |
| 53 | 55 | /> |
| 54 | 56 | <Show when={props.value}> |
| 55 | 57 | <button |
src/components/ui/data-table.test.tsxmodified+27 -4
| @@ -92,16 +92,39 @@ test("paginates tables by default", () => { | ||
| 92 | 92 | expect(screen.getByText("Person 11")).toBeTruthy(); |
| 93 | 93 | }); |
| 94 | 94 | |
| 95 | -test("shows the pagination footer on a single page", () => { | |
| 95 | +test("halves the page on a phone", () => { | |
| 96 | + vi.stubGlobal("matchMedia", (query: string) => ({ | |
| 97 | + matches: true, | |
| 98 | + media: query, | |
| 99 | + addEventListener: () => undefined, | |
| 100 | + removeEventListener: () => undefined, | |
| 101 | + })); | |
| 102 | + const rows = Array.from({ length: 11 }, (_, index) => ({ name: `Person ${index + 1}` })); | |
| 103 | + try { | |
| 104 | + render(() => ( | |
| 105 | + <PreferencesProvider> | |
| 106 | + <DataTable columns={[columns[0]]} data={rows} enableColumnVisibility={false} /> | |
| 107 | + </PreferencesProvider> | |
| 108 | + )); | |
| 109 | + | |
| 110 | + expect(screen.getByText("Person 5")).toBeTruthy(); | |
| 111 | + expect(screen.queryByText("Person 6")).toBeNull(); | |
| 112 | + expect(screen.getByText("1 / 3")).toBeTruthy(); | |
| 113 | + } finally { | |
| 114 | + vi.unstubAllGlobals(); | |
| 115 | + } | |
| 116 | +}); | |
| 117 | + | |
| 118 | +test("a single page keeps the row count but drops the page buttons", () => { | |
| 96 | 119 | render(() => ( |
| 97 | 120 | <PreferencesProvider> |
| 98 | 121 | <DataTable columns={[columns[0]]} data={[{ name: "Ada" }]} enableColumnVisibility={false} /> |
| 99 | 122 | </PreferencesProvider> |
| 100 | 123 | )); |
| 101 | 124 | |
| 102 | - expect(screen.getByText("1 / 1")).toBeTruthy(); | |
| 103 | - expect((screen.getByRole("button", { name: "Previous" }) as HTMLButtonElement).disabled).toBe(true); | |
| 104 | - expect((screen.getByRole("button", { name: "Next" }) as HTMLButtonElement).disabled).toBe(true); | |
| 125 | + expect(screen.getByText("1-1 / 1")).toBeTruthy(); | |
| 126 | + expect(screen.queryByRole("button", { name: "Previous" })).toBeNull(); | |
| 127 | + expect(screen.queryByRole("button", { name: "Next" })).toBeNull(); | |
| 105 | 128 | }); |
| 106 | 129 | |
| 107 | 130 | test("a display column renders its own cell instead of the empty dash", () => { |
src/components/ui/data-table.tsxmodified+57 -42
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { For, Show, createEffect, createSignal, onCleanup } from "solid-js"; | |
| 1 | +import { For, Show, createEffect, createSignal, on, onCleanup } from "solid-js"; | |
| 2 | 2 | import type { JSX, ParentProps } from "solid-js"; |
| 3 | 3 | import { |
| 4 | 4 | type Column, |
| @@ -23,6 +23,7 @@ import { TablePagination } from "@/components/ui/table-pagination"; | ||
| 23 | 23 | import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/icons"; |
| 24 | 24 | import { cn } from "@/lib/cn"; |
| 25 | 25 | import { createMediaQuery } from "@/lib/create-media-query"; |
| 26 | +import { COMPACT_SCREEN_QUERY, createResponsivePageSize } from "@/lib/create-page-size"; | |
| 26 | 27 | import { createTablePreferences } from "@/lib/table-preferences"; |
| 27 | 28 | import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; |
| 28 | 29 | import { useT } from "@/stores/preferences-context"; |
| @@ -64,6 +65,7 @@ export type DataTableProps<TData, TValue = unknown> = { | ||
| 64 | 65 | actions?: JSX.Element; |
| 65 | 66 | manualPagination?: { |
| 66 | 67 | pageIndex: number; |
| 68 | + /** The size the caller actually fetched — pass a `createResponsivePageSize` accessor's value. */ | |
| 67 | 69 | pageSize: number; |
| 68 | 70 | total: number; |
| 69 | 71 | onPageChange: (pageIndex: number) => void; |
| @@ -76,6 +78,7 @@ export type DataTableProps<TData, TValue = unknown> = { | ||
| 76 | 78 | mobileLayout?: "cards" | "scroll"; |
| 77 | 79 | onRowClick?: (row: TData) => void; |
| 78 | 80 | onSearchInput?: (value: string) => void; |
| 81 | + /** Rows per page on a wide screen; phones get `compactPageSize` of it. */ | |
| 79 | 82 | pageSize?: number; |
| 80 | 83 | searchPredicate?: (row: TData, query: string) => boolean; |
| 81 | 84 | searchValue?: string; |
| @@ -99,10 +102,12 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 99 | 102 | const prefs = createTablePreferences(props.storageKey); |
| 100 | 103 | const [sorting, setSorting] = createSignal<SortingState>([]); |
| 101 | 104 | const [columnFilters, setColumnFilters] = createSignal<ColumnFiltersState>([]); |
| 102 | - const [pagination, setPagination] = createSignal<PaginationState>({ | |
| 103 | - pageIndex: 0, | |
| 104 | - pageSize: props.pageSize ?? 10, | |
| 105 | - }); | |
| 105 | + const clientPageSize = createResponsivePageSize(props.pageSize ?? 10); | |
| 106 | + const [clientPageIndex, setClientPageIndex] = createSignal(0); | |
| 107 | + const pagination = (): PaginationState => ({ pageIndex: clientPageIndex(), pageSize: clientPageSize() }); | |
| 108 | + // A page index means nothing once the page size changes under it (a phone | |
| 109 | + // rotated, a window narrowed): start over rather than land mid-list. | |
| 110 | + createEffect(on(clientPageSize, () => setClientPageIndex(0), { defer: true })); | |
| 106 | 111 | const [search, setSearch] = createSignal(""); |
| 107 | 112 | const searchValue = () => props.searchValue ?? search(); |
| 108 | 113 | // Sorting is client-side only, and the backend takes no sort parameter: on |
| @@ -135,7 +140,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 135 | 140 | onColumnFiltersChange: setColumnFilters, |
| 136 | 141 | onColumnVisibilityChange: (updater) => |
| 137 | 142 | prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)), |
| 138 | - onPaginationChange: setPagination, | |
| 143 | + onPaginationChange: (updater) => setClientPageIndex(resolveUpdater(updater, pagination()).pageIndex), | |
| 139 | 144 | state: { |
| 140 | 145 | get sorting() { |
| 141 | 146 | return sorting(); |
| @@ -206,7 +211,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 206 | 211 | const share = column.getSize() / total; |
| 207 | 212 | return `calc(${share * 100}% - ${share * actionColumnsWidth()}px)`; |
| 208 | 213 | }; |
| 209 | - const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0; | |
| 214 | + const compactScreen = createMediaQuery(COMPACT_SCREEN_QUERY); | |
| 215 | + const useCards = () => (props.mobileLayout ?? "cards") === "cards" && compactScreen(); | |
| 216 | + // Cards print every visible column as a label/value pair, so a column picker | |
| 217 | + // there only hides lines; on phones it is one more control for nothing. | |
| 218 | + const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0 && !useCards(); | |
| 210 | 219 | const showSearch = () => props.searchPredicate != null || props.filterColumn != null || props.onSearchInput != null; |
| 211 | 220 | const sectioned = () => props.surfaceSections !== false; |
| 212 | 221 | const showHeader = () => false; |
| @@ -255,8 +264,6 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 255 | 264 | </div> |
| 256 | 265 | </Show> |
| 257 | 266 | ); |
| 258 | - const compactScreen = createMediaQuery("(max-width: 639px)"); | |
| 259 | - const useCards = () => (props.mobileLayout ?? "cards") === "cards" && compactScreen(); | |
| 260 | 267 | const headerLabel = (columnId: string) => { |
| 261 | 268 | const header = table.getFlatHeaders().find((candidate) => candidate.column.id === columnId); |
| 262 | 269 | return header ? flexRender(header.column.columnDef.header, header.getContext()) : columnId; |
| @@ -311,28 +318,36 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 311 | 318 | </div> |
| 312 | 319 | </Show> |
| 313 | 320 | <Show when={showToolbar()}> |
| 314 | - <div class={cn("flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between", sectioned() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}> | |
| 315 | - <div class="flex flex-1 flex-wrap items-center gap-2"> | |
| 316 | - <Show when={showSearch()}> | |
| 317 | - <DataTableSearch | |
| 318 | - value={searchFieldValue()} | |
| 319 | - onChange={handleSearch} | |
| 320 | - placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")} | |
| 321 | - hint={props.filterHint} | |
| 322 | - /> | |
| 323 | - </Show> | |
| 324 | - <Show when={props.filters}> | |
| 325 | - <div class="flex flex-wrap items-center gap-2 [&_button]:h-8 [&_button]:rounded-lg [&_button]:text-[13px] [&_select]:h-8 [&_select]:rounded-lg [&_select]:text-[13px]">{props.filters}</div> | |
| 326 | - </Show> | |
| 327 | - </div> | |
| 328 | - <div class="flex shrink-0 flex-wrap items-center justify-end gap-2"> | |
| 329 | - <Show when={props.actions}> | |
| 330 | - <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md">{props.actions}</div> | |
| 331 | - </Show> | |
| 332 | - <Show when={showColumnMenu()}> | |
| 333 | - <DataTableViewMenu columns={viewMenuColumns()} /> | |
| 334 | - </Show> | |
| 335 | - </div> | |
| 321 | + {/* One wrapping row, ordered by width. Phones: search and actions share | |
| 322 | + the first line, filters get a line of their own that scrolls | |
| 323 | + sideways instead of stacking one control per line. From `lg`: | |
| 324 | + search, filters, then actions pushed to the right edge. Controls | |
| 325 | + are touch-sized (h-10) below `sm` and compact (h-8) above it. */} | |
| 326 | + <div class={cn("flex flex-wrap items-center gap-2", sectioned() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}> | |
| 327 | + <Show when={showSearch()}> | |
| 328 | + <DataTableSearch | |
| 329 | + class="order-1 w-auto min-w-40 flex-1 sm:max-w-xs" | |
| 330 | + value={searchFieldValue()} | |
| 331 | + onChange={handleSearch} | |
| 332 | + placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")} | |
| 333 | + hint={props.filterHint} | |
| 334 | + /> | |
| 335 | + </Show> | |
| 336 | + <Show when={props.filters}> | |
| 337 | + <div class="order-3 -my-1 flex w-full items-center gap-2 overflow-x-auto py-1 [scrollbar-width:none] sm:my-0 sm:py-0 sm:flex-wrap sm:overflow-visible lg:order-2 lg:w-auto [&_button]:h-10 [&_button]:shrink-0 [&_button]:rounded-lg [&_button]:text-[13px] sm:[&_button]:h-8 [&_select]:h-10 [&_select]:rounded-lg [&_select]:text-[13px] sm:[&_select]:h-8 max-sm:[&>*]:flex-nowrap max-sm:[&>*]:shrink-0">{props.filters}</div> | |
| 338 | + </Show> | |
| 339 | + <Show when={props.actions || showColumnMenu()}> | |
| 340 | + <div class="order-2 ml-auto flex shrink-0 flex-wrap items-center justify-end gap-2 lg:order-3"> | |
| 341 | + <Show when={props.actions}> | |
| 342 | + {/* A "yakında" button does nothing yet; on a phone it only | |
| 343 | + pushes the working action off the search row. */} | |
| 344 | + <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:[&_button]:h-10 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div> | |
| 345 | + </Show> | |
| 346 | + <Show when={showColumnMenu()}> | |
| 347 | + <DataTableViewMenu columns={viewMenuColumns()} /> | |
| 348 | + </Show> | |
| 349 | + </div> | |
| 350 | + </Show> | |
| 336 | 351 | </div> |
| 337 | 352 | </Show> |
| 338 | 353 | <Show when={useCards()}> |
| @@ -347,6 +362,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 347 | 362 | row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards); |
| 348 | 363 | const action = () => cells().find((cell) => cell.column.id === "actions"); |
| 349 | 364 | const body = () => cells().filter((cell) => cell.column.id !== "actions"); |
| 365 | + // A "-" line only makes a phone card taller: leave out fields | |
| 366 | + // with no value. Display columns draw themselves from | |
| 367 | + // row.original, so they have no value to test and always stay. | |
| 368 | + const details = () => | |
| 369 | + body().slice(1).filter((cell) => cell.column.accessorFn == null || (cell.getValue() != null && cell.getValue() !== "")); | |
| 350 | 370 | return ( |
| 351 | 371 | <li> |
| 352 | 372 | <div |
| @@ -370,22 +390,17 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 370 | 390 | <div class="min-w-0 flex-1 font-medium"> |
| 371 | 391 | <Show when={body()[0]}>{(first) => flexRender(first().column.columnDef.cell, first().getContext())}</Show> |
| 372 | 392 | </div> |
| 373 | - <Show when={action()}>{(cell) => <div class="-my-1 shrink-0">{flexRender(cell().column.columnDef.cell, cell().getContext())}</div>}</Show> | |
| 393 | + {/* The row menu shrinks to its ⋮ glyph here — the word | |
| 394 | + beside it cost the title a third of the card width. */} | |
| 395 | + <Show when={action()}>{(cell) => <div class="-my-1 shrink-0 [&_[data-row-actions-label]]:hidden [&_[data-row-actions-trigger]]:h-10 [&_[data-row-actions-trigger]]:w-10 [&_[data-row-actions-trigger]]:min-w-0 [&_[data-row-actions-trigger]]:px-0">{flexRender(cell().column.columnDef.cell, cell().getContext())}</div>}</Show> | |
| 374 | 396 | </div> |
| 375 | - <Show when={body().length > 1}> | |
| 397 | + <Show when={details().length > 0}> | |
| 376 | 398 | <dl class="mt-2 grid grid-cols-[minmax(6rem,auto)_minmax(0,1fr)] gap-x-3 gap-y-1.5"> |
| 377 | - <For each={body().slice(1)}> | |
| 399 | + <For each={details()}> | |
| 378 | 400 | {(cell) => ( |
| 379 | 401 | <> |
| 380 | 402 | <dt class="truncate text-xs text-muted-foreground">{headerLabel(cell.column.id)}</dt> |
| 381 | - <dd class="min-w-0 break-words text-foreground"> | |
| 382 | - <Show | |
| 383 | - when={cell.column.accessorFn == null || (cell.getValue() != null && cell.getValue() !== "")} | |
| 384 | - fallback={<span class="text-muted-foreground/60">-</span>} | |
| 385 | - > | |
| 386 | - {flexRender(cell.column.columnDef.cell, cell.getContext())} | |
| 387 | - </Show> | |
| 388 | - </dd> | |
| 403 | + <dd class="min-w-0 break-words text-foreground">{flexRender(cell.column.columnDef.cell, cell.getContext())}</dd> | |
| 389 | 404 | </> |
| 390 | 405 | )} |
| 391 | 406 | </For> |
src/components/ui/data-toolbar.tsxmodified+20 -14
| @@ -11,26 +11,32 @@ export function DataToolbar(props: { | ||
| 11 | 11 | onSearchInput?: (value: string) => void; |
| 12 | 12 | filters?: JSX.Element; |
| 13 | 13 | actions?: JSX.Element; |
| 14 | + /** Let the search box grow into the free width instead of stopping at `max-w-72`. */ | |
| 14 | 15 | inline?: boolean; |
| 15 | 16 | class?: string; |
| 16 | 17 | }) { |
| 17 | 18 | const hasSearch = () => props.searchValue !== undefined || props.searchPlaceholder !== undefined || props.onSearchInput !== undefined; |
| 18 | 19 | return ( |
| 19 | - <div class={cn("flex gap-3", props.inline ? "flex-row items-center" : "flex-col sm:flex-row sm:items-center sm:justify-between", props.class)}> | |
| 20 | - <div class={cn("flex min-w-0 flex-1 gap-2", props.inline ? "flex-row flex-nowrap items-center" : "flex-col sm:flex-row sm:flex-wrap sm:items-center")}> | |
| 21 | - <Show when={hasSearch()}> | |
| 22 | - <DataTableSearch | |
| 23 | - class={cn("sm:max-w-72", props.inline && "min-w-0 flex-1")} | |
| 24 | - value={props.searchValue ?? ""} | |
| 25 | - placeholder={props.searchPlaceholder} | |
| 26 | - hint={props.searchHint} | |
| 27 | - onChange={(value) => props.onSearchInput?.(value)} | |
| 28 | - /> | |
| 29 | - </Show> | |
| 30 | - {props.filters} | |
| 31 | - </div> | |
| 20 | + // One wrapping row, ordered by width — the same shape as DataTable's | |
| 21 | + // toolbar. Phones: search and actions share the first line and the | |
| 22 | + // filters take the next one; nothing is squeezed into a fixed row, where | |
| 23 | + // the search box shrank to a sliver and a filter painted over its icon. | |
| 24 | + // From `sm`: search, filters, then actions pushed to the right edge. | |
| 25 | + <div class={cn("flex flex-wrap items-center gap-2 sm:gap-3", props.class)}> | |
| 26 | + <Show when={hasSearch()}> | |
| 27 | + <DataTableSearch | |
| 28 | + class={cn("order-1 w-auto min-w-40 flex-1", !props.inline && "sm:max-w-72")} | |
| 29 | + value={props.searchValue ?? ""} | |
| 30 | + placeholder={props.searchPlaceholder} | |
| 31 | + hint={props.searchHint} | |
| 32 | + onChange={(value) => props.onSearchInput?.(value)} | |
| 33 | + /> | |
| 34 | + </Show> | |
| 35 | + <Show when={props.filters}> | |
| 36 | + <div class="order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto">{props.filters}</div> | |
| 37 | + </Show> | |
| 32 | 38 | <Show when={props.actions}> |
| 33 | - <div class="flex shrink-0 items-center gap-2 sm:justify-end">{props.actions}</div> | |
| 39 | + <div class="order-2 ml-auto flex shrink-0 items-center gap-2 sm:order-3 max-sm:[&_button]:h-10 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div> | |
| 34 | 40 | </Show> |
| 35 | 41 | </div> |
| 36 | 42 | ); |
src/components/ui/pagination-controls.tsxdeleted+0 -40
| @@ -1,40 +0,0 @@ | ||
| 1 | -import { Button } from "@/components/ui/button"; | |
| 2 | -import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; | |
| 3 | -import { useT } from "@/stores/preferences-context"; | |
| 4 | - | |
| 5 | -export function PaginationControls(props: { | |
| 6 | - page: number; | |
| 7 | - totalPages: number; | |
| 8 | - onPageChange: (page: number) => void; | |
| 9 | -}) { | |
| 10 | - const t = useT(); | |
| 11 | - return ( | |
| 12 | - <div class="flex items-center justify-between gap-2 border-t border-border/60 pt-3"> | |
| 13 | - <Button | |
| 14 | - type="button" | |
| 15 | - variant="outline" | |
| 16 | - size="sm" | |
| 17 | - class="h-8 gap-1 px-3" | |
| 18 | - disabled={props.page <= 0} | |
| 19 | - onClick={() => props.onPageChange(Math.max(0, props.page - 1))} | |
| 20 | - > | |
| 21 | - <IconChevronLeft class="h-3.5 w-3.5" /> | |
| 22 | - {t("common.prev")} | |
| 23 | - </Button> | |
| 24 | - <span class="text-xs tabular-nums text-muted-foreground"> | |
| 25 | - {t("common.pageOf", { page: props.page + 1, total: props.totalPages })} | |
| 26 | - </span> | |
| 27 | - <Button | |
| 28 | - type="button" | |
| 29 | - variant="outline" | |
| 30 | - size="sm" | |
| 31 | - class="h-8 gap-1 px-3" | |
| 32 | - disabled={props.page >= props.totalPages - 1} | |
| 33 | - onClick={() => props.onPageChange(Math.min(props.totalPages - 1, props.page + 1))} | |
| 34 | - > | |
| 35 | - {t("common.next")} | |
| 36 | - <IconChevronRight class="h-3.5 w-3.5" /> | |
| 37 | - </Button> | |
| 38 | - </div> | |
| 39 | - ); | |
| 40 | -} |
src/components/ui/table-pagination.tsxmodified+58 -35
| @@ -1,55 +1,78 @@ | ||
| 1 | +import { Show } from "solid-js"; | |
| 1 | 2 | import { Button } from "@/components/ui/button"; |
| 2 | 3 | import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; |
| 4 | +import { cn } from "@/lib/cn"; | |
| 3 | 5 | import { useT } from "@/stores/preferences-context"; |
| 4 | 6 | |
| 5 | 7 | export type TablePaginationProps = { |
| 6 | 8 | /** Zero-based current page index. */ |
| 7 | 9 | pageIndex: number; |
| 8 | 10 | pageCount: number; |
| 9 | - pageSize: number; | |
| 11 | + /** With `total`, prints "a-b / total"; without either only the page counter shows. */ | |
| 12 | + pageSize?: number; | |
| 10 | 13 | /** Total row count (across all pages). */ |
| 11 | - total: number; | |
| 14 | + total?: number; | |
| 12 | 15 | onPageChange: (pageIndex: number) => void; |
| 16 | + class?: string; | |
| 13 | 17 | }; |
| 14 | 18 | |
| 15 | -/** Footer: "X kayıttan a-b arası" + prev/next + "page / total". */ | |
| 19 | +/** | |
| 20 | + * Footer: "a-b / total" + prev / "page / count" / next, on one row at every | |
| 21 | + * width. The buttons are full touch targets on phones and compact from `sm` | |
| 22 | + * up. A single page keeps the row count but drops the buttons — two disabled | |
| 23 | + * arrows around "1 / 1" only take room. | |
| 24 | + */ | |
| 16 | 25 | export function TablePagination(props: TablePaginationProps) { |
| 17 | 26 | const t = useT(); |
| 18 | - const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1); | |
| 19 | - const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total); | |
| 27 | + const hasRange = () => props.total != null && props.pageSize != null; | |
| 28 | + const start = () => (!props.total || !props.pageSize ? 0 : props.pageIndex * props.pageSize + 1); | |
| 29 | + const end = () => Math.min((props.pageIndex + 1) * (props.pageSize ?? 0), props.total ?? 0); | |
| 30 | + const navButton = "h-10 w-10 gap-1 px-0 text-xs sm:h-7 sm:w-auto sm:px-1.5 sm:text-[11px]"; | |
| 20 | 31 | |
| 21 | 32 | return ( |
| 22 | - <div class="flex w-full flex-col gap-2 rounded-lg border border-border-line bg-surface-overlay px-2.5 py-1.5 sm:flex-row sm:items-center sm:justify-between"> | |
| 23 | - <span class="text-[11px] font-medium tabular-nums text-muted-foreground"> | |
| 24 | - {t("common.pageRange", { start: start(), end: end(), total: props.total })} | |
| 33 | + // Nothing to count and nowhere to go: an empty frame would only take room. | |
| 34 | + <Show when={hasRange() || props.pageCount > 1}> | |
| 35 | + <div | |
| 36 | + class={cn( | |
| 37 | + "flex w-full items-center justify-between gap-2 rounded-lg border border-border-line bg-surface-overlay px-2.5 py-1.5", | |
| 38 | + props.class, | |
| 39 | + )} | |
| 40 | + > | |
| 41 | + <span class="text-xs font-medium tabular-nums text-muted-foreground sm:text-[11px]"> | |
| 42 | + <Show when={hasRange()}>{t("common.pageRange", { start: start(), end: end(), total: props.total ?? 0 })}</Show> | |
| 25 | 43 | </span> |
| 26 | - <div class="flex items-center justify-end gap-1"> | |
| 27 | - <Button | |
| 28 | - type="button" | |
| 29 | - variant="outline" | |
| 30 | - size="sm" | |
| 31 | - class="h-7 gap-1 px-1.5 text-[11px]" | |
| 32 | - disabled={props.pageIndex <= 0} | |
| 33 | - onClick={() => props.onPageChange(Math.max(0, props.pageIndex - 1))} | |
| 34 | - > | |
| 35 | - <IconChevronLeft class="h-3 w-3" /> | |
| 36 | - <span class="hidden sm:inline">{t("common.prev")}</span> | |
| 37 | - </Button> | |
| 38 | - <span class="min-w-12 rounded-md border border-border-line bg-surface-base px-1.5 py-0.5 text-center text-[11px] font-semibold tabular-nums text-foreground"> | |
| 39 | - {t("common.pageOf", { page: props.pageIndex + 1, total: props.pageCount })} | |
| 40 | - </span> | |
| 41 | - <Button | |
| 42 | - type="button" | |
| 43 | - variant="outline" | |
| 44 | - size="sm" | |
| 45 | - class="h-7 gap-1 px-1.5 text-[11px]" | |
| 46 | - disabled={props.pageIndex >= props.pageCount - 1} | |
| 47 | - onClick={() => props.onPageChange(Math.min(props.pageCount - 1, props.pageIndex + 1))} | |
| 48 | - > | |
| 49 | - <span class="hidden sm:inline">{t("common.next")}</span> | |
| 50 | - <IconChevronRight class="h-3 w-3" /> | |
| 51 | - </Button> | |
| 52 | - </div> | |
| 44 | + <Show when={props.pageCount > 1}> | |
| 45 | + <nav class="flex items-center gap-1" aria-label={t("common.pagination")}> | |
| 46 | + <Button | |
| 47 | + type="button" | |
| 48 | + variant="outline" | |
| 49 | + size="sm" | |
| 50 | + class={navButton} | |
| 51 | + aria-label={t("common.prev")} | |
| 52 | + disabled={props.pageIndex <= 0} | |
| 53 | + onClick={() => props.onPageChange(Math.max(0, props.pageIndex - 1))} | |
| 54 | + > | |
| 55 | + <IconChevronLeft class="h-4 w-4 sm:h-3 sm:w-3" /> | |
| 56 | + <span class="hidden sm:inline">{t("common.prev")}</span> | |
| 57 | + </Button> | |
| 58 | + <span class="min-w-14 rounded-md border border-border-line bg-surface-base px-1.5 py-1 text-center text-xs font-semibold tabular-nums text-foreground sm:min-w-12 sm:py-0.5 sm:text-[11px]"> | |
| 59 | + {t("common.pageOf", { page: props.pageIndex + 1, total: props.pageCount })} | |
| 60 | + </span> | |
| 61 | + <Button | |
| 62 | + type="button" | |
| 63 | + variant="outline" | |
| 64 | + size="sm" | |
| 65 | + class={navButton} | |
| 66 | + aria-label={t("common.next")} | |
| 67 | + disabled={props.pageIndex >= props.pageCount - 1} | |
| 68 | + onClick={() => props.onPageChange(Math.min(props.pageCount - 1, props.pageIndex + 1))} | |
| 69 | + > | |
| 70 | + <span class="hidden sm:inline">{t("common.next")}</span> | |
| 71 | + <IconChevronRight class="h-4 w-4 sm:h-3 sm:w-3" /> | |
| 72 | + </Button> | |
| 73 | + </nav> | |
| 74 | + </Show> | |
| 53 | 75 | </div> |
| 76 | + </Show> | |
| 54 | 77 | ); |
| 55 | 78 | } |
src/components/ui/table-row-actions.tsxmodified+3 -1
| @@ -34,10 +34,11 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[ | ||
| 34 | 34 | class={props.compact |
| 35 | 35 | ? "inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-muted data-expanded:text-foreground" |
| 36 | 36 | : "inline-flex h-8 min-w-[78px] cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-border/80 bg-muted/45 px-2 text-xs font-semibold text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary-text"} |
| 37 | + data-row-actions-trigger | |
| 37 | 38 | aria-label={props.label} |
| 38 | 39 | title={props.label} |
| 39 | 40 | > |
| 40 | - {!props.compact && <span>{props.triggerLabel ?? t("common.action")}</span>} | |
| 41 | + {!props.compact && <span data-row-actions-label>{props.triggerLabel ?? t("common.action")}</span>} | |
| 41 | 42 | <IconDotsVertical class="h-3.5 w-3.5" /> |
| 42 | 43 | </DropdownMenuTrigger> |
| 43 | 44 | <DropdownMenuContent class="w-48"> |
| @@ -64,6 +65,7 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[ | ||
| 64 | 65 | {(action) => ( |
| 65 | 66 | <button |
| 66 | 67 | type="button" |
| 68 | + data-row-actions-trigger | |
| 67 | 69 | class="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-muted-foreground outline-hidden transition-colors hover:border-primary/20 hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" |
| 68 | 70 | aria-label={action().label} |
| 69 | 71 | title={action().label} |
src/components/users/profile-memberships.tsxmodified+7 -7
| @@ -4,7 +4,7 @@ import type { ClassGroup, ProfileClassRef, ProfileCourseRef } from "@/api/client | ||
| 4 | 4 | import { courseKindLabel } from "@/lib/course-kind"; |
| 5 | 5 | import { Badge } from "@/components/ui/badge"; |
| 6 | 6 | import { IconBook, IconSchool } from "@/components/ui/icons"; |
| 7 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 7 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 8 | 8 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 9 | 9 | import { cn } from "@/lib/cn"; |
| 10 | 10 | import { personLabel } from "@/lib/person"; |
| @@ -91,9 +91,9 @@ export function ProfileMemberships(props: { | ||
| 91 | 91 | </ul> |
| 92 | 92 | <Show when={pageCount(props.classes.length) > 1}> |
| 93 | 93 | <div class="mt-3"> |
| 94 | - <PaginationControls | |
| 95 | - page={classPage()} | |
| 96 | - totalPages={pageCount(props.classes.length)} | |
| 94 | + <TablePagination | |
| 95 | + pageIndex={classPage()} | |
| 96 | + pageCount={pageCount(props.classes.length)} | |
| 97 | 97 | onPageChange={setClassPage} |
| 98 | 98 | /> |
| 99 | 99 | </div> |
| @@ -132,9 +132,9 @@ export function ProfileMemberships(props: { | ||
| 132 | 132 | </ul> |
| 133 | 133 | <Show when={pageCount(props.courses.length) > 1}> |
| 134 | 134 | <div class="mt-3"> |
| 135 | - <PaginationControls | |
| 136 | - page={coursePage()} | |
| 137 | - totalPages={pageCount(props.courses.length)} | |
| 135 | + <TablePagination | |
| 136 | + pageIndex={coursePage()} | |
| 137 | + pageCount={pageCount(props.courses.length)} | |
| 138 | 138 | onPageChange={setCoursePage} |
| 139 | 139 | /> |
| 140 | 140 | </div> |
src/i18n/locales/en.tsmodified+2 -2
| @@ -91,7 +91,6 @@ export const en: Dict = { | ||
| 91 | 91 | "classGroups.selectTeacher": "Select a teacher", |
| 92 | 92 | "classGroups.yourClass": "Class", |
| 93 | 93 | "classGroups.searchPlaceholder": "Search by class, grade or homeroom teacher…", |
| 94 | - "classGroups.allGrades": "All grades", | |
| 95 | 94 | "classGroups.studentsCount": "{count} students", |
| 96 | 95 | "classGroups.noGrade": "No grade", |
| 97 | 96 | "classGroups.attendanceRate": "Attendance", |
| @@ -485,7 +484,6 @@ export const en: Dict = { | ||
| 485 | 484 | "roster.studentClass": "Class", |
| 486 | 485 | "roster.teacher": "Teacher", |
| 487 | 486 | "roster.class": "Class", |
| 488 | - "roster.classAll": "Class: All", | |
| 489 | 487 | "roster.term": "Term", |
| 490 | 488 | "roster.termAll": "Term: All", |
| 491 | 489 | "roster.mastery": "Topic mastery", |
| @@ -658,6 +656,7 @@ export const en: Dict = { | ||
| 658 | 656 | "common.prev": "Previous", |
| 659 | 657 | "common.next": "Next", |
| 660 | 658 | "common.pageOf": "{page} / {total}", |
| 659 | + "common.pagination": "Pagination", | |
| 661 | 660 | "common.noResults": "No results.", |
| 662 | 661 | "common.scrollHint": "Scroll horizontally", |
| 663 | 662 | "common.noMatches": "Nothing matches your search.", |
| @@ -710,6 +709,7 @@ export const en: Dict = { | ||
| 710 | 709 | "aiStudio.run.ended": "Ended", |
| 711 | 710 | "aiStudio.run.length": "Length", |
| 712 | 711 | "aiStudio.library.title": "Your generated library", |
| 712 | + "aiStudio.backToLibrary": "Back to library", | |
| 713 | 713 | "aiStudio.library.description": "Every summary and podcast you produced, newest first.", |
| 714 | 714 | "aiStudio.library.count": "{count} outputs", |
| 715 | 715 | "aiStudio.library.empty": "Your generated content will appear here", |
src/i18n/locales/tr.tsmodified+2 -2
| @@ -87,7 +87,6 @@ export const tr: Dict = { | ||
| 87 | 87 | "classGroups.selectTeacher": "Bir öğretmen seç", |
| 88 | 88 | "classGroups.yourClass": "Şube", |
| 89 | 89 | "classGroups.searchPlaceholder": "Şube, sınıf veya danışman ara…", |
| 90 | - "classGroups.allGrades": "Tüm sınıflar", | |
| 91 | 90 | "classGroups.studentsCount": "{count} öğrenci", |
| 92 | 91 | "classGroups.noGrade": "Sınıf yok", |
| 93 | 92 | "classGroups.attendanceRate": "Devam", |
| @@ -481,7 +480,6 @@ export const tr: Dict = { | ||
| 481 | 480 | "roster.studentClass": "Sınıfı", |
| 482 | 481 | "roster.teacher": "Öğretmen", |
| 483 | 482 | "roster.class": "Sınıf", |
| 484 | - "roster.classAll": "Sınıf: Tümü", | |
| 485 | 483 | "roster.term": "Dönem", |
| 486 | 484 | "roster.termAll": "Dönem: Tümü", |
| 487 | 485 | "roster.mastery": "Konu yetkinliği", |
| @@ -654,6 +652,7 @@ export const tr: Dict = { | ||
| 654 | 652 | "common.prev": "Önceki", |
| 655 | 653 | "common.next": "Sonraki", |
| 656 | 654 | "common.pageOf": "{page} / {total}", |
| 655 | + "common.pagination": "Sayfalar", | |
| 657 | 656 | "common.noResults": "Sonuç yok.", |
| 658 | 657 | "common.scrollHint": "Yatay kaydır", |
| 659 | 658 | "common.noMatches": "Aramanızla eşleşen kayıt yok.", |
| @@ -706,6 +705,7 @@ export const tr: Dict = { | ||
| 706 | 705 | "aiStudio.run.ended": "Bitti", |
| 707 | 706 | "aiStudio.run.length": "Uzunluk", |
| 708 | 707 | "aiStudio.library.title": "Üretim kitaplığın", |
| 708 | + "aiStudio.backToLibrary": "Kitaplığa dön", | |
| 709 | 709 | "aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.", |
| 710 | 710 | "aiStudio.library.count": "{count} çıktı", |
| 711 | 711 | "aiStudio.library.empty": "Ürettiğin içerikler burada görünecek", |
src/i18n/messages.tsmodified+2 -2
| @@ -80,7 +80,6 @@ export type MessageKey = | ||
| 80 | 80 | | "classGroups.selectTeacher" |
| 81 | 81 | | "classGroups.yourClass" |
| 82 | 82 | | "classGroups.searchPlaceholder" |
| 83 | - | "classGroups.allGrades" | |
| 84 | 83 | | "classGroups.studentsCount" |
| 85 | 84 | | "classGroups.noGrade" |
| 86 | 85 | | "classGroups.attendanceRate" |
| @@ -450,7 +449,6 @@ export type MessageKey = | ||
| 450 | 449 | | "roster.studentClass" |
| 451 | 450 | | "roster.teacher" |
| 452 | 451 | | "roster.class" |
| 453 | - | "roster.classAll" | |
| 454 | 452 | | "roster.term" |
| 455 | 453 | | "roster.termAll" |
| 456 | 454 | | "roster.mastery" |
| @@ -642,6 +640,7 @@ export type MessageKey = | ||
| 642 | 640 | | "common.prev" |
| 643 | 641 | | "common.next" |
| 644 | 642 | | "common.pageOf" |
| 643 | + | "common.pagination" | |
| 645 | 644 | | "common.noResults" |
| 646 | 645 | | "common.scrollHint" |
| 647 | 646 | | "common.noMatches" |
| @@ -694,6 +693,7 @@ export type MessageKey = | ||
| 694 | 693 | | "aiStudio.run.ended" |
| 695 | 694 | | "aiStudio.run.length" |
| 696 | 695 | | "aiStudio.library.title" |
| 696 | + | "aiStudio.backToLibrary" | |
| 697 | 697 | | "aiStudio.library.description" |
| 698 | 698 | | "aiStudio.library.count" |
| 699 | 699 | | "aiStudio.library.empty" |
src/lib/create-page-size.test.tsadded+15 -0
| @@ -0,0 +1,15 @@ | ||
| 1 | +import { compactPageSize } from "@/lib/create-page-size"; | |
| 2 | + | |
| 3 | +it("halves a page for phones, never below five", () => { | |
| 4 | + expect(compactPageSize(10)).toBe(5); | |
| 5 | + expect(compactPageSize(8)).toBe(5); | |
| 6 | + expect(compactPageSize(12)).toBe(6); | |
| 7 | + expect(compactPageSize(15)).toBe(8); | |
| 8 | + expect(compactPageSize(20)).toBe(10); | |
| 9 | +}); | |
| 10 | + | |
| 11 | +it("leaves an already short page alone", () => { | |
| 12 | + expect(compactPageSize(5)).toBe(5); | |
| 13 | + expect(compactPageSize(4)).toBe(4); | |
| 14 | + expect(compactPageSize(1)).toBe(1); | |
| 15 | +}); |
src/lib/create-page-size.tsadded+25 -0
| @@ -0,0 +1,25 @@ | ||
| 1 | +import { createMediaQuery } from "@/lib/create-media-query"; | |
| 2 | + | |
| 3 | +/** Below Tailwind's `sm` breakpoint — the width where tables turn into cards. */ | |
| 4 | +export const COMPACT_SCREEN_QUERY = "(max-width: 639px)"; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Rows per page on a phone for a list that shows `desktop` rows on a wide | |
| 8 | + * screen. A table row becomes a four- or five-line card there, so the same | |
| 9 | + * count is several screens tall: half as many, never fewer than five, and a | |
| 10 | + * list that is already short keeps its own size. | |
| 11 | + */ | |
| 12 | +export function compactPageSize(desktop: number): number { | |
| 13 | + return Math.min(desktop, Math.max(5, Math.ceil(desktop / 2))); | |
| 14 | +} | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * A page size that follows the screen: `desktop` on wide screens, | |
| 18 | + * `compactPageSize(desktop)` on phones. Callers that page on the server pass | |
| 19 | + * the accessor into their fetch source, so a rotation refetches the right | |
| 20 | + * slice; callers keeping a page index should reset it when this changes. | |
| 21 | + */ | |
| 22 | +export function createResponsivePageSize(desktop: number): () => number { | |
| 23 | + const compact = createMediaQuery(COMPACT_SCREEN_QUERY); | |
| 24 | + return () => (compact() ? compactPageSize(desktop) : desktop); | |
| 25 | +} |
src/pages/classes-page.tsxmodified+2 -2
| @@ -232,10 +232,10 @@ function ClassesContent() { | ||
| 232 | 232 | filters={ |
| 233 | 233 | <Show when={grades().length > 0}> |
| 234 | 234 | <DropdownSelect |
| 235 | - options={[{ value: "all", label: t("classGroups.allGrades") }, ...grades().map((g) => ({ value: g, label: g }))]} | |
| 235 | + labelPrefix={t("classGroups.grade")} | |
| 236 | + options={[{ value: "all", label: t("common.all") }, ...grades().map((g) => ({ value: g, label: g }))]} | |
| 236 | 237 | value={gradeFilter()} |
| 237 | 238 | onChange={setGradeFilter} |
| 238 | - class="min-w-44" | |
| 239 | 239 | /> |
| 240 | 240 | </Show> |
| 241 | 241 | } |
src/pages/courses-page.tsxmodified+7 -5
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import { useNavigate, useSearch } from "@tanstack/solid-router"; |
| 4 | 5 | import { getCourses, postCourse } from "@/api/courses"; |
| @@ -16,7 +17,7 @@ import { IconPlus } from "@/components/ui/icons"; | ||
| 16 | 17 | import { Input } from "@/components/ui/input"; |
| 17 | 18 | import { Label } from "@/components/ui/label"; |
| 18 | 19 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 19 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 20 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 20 | 21 | import { Select } from "@/components/ui/select"; |
| 21 | 22 | import { courseKindLabel } from "@/lib/course-kind"; |
| 22 | 23 | import { SidePanel } from "@/components/ui/side-panel"; |
| @@ -56,6 +57,7 @@ function CoursesContent() { | ||
| 56 | 57 | // any şube has. |
| 57 | 58 | const [taughtFilter, setTaughtFilter] = createSignal("all"); |
| 58 | 59 | const [page, setPage] = createSignal(0); |
| 60 | + const pageSize = createResponsivePageSize(PAGE_SIZE); | |
| 59 | 61 | const [search, setSearch] = createSignal(""); |
| 60 | 62 | const [error, setError] = createSignal(""); |
| 61 | 63 | const [pending, setPending] = createSignal(false); |
| @@ -68,7 +70,7 @@ function CoursesContent() { | ||
| 68 | 70 | setPageKind(routeSearch().kind); |
| 69 | 71 | }); |
| 70 | 72 | createEffect(() => { |
| 71 | - pageKind(); taughtFilter(); search(); setPage(0); | |
| 73 | + pageKind(); taughtFilter(); search(); pageSize(); setPage(0); | |
| 72 | 74 | }); |
| 73 | 75 | |
| 74 | 76 | const [limits, { refetch: refetchLimits }] = createResource(() => canCreate() ? getLimits() : null); |
| @@ -87,8 +89,8 @@ function CoursesContent() { | ||
| 87 | 89 | return matchesSearch(query, course.title, course.description, personLabel(course.creator)); |
| 88 | 90 | }); |
| 89 | 91 | }); |
| 90 | - const totalPages = createMemo(() => Math.max(1, Math.ceil(filteredCourses().length / PAGE_SIZE))); | |
| 91 | - const visibleCourses = createMemo(() => filteredCourses().slice(page() * PAGE_SIZE, (page() + 1) * PAGE_SIZE)); | |
| 92 | + const totalPages = createMemo(() => Math.max(1, Math.ceil(filteredCourses().length / pageSize()))); | |
| 93 | + const visibleCourses = createMemo(() => filteredCourses().slice(page() * pageSize(), (page() + 1) * pageSize())); | |
| 92 | 94 | |
| 93 | 95 | const createCourse = async (event: SubmitEvent) => { |
| 94 | 96 | event.preventDefault(); |
| @@ -200,7 +202,7 @@ function CoursesContent() { | ||
| 200 | 202 | )} |
| 201 | 203 | </For> |
| 202 | 204 | </div> |
| 203 | - <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 205 | + <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 204 | 206 | </Show> |
| 205 | 207 | </Show> |
| 206 | 208 | </Suspense> |
src/pages/exam-detail-page.tsxmodified+22 -10
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; |
| 2 | -import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | |
| 2 | +import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; | |
| 3 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 3 | 4 | import { createResource } from "@/lib/create-resource"; |
| 4 | 5 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 5 | 6 | import { deleteExamById } from "@/api/exams"; |
| @@ -33,7 +34,6 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 33 | 34 | import { EmptyState } from "@/components/ui/empty-state"; |
| 34 | 35 | import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconRefresh, IconSchool, IconTrash } from "@/components/ui/icons"; |
| 35 | 36 | import { Input } from "@/components/ui/input"; |
| 36 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 37 | 37 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 38 | 38 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 39 | 39 | import { SidePanel } from "@/components/ui/side-panel"; |
| @@ -116,6 +116,8 @@ function ExamDetailContent() { | ||
| 116 | 116 | const [removeUserId, setRemoveUserId] = createSignal<string | null>(null); |
| 117 | 117 | const [gradeOpen, setGradeOpen] = createSignal(false); |
| 118 | 118 | const [resultPage, setResultPage] = createSignal(0); |
| 119 | + const resultPageSize = createResponsivePageSize(RESULT_PAGE_SIZE); | |
| 120 | + createEffect(on(resultPageSize, () => setResultPage(0), { defer: true })); | |
| 119 | 121 | const [answerSheetUserId, setAnswerSheetUserId] = createSignal<string | null>(null); |
| 120 | 122 | const answerSheetOpen = () => answerSheetUserId() != null; |
| 121 | 123 | const [answerMark, setAnswerMark] = createSignal("0"); |
| @@ -153,11 +155,11 @@ function ExamDetailContent() { | ||
| 153 | 155 | ); |
| 154 | 156 | |
| 155 | 157 | const [results, { refetch: refetchResults }] = createResource( |
| 156 | - () => (hasCourseManagementRights() ? [id(), resultPage()] as const : null), | |
| 158 | + () => (hasCourseManagementRights() ? [id(), resultPage(), resultPageSize()] as const : null), | |
| 157 | 159 | async (source) => { |
| 158 | 160 | if (!source) return { items: [], total: 0, limit: RESULT_PAGE_SIZE, offset: 0 }; |
| 159 | - const [examId, page] = source; | |
| 160 | - return getExamResults(examId, { limit: RESULT_PAGE_SIZE, offset: page * RESULT_PAGE_SIZE }); | |
| 161 | + const [examId, page, size] = source; | |
| 162 | + return getExamResults(examId, { limit: size, offset: page * size }); | |
| 161 | 163 | }, |
| 162 | 164 | ); |
| 163 | 165 | const [gradeResults, { refetch: refetchGradeResults }] = createResource( |
| @@ -258,7 +260,7 @@ function ExamDetailContent() { | ||
| 258 | 260 | async (examId) => examId ? getExamLive(examId) : null, |
| 259 | 261 | ); |
| 260 | 262 | const resultTotal = () => results()?.total ?? 0; |
| 261 | - const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / RESULT_PAGE_SIZE)); | |
| 263 | + const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / resultPageSize())); | |
| 262 | 264 | const setClampedAnswerMark = (value: string) => { |
| 263 | 265 | if (value === "") { |
| 264 | 266 | setAnswerMark(value); |
| @@ -735,10 +737,20 @@ function ExamDetailContent() { | ||
| 735 | 737 | when={(results()?.items ?? []).length > 0} |
| 736 | 738 | fallback={<EmptyState kind="exams" title={t("exams.noResults")} />} |
| 737 | 739 | > |
| 738 | - <DataTable columns={resultColumns()} data={results()?.items ?? []} filterColumn="user" /> | |
| 739 | - <Show when={resultTotal() > RESULT_PAGE_SIZE}> | |
| 740 | - <PaginationControls page={Math.min(resultPage(), resultTotalPages() - 1)} totalPages={resultTotalPages()} onPageChange={setResultPage} /> | |
| 741 | - </Show> | |
| 740 | + {/* Server-paged: the table's own pager drives the fetch, so a | |
| 741 | + phone's smaller page never shows up as a second pager | |
| 742 | + slicing the fetched page again. */} | |
| 743 | + <DataTable | |
| 744 | + columns={resultColumns()} | |
| 745 | + data={results()?.items ?? []} | |
| 746 | + filterColumn="user" | |
| 747 | + manualPagination={{ | |
| 748 | + pageIndex: Math.min(resultPage(), resultTotalPages() - 1), | |
| 749 | + pageSize: resultPageSize(), | |
| 750 | + total: resultTotal(), | |
| 751 | + onPageChange: setResultPage, | |
| 752 | + }} | |
| 753 | + /> | |
| 742 | 754 | </Show> |
| 743 | 755 | </Suspense> |
| 744 | 756 | </TabsContent> |
src/pages/meals-page.tsxmodified+9 -6
| @@ -1,4 +1,5 @@ | ||
| 1 | -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; | |
| 1 | +import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; | |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import { getLimits } from "@/api/limits"; |
| 4 | 5 | import { getMealMenuBookings, getMealMenus, postMealMenu } from "@/api/meals"; |
| @@ -16,7 +17,7 @@ import { IconPlus } from "@/components/ui/icons"; | ||
| 16 | 17 | import { Input } from "@/components/ui/input"; |
| 17 | 18 | import { Label } from "@/components/ui/label"; |
| 18 | 19 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 19 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 20 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 20 | 21 | import { Select } from "@/components/ui/select"; |
| 21 | 22 | import { SidePanel } from "@/components/ui/side-panel"; |
| 22 | 23 | import { inputDateToIso, isoDateToInput } from "@/lib/datetime-input"; |
| @@ -38,6 +39,8 @@ function MealsContent() { | ||
| 38 | 39 | const { locale } = usePreferences(); |
| 39 | 40 | const canManage = () => hasMinRole(auth.user()?.role, "manager"); |
| 40 | 41 | const [page, setPage] = createSignal(0); |
| 42 | + const pageSize = createResponsivePageSize(PAGE_SIZE); | |
| 43 | + createEffect(on(pageSize, () => setPage(0), { defer: true })); | |
| 41 | 44 | const [from, setFrom] = createSignal(today()); |
| 42 | 45 | const [slot, setSlot] = createSignal("all"); |
| 43 | 46 | const [showCreate, setShowCreate] = createSignal(false); |
| @@ -50,11 +53,11 @@ function MealsContent() { | ||
| 50 | 53 | const [settings] = createResource(() => getSettings()); |
| 51 | 54 | const [limits, { refetch: refetchLimits }] = createResource(() => canManage() ? getLimits() : null); |
| 52 | 55 | const [menus, { refetch }] = createResource( |
| 53 | - () => [from(), page()] as const, | |
| 54 | - async ([start, index]) => getMealMenus({ from: start || undefined, limit: PAGE_SIZE, offset: index * PAGE_SIZE }), | |
| 56 | + () => [from(), page(), pageSize()] as const, | |
| 57 | + async ([start, index, size]) => getMealMenus({ from: start || undefined, limit: size, offset: index * size }), | |
| 55 | 58 | ); |
| 56 | 59 | const visible = createMemo(() => slot() === "all" ? menus()?.items ?? [] : (menus()?.items ?? []).filter((menu) => menu.slot === slot())); |
| 57 | - const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / PAGE_SIZE))); | |
| 60 | + const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / pageSize()))); | |
| 58 | 61 | |
| 59 | 62 | // Real occupancy = confirmed bookings / capacity, both true fields — not the |
| 60 | 63 | // fabricated İyi/Takipte/Risk badge Figma shows. `getMealMenuBookings` is |
| @@ -111,7 +114,7 @@ function MealsContent() { | ||
| 111 | 114 | <Show when={menus.error}><ErrorAlert message={formatApiError(menus.error)} onRetry={() => void refetch()} /></Show> |
| 112 | 115 | <Show when={visible().length > 0} fallback={<EmptyState kind="meals" title={t("meals.empty")} />}> |
| 113 | 116 | <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"><For each={visible()}>{(menu) => <MealMenuCard menu={menu} locale={locale() === "tr" ? "tr-TR" : "en-US"} labels={{ dishes: t("meals.dishes"), capacity: t("meals.capacity"), conflict: t("meals.conflict"), reservations: t("meals.reservations"), topPick: t("meals.topPick") }} reservationCount={reservationCounts()?.get(menu.id) ?? undefined} />}</For></div> |
| 114 | - <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 117 | + <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 115 | 118 | </Show> |
| 116 | 119 | </Suspense> |
| 117 | 120 | </DataSection> |
src/pages/messages-page.tsxmodified+4 -4
| @@ -8,7 +8,7 @@ import { | ||
| 8 | 8 | } from "solid-js"; |
| 9 | 9 | import { createResource } from "@/lib/create-resource"; |
| 10 | 10 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 11 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 11 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 12 | 12 | import { Button } from "@/components/ui/button"; |
| 13 | 13 | import { |
| 14 | 14 | IconArchive, |
| @@ -421,10 +421,10 @@ export default function MessagesPage() { | ||
| 421 | 421 | |
| 422 | 422 | <Show when={messagePage() && messagePage()!.total > limit}> |
| 423 | 423 | <div class="p-4 border-t border-border-hairline"> |
| 424 | - <PaginationControls | |
| 425 | - page={page()} | |
| 424 | + <TablePagination | |
| 425 | + pageIndex={page()} | |
| 426 | 426 | onPageChange={setPage} |
| 427 | - totalPages={Math.ceil((messagePage()?.total ?? 0) / limit)} | |
| 427 | + pageCount={Math.ceil((messagePage()?.total ?? 0) / limit)} | |
| 428 | 428 | /> |
| 429 | 429 | </div> |
| 430 | 430 | </Show> |
src/pages/notes-page.tsxmodified+12 -9
| @@ -1,4 +1,5 @@ | ||
| 1 | -import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | |
| 1 | +import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; | |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import { useLocation, useNavigate } from "@tanstack/solid-router"; |
| 4 | 5 | import { deleteNoteById } from "@/api/notes"; |
| @@ -13,7 +14,7 @@ import { NoteList } from "@/components/notes/note-list"; | ||
| 13 | 14 | import { Button } from "@/components/ui/button"; |
| 14 | 15 | import { IconPlus, IconUploadCloud } from "@/components/ui/icons"; |
| 15 | 16 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 16 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 17 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 17 | 18 | import { SidePanel } from "@/components/ui/side-panel"; |
| 18 | 19 | import { createFlash } from "@/lib/flash"; |
| 19 | 20 | import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; |
| @@ -43,13 +44,15 @@ function NotesContent() { | ||
| 43 | 44 | if (location().searchStr.includes("action=import")) setImportOpen(true); |
| 44 | 45 | }); |
| 45 | 46 | const [page, setPage] = createSignal(0); |
| 47 | + const pageSize = createResponsivePageSize(NOTE_PAGE_SIZE); | |
| 48 | + createEffect(on(pageSize, () => setPage(0), { defer: true })); | |
| 46 | 49 | |
| 47 | 50 | const [list, { refetch }] = createResource( |
| 48 | - () => page(), | |
| 49 | - async (currentPage) => | |
| 51 | + () => ({ page: page(), size: pageSize() }), | |
| 52 | + async (source) => | |
| 50 | 53 | loadListPage({ |
| 51 | - page: currentPage, | |
| 52 | - pageSize: NOTE_PAGE_SIZE, | |
| 54 | + page: source.page, | |
| 55 | + pageSize: source.size, | |
| 53 | 56 | clientMode: false, |
| 54 | 57 | fetch: getNotes, |
| 55 | 58 | }), |
| @@ -57,7 +60,7 @@ function NotesContent() { | ||
| 57 | 60 | |
| 58 | 61 | const total = () => list()?.total ?? 0; |
| 59 | 62 | const pageItems = () => list()?.items ?? []; |
| 60 | - const totalPages = createMemo(() => pagesOf(total(), NOTE_PAGE_SIZE)); | |
| 63 | + const totalPages = createMemo(() => pagesOf(total(), pageSize())); | |
| 61 | 64 | const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); |
| 62 | 65 | |
| 63 | 66 | const wrap = async (fn: () => Promise<void>, okMessage: string) => { |
| @@ -129,8 +132,8 @@ function NotesContent() { | ||
| 129 | 132 | }, t("common.deleted")) |
| 130 | 133 | } |
| 131 | 134 | /> |
| 132 | - <Show when={total() > NOTE_PAGE_SIZE}> | |
| 133 | - <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> | |
| 135 | + <Show when={total() > pageSize()}> | |
| 136 | + <TablePagination pageIndex={safePage()} pageCount={totalPages()} onPageChange={setPage} /> | |
| 134 | 137 | </Show> |
| 135 | 138 | </Show> |
| 136 | 139 | </Suspense> |
src/pages/payments-page.tsxmodified+6 -3
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { useLocation, useNavigate } from "@tanstack/solid-router"; |
| 2 | 2 | import { For, Index, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; |
| 3 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 3 | 4 | import { createResource } from "@/lib/create-resource"; |
| 4 | 5 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 5 | 6 | import { |
| @@ -118,10 +119,12 @@ function PaymentsContent() { | ||
| 118 | 119 | onCleanup(() => clearTimeout(queryTimer)); |
| 119 | 120 | |
| 120 | 121 | const [studentPage, setStudentPage] = createSignal(0); |
| 121 | - // Reset to page 1 whenever the query or plan filter changes underneath it. | |
| 122 | + const studentPageSize = createResponsivePageSize(STUDENT_PAGE_SIZE); | |
| 123 | + // Reset to page 1 whenever the query, plan filter or page size changes underneath it. | |
| 122 | 124 | createEffect(() => { |
| 123 | 125 | debouncedQuery(); |
| 124 | 126 | planFilter(); |
| 127 | + studentPageSize(); | |
| 125 | 128 | setStudentPage(0); |
| 126 | 129 | }); |
| 127 | 130 | |
| @@ -134,7 +137,7 @@ function PaymentsContent() { | ||
| 134 | 137 | // (already name-resolved) plan roster and filters/pages it client-side — |
| 135 | 138 | // a plan's assignees are a small, bounded list on their own. |
| 136 | 139 | const [studentsPage, { refetch: refetchStudents }] = createResource( |
| 137 | - () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: STUDENT_PAGE_SIZE }), | |
| 140 | + () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: studentPageSize() }), | |
| 138 | 141 | async ({ plan, q, page, size }): Promise<{ items: PersonRef[]; total: number }> => { |
| 139 | 142 | if (plan) { |
| 140 | 143 | const assignments = await getPlanAssignments(plan, { limit: 500 }); |
| @@ -650,7 +653,7 @@ function PaymentsContent() { | ||
| 650 | 653 | enablePagination |
| 651 | 654 | manualPagination={{ |
| 652 | 655 | pageIndex: studentPage(), |
| 653 | - pageSize: STUDENT_PAGE_SIZE, | |
| 656 | + pageSize: studentPageSize(), | |
| 654 | 657 | total: studentsTotal(), |
| 655 | 658 | onPageChange: setStudentPage, |
| 656 | 659 | }} |
src/pages/question-bank-page.tsxmodified+9 -5
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { useNavigate } from "@tanstack/solid-router"; |
| 2 | -import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | |
| 2 | +import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; | |
| 3 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 3 | 4 | import { createResource } from "@/lib/create-resource"; |
| 4 | 5 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 5 | 6 | import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions"; |
| @@ -45,6 +46,8 @@ function QuestionBankContent() { | ||
| 45 | 46 | const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school"; |
| 46 | 47 | const [subjectFilter, setSubjectFilter] = createSignal("all"); |
| 47 | 48 | const [page, setPage] = createSignal(0); |
| 49 | + const pageSize = createResponsivePageSize(BANK_PAGE_SIZE); | |
| 50 | + createEffect(on(pageSize, () => setPage(0), { defer: true })); | |
| 48 | 51 | const [query, setQuery, debouncedQuery] = createDebouncedSignal(); |
| 49 | 52 | const [createOpen, setCreateOpen] = createSignal(false); |
| 50 | 53 | const [editing, setEditing] = createSignal<BankQuestion | null>(null); |
| @@ -58,6 +61,7 @@ function QuestionBankContent() { | ||
| 58 | 61 | const [list, { refetch }] = createResource( |
| 59 | 62 | () => ({ |
| 60 | 63 | page: page(), |
| 64 | + size: pageSize(), | |
| 61 | 65 | owner: ownerFilter(), |
| 62 | 66 | subject: subjectFilter(), |
| 63 | 67 | visibility: visibilityFilter(), |
| @@ -65,8 +69,8 @@ function QuestionBankContent() { | ||
| 65 | 69 | }), |
| 66 | 70 | async (filters) => { |
| 67 | 71 | const result = await getBankQuestions({ |
| 68 | - limit: BANK_PAGE_SIZE, | |
| 69 | - offset: filters.page * BANK_PAGE_SIZE, | |
| 72 | + limit: filters.size, | |
| 73 | + offset: filters.page * filters.size, | |
| 70 | 74 | ...(filters.owner === "me" ? { owner: "me" } : {}), |
| 71 | 75 | ...(filters.subject !== "all" ? { subject: filters.subject } : {}), |
| 72 | 76 | ...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}), |
| @@ -84,7 +88,7 @@ function QuestionBankContent() { | ||
| 84 | 88 | // Deleting the last row of the last page shrinks the page count under the |
| 85 | 89 | // current page; the table then hides its pagination bar entirely and the user |
| 86 | 90 | // is stranded with no control to get back. Same clamp as exam-questions-panel. |
| 87 | - const pageCount = () => Math.max(1, Math.ceil(total() / BANK_PAGE_SIZE)); | |
| 91 | + const pageCount = () => Math.max(1, Math.ceil(total() / pageSize())); | |
| 88 | 92 | createEffect(() => { |
| 89 | 93 | if (page() >= pageCount()) setPage(pageCount() - 1); |
| 90 | 94 | }); |
| @@ -267,7 +271,7 @@ function QuestionBankContent() { | ||
| 267 | 271 | setPage(0); |
| 268 | 272 | }} |
| 269 | 273 | enablePagination |
| 270 | - manualPagination={{ pageIndex: page(), pageSize: BANK_PAGE_SIZE, total: total(), onPageChange: setPage }} | |
| 274 | + manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }} | |
| 271 | 275 | empty={t("bank.empty")} |
| 272 | 276 | storageKey="question-bank" |
| 273 | 277 | onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })} |
src/pages/staff-work-page.tsxmodified+7 -4
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { For, Show, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 2 | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | 4 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 4 | 5 | import { deleteWorkEntryById } from "@/api/work"; |
| @@ -23,7 +24,7 @@ import { DatePicker } from "@/components/ui/date-picker"; | ||
| 23 | 24 | import { IconChevronRight, IconEdit, IconTrash } from "@/components/ui/icons"; |
| 24 | 25 | import { Input } from "@/components/ui/input"; |
| 25 | 26 | import { Label } from "@/components/ui/label"; |
| 26 | -import { PaginationControls } from "@/components/ui/pagination-controls"; | |
| 27 | +import { TablePagination } from "@/components/ui/table-pagination"; | |
| 27 | 28 | import { SidePanel } from "@/components/ui/side-panel"; |
| 28 | 29 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 29 | 30 | import { formatDateTime, formatDurationMinutes } from "@/lib/format"; |
| @@ -145,6 +146,7 @@ function StaffWorkContent() { | ||
| 145 | 146 | |
| 146 | 147 | const [staffSearch, setStaffSearch] = createSignal(""); |
| 147 | 148 | const [staffPage, setStaffPage] = createSignal(0); |
| 149 | + const peoplePageSize = createResponsivePageSize(PEOPLE_PAGE_SIZE); | |
| 148 | 150 | |
| 149 | 151 | const entryRows = () => entries().items; |
| 150 | 152 | const peopleLoading = () => people.loading; |
| @@ -155,10 +157,11 @@ function StaffWorkContent() { | ||
| 155 | 157 | const q = staffSearch().trim(); |
| 156 | 158 | return q ? people().filter((person) => searchPerson(person, q)) : people(); |
| 157 | 159 | }); |
| 158 | - const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / PEOPLE_PAGE_SIZE))); | |
| 159 | - const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * PEOPLE_PAGE_SIZE, staffPage() * PEOPLE_PAGE_SIZE + PEOPLE_PAGE_SIZE)); | |
| 160 | + const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / peoplePageSize()))); | |
| 161 | + const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * peoplePageSize(), (staffPage() + 1) * peoplePageSize())); | |
| 160 | 162 | createEffect(() => { |
| 161 | 163 | staffSearch(); |
| 164 | + peoplePageSize(); | |
| 162 | 165 | setStaffPage(0); |
| 163 | 166 | }); |
| 164 | 167 | |
| @@ -326,7 +329,7 @@ function StaffWorkContent() { | ||
| 326 | 329 | )} |
| 327 | 330 | </For> |
| 328 | 331 | </div> |
| 329 | - <PaginationControls page={staffPage()} totalPages={staffPageCount()} onPageChange={setStaffPage} /> | |
| 332 | + <TablePagination pageIndex={staffPage()} pageCount={staffPageCount()} onPageChange={setStaffPage} /> | |
| 330 | 333 | </Show> |
| 331 | 334 | </Show> |
| 332 | 335 | </div> |
src/pages/students-roster-page.tsxmodified+13 -9
| @@ -15,7 +15,7 @@ import { ComingSoonBadge, ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 15 | 15 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 16 | 16 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 17 | 17 | import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; |
| 18 | -import { Select } from "@/components/ui/select"; | |
| 18 | +import { DropdownSelect } from "@/components/ui/select"; | |
| 19 | 19 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 20 | 20 | import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 21 | 21 | import { useT } from "@/stores/preferences-context"; |
| @@ -154,14 +154,18 @@ function StudentsRosterContent() { | ||
| 154 | 154 | } |
| 155 | 155 | filters={ |
| 156 | 156 | <> |
| 157 | - <Select aria-label={t("roster.class")} value={classFilter()} onChange={(e) => setClassFilter(e.currentTarget.value)} wrapperClass="w-auto"> | |
| 158 | - <option value="">{t("roster.classAll")}</option> | |
| 159 | - <For each={value().classes}>{(cls) => <option value={cls.id}>{cls.name}</option>}</For> | |
| 160 | - </Select> | |
| 161 | - <Select aria-label={t("academicYears.year")} value={yearFilter()} onChange={(e) => setYearFilter(e.currentTarget.value)} wrapperClass="w-auto"> | |
| 162 | - <option value="">{t("common.all")}</option> | |
| 163 | - <For each={value().years}>{(year) => <option value={year.id}>{year.name}</option>}</For> | |
| 164 | - </Select> | |
| 157 | + <DropdownSelect | |
| 158 | + labelPrefix={t("roster.class")} | |
| 159 | + value={classFilter()} | |
| 160 | + onChange={setClassFilter} | |
| 161 | + options={[{ value: "", label: t("common.all") }, ...value().classes.map((cls) => ({ value: cls.id, label: cls.name }))]} | |
| 162 | + /> | |
| 163 | + <DropdownSelect | |
| 164 | + labelPrefix={t("academicYears.year")} | |
| 165 | + value={yearFilter()} | |
| 166 | + onChange={setYearFilter} | |
| 167 | + options={[{ value: "", label: t("common.all") }, ...value().years.map((year) => ({ value: year.id, label: year.name }))]} | |
| 168 | + /> | |
| 165 | 169 | </> |
| 166 | 170 | } |
| 167 | 171 | enablePagination |
src/pages/whiteboards-page.tsxmodified+9 -7
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { useNavigate } from "@tanstack/solid-router"; |
| 2 | -import { For, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; | |
| 2 | +import { For, Show, Suspense, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js"; | |
| 3 | +import { createResponsivePageSize } from "@/lib/create-page-size"; | |
| 3 | 4 | import { createResource } from "@/lib/create-resource"; |
| 4 | 5 | import { getBoards, postBoard, type Board } from "@/api/boards"; |
| 5 | 6 | import { getUserSearch } from "@/api/users"; |
| @@ -38,14 +39,15 @@ function WhiteboardsContent() { | ||
| 38 | 39 | const auth = useAuth(); |
| 39 | 40 | const navigate = useNavigate(); |
| 40 | 41 | |
| 41 | - const PAGE_SIZE = 12; | |
| 42 | + const pageSize = createResponsivePageSize(12); | |
| 42 | 43 | const [page, setPage] = createSignal(0); |
| 44 | + createEffect(on(pageSize, () => setPage(0), { defer: true })); | |
| 43 | 45 | const [boards, { refetch }] = createResource( |
| 44 | - page, | |
| 45 | - (pageIndex) => getBoards({ limit: PAGE_SIZE, offset: pageIndex * PAGE_SIZE }), | |
| 46 | + () => ({ page: page(), size: pageSize() }), | |
| 47 | + (source) => getBoards({ limit: source.size, offset: source.page * source.size }), | |
| 46 | 48 | ); |
| 47 | 49 | const [createOpen, setCreateOpen] = createSignal(false); |
| 48 | - const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / PAGE_SIZE))); | |
| 50 | + const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / pageSize()))); | |
| 49 | 51 | const [query, setQuery] = createSignal(""); |
| 50 | 52 | // The board list endpoint has no server-side text filter, so this narrows |
| 51 | 53 | // only the current page's real titles — a client-side search over real |
| @@ -98,11 +100,11 @@ function WhiteboardsContent() { | ||
| 98 | 100 | </For> |
| 99 | 101 | </div> |
| 100 | 102 | </Show> |
| 101 | - <Show when={(boards()?.total ?? 0) > PAGE_SIZE}> | |
| 103 | + <Show when={(boards()?.total ?? 0) > pageSize()}> | |
| 102 | 104 | <TablePagination |
| 103 | 105 | pageIndex={page()} |
| 104 | 106 | pageCount={pageCount()} |
| 105 | - pageSize={PAGE_SIZE} | |
| 107 | + pageSize={pageSize()} | |
| 106 | 108 | total={boards()?.total ?? 0} |
| 107 | 109 | onPageChange={setPage} |
| 108 | 110 | /> |