diff --git a/src/components/ai/insights-board.tsx b/src/components/ai/insights-board.tsx index ea3a8d0..319e8f4 100644 --- a/src/components/ai/insights-board.tsx +++ b/src/components/ai/insights-board.tsx @@ -98,7 +98,7 @@ export function InsightsBoard() { diff --git a/src/components/courses/course-offerings-panel.tsx b/src/components/courses/course-offerings-panel.tsx index dee6b96..445c983 100644 --- a/src/components/courses/course-offerings-panel.tsx +++ b/src/components/courses/course-offerings-panel.tsx @@ -105,7 +105,7 @@ export function CourseOfferingsPanel(props: { courseId: string; courseTitle: str onRowClick={(offering) => open(offering)} actions={ - diff --git a/src/components/courses/course-subjects-panel.tsx b/src/components/courses/course-subjects-panel.tsx index ba78b7f..263144b 100644 --- a/src/components/courses/course-subjects-panel.tsx +++ b/src/components/courses/course-subjects-panel.tsx @@ -177,7 +177,7 @@ export function CourseSubjectsPanel(props: { courseId: string; canManage: boolea empty={t("subjects.empty")} emptyIllustration="courses" actions={props.canManage ? ( - ) : undefined} diff --git a/src/components/courses/course-teachers-panel.tsx b/src/components/courses/course-teachers-panel.tsx index 6131679..2882b1e 100644 --- a/src/components/courses/course-teachers-panel.tsx +++ b/src/components/courses/course-teachers-panel.tsx @@ -121,7 +121,7 @@ export function CourseTeachersPanel(props: { empty={t("courses.noTeachers")} emptyIllustration="people" actions={props.canStaff ? ( - ) : undefined} diff --git a/src/components/courses/offering-panel.tsx b/src/components/courses/offering-panel.tsx index 29e966f..ccaa1bd 100644 --- a/src/components/courses/offering-panel.tsx +++ b/src/components/courses/offering-panel.tsx @@ -33,7 +33,6 @@ import { gradeLevelLabel } from "@/lib/grade-level"; import { useT } from "@/stores/preferences-context"; const SECTION = "space-y-3 border-t border-border-hairline pt-4"; -const SECTION_HEAD = "flex flex-wrap items-start justify-between gap-2"; /** * One grade template of a catalog course: `offering` null creates it (grade @@ -199,36 +198,28 @@ export function OfferingPanel(props: {
-
-
-

{t("weeklyPlan.title")}

- -
- - - +
+

{t("weeklyPlan.title")}

+
void guard(async () => { await deleteOfferingWeeklySlotById(offering().id, slot.id); await refetchSlots(); }) : undefined} + actions={ + + + + } />
-
-
-

{t("instances.examWeightsTitle")}

- -
- - - +
+

{t("instances.examWeightsTitle")}

+
{ await patchOfferingExamWeight(offering().id, entry); await refetchWeights(); }} onRemove={async (kind) => { await deleteOfferingExamWeightByKind(offering().id, kind); await refetchWeights(); }} + actions={ + + + + } />
diff --git a/src/components/events/event-roll-call.tsx b/src/components/events/event-roll-call.tsx index fb950d4..8bcd653 100644 --- a/src/components/events/event-roll-call.tsx +++ b/src/components/events/event-roll-call.tsx @@ -7,6 +7,7 @@ import type { AttendanceStatus, EventRosterEntry } from "@/api/client"; import { Alert } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { DataTableSearch } from "@/components/ui/data-table-search"; +import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { EmptyState } from "@/components/ui/empty-state"; import { InfoTip } from "@/components/ui/info-tip"; import { IconCheck } from "@/components/ui/icons"; @@ -212,7 +213,7 @@ export function EventRollCall(props: { type="button" size="sm" variant="outline" - class="h-8 rounded-lg" + class={cn(TOOLBAR_CONTROL, "px-3.5")} disabled={locked() || unmarkedIds().length === 0} onClick={markRestPresent} > @@ -223,7 +224,7 @@ export function EventRollCall(props: { type="button" size="sm" variant="outline" - class="h-8 rounded-lg" + class={cn(TOOLBAR_CONTROL, "px-3.5")} aria-pressed={onlyUnmarked()} onClick={() => setOnlyUnmarked((value) => !value)} > diff --git a/src/components/exams/exam-audience-panel.tsx b/src/components/exams/exam-audience-panel.tsx index bc37f25..5c48284 100644 --- a/src/components/exams/exam-audience-panel.tsx +++ b/src/components/exams/exam-audience-panel.tsx @@ -186,7 +186,7 @@ export function ExamAudiencePanel(props: { enableColumnVisibility={false} actions={ - diff --git a/src/components/exams/exam-questions-panel.tsx b/src/components/exams/exam-questions-panel.tsx index d306f3f..25590ed 100644 --- a/src/components/exams/exam-questions-panel.tsx +++ b/src/components/exams/exam-questions-panel.tsx @@ -20,11 +20,13 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; +import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { SidePanel } from "@/components/ui/side-panel"; import { BankQuestionPicker } from "@/components/exams/bank-question-picker"; import { QuestionForm, type QuestionValues } from "@/components/exams/question-form"; import { IconArchive, IconChevronLeft, IconChevronRight, IconPlus, IconRefresh, IconTrash } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; +import { cn } from "@/lib/cn"; import { createFlash } from "@/lib/flash"; import { hasMinRole } from "@/lib/roles"; import { useAuth } from "@/stores/auth-context"; @@ -265,13 +267,13 @@ export function ExamQuestionsPanel(props: { -
+
) : undefined} diff --git a/src/components/insights/insight-run-report.tsx b/src/components/insights/insight-run-report.tsx index 78a0dd8..0808a2a 100644 --- a/src/components/insights/insight-run-report.tsx +++ b/src/components/insights/insight-run-report.tsx @@ -443,16 +443,18 @@ export function InsightRunReport(props: { run: InsightRun }) { return (
-
- - - @@ -460,7 +462,6 @@ export function InsightRunReport(props: { run: InsightRun }) {
@@ -179,17 +179,6 @@ export function InstanceSettingsPanel(props: { - - {resetButton({ fields: ["exam_weights"], label: t("instances.examWeightsTitle"), run: () => deleteInstanceExamWeights(props.instance.id) })} - - - - } > mutate(() => patchInstanceExamWeight(props.instance.id, entry))} onRemove={props.instance.exam_weights_inherited ? undefined : (kind) => mutate(() => deleteInstanceExamWeightByKind(props.instance.id, kind))} + actions={ + + + {resetButton({ fields: ["exam_weights"], label: t("instances.examWeightsTitle"), run: () => deleteInstanceExamWeights(props.instance.id) })} + + + + } /> diff --git a/src/components/instances/instance-weekly-plan-panel.tsx b/src/components/instances/instance-weekly-plan-panel.tsx index 6703b47..fde4b57 100644 --- a/src/components/instances/instance-weekly-plan-panel.tsx +++ b/src/components/instances/instance-weekly-plan-panel.tsx @@ -52,40 +52,42 @@ export function InstanceWeeklyPlanPanel(props: { - - - - - - - - - } >
{error()} - void remove(slot) : undefined} /> + void remove(slot) : undefined} + actions={ + + + + + + + + + + } + /> 0} fallback={

{t("instances.allSubjectsSelected")}

}> + {/* Picker and button are one control row: both take the toolbar + pill so the button is not a 26px chip beside a 36px field. */}
void run(async () => { await props.onAdd(pick()); setPick(""); })} > diff --git a/src/components/instances/weekly-plan-table.tsx b/src/components/instances/weekly-plan-table.tsx index 8d7ab18..3fe8537 100644 --- a/src/components/instances/weekly-plan-table.tsx +++ b/src/components/instances/weekly-plan-table.tsx @@ -1,4 +1,4 @@ -import { createMemo } from "solid-js"; +import { createMemo, type JSX } from "solid-js"; import type { ColumnDef } from "@tanstack/solid-table"; import type { WeeklySlot } from "@/api/client"; import { DataTable } from "@/components/ui/data-table"; @@ -7,8 +7,12 @@ import { TableRowActions } from "@/components/ui/table-row-actions"; import { minutesToHHmm, sortSlots, weekdayLabel } from "@/lib/weekly-plan"; import { usePreferences, useT } from "@/stores/preferences-context"; -/** A weekly plan's slots, weekday first; removable when `onRemove` is given. */ -export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot: WeeklySlot) => void; empty?: string }) { +/** + * A weekly plan's slots, weekday first; removable when `onRemove` is given. + * `actions` (add slot, generate, reset) sit in the table's toolbar card beside + * "Sütunlar", not in a header row above it. + */ +export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot: WeeklySlot) => void; empty?: string; actions?: JSX.Element }) { const t = useT(); const { locale } = usePreferences(); const rows = createMemo(() => sortSlots(props.slots)); @@ -50,5 +54,5 @@ export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot: ] : []), ]); - return ; + return ; } diff --git a/src/components/meals/meal-dish-list.tsx b/src/components/meals/meal-dish-list.tsx index b3747d6..99b7780 100644 --- a/src/components/meals/meal-dish-list.tsx +++ b/src/components/meals/meal-dish-list.tsx @@ -2,8 +2,10 @@ import { For, Show } from "solid-js"; import type { MealDish } from "@/api/client"; import { MealDishRow } from "@/components/meals/meal-dish-row"; import { Button } from "@/components/ui/button"; +import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { EmptyInline } from "@/components/ui/empty-inline"; import { IconAlert, IconPlus } from "@/components/ui/icons"; +import { cn } from "@/lib/cn"; import { dietaryTagLabel, formatTry } from "@/lib/meals"; import { useT } from "@/stores/preferences-context"; @@ -27,7 +29,7 @@ export function MealDishList(props: {

{t("meals.dishCount", { count: props.dishes.length })}

- diff --git a/src/components/meals/meal-week-nav.tsx b/src/components/meals/meal-week-nav.tsx index 87c7e59..2f9e553 100644 --- a/src/components/meals/meal-week-nav.tsx +++ b/src/components/meals/meal-week-nav.tsx @@ -3,12 +3,15 @@ import type { MealSlot } from "@/api/client"; import { Button } from "@/components/ui/button"; import { DatePicker } from "@/components/ui/date-picker"; import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; +import { TOOLBAR_CARD, TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { Select } from "@/components/ui/select"; +import { cn } from "@/lib/cn"; import { inputDateToIso } from "@/lib/datetime-input"; import { addDaysIso, formatMealWeek, mealSlotLabel, weekStartIso } from "@/lib/meals"; import { useT } from "@/stores/preferences-context"; -/** Week stepper, a date jump and the slot filter — the list's whole toolbar. */ +/** Week stepper, a date jump and the slot filter — the list's whole toolbar, + * on its own card with every control at the shared toolbar height. */ export function MealWeekNav(props: { weekStart: string; thisWeek: string; @@ -19,29 +22,31 @@ export function MealWeekNav(props: { onSlotChange: (slot: string) => void; }) { const t = useT(); + const step = "h-10 w-10 rounded-full sm:h-8 sm:w-8 touch:h-10 touch:w-10"; return ( -
+
- -

{formatMealWeek(props.weekStart, props.locale)}

-
{ const iso = inputDateToIso(value); if (iso) props.onWeekChange(weekStartIso(iso), iso); }} /> - props.onSlotChange(e.currentTarget.value)}> {(item) => } diff --git a/src/components/sessions/course-sessions-panel.tsx b/src/components/sessions/course-sessions-panel.tsx index b90b36a..7f13dd2 100644 --- a/src/components/sessions/course-sessions-panel.tsx +++ b/src/components/sessions/course-sessions-panel.tsx @@ -286,7 +286,7 @@ export function CourseSessionsPanel(props: { empty={t("sessions.empty")} onRowClick={setDetailSession} actions={props.canManage ? ( - ) : undefined} diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index d27cd2f..e3b057e 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -9,11 +9,18 @@ export const buttonVariants = cva( variants: { variant: { // Flat (no shadows), neutral fills, subtle hairline outlines. - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90", + // Filled variants carry a transparent 1px border and clip their fill + // to the padding box: the box matches an outline button's height, and + // the visible fill sits 1px inside it like an outline's hairline, so a + // filled pill never reads bigger than the bordered pill next to it. + // A filled button never gets a border in its own fill colour. + default: "border border-transparent bg-primary bg-clip-padding text-primary-foreground hover:bg-primary/90", + destructive: + "border border-transparent bg-destructive bg-clip-padding text-destructive-foreground hover:bg-destructive/90", outline: "border border-border/70 bg-transparent hover:border-border hover:bg-muted/60 hover:text-foreground", - secondary: "border border-border/60 bg-secondary text-secondary-foreground hover:bg-secondary/80", + secondary: + "border border-transparent bg-secondary bg-clip-padding text-secondary-foreground hover:bg-secondary/80", ghost: "text-foreground/75 hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent", link: "text-primary-text underline-offset-4 hover:underline active:scale-100", }, diff --git a/src/components/ui/data-section.tsx b/src/components/ui/data-section.tsx index 046f560..e8299a1 100644 --- a/src/components/ui/data-section.tsx +++ b/src/components/ui/data-section.tsx @@ -1,4 +1,5 @@ import { Show, type JSX, type ParentProps } from "solid-js"; +import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { cn } from "@/lib/cn"; /** @@ -22,7 +23,9 @@ export function DataSection(
-
{props.actions}
+ {/* Header actions are toolbar controls too: the same pill and height + as a DataTable toolbar, never a taller h-9 button of their own. */} +
{props.actions}
diff --git a/src/components/ui/data-table-search.tsx b/src/components/ui/data-table-search.tsx index 624abdf..1632de8 100644 --- a/src/components/ui/data-table-search.tsx +++ b/src/components/ui/data-table-search.tsx @@ -51,7 +51,8 @@ export function DataTableSearch(props: DataTableSearchProps) { aria-describedby={props.hint ? hintId : undefined} // Touch screens get a touch-sized box at 16px (index.css): below that // iOS Safari zooms the page into a focused field. Compact otherwise. - class={cn("h-10 rounded-lg bg-muted/40 text-base sm:h-8 sm:text-[13px] md:text-[13px] touch:h-10", props.value ? "pl-9 pr-8" : "pl-9")} + // A pill, like every other toolbar control beside it. + class={cn("h-10 rounded-full bg-muted/40 text-base sm:h-8 sm:text-[13px] md:text-[13px] touch:h-10", props.value ? "pl-9 pr-8" : "pl-9")} /> } + /> )); - const toolbar = container.querySelector(".space-y-3 > div"); - expect(toolbar?.className).not.toContain("rounded-xl"); + const add = [...container.querySelectorAll("button")].find((el) => el.textContent === "Add"); + expect(add?.parentElement?.className).toContain("sm:[&_button]:h-8"); }); test("meta.headerInfo puts a labelled info icon beside the header that opens without sorting", async () => { @@ -359,3 +383,28 @@ test("meta.headerInfo puts a labelled info icon beside the header that opens wit // No always-visible copy of the note is left in the table. expect(document.querySelector("table")?.textContent).not.toContain("Filled in for small schools only."); }); + +test("an infinite table asks for the next page near its end and does not sort", async () => { + const reachEnd = stubIntersectionObserver(); + const onLoadMore = vi.fn(); + const rows = Array.from({ length: 50 }, (_, index) => ({ name: `Person ${index + 1}` })); + try { + render(() => ( + + + + )); + expect(screen.getByText("Person 50")).toBeTruthy(); + expect(screen.getByText(/(Showing 50 of 120|120 kayıttan 50)/)).toBeTruthy(); + expect(screen.getByRole("columnheader").getAttribute("aria-sort")).not.toBe("ascending"); + reachEnd(); + expect(onLoadMore).toHaveBeenCalledTimes(1); + } finally { + vi.unstubAllGlobals(); + } +}); diff --git a/src/components/ui/data-table.tsx b/src/components/ui/data-table.tsx index 971936c..42f4045 100644 --- a/src/components/ui/data-table.tsx +++ b/src/components/ui/data-table.tsx @@ -11,7 +11,6 @@ import { flexRender, getCoreRowModel, getFilteredRowModel, - getPaginationRowModel, getSortedRowModel, } from "@tanstack/solid-table"; import { Illustration } from "@/components/ui/illustration"; @@ -24,9 +23,9 @@ import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/ import { InfoTip } from "@/components/ui/info-tip"; import { cn } from "@/lib/cn"; import { createMediaQuery } from "@/lib/create-media-query"; -import { COMPACT_SCREEN_QUERY, createResponsivePageSize } from "@/lib/create-page-size"; +import { COMPACT_SCREEN_QUERY } from "@/lib/create-page-size"; import { createTablePreferences } from "@/lib/table-preferences"; -import { createUrlPageIndex, createUrlParam, createUrlString, decodeSort, encodeSort, listParamKeys } from "@/lib/url-state"; +import { createUrlParam, createUrlString, decodeSort, encodeSort, listParamKeys } from "@/lib/url-state"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { useT } from "@/stores/preferences-context"; @@ -78,6 +77,19 @@ export type DataTableProps = { total: number; onPageChange: (pageIndex: number) => void; }; + /** + * Fetch-as-you-scroll: `data` holds the rows loaded so far and the table + * asks for the next page (`onLoadMore`) as the reader nears its end. Pair + * with `createInfiniteList` (lib/infinite-list); search must reach the + * server through `onSearchInput`, and sorting is off (the backend takes no + * sort parameter, so a header sort would order the loaded rows alone). + */ + infinite?: { + hasMore: boolean; + loading: boolean; + total: number; + onLoadMore: () => void; + }; /** * Below the `sm` breakpoint rows render as cards (first column as the * title, actions top-right, the rest as label/value pairs) instead of a @@ -86,7 +98,10 @@ export type DataTableProps = { mobileLayout?: "cards" | "scroll"; onRowClick?: (row: TData) => void; onSearchInput?: (value: string) => void; - /** Rows per page on a wide screen; phones get `compactPageSize` of it. */ + /** + * Server-paged tables only: rows per page on a wide screen. A client-side + * table has no pages — it reveals rows as the reader scrolls. + */ pageSize?: number; searchPredicate?: (row: TData, query: string) => boolean; searchValue?: string; @@ -105,7 +120,7 @@ export type DataTableProps = { * `searchValue` / `onSearchInput` keeps its own. */ urlState?: boolean | string; - /** Back to page one whenever this changes — pass the caller's own filters. */ + /** Back to the top of the list whenever this changes — pass the caller's own filters. */ pageResetKey?: unknown; /** * The caller's own filters narrow the list. An empty result then offers @@ -120,6 +135,15 @@ const resolveUpdater = (updater: Updater, old: T): T => const alignClass = { left: "text-left", center: "text-center", right: "text-right" } as const; +/** + * A client-side table renders this many rows, then this many more each time + * the reader nears the end. The data is already in memory, so sorting, search + * and filters still see every row — only the DOM is paced. + */ +const REVEAL_STEP = 50; +/** Start revealing the next rows this far before the list's end comes into view. */ +const REVEAL_MARGIN_PX = 600; + export function DataTable(props: DataTableProps) { const t = useT(); const paginationEnabled = props.enablePagination ?? true; @@ -132,15 +156,12 @@ export function DataTable(props: DataTableProps(urlKeys.sort, { parse: decodeSort, serialize: encodeSort }) : createSignal([]); const [otherColumnFilters, setOtherColumnFilters] = createSignal([]); - const clientPageSize = createResponsivePageSize(props.pageSize ?? 10); - const [clientPageIndex, setClientPageIndex] = urlKeys && !props.manualPagination - ? createUrlPageIndex(urlKeys.page) - : createSignal(0); - const pagination = (): PaginationState => ({ pageIndex: clientPageIndex(), pageSize: clientPageSize() }); - // A page index means nothing once the page size changes under it (a phone - // rotated, a window narrowed): start over rather than land mid-list. - createEffect(on(clientPageSize, () => setClientPageIndex(0), { defer: true })); - createEffect(on(() => props.pageResetKey, () => setClientPageIndex(0), { defer: true })); + // Client-side tables drop page numbers for scroll-to-reveal; only a + // server-paged table (`manualPagination`) still pages. + const revealing = () => paginationEnabled && !props.manualPagination && !props.infinite; + const [revealed, setRevealed] = createSignal(REVEAL_STEP); + const resetReveal = () => setRevealed(REVEAL_STEP); + createEffect(on(() => props.pageResetKey, resetReveal, { defer: true })); // The search box's text when the table owns it — the `searchPredicate` // query, or the `filterColumn` filter value. const [search, setSearch] = urlKeys && props.searchValue === undefined && !props.onSearchInput @@ -164,16 +185,17 @@ export function DataTable(props: DataTableProps filter.id === column); setSearch(typeof own?.value === "string" ? own.value : ""); setOtherColumnFilters(next.filter((filter) => filter.id !== column)); + resetReveal(); }; - // A sort order reshuffles every page: start from the first one. + // A new sort order is a new list: start again from its top. const setSorting = (next: SortingState) => { setSortingState(next); - setClientPageIndex(0); + resetReveal(); }; // Sorting is client-side only, and the backend takes no sort parameter: on // a server-paged table it would reorder the visible page alone while the // header claimed the whole list. Off there unless a caller opts in. - const sortingEnabled = () => props.enableSorting ?? !props.manualPagination; + const sortingEnabled = () => props.enableSorting ?? !(props.manualPagination || props.infinite); const tableData = () => { const query = searchValue().trim(); if (!query || !props.searchPredicate) return props.data; @@ -195,17 +217,12 @@ export function DataTable(props: DataTableProps setSorting(resolveUpdater(updater, sorting())), onColumnFiltersChange: (updater) => setColumnFilters(resolveUpdater(updater, columnFilters())), onColumnVisibilityChange: (updater) => prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)), - onPaginationChange: (updater) => setClientPageIndex(resolveUpdater(updater, pagination()).pageIndex), state: { get sorting() { return sorting(); @@ -216,10 +233,10 @@ export function DataTable(props: DataTableProps(props: DataTableProps props.surfaceSections !== false; const showHeader = () => false; const showToolbar = () => showSearch() || props.filters != null || showColumnMenu() || props.actions != null; - // A lone "Sütunlar" button does not need a card of its own: a full-width - // box with one button at its far end only adds a layer (a third nested box - // inside a detail tab). It sits bare at the right edge instead. - const columnMenuOnly = () => showColumnMenu() && !showSearch() && props.filters == null && props.actions == null; - const pageCount = () => props.manualPagination ? Math.max(1, Math.ceil(props.manualPagination.total / props.manualPagination.pageSize)) : table.getPageCount(); - const pageIndex = () => props.manualPagination?.pageIndex ?? table.getState().pagination.pageIndex; - const pageSize = () => props.manualPagination?.pageSize ?? table.getState().pagination.pageSize; - const totalRows = () => props.manualPagination?.total ?? table.getFilteredRowModel().rows.length; + // Toolbar controls — search, filters, actions, "Sütunlar" — are one pill + // shape and one height on every page: touch-sized (h-10) below `sm` and on touch screens, h-8 + // above. Page actions arrive as plain Buttons (size="sm" is 26px), so the + // slot sizes them rather than trusting each page to. + const TOOLBAR_ACTIONS = + "[&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10 [&_a]:h-10 [&_a]:rounded-full [&_a]:px-3.5 [&_a]:text-[13px] sm:[&_a]:h-8 touch:[&_a]:h-10"; + const totalRows = () => props.manualPagination?.total ?? props.infinite?.total ?? table.getRowModel().rows.length; const setPageIndex = (next: number) => { if (props.manualPagination) props.manualPagination.onPageChange(next); - else setClientPageIndex(next); + else resetReveal(); + }; + /** The rows actually rendered: all of them, or the revealed head of the list. */ + const visibleRows = () => { + const rows = table.getRowModel().rows; + return revealing() ? rows.slice(0, revealed()) : rows; + }; + const hasHidden = () => revealing() && table.getRowModel().rows.length > revealed(); + // A sentinel under the list reveals the next rows as it nears the viewport. + // Without IntersectionObserver (old engines, jsdom) everything renders. + let sentinel: HTMLDivElement | undefined; + const observing = typeof IntersectionObserver !== "undefined"; + const nearEnd = () => !!sentinel && sentinel.getBoundingClientRect().top < window.innerHeight + REVEAL_MARGIN_PX; + const revealMore = () => { + if (!nearEnd()) return; + const infinite = props.infinite; + if (infinite) { + if (infinite.hasMore && !infinite.loading) infinite.onLoadMore(); + return; + } + if (hasHidden()) setRevealed((count) => count + REVEAL_STEP); }; - // A page past the end — rows deleted, a filter narrowed the list, a stale - // `?page=` — slides back to the last page there is. Only once rows exist: - // before the data arrives every page is "past the end". createEffect(() => { - if (props.manualPagination || !paginationEnabled) return; - const rows = table.getFilteredRowModel().rows.length; - if (rows === 0) return; - const last = Math.max(0, Math.ceil(rows / clientPageSize()) - 1); - if (clientPageIndex() > last) setClientPageIndex(last); + if (!(revealing() || props.infinite) || !observing) return; + const node = sentinel; + if (!node) return; + const observer = new IntersectionObserver((entries) => { + if (entries.some((entry) => entry.isIntersecting)) revealMore(); + }, { rootMargin: `0px 0px ${REVEAL_MARGIN_PX}px 0px` }); + observer.observe(node); + onCleanup(() => observer.disconnect()); }); + // The observer only fires when the sentinel crosses the margin; after a + // reveal of short rows it can still sit inside it, so check again. + createEffect(on(revealed, () => queueMicrotask(revealMore), { defer: true })); + // Same for a fetched page: once it lands, a short page may leave the end + // in view, so ask for the next one straight away. + createEffect(on(() => props.infinite?.loading, (busy) => { + if (busy === false && observing) queueMicrotask(revealMore); + }, { defer: true })); + if (!observing) setRevealed(Number.MAX_SAFE_INTEGER); const searchFieldValue = () => { if (props.onSearchInput || props.searchPredicate || props.filterColumn) return searchValue(); return ""; @@ -333,6 +378,7 @@ export function DataTable(props: DataTableProps { if (!(target instanceof Element)) return false; @@ -451,7 +497,7 @@ export function DataTable(props: DataTableProps
-
{props.actions}
+
{props.actions}
@@ -461,7 +507,9 @@ export function DataTable(props: DataTableProps + {/* Always a card when sectioned, even when "Sütunlar" is its only + control, so every list page's toolbar reads the same. */} +
(props: DataTableProps -
{props.filters}
+
{props.filters}
{/* Beside the search the actions keep their own width (the search @@ -481,7 +529,7 @@ export function DataTable(props: DataTableProps -
{props.actions}
+
{props.actions}
@@ -493,10 +541,10 @@ export function DataTable(props: DataTableProps
    0} + when={visibleRows().length > 0} fallback={
  • {emptyContent()}
  • } > - + {(row, rowIndex) => { const cells = () => row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards); @@ -610,7 +658,7 @@ export function DataTable(props: DataTableProps 0} + when={visibleRows().length > 0} fallback={ @@ -619,7 +667,7 @@ export function DataTable(props: DataTableProps } > - + {(row) => ( (props: DataTableProps - 0}> - + + {(manual) => ( + 0}> + + + )} + + 0}> + ); diff --git a/src/components/ui/data-toolbar.tsx b/src/components/ui/data-toolbar.tsx index 7efe7c4..04090eb 100644 --- a/src/components/ui/data-toolbar.tsx +++ b/src/components/ui/data-toolbar.tsx @@ -3,6 +3,24 @@ import type { JSX } from "solid-js"; import { DataTableSearch } from "@/components/ui/data-table-search"; import { cn } from "@/lib/cn"; +/** The card a list toolbar sits on — the same box DataTable draws. */ +export const TOOLBAR_CARD = "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs"; + +/** + * One toolbar control: a pill, touch-sized (h-10) below `sm` and on touch + * screens, h-8 from `sm` up, at 13px. For controls a page places by hand + * (a stepper, a date jump) beside the slot-sized ones. + */ +export const TOOLBAR_CONTROL = "h-10 rounded-full text-[13px] sm:h-8 touch:h-10"; + +/** + * The same standard applied to every button and link inside a slot, so the + * page's plain `
); diff --git a/src/components/ui/infinite-sentinel.tsx b/src/components/ui/infinite-sentinel.tsx new file mode 100644 index 0000000..6c8794a --- /dev/null +++ b/src/components/ui/infinite-sentinel.tsx @@ -0,0 +1,66 @@ +import { Show, createEffect, on, onCleanup } from "solid-js"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/cn"; +import { useT } from "@/stores/preferences-context"; + +/** Ask for the next page this far before the list's end scrolls into view. */ +const LOAD_MARGIN_PX = 600; + +/** + * The end of a fetch-as-you-scroll list that is not a DataTable (card grids, + * message lists). Sits under the last item, asks for the next page as it + * nears the viewport, and says how much of the list is loaded. Pair with + * `createInfiniteList`; DataTable has the same behaviour built in (`infinite`). + */ +export function InfiniteSentinel(props: { + hasMore: boolean; + loading: boolean; + onLoadMore: () => void; + /** Rows loaded so far. */ + shown: number; + total: number; + class?: string; +}) { + const t = useT(); + let sentinel: HTMLDivElement | undefined; + // Without IntersectionObserver there is no reliable "near the end" signal, + // so the next page waits for a button instead of chaining in on its own. + const observing = typeof IntersectionObserver !== "undefined"; + + const nearEnd = () => !!sentinel && sentinel.getBoundingClientRect().top < window.innerHeight + LOAD_MARGIN_PX; + const maybeLoad = () => { + if (props.hasMore && !props.loading && nearEnd()) props.onLoadMore(); + }; + + createEffect(() => { + if (!observing || !sentinel) return; + const observer = new IntersectionObserver((entries) => { + if (entries.some((entry) => entry.isIntersecting)) maybeLoad(); + }, { rootMargin: `0px 0px ${LOAD_MARGIN_PX}px 0px` }); + observer.observe(sentinel); + onCleanup(() => observer.disconnect()); + }); + // A page that lands short of filling the screen leaves the sentinel in + // view, where the observer will not fire again: check once more. + createEffect(on(() => props.loading, (busy) => { + if (!busy && observing) queueMicrotask(maybeLoad); + }, { defer: true })); + + return ( + 0}> + -
+ {/* Header actions are toolbar pills: h-10 below `sm` and on touch, h-8 above. */} +
- diff --git a/src/pages/bank-question-detail-page.tsx b/src/pages/bank-question-detail-page.tsx index 9c5ab72..d7567e8 100644 --- a/src/pages/bank-question-detail-page.tsx +++ b/src/pages/bank-question-detail-page.tsx @@ -28,6 +28,12 @@ import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; import { TableRowActions } from "@/components/ui/table-row-actions"; +// Edit and the actions menu share one row: the toolbar pill, touch-sized +// (h-10) below `sm` and on touch screens, h-8 above. The menu trigger is a +// @@ -123,7 +129,7 @@ function BankQuestionDetailContent() { }]} /> - +
} />
diff --git a/src/pages/builder-school-detail-page.tsx b/src/pages/builder-school-detail-page.tsx index a9c8685..c64d620 100644 --- a/src/pages/builder-school-detail-page.tsx +++ b/src/pages/builder-school-detail-page.tsx @@ -104,17 +104,19 @@ function BuilderSchoolDetailContent() { title={current().name} description={`${current().id} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`} actions={ -
+ // One pill height for every header control: the buttons and + // the row-actions trigger (h-8 on its own) sit in one row. +
- - - diff --git a/src/pages/builder-schools-page.tsx b/src/pages/builder-schools-page.tsx index 0c99ba0..b94ed40 100644 --- a/src/pages/builder-schools-page.tsx +++ b/src/pages/builder-schools-page.tsx @@ -144,7 +144,7 @@ function BuilderSchoolsContent() { title={t("builder.schools")} description={t("builder.schoolsSubtitle")} actions={ - diff --git a/src/pages/calendar-page.tsx b/src/pages/calendar-page.tsx index cddb0c0..402a338 100644 --- a/src/pages/calendar-page.tsx +++ b/src/pages/calendar-page.tsx @@ -437,18 +437,19 @@ function CalendarContent() {

{t("calendar.title")}

- {rangeLabel()} -
{/* Day / week / month, the way a phone calendar switches zoom. */} -
+ {/* Same height and pill as the "Bugün" button beside it. */} +
{(entry) => (
- diff --git a/src/pages/class-detail-page.tsx b/src/pages/class-detail-page.tsx index d7e0d0e..f7dc9ec 100644 --- a/src/pages/class-detail-page.tsx +++ b/src/pages/class-detail-page.tsx @@ -61,8 +61,9 @@ const TILE = "min-w-0 rounded-xl border border-border-hairline bg-surface-tint p const TILE_LABEL = "text-xs font-medium uppercase tracking-[0.08em] text-text-subtle"; const TILE_VALUE = "mt-1 break-words font-medium text-text-default"; -// Header and section buttons share the row-actions trigger's box (h-8, -// rounded-lg) so a button and the ⋮ menu beside it line up. +// Header buttons share the row-actions trigger's box (h-8, rounded-lg) so a +// button and the ⋮ menu beside it line up. Tab toolbar actions go through +// DataTable's `actions` slot, which sizes them as pills like "Sütunlar". const ACTION_BUTTON = "h-8 min-w-[7.5rem] rounded-lg! px-3 text-[13px]"; function ClassDetailContent() { @@ -383,7 +384,7 @@ function ClassDetailContent() { setShowAddMember(true)}> + ) : undefined} @@ -406,7 +407,7 @@ function ClassDetailContent() { setShowAttachCourse(true)}> + ) : undefined} diff --git a/src/pages/classes-page.tsx b/src/pages/classes-page.tsx index 2b559de..24ac7a5 100644 --- a/src/pages/classes-page.tsx +++ b/src/pages/classes-page.tsx @@ -427,7 +427,7 @@ function ClassesContent() { } actions={ - diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index 04aed0b..e46ccc5 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -466,7 +466,7 @@ function CourseDetailContent() { empty={t("exams.emptyRoster")} emptyIllustration="people" actions={ - } diff --git a/src/pages/courses-page.test.tsx b/src/pages/courses-page.test.tsx index 5bf3844..ff71f3d 100644 --- a/src/pages/courses-page.test.tsx +++ b/src/pages/courses-page.test.tsx @@ -124,14 +124,18 @@ test("student course list filters on the server via kind, q and taught", async ( expect(screen.queryByRole("button", { name: /^Robotics/ })).toBeNull(); }); -test("course search checks returned rows when the backend ignores q", async () => { - getCourses.mockResolvedValue({ items: catalog, total: catalog.length, limit: 100, offset: 0 }); +test("course search goes to the server and starts again from the first page", async () => { + getCourses.mockImplementation(async (params: { q?: string; offset?: number }) => + params.q + ? { items: [], total: 0, limit: 50, offset: 0 } + : { items: catalog, total: catalog.length, limit: 50, offset: 0 }, + ); render(() => ); expect(await screen.findByRole("button", { name: /^Algebra/ })).toBeTruthy(); + expect(getCourses.mock.calls[0][0]).toMatchObject({ limit: 50, offset: 0 }); fireEvent.input(screen.getByPlaceholderText("Search…"), { target: { value: "no-such-course" } }); - await waitFor(() => expect(getCourses.mock.calls.at(-1)[0].q).toBe("no-such-course"), { timeout: 2000 }); + await waitFor(() => expect(getCourses.mock.calls.at(-1)[0]).toMatchObject({ q: "no-such-course", limit: 50, offset: 0 }), { timeout: 2000 }); await waitFor(() => expect(screen.queryByRole("button", { name: /^Algebra/ })).toBeNull()); - expect(screen.queryByRole("button", { name: /^Study Lab/ })).toBeNull(); }); diff --git a/src/pages/courses-page.tsx b/src/pages/courses-page.tsx index 753f08a..c96575b 100644 --- a/src/pages/courses-page.tsx +++ b/src/pages/courses-page.tsx @@ -1,7 +1,6 @@ -import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; -import { createResponsivePageSize } from "@/lib/create-page-size"; -import { loadAllPages } from "@/lib/capped-list"; +import { Show, createEffect, createMemo, createSignal } from "solid-js"; import { createResource } from "@/lib/create-resource"; +import { createInfiniteList } from "@/lib/infinite-list"; import { useNavigate, useSearch } from "@tanstack/solid-router"; import type { ColumnDef } from "@tanstack/solid-table"; import { deleteCourseById, getCourses, postCourse } from "@/api/courses"; @@ -28,13 +27,10 @@ import { createDebouncedSignal } from "@/lib/create-debounced-signal"; import { createFlash } from "@/lib/flash"; import { personLabel } from "@/lib/person"; import { hasMinRole } from "@/lib/roles"; -import { matchesSearch } from "@/lib/search-text"; -import { createUrlEnum, readPageIndex, readString } from "@/lib/url-state"; +import { createUrlEnum, readString } from "@/lib/url-state"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; -const PAGE_SIZE = 10; - export default function CoursesPage() { return ; } @@ -55,14 +51,9 @@ function CoursesContent() { const [showForm, setShowForm] = createSignal(routeSearch().action === "new"); const [title, setTitle] = createSignal(""); const [description, setDescription] = createSignal(""); - // URL parameters restore the kind, search, taught filter and page on reload. - // Deployed backends can ignore list filters, so filtered results are checked - // locally after fetching the complete list. + // URL parameters restore the kind, search and taught filter on reload. const [taughtFilter, setTaughtFilter] = createUrlEnum("taught", ["all", "taught", "untaught"] as const, "all"); const taughtParam = () => (taughtFilter() === "taught" ? true : taughtFilter() === "untaught" ? false : undefined); - const pageSize = createResponsivePageSize(PAGE_SIZE); - const [page, setPage] = createSignal(readPageIndex(routeSearch().page)); - createEffect(on(pageSize, () => setPage(0), { defer: true })); const [search, setSearch, debouncedSearch] = createDebouncedSignal(readString(routeSearch().q)); const [error, setError] = createSignal(""); const [pending, setPending] = createSignal(false); @@ -76,50 +67,24 @@ function CoursesContent() { }); const [limits, { refetch: refetchLimits }] = createResource(() => canCreate() ? getLimits() : null); - const filtersActive = () => pageKind() != null || debouncedSearch().trim() !== "" || taughtParam() != null; - // Scoped server-side: a student reads only the courses they take. The - // source carries every input the fetch reads. Filtered lists are read in - // full and checked locally because the current deployment accepts filter - // query keys but can return the unfiltered page and total. - const [list, { refetch }] = createResource( - () => ({ - role: auth.user()?.role ?? null, - kind: pageKind(), - q: debouncedSearch().trim(), - taught: taughtParam(), - page: filtersActive() ? 0 : page(), - size: pageSize(), - }), - async (filters) => { - const requested = { + // Scoped server-side: a student reads only the courses they take. Kind, + // search and the taught filter are all applied by the backend (checked + // live on 2026-09-26), so the catalog loads a page at a time as the reader + // scrolls and any filter change starts again from the top. + const list = createInfiniteList( + () => auth.user() + ? { role: auth.user()!.role, kind: pageKind(), q: debouncedSearch().trim(), taught: taughtParam() } + : null, + (filters, paging) => + getCourses({ + ...paging, ...(filters.kind ? { kind: filters.kind } : {}), ...(filters.q ? { q: filters.q } : {}), ...(filters.taught != null ? { taught: filters.taught } : {}), - }; - if (!filters.kind && !filters.q && filters.taught == null) { - return getCourses({ limit: filters.size, offset: filters.page * filters.size }); - } - const all = await loadAllPages((paging) => getCourses({ ...requested, ...paging })); - const items = all.filter((course) => - (!filters.kind || course.kind === filters.kind) && - (!filters.q || matchesSearch(filters.q, course.title, course.description)) && - (filters.taught == null || (course.class_course_count > 0) === filters.taught), - ); - return { items, total: items.length, limit: filters.size, offset: 0 }; - }, + }), + { equals: (a, b) => a.role === b.role && a.kind === b.kind && a.q === b.q && a.taught === b.taught }, ); - const listData = () => list.latest ?? list(); - const total = () => listData()?.total ?? 0; - const visibleItems = () => { - const items = listData()?.items ?? []; - return filtersActive() ? items.slice(page() * pageSize(), (page() + 1) * pageSize()) : items; - }; - // Deleting the last row of the last page shrinks the page count under the - // current page; clamp instead of stranding the user off the end. - const pageCount = () => Math.max(1, Math.ceil(total() / pageSize())); - createEffect(() => { - if (page() >= pageCount()) setPage(pageCount() - 1); - }); + const refetch = () => list.reload(); const openCourse = (course: Course) => void navigate({ to: "/courses/$id", params: { id: course.id } }); // Catalog rights, as on the detail page: the creator or a manager+. const canManageCatalog = (course: Course) => { @@ -129,9 +94,7 @@ function CoursesContent() { const [editTarget, setEditTarget] = createSignal(null); const [deleteTarget, setDeleteTarget] = createSignal(null); const [rowError, setRowError] = createSignal(""); - const refreshList = async () => { - try { await refetch(); } catch { /* stale rows until the next load */ } - }; + const refreshList = async () => refetch(); const columns = createMemo[]>(() => [ { accessorKey: "title", @@ -294,7 +257,6 @@ function CoursesContent() { onChange={(value) => { const kind = value === "course" || value === "study" || value === "club" ? value : undefined; setPageKind(kind); - setPage(0); void navigate({ to: "/courses", search: (prev) => ({ q: prev.q, taught: prev.taught, sort: prev.sort, action: undefined, kind, page: undefined }), @@ -310,27 +272,22 @@ function CoursesContent() { - }> - - void refetch()} /> - + + {(err) => } + + }> { - setSearch(value); - setPage(0); - }} - enablePagination - manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }} + onSearchInput={setSearch} + infinite={{ hasMore: list.hasMore(), loading: list.loading(), total: list.total(), onLoadMore: list.loadMore }} filtersActive={taughtFilter() !== "all"} onClearFilters={() => { setTaughtFilter("all"); - setPage(0); }} empty={t("courses.empty", { item: kindInSentence() })} onRowClick={openCourse} @@ -341,7 +298,6 @@ function CoursesContent() { value={taughtFilter()} onChange={(value) => { setTaughtFilter(value === "taught" || value === "untaught" ? value : "all"); - setPage(0); }} options={[ { value: "all", label: t("common.all") }, @@ -352,14 +308,14 @@ function CoursesContent() { } actions={ - } /> - +
diff --git a/src/pages/event-detail-page.tsx b/src/pages/event-detail-page.tsx index fbd44d1..65d5253 100644 --- a/src/pages/event-detail-page.tsx +++ b/src/pages/event-detail-page.tsx @@ -21,6 +21,7 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs"; import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { EmptyState } from "@/components/ui/empty-state"; @@ -185,8 +186,8 @@ function EventDetailContent() { description={ev().description || undefined} actions={ canManage() ? ( -
- diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index be1ec96..1e2d748 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -29,6 +29,7 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs"; import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { TOOLBAR_CONTROL, TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconRefresh, IconSchool, IconTrash } from "@/components/ui/icons"; @@ -408,13 +409,16 @@ function ExamDetailContent() { title={ex().title} description={ex().description || undefined} actions={ -
+ // Header buttons and the ⋮ menu are toolbar controls: one pill + // height. The Links are `contents` so the slot sizes the Button + // inside rather than padding the anchor around it. +
- @@ -428,8 +432,8 @@ function ExamDetailContent() { - - @@ -737,7 +741,9 @@ function ExamDetailContent() { - diff --git a/src/pages/exams-page.tsx b/src/pages/exams-page.tsx index 41d1a2a..d612ea6 100644 --- a/src/pages/exams-page.tsx +++ b/src/pages/exams-page.tsx @@ -17,6 +17,7 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; +import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { IconChart, IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons"; import { DropdownSelect } from "@/components/ui/select"; import { SearchableSelect } from "@/components/ui/searchable-select"; @@ -40,6 +41,9 @@ import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; const EXAM_PAGE_SIZE = 10; +// The course combobox is a bordered div, not a @@ -422,7 +426,7 @@ function ExamsContent() { setCourseFilter(val)} options={[ @@ -446,7 +450,7 @@ function ExamsContent() { type="button" variant="ghost" size="sm" - class="h-8 rounded-lg px-3 text-[13px] font-medium text-muted-foreground hover:text-foreground" + class="font-medium text-muted-foreground hover:text-foreground" onClick={clearFilters} > diff --git a/src/pages/holidays-page.tsx b/src/pages/holidays-page.tsx index aaa0949..8ff4395 100644 --- a/src/pages/holidays-page.tsx +++ b/src/pages/holidays-page.tsx @@ -158,7 +158,7 @@ function HolidaysContent() { title={t("holidays.title")} description={t("holidays.subtitle")} actions={ - diff --git a/src/pages/homework-page.tsx b/src/pages/homework-page.tsx index cde5dbb..ad40bfc 100644 --- a/src/pages/homework-page.tsx +++ b/src/pages/homework-page.tsx @@ -14,6 +14,7 @@ import { RouteGuard } from "@/components/layout/route-guard"; import { Alert } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; +import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { DatePicker } from "@/components/ui/date-picker"; import { IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; @@ -27,6 +28,7 @@ import { Textarea } from "@/components/ui/textarea"; import { formatDateTime } from "@/lib/format"; import { hasMinRole } from "@/lib/roles"; import { createUrlString } from "@/lib/url-state"; +import { cn } from "@/lib/cn"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -46,6 +48,10 @@ function dateInputToMs(date: string, time: string): number | null { return d.getTime(); } +// The course combobox is a bordered div, not a diff --git a/src/pages/instance-detail-page.tsx b/src/pages/instance-detail-page.tsx index b33be84..74f0c62 100644 --- a/src/pages/instance-detail-page.tsx +++ b/src/pages/instance-detail-page.tsx @@ -673,7 +673,7 @@ function InstanceDetailContent() { pageSize={10} empty={t("exams.empty")} actions={canManage() ? ( - ) : undefined} @@ -752,7 +752,7 @@ function InstanceDetailContent() { empty={t("exams.emptyRoster")} emptyIllustration="people" actions={ - } diff --git a/src/pages/live-monitor-page.tsx b/src/pages/live-monitor-page.tsx index 6a6c055..e5d49d7 100644 --- a/src/pages/live-monitor-page.tsx +++ b/src/pages/live-monitor-page.tsx @@ -13,6 +13,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DataTable } from "@/components/ui/data-table"; +import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { DetailField } from "@/components/ui/detail-field"; import { IconAlert, IconCheck, IconChevronLeft, IconClock, IconExam, IconEye, IconUsers } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; @@ -263,9 +264,12 @@ function LiveMonitorContent() { title={ex().title} description={isFinished() ? t("exams.finalStateDesc") : t("exams.liveMonitorDesc")} actions={ -
- - diff --git a/src/pages/meal-detail-page.tsx b/src/pages/meal-detail-page.tsx index e0a5c32..1bbb9cf 100644 --- a/src/pages/meal-detail-page.tsx +++ b/src/pages/meal-detail-page.tsx @@ -47,11 +47,13 @@ import { RouteGuard } from "@/components/layout/route-guard"; import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { ErrorAlert } from "@/components/ui/error-alert"; import { IconEdit, IconTrash, IconUsers } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { TableRowActions } from "@/components/ui/table-row-actions"; +import { cn } from "@/lib/cn"; import { formatDateTime } from "@/lib/format"; import { formatMealDay, formatTry, mealCutoffAt, mealSlotLabel } from "@/lib/meals"; import { personLabel } from "@/lib/person"; @@ -214,12 +216,12 @@ function MealDetailContent() { description={formatMealDay(current().date, moneyLocale(), true)} actions={ canManage() ? ( -
- - diff --git a/src/pages/meals-page.tsx b/src/pages/meals-page.tsx index 6d124f0..27fa5b9 100644 --- a/src/pages/meals-page.tsx +++ b/src/pages/meals-page.tsx @@ -95,7 +95,7 @@ function MealsContent() { description={t("meals.subtitle")} actions={ - diff --git a/src/pages/messages-page.test.tsx b/src/pages/messages-page.test.tsx index f9b16c9..4367eee 100644 --- a/src/pages/messages-page.test.tsx +++ b/src/pages/messages-page.test.tsx @@ -46,8 +46,9 @@ afterEach(() => { test("emptying trash waits for confirmation and names what it deletes", async () => { getMessages.mockImplementation(async (folder: string) => folder === "trash" - ? { items: [message(1), message(2)], total: 5, limit: 30, offset: 0 } - : { items: [], total: 0, limit: 30, offset: 0 }, + // A full first page (50) of a 55-message trash: the rest is not loaded yet. + ? { items: Array.from({ length: 50 }, (_, i) => message(i + 1)), total: 55, limit: 50, offset: 0 } + : { items: [], total: 0, limit: 50, offset: 0 }, ); deleteMessageById.mockResolvedValue(undefined); @@ -62,16 +63,16 @@ test("emptying trash waits for confirmation and names what it deletes", async () fireEvent.click(await screen.findByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ })); const dialog = await screen.findByRole("alertdialog"); - expect(dialog.textContent).toMatch(/2 mesaj|2 messages/); - expect(dialog.textContent).toMatch(/toplam 5|5 in trash/); + expect(dialog.textContent).toMatch(/50 mesaj|50 messages/); + expect(dialog.textContent).toMatch(/toplam 55|55 in trash/); expect(deleteMessageById).not.toHaveBeenCalled(); fireEvent.click(within(dialog).getByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ })); - await waitFor(() => expect(deleteMessageById).toHaveBeenCalledTimes(2)); + await waitFor(() => expect(deleteMessageById).toHaveBeenCalledTimes(50)); }); test("searching hits the server with a trimmed q at first-page offset", async () => { - getMessages.mockResolvedValue({ items: [message(1)], total: 1, limit: 30, offset: 0 }); + getMessages.mockResolvedValue({ items: [message(1)], total: 1, limit: 50, offset: 0 }); render(() => ( @@ -83,6 +84,6 @@ test("searching hits the server with a trimmed q at first-page offset", async () fireEvent.input(search, { target: { value: " Subject 7 " } }); await waitFor(() => - expect(getMessages).toHaveBeenCalledWith("inbox", { limit: 30, offset: 0, q: "Subject 7" }), + expect(getMessages).toHaveBeenCalledWith("inbox", { limit: 50, offset: 0, q: "Subject 7" }), ); }); diff --git a/src/pages/messages-page.tsx b/src/pages/messages-page.tsx index 6a19170..d81756b 100644 --- a/src/pages/messages-page.tsx +++ b/src/pages/messages-page.tsx @@ -2,14 +2,14 @@ import { For, Show, createMemo, - createEffect, createSignal, Suspense, useTransition, } from "solid-js"; import { createResource } from "@/lib/create-resource"; import { RouteGuard } from "@/components/layout/route-guard"; -import { TablePagination } from "@/components/ui/table-pagination"; +import { InfiniteSentinel } from "@/components/ui/infinite-sentinel"; +import { createInfiniteList } from "@/lib/infinite-list"; import { Button } from "@/components/ui/button"; import { IconArchive, @@ -20,6 +20,7 @@ import { IconRefresh, } from "@/components/ui/icons"; import { DataTableSearch } from "@/components/ui/data-table-search"; +import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar"; import { GmailMailRow } from "@/components/messages/gmail-mail-row"; import { GmailMailDetail } from "@/components/messages/gmail-mail-detail"; import { GmailComposeBox } from "@/components/messages/gmail-compose-box"; @@ -49,8 +50,6 @@ export default function MessagesPage() { const t = useT(); const auth = useAuth(); const [folder, setFolder] = createSignal("inbox"); - const [page, setPage] = createSignal(1); - const limit = 30; const [selectedId, setSelectedId] = createSignal(""); const [query, setQuery, debouncedQuery] = createDebouncedSignal(); const [composeOpen, setComposeOpen] = createSignal(false); @@ -58,27 +57,20 @@ export default function MessagesPage() { const [isPending, startTransition] = useTransition(); const [, setFlash] = createFlash(); - const [messagePage, { refetch }] = createResource( - () => ({ f: folder(), p: page(), q: debouncedQuery().trim() }), - async (args) => - await getMessages(args.f, { - limit, - offset: (args.p - 1) * limit, - ...(args.q ? { q: args.q } : {}), - }) + // Folder and search are both applied by the backend, so the list loads a + // page at a time as the reader scrolls and starts over on either change. + const messageList = createInfiniteList( + () => ({ f: folder(), q: debouncedQuery().trim() }), + (args, paging) => getMessages(args.f, { ...paging, ...(args.q ? { q: args.q } : {}) }), + { equals: (a, b) => a.f === b.f && a.q === b.q }, ); - createEffect(() => { - const total = messagePage()?.total; - if (total === undefined) return; - const lastPage = Math.max(1, Math.ceil(total / limit)); - if (page() > lastPage) setPage(lastPage); - }); + const refetch = async () => messageList.reload(); const [unreadCount, { refetch: refetchUnread }] = createResource( async () => (await getMessages("inbox", { read: false, limit: 1 })).total ); - const rawMessages = createMemo(() => messagePage()?.items ?? []); + const rawMessages = createMemo(() => messageList.items()); // En yeni mesaj en üstte sıralama const messages = createMemo(() => @@ -155,7 +147,7 @@ export default function MessagesPage() { /** Empty trash deletes the loaded page only; the summary says so when more remain. */ const emptyTrashSummary = () => { const count = messages().length; - const total = messagePage()?.total ?? count; + const total = messageList.total() || count; return total > count ? t("messages.emptyTrashPageSummary", { count, total }) : t("messages.emptyTrashSummary", { count }); @@ -202,7 +194,7 @@ export default function MessagesPage() { type="button" aria-current={active() ? "page" : undefined} class={cn( - "relative flex min-w-0 flex-col items-center justify-center gap-0.5 rounded-lg px-0 py-1.5 text-[11px] font-semibold tracking-tight transition-colors sm:h-8 sm:tracking-normal sm:shrink-0 sm:flex-row sm:gap-2 sm:px-3 sm:py-0 sm:text-xs", + "relative flex min-w-0 flex-col items-center justify-center gap-0.5 rounded-lg px-0 py-1.5 text-[11px] font-semibold tracking-tight transition-colors sm:h-8 sm:rounded-full sm:tracking-normal sm:shrink-0 sm:flex-row sm:gap-2 sm:px-3.5 sm:py-0 sm:text-[13px]", active() ? entry.id === "trash" ? "bg-destructive/10 text-destructive-text" @@ -212,7 +204,6 @@ export default function MessagesPage() { onClick={() => startTransition(() => { setFolder(entry.id); - setPage(1); setSelectedId(""); }) } @@ -239,7 +230,7 @@ export default function MessagesPage() {
@@ -288,7 +275,7 @@ export default function MessagesPage() { - - - {messagePage()!.total > 0 - ? `${(page() - 1) * limit + 1}-${Math.min(page() * limit, messagePage()!.total)} / ${messagePage()!.total}` - : "0 / 0"} - - +
@@ -368,15 +349,15 @@ export default function MessagesPage() { - limit}> -
- -
-
+
+ +
} > diff --git a/src/pages/my-students-page.tsx b/src/pages/my-students-page.tsx index 7b0582c..a5158c7 100644 --- a/src/pages/my-students-page.tsx +++ b/src/pages/my-students-page.tsx @@ -17,6 +17,7 @@ import { PageSpinner } from "@/components/ui/page-spinner"; import { SidePanel } from "@/components/ui/side-panel"; import { Button } from "@/components/ui/button"; import { DataTable, DataTableEmpty } from "@/components/ui/data-table"; +import { cn } from "@/lib/cn"; import { personLabel } from "@/lib/person"; import { useT } from "@/stores/preferences-context"; import { IconChart, IconChevronRight, IconClipboardCheck, IconClock, IconExam, IconExternalLink, IconHomework, IconMessage } from "@/components/ui/icons"; @@ -28,6 +29,11 @@ import { examKindLabel } from "@/lib/exam-labels"; type StudentTab = "marks" | "attendance" | "exams" | "homework" | "study"; +// The panel's action and tab buttons are toolbar pills: touch-sized (h-10) +// below `sm` and on touch screens, h-8 above, so both rows read as one set. +const PANEL_CONTROLS = + "[&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10"; + // /students opens a child on the progress report; the parent sidebar's // Devamsızlık / Sınav sonuçları / Çalışma planı entries are the same page // landing on another tab (/students/attendance, /students/exams, /students/study). @@ -198,7 +204,7 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud !open && props.onClose()} title={props.student ? personLabel(props.student) : ""} description={`@${props.student?.username}`}>
-
+
{/* A parent may read their linked students' profiles, so this is safe — it 403s only for someone else's child. Close the panel before navigating: a click that stays inside this modal never leaves it. */} @@ -207,7 +213,6 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud
-
+
{(tab) => { const Icon = tab.icon; diff --git a/src/pages/notes-page.tsx b/src/pages/notes-page.tsx index c946ffa..0383946 100644 --- a/src/pages/notes-page.tsx +++ b/src/pages/notes-page.tsx @@ -12,10 +12,12 @@ import { RouteGuard } from "@/components/layout/route-guard"; import { NoteImportPanel } from "@/components/notes/note-import-panel"; import { NoteList } from "@/components/notes/note-list"; import { Button } from "@/components/ui/button"; +import { TOOLBAR_CARD, TOOLBAR_SLOT } from "@/components/ui/data-toolbar"; import { IconPlus, IconUploadCloud } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { TablePagination } from "@/components/ui/table-pagination"; import { SidePanel } from "@/components/ui/side-panel"; +import { cn } from "@/lib/cn"; import { createFlash } from "@/lib/flash"; import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; import { personalNoteFiles } from "@/lib/note-source"; @@ -93,12 +95,12 @@ function NotesContent() {
-
- - diff --git a/src/pages/payments-page.tsx b/src/pages/payments-page.tsx index 7613316..faac789 100644 --- a/src/pages/payments-page.tsx +++ b/src/pages/payments-page.tsx @@ -36,7 +36,7 @@ import { ErrorAlert } from "@/components/ui/error-alert"; import { IconChevronLeft, IconEdit, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { Select } from "@/components/ui/select"; +import { DropdownSelect, Select } from "@/components/ui/select"; import { SidePanel } from "@/components/ui/side-panel"; import { TableRowActions } from "@/components/ui/table-row-actions"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; @@ -628,11 +628,15 @@ function PaymentsContent() { description={t("payments.subtitle")} empty={t("form.noStudents")} filters={ - + { setPlanFilter(value); setStudentPage(0); }} + options={[{ value: "", label: t("common.all") }, ...planList().map((plan) => ({ value: plan.id, label: plan.name }))]} + /> } + filtersActive={planFilter() !== ""} + onClearFilters={() => { setPlanFilter(""); setStudentPage(0); }} tableClass="min-w-160" storageKey="payment-students" enableSorting @@ -655,7 +659,7 @@ function PaymentsContent() {

{personLabel(current())}

@{current().username}

-
@@ -682,25 +686,33 @@ function PaymentsContent() {
} > -
- - - {t("payments.entryTabAll")} - {t("payments.entryTabOverdue")} - {t("payments.entryTabMonth")} - {t("payments.entryTabClosed")} - - - -
+ {/* The status filter is a chip in the table's own toolbar card, + beside "Sütunlar", so both share one row and one height. */} + + } + filtersActive={entryTab() !== "all"} + pageResetKey={entryTab()} + onClearFilters={() => setEntryTab("all")} + enablePagination + pageSize={STATEMENT_PAGE_SIZE} + onRowClick={setViewEntry} + /> @@ -756,7 +768,7 @@ function PaymentsContent() { title={t("payments.tabPlans")} description={t("payments.subtitle")} actions={ - diff --git a/src/pages/profile-page.tsx b/src/pages/profile-page.tsx index bca7108..70b0f70 100644 --- a/src/pages/profile-page.tsx +++ b/src/pages/profile-page.tsx @@ -202,15 +202,16 @@ function ProfileContent() {
-
+ {/* Header actions are toolbar pills: h-10 below `sm` and on touch, h-8 above. */} +
- - diff --git a/src/pages/question-bank-page.test.tsx b/src/pages/question-bank-page.test.tsx index e117291..cfe99e3 100644 --- a/src/pages/question-bank-page.test.tsx +++ b/src/pages/question-bank-page.test.tsx @@ -3,8 +3,8 @@ import { Show } from "solid-js"; import QuestionBankPage from "@/pages/question-bank-page"; import { PreferencesProvider } from "@/stores/preferences-context"; -// 11 templates, page size 10: the last page holds exactly one row. -let templates = Array.from({ length: 11 }, (_, index) => ({ +// More templates than one scroll page (50) holds. +let templates = Array.from({ length: 60 }, (_, index) => ({ id: `bq-${index}`, text: `Template ${index}`, kind: "text", @@ -59,23 +59,24 @@ const tick = () => new Promise((resolve) => setTimeout(resolve, 0)); afterEach(() => vi.restoreAllMocks()); -test("deleting the last row of the last page clamps back instead of stranding the user", async () => { +test("fetches one page at a time and starts over from the top after a delete", async () => { render(() => ( )); - fireEvent.click(await screen.findByRole("button", { name: "Next" })); - expect(await screen.findByText("Template 10")).toBeTruthy(); - expect(screen.getByText("2 / 2")).toBeTruthy(); + // Only the first page is fetched until the reader scrolls. + expect(await screen.findByText("Template 49")).toBeTruthy(); + expect(screen.queryByText("Template 50")).toBeNull(); - fireEvent.click(screen.getByRole("button", { name: "delete-row" })); + fireEvent.click(screen.getAllByRole("button", { name: "delete-row" })[0]); fireEvent.click(screen.getByRole("button", { name: "confirm-delete" })); await tick(); await tick(); - // 10 left → one page: the user must be on it, not on the vanished page 2. - expect(screen.queryByText("Template 10")).toBeNull(); - expect(await screen.findByText("Template 0")).toBeTruthy(); + // The list reloads from offset 0: the deleted row is gone and the next one + // moves up into the first page. + expect(screen.queryByText("Template 0")).toBeNull(); + expect(await screen.findByText("Template 50")).toBeTruthy(); }); diff --git a/src/pages/question-bank-page.tsx b/src/pages/question-bank-page.tsx index 8830b99..adf701d 100644 --- a/src/pages/question-bank-page.tsx +++ b/src/pages/question-bank-page.tsx @@ -1,7 +1,7 @@ import { useNavigate } from "@tanstack/solid-router"; -import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; -import { createResponsivePageSize } from "@/lib/create-page-size"; +import { Show, createMemo, createSignal } from "solid-js"; import { createResource } from "@/lib/create-resource"; +import { createInfiniteList } from "@/lib/infinite-list"; import type { ColumnDef } from "@tanstack/solid-table"; import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions"; import { getCourses } from "@/api/courses"; @@ -25,8 +25,6 @@ import { hasMinRole } from "@/lib/roles"; import { useAuth } from "@/stores/auth-context"; import { useT } from "@/stores/preferences-context"; -const BANK_PAGE_SIZE = 10; - export default function QuestionBankPage() { return ( @@ -43,9 +41,6 @@ function QuestionBankContent() { const ownerFilter = () => (bankTab() === "mine" ? "me" : "all") as "all" | "me"; const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school"; const [subjectFilter, setSubjectFilter] = createSignal("all"); - const [page, setPage] = createSignal(0); - const pageSize = createResponsivePageSize(BANK_PAGE_SIZE); - createEffect(on(pageSize, () => setPage(0), { defer: true })); const [query, setQuery, debouncedQuery] = createDebouncedSignal(); const [createOpen, setCreateOpen] = createSignal(false); const [editing, setEditing] = createSignal(null); @@ -56,19 +51,18 @@ function QuestionBankContent() { const [flash, setFlash] = createFlash(); const [error, setError] = createSignal(""); - const [list, { refetch }] = createResource( + // Every filter here is applied by the backend, so the bank loads a page at + // a time as the reader scrolls; a new filter starts again from the top. + const list = createInfiniteList( () => ({ - page: page(), - size: pageSize(), owner: ownerFilter(), subject: subjectFilter(), visibility: visibilityFilter(), q: debouncedQuery().trim(), }), - async (filters) => { + async (filters, paging) => { const result = await getBankQuestions({ - limit: filters.size, - offset: filters.page * filters.size, + ...paging, ...(filters.owner === "me" ? { owner: "me" } : {}), ...(filters.subject !== "all" ? { subject: filters.subject } : {}), ...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}), @@ -81,15 +75,10 @@ function QuestionBankContent() { }); return result; }, + { equals: (a, b) => JSON.stringify(a) === JSON.stringify(b) }, ); - const total = () => list.latest?.total ?? 0; - // Deleting the last row of the last page shrinks the page count under the - // current page; the table then hides its pagination bar entirely and the user - // is stranded with no control to get back. Same clamp as exam-questions-panel. - const pageCount = () => Math.max(1, Math.ceil(total() / pageSize())); - createEffect(() => { - if (page() >= pageCount()) setPage(pageCount() - 1); - }); + const total = () => list.total(); + const refetch = () => list.reload(); // Only courses the teacher can author in supply subjects for a new template. const [courses] = createResource(async () => (await getCourses({ limit: 100 })).items); @@ -220,7 +209,6 @@ function QuestionBankContent() { value={bankTab()} onChange={(value) => { setBankTab(value as "all" | "mine" | "school"); - setPage(0); }} > @@ -231,33 +219,29 @@ function QuestionBankContent() {
- }> - - {formatApiError(list.error)} - + + {(err) => {formatApiError(err())}} + + }> 0}> - } columns={columns()} - data={list()?.items ?? []} + data={list.items()} tableClass="min-w-[40rem]" filterPlaceholder={t("bank.search")} filterHint={t("search.hint.bank")} searchValue={query()} - onSearchInput={(value) => { - setQuery(value); - setPage(0); - }} - enablePagination - manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }} + onSearchInput={setQuery} + infinite={{ hasMore: list.hasMore(), loading: list.loading(), total: total(), onLoadMore: list.loadMore }} empty={t("bank.empty")} storageKey="question-bank" onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })} @@ -266,16 +250,13 @@ function QuestionBankContent() { { - setSubjectFilter(value); - setPage(0); - }} + onChange={setSubjectFilter} options={subjectOptions()} />
} /> - + diff --git a/src/pages/question-detail-page.tsx b/src/pages/question-detail-page.tsx index 60c8344..8176d3e 100644 --- a/src/pages/question-detail-page.tsx +++ b/src/pages/question-detail-page.tsx @@ -29,6 +29,12 @@ import { formatBytes, maxUploadBytes } from "@/lib/upload-limits"; // Lazy so the drawing pad rides its own chunk, off the question detail's initial load. const DrawCanvas = lazy(() => import("@/components/ui/draw-canvas").then((m) => ({ default: m.DrawCanvas }))); +// Approve and the actions menu share one row: the toolbar pill, touch-sized +// (h-10) below `sm` and on touch screens, h-8 above. The menu trigger is a +//
-
+
- diff --git a/src/pages/questions-page.tsx b/src/pages/questions-page.tsx index 4c434bb..aa1b93f 100644 --- a/src/pages/questions-page.tsx +++ b/src/pages/questions-page.tsx @@ -1,5 +1,7 @@ import { For, Show, Suspense, createEffect, createSignal, lazy } from "solid-js"; import { createResource } from "@/lib/create-resource"; +import { createInfiniteList } from "@/lib/infinite-list"; +import { InfiniteSentinel } from "@/components/ui/infinite-sentinel"; import { Link, useLocation, useNavigate, useSearch } from "@tanstack/solid-router"; import { getQuestions, postQuestion, deleteQuestionById } from "@/api/shared"; import { getSettings } from "@/api/settings"; @@ -45,10 +47,14 @@ function QuestionsContent() { const statusFilter = () => ((searchParams() as any).status === "pending" ? "pending" : "approved"); - const [list, { refetch }] = createResource( - () => ({ status: statusFilter(), limit: 50, offset: 0 }), - async (params) => (await getQuestions(params.status as "pending" | "approved", params)).items + // The status is the only filter and the backend applies it, so the pool + // loads a page at a time as the reader scrolls (it used to stop at 50). + const questions = createInfiniteList( + () => statusFilter(), + (status, paging) => getQuestions(status, paging), ); + const list = () => questions.items(); + const refetch = () => questions.reload(); const [askOpen, setAskOpen] = createSignal(location().searchStr.includes("action=new")); const [questionToDelete, setQuestionToDelete] = createSignal(null); @@ -100,7 +106,7 @@ function QuestionsContent() { description={t("pool.subtitle")} actions={ - @@ -108,9 +114,11 @@ function QuestionsContent() { } >
- }> - - 0} fallback={}> + + {(err) =>

{formatApiError(err())}

} +
+ }> + 0} fallback={}>
{(question) => ( @@ -164,9 +172,16 @@ function QuestionsContent() { )}
+
-
-
+
diff --git a/src/pages/students-roster-page.tsx b/src/pages/students-roster-page.tsx index b0ccbd4..1a2a14f 100644 --- a/src/pages/students-roster-page.tsx +++ b/src/pages/students-roster-page.tsx @@ -139,7 +139,7 @@ function StudentsRosterContent() { title={t("nav.studentsRoster")} description={t("roster.studentsSubtitle")} actions={<> - diff --git a/src/pages/teachers-roster-page.tsx b/src/pages/teachers-roster-page.tsx index dca2ae0..e22b250 100644 --- a/src/pages/teachers-roster-page.tsx +++ b/src/pages/teachers-roster-page.tsx @@ -130,7 +130,7 @@ function TeachersRosterContent() { title={t("nav.teachersRoster")} description={t("roster.teachersSubtitle")} actions={<> - diff --git a/src/pages/terms-page.tsx b/src/pages/terms-page.tsx index 5e13dc2..a22af47 100644 --- a/src/pages/terms-page.tsx +++ b/src/pages/terms-page.tsx @@ -260,7 +260,7 @@ function TermsContent() { title={t("terms.title")} description={t("terms.subtitle")} actions={ - diff --git a/src/pages/whiteboards-page.tsx b/src/pages/whiteboards-page.tsx index 46c8fff..25b029d 100644 --- a/src/pages/whiteboards-page.tsx +++ b/src/pages/whiteboards-page.tsx @@ -1,13 +1,12 @@ import { useNavigate } from "@tanstack/solid-router"; -import { For, Show, Suspense, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js"; -import { createResponsivePageSize } from "@/lib/create-page-size"; +import { For, Show, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; import { createDebouncedSignal } from "@/lib/create-debounced-signal"; -import { createResource } from "@/lib/create-resource"; +import { createInfiniteList } from "@/lib/infinite-list"; import { getBoards, postBoard, type Board } from "@/api/boards"; import { getUserSearch } from "@/api/users"; import { formatApiError, type PersonRef } from "@/api/client"; import { RouteGuard } from "@/components/layout/route-guard"; -import { DataToolbar } from "@/components/ui/data-toolbar"; +import { DataToolbar, TOOLBAR_CARD } from "@/components/ui/data-toolbar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { EmptyState } from "@/components/ui/empty-state"; @@ -17,7 +16,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { PageSpinner } from "@/components/ui/page-spinner"; import { SidePanel } from "@/components/ui/side-panel"; -import { TablePagination } from "@/components/ui/table-pagination"; +import { InfiniteSentinel } from "@/components/ui/infinite-sentinel"; import { cn } from "@/lib/cn"; import { formatDate } from "@/lib/format"; import { personLabel } from "@/lib/person"; @@ -39,57 +38,41 @@ function WhiteboardsContent() { const auth = useAuth(); const navigate = useNavigate(); - const pageSize = createResponsivePageSize(12); - const [page, setPage] = createSignal(0); - createEffect(on(pageSize, () => setPage(0), { defer: true })); const [query, setQuery, debouncedQuery] = createDebouncedSignal(); - const [boards, { refetch }] = createResource( - () => ({ page: page(), size: pageSize(), q: debouncedQuery().trim() }), - (source) => - getBoards({ - limit: source.size, - offset: source.page * source.size, - ...(source.q ? { q: source.q } : {}), - }), + // The server narrows by title via `q`, so boards load a page at a time as + // the reader scrolls; a new search starts again from the first board. + const boards = createInfiniteList( + () => debouncedQuery().trim(), + (q, paging) => getBoards({ ...paging, ...(q ? { q } : {}) }), ); const [createOpen, setCreateOpen] = createSignal(false); - const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / pageSize()))); - createEffect(() => { - if (boards.latest && page() >= pageCount()) setPage(pageCount() - 1); - }); - // The server narrows by title via `q`; the page holds whatever the current - // query matched, so totals and pagination already reflect the search. - const visibleBoards = createMemo(() => boards()?.items ?? []); + const visibleBoards = () => boards.items(); const meId = () => auth.user()?.id ?? ""; return (
-
+
{ - setQuery(value); - // The server filters from the first row; offset restarts with each search. - setPage(0); - }} + onSearchInput={setQuery} actions={ - } />
- }> - - - + + {(err) => } + + }> 0} + when={query().trim() || visibleBoards().length > 0} fallback={} >
@@ -107,18 +90,16 @@ function WhiteboardsContent() {
- pageSize()}> - - +
- +
{ setCreateOpen(false); - void refetch(); + boards.reload(); navigate({ to: "/whiteboards/$id", params: { id: board.id } }); }} /> diff --git a/src/pages/work-log-page.tsx b/src/pages/work-log-page.tsx index 35477b1..7ed9419 100644 --- a/src/pages/work-log-page.tsx +++ b/src/pages/work-log-page.tsx @@ -106,7 +106,7 @@ function WorkLogContent() { title={openEntry() ? t("work.checkedIn") : t("work.notCheckedIn")} description={openEntry() ? t("work.since", { time: formatDateTime(openEntry()!.check_in, locale()) }) : t("work.subtitle")} actions={ - }