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