forge
Explore
Log in

Don't you dare go Hollow

💊 pill toolbars, clean button borders, fetch-as-you-scroll lists

Browse files at this commit

33fa92d803a67b5a0ca44a81b96c9d58b106ad31Burak BoduroğluParent: 1156777
  • feat
    • 💊 pill toolbars, clean button borders, fetch-as-you-scroll lists
Show full message
feat: 💊 pill toolbars, clean button borders, fetch-as-you-scroll lists
- every list toolbar is one card; search, filters, actions and Sütunlar
  are pills of one height (h-8 from sm, h-10 below sm and on touch);
  active filter chips get a primary border; pages move stray add
  buttons into their table toolbar and drop radius overrides
- filled buttons get a transparent border with padding-box fill, so they
  no longer look bigger than outlined ones; hover borders stop matching
  their fill
- createInfiniteList fetches 50 rows at a time, restarts on a new query
  and drops stale replies; DataTable gains an `infinite` mode and
  InfiniteSentinel covers card and message lists
- question bank, whiteboards, messages, question pool and courses load
  from the server as you scroll; courses drop the load-all workaround
  now that the backend applies kind, q and taught
- client-side tables drop page numbers and reveal 50 rows at a time;
  without IntersectionObserver a "Load more" button replaces auto-load
src/components/ai/insights-board.tsxmodified+1 -1
@@ -98,7 +98,7 @@ export function InsightsBoard() {
98 <Show when={canManageRuns()}>98 <Show when={canManageRuns()}>
99 <Button99 <Button
100 size="sm"100 size="sm"
101- class="min-w-[7.5rem] rounded-lg"101+ class="min-w-[7.5rem]"
102 disabled={refreshingAll()}102 disabled={refreshingAll()}
103 onClick={() => void queueSchoolRefresh()}103 onClick={() => void queueSchoolRefresh()}
104 >104 >
src/components/classes/blueprints-tab.tsxmodified+1 -1
@@ -201,7 +201,7 @@ export function BlueprintsTab(props: {
201 actions={201 actions={
202 <Button202 <Button
203 size="sm"203 size="sm"
204- class="rounded-lg"204+ class="min-w-[7.5rem]"
205 onClick={() => {205 onClick={() => {
206 setEditing(null);206 setEditing(null);
207 setPanelOpen(true);207 setPanelOpen(true);
src/components/courses/course-notes-panel.tsxmodified+1 -1
@@ -92,7 +92,7 @@ export function CourseNotesPanel(props: {
92 onSearchInput={setSearch}92 onSearchInput={setSearch}
93 actions={93 actions={
94 <Show when={props.canManage}>94 <Show when={props.canManage}>
95- <Button type="button" size="sm" class="shrink-0 rounded-lg" onClick={() => props.onCreateOpenChange(true)}>95+ <Button type="button" size="sm" class="shrink-0" onClick={() => props.onCreateOpenChange(true)}>
96 <IconPlus class="h-4 w-4" />{t("courseNotes.add")}96 <IconPlus class="h-4 w-4" />{t("courseNotes.add")}
97 </Button>97 </Button>
98 </Show>98 </Show>
src/components/courses/course-offerings-panel.tsxmodified+1 -1
@@ -105,7 +105,7 @@ export function CourseOfferingsPanel(props: { courseId: string; courseTitle: str
105 onRowClick={(offering) => open(offering)}105 onRowClick={(offering) => open(offering)}
106 actions={106 actions={
107 <Show when={props.canEdit}>107 <Show when={props.canEdit}>
108- <Button type="button" size="sm" class="rounded-lg" onClick={() => open(null)}>108+ <Button type="button" size="sm" onClick={() => open(null)}>
109 <IconPlus class="h-4 w-4" />109 <IconPlus class="h-4 w-4" />
110 {t("offerings.new")}110 {t("offerings.new")}
111 </Button>111 </Button>
src/components/courses/course-subjects-panel.tsxmodified+1 -1
@@ -177,7 +177,7 @@ export function CourseSubjectsPanel(props: { courseId: string; canManage: boolea
177 empty={t("subjects.empty")}177 empty={t("subjects.empty")}
178 emptyIllustration="courses"178 emptyIllustration="courses"
179 actions={props.canManage ? (179 actions={props.canManage ? (
180- <Button type="button" size="sm" class="rounded-lg" onClick={() => props.onCreateOpenChange(true)}>180+ <Button type="button" size="sm" onClick={() => props.onCreateOpenChange(true)}>
181 <IconPlus class="h-4 w-4" />{t("subjects.add")}181 <IconPlus class="h-4 w-4" />{t("subjects.add")}
182 </Button>182 </Button>
183 ) : undefined}183 ) : undefined}
src/components/courses/course-teachers-panel.tsxmodified+1 -1
@@ -121,7 +121,7 @@ export function CourseTeachersPanel(props: {
121 empty={t("courses.noTeachers")}121 empty={t("courses.noTeachers")}
122 emptyIllustration="people"122 emptyIllustration="people"
123 actions={props.canStaff ? (123 actions={props.canStaff ? (
124- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => props.onAssignOpenChange(true)}>124+ <Button type="button" size="sm" onClick={() => props.onAssignOpenChange(true)}>
125 <IconPlus class="h-4 w-4" />{t("courses.assignTeacher")}125 <IconPlus class="h-4 w-4" />{t("courses.assignTeacher")}
126 </Button>126 </Button>
127 ) : undefined}127 ) : undefined}
src/components/courses/offering-panel.tsxmodified+22 -23
@@ -33,7 +33,6 @@ import { gradeLevelLabel } from "@/lib/grade-level";
33 import { useT } from "@/stores/preferences-context";33 import { useT } from "@/stores/preferences-context";
34 34
35 const SECTION = "space-y-3 border-t border-border-hairline pt-4";35 const SECTION = "space-y-3 border-t border-border-hairline pt-4";
36-const SECTION_HEAD = "flex flex-wrap items-start justify-between gap-2";
37 36
38 /**37 /**
39 * One grade template of a catalog course: `offering` null creates it (grade38 * One grade template of a catalog course: `offering` null creates it (grade
@@ -199,36 +198,28 @@ export function OfferingPanel(props: {
199 </section>198 </section>
200 199
201 <section class={SECTION}>200 <section class={SECTION}>
202- <div class={SECTION_HEAD}>201+ <div class="flex items-center gap-1">
203- <div class="flex items-center gap-1">202+ <h3 class="text-sm font-semibold">{t("weeklyPlan.title")}</h3>
204- <h3 class="text-sm font-semibold">{t("weeklyPlan.title")}</h3>203+ <InfoTip text={t("offerings.weeklyPlanHelp")} label={t("common.infoAbout", { item: t("weeklyPlan.title") })} />
205- <InfoTip text={t("offerings.weeklyPlanHelp")} label={t("common.infoAbout", { item: t("weeklyPlan.title") })} />
206- </div>
207- <Show when={props.canEdit}>
208- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setAddingSlot(true)}>
209- <IconPlus class="h-4 w-4" />
210- {t("weeklyPlan.addSlot")}
211- </Button>
212- </Show>
213 </div>204 </div>
214 <WeeklyPlanTable205 <WeeklyPlanTable
215 slots={slots.latest ?? []}206 slots={slots.latest ?? []}
216 onRemove={props.canEdit ? (slot: WeeklySlot) => void guard(async () => { await deleteOfferingWeeklySlotById(offering().id, slot.id); await refetchSlots(); }) : undefined}207 onRemove={props.canEdit ? (slot: WeeklySlot) => void guard(async () => { await deleteOfferingWeeklySlotById(offering().id, slot.id); await refetchSlots(); }) : undefined}
208+ actions={
209+ <Show when={props.canEdit}>
210+ <Button type="button" size="sm" onClick={() => setAddingSlot(true)}>
211+ <IconPlus class="h-4 w-4" />
212+ {t("weeklyPlan.addSlot")}
213+ </Button>
214+ </Show>
215+ }
217 />216 />
218 </section>217 </section>
219 218
220 <section class={SECTION}>219 <section class={SECTION}>
221- <div class={SECTION_HEAD}>220+ <div class="flex items-center gap-1">
222- <div class="flex items-center gap-1">221+ <h3 class="text-sm font-semibold">{t("instances.examWeightsTitle")}</h3>
223- <h3 class="text-sm font-semibold">{t("instances.examWeightsTitle")}</h3>222+ <InfoTip text={t("offerings.weightsHelp")} label={t("common.infoAbout", { item: t("instances.examWeightsTitle") })} />
224- <InfoTip text={t("offerings.weightsHelp")} label={t("common.infoAbout", { item: t("instances.examWeightsTitle") })} />
225- </div>
226- <Show when={props.canEdit}>
227- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setWeightEditing("new")}>
228- <IconPlus class="h-4 w-4" />
229- {t("instances.addWeight")}
230- </Button>
231- </Show>
232 </div>223 </div>
233 <ExamWeightsEditor224 <ExamWeightsEditor
234 weights={weights.latest ?? []}225 weights={weights.latest ?? []}
@@ -238,6 +229,14 @@ export function OfferingPanel(props: {
238 onEditingChange={setWeightEditing}229 onEditingChange={setWeightEditing}
239 onSet={async (entry) => { await patchOfferingExamWeight(offering().id, entry); await refetchWeights(); }}230 onSet={async (entry) => { await patchOfferingExamWeight(offering().id, entry); await refetchWeights(); }}
240 onRemove={async (kind) => { await deleteOfferingExamWeightByKind(offering().id, kind); await refetchWeights(); }}231 onRemove={async (kind) => { await deleteOfferingExamWeightByKind(offering().id, kind); await refetchWeights(); }}
232+ actions={
233+ <Show when={props.canEdit}>
234+ <Button type="button" size="sm" onClick={() => setWeightEditing("new")}>
235+ <IconPlus class="h-4 w-4" />
236+ {t("instances.addWeight")}
237+ </Button>
238+ </Show>
239+ }
241 />240 />
242 </section>241 </section>
243 242
src/components/events/event-roll-call.tsxmodified+3 -2
@@ -7,6 +7,7 @@ import type { AttendanceStatus, EventRosterEntry } from "@/api/client";
7 import { Alert } from "@/components/ui/alert";7 import { Alert } from "@/components/ui/alert";
8 import { Button } from "@/components/ui/button";8 import { Button } from "@/components/ui/button";
9 import { DataTableSearch } from "@/components/ui/data-table-search";9 import { DataTableSearch } from "@/components/ui/data-table-search";
10+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
10 import { EmptyState } from "@/components/ui/empty-state";11 import { EmptyState } from "@/components/ui/empty-state";
11 import { InfoTip } from "@/components/ui/info-tip";12 import { InfoTip } from "@/components/ui/info-tip";
12 import { IconCheck } from "@/components/ui/icons";13 import { IconCheck } from "@/components/ui/icons";
@@ -212,7 +213,7 @@ export function EventRollCall(props: {
212 type="button"213 type="button"
213 size="sm"214 size="sm"
214 variant="outline"215 variant="outline"
215- class="h-8 rounded-lg"216+ class={cn(TOOLBAR_CONTROL, "px-3.5")}
216 disabled={locked() || unmarkedIds().length === 0}217 disabled={locked() || unmarkedIds().length === 0}
217 onClick={markRestPresent}218 onClick={markRestPresent}
218 >219 >
@@ -223,7 +224,7 @@ export function EventRollCall(props: {
223 type="button"224 type="button"
224 size="sm"225 size="sm"
225 variant="outline"226 variant="outline"
226- class="h-8 rounded-lg"227+ class={cn(TOOLBAR_CONTROL, "px-3.5")}
227 aria-pressed={onlyUnmarked()}228 aria-pressed={onlyUnmarked()}
228 onClick={() => setOnlyUnmarked((value) => !value)}229 onClick={() => setOnlyUnmarked((value) => !value)}
229 >230 >
src/components/exams/exam-audience-panel.tsxmodified+1 -1
@@ -186,7 +186,7 @@ export function ExamAudiencePanel(props: {
186 enableColumnVisibility={false}186 enableColumnVisibility={false}
187 actions={187 actions={
188 <Show when={props.canManage}>188 <Show when={props.canManage}>
189- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setAddOpen(true)}>189+ <Button type="button" size="sm" onClick={() => setAddOpen(true)}>
190 <IconPlus class="h-4 w-4" />190 <IconPlus class="h-4 w-4" />
191 {t("exams.audience.add")}191 {t("exams.audience.add")}
192 </Button>192 </Button>
src/components/exams/exam-questions-panel.tsxmodified+5 -3
@@ -20,11 +20,13 @@ import { Alert } from "@/components/ui/alert";
20 import { Badge } from "@/components/ui/badge";20 import { Badge } from "@/components/ui/badge";
21 import { Button } from "@/components/ui/button";21 import { Button } from "@/components/ui/button";
22 import { ConfirmDialog } from "@/components/ui/confirm-dialog";22 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
23+import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
23 import { SidePanel } from "@/components/ui/side-panel";24 import { SidePanel } from "@/components/ui/side-panel";
24 import { BankQuestionPicker } from "@/components/exams/bank-question-picker";25 import { BankQuestionPicker } from "@/components/exams/bank-question-picker";
25 import { QuestionForm, type QuestionValues } from "@/components/exams/question-form";26 import { QuestionForm, type QuestionValues } from "@/components/exams/question-form";
26 import { IconArchive, IconChevronLeft, IconChevronRight, IconPlus, IconRefresh, IconTrash } from "@/components/ui/icons";27 import { IconArchive, IconChevronLeft, IconChevronRight, IconPlus, IconRefresh, IconTrash } from "@/components/ui/icons";
27 import { PageSpinner } from "@/components/ui/page-spinner";28 import { PageSpinner } from "@/components/ui/page-spinner";
29+import { cn } from "@/lib/cn";
28 import { createFlash } from "@/lib/flash";30 import { createFlash } from "@/lib/flash";
29 import { hasMinRole } from "@/lib/roles";31 import { hasMinRole } from "@/lib/roles";
30 import { useAuth } from "@/stores/auth-context";32 import { useAuth } from "@/stores/auth-context";
@@ -265,13 +267,13 @@ export function ExamQuestionsPanel(props: {
265 </Badge>267 </Badge>
266 </div>268 </div>
267 <Show when={!props.readOnly}>269 <Show when={!props.readOnly}>
268- <div class="flex flex-wrap items-center gap-1.5">270+ <div class={cn("flex flex-wrap items-center gap-2", TOOLBAR_SLOT)}>
269 <Show when={isTeacherPlus()}>271 <Show when={isTeacherPlus()}>
270 <Button272 <Button
271 type="button"273 type="button"
272 variant="outline"274 variant="outline"
273 size="sm"275 size="sm"
274- class="h-8 gap-1.5 rounded-md text-xs font-semibold"276+ class="gap-1.5 font-semibold"
275 onClick={() => setBankOpen(true)}277 onClick={() => setBankOpen(true)}
276 >278 >
277 <IconArchive class="h-3.5 w-3.5" />279 <IconArchive class="h-3.5 w-3.5" />
@@ -282,7 +284,7 @@ export function ExamQuestionsPanel(props: {
282 type="button"284 type="button"
283 variant="default"285 variant="default"
284 size="sm"286 size="sm"
285- class="h-8 gap-1.5 rounded-md text-xs font-semibold"287+ class="gap-1.5 font-semibold"
286 onClick={() => {288 onClick={() => {
287 setEditing(null);289 setEditing(null);
288 setFormOpen(true);290 setFormOpen(true);
src/components/homework/course-homework-panel.tsxmodified+1 -1
@@ -224,7 +224,7 @@ export function CourseHomeworkPanel(props: {
224 emptyIllustration="homework"224 emptyIllustration="homework"
225 onRowClick={(item) => void navigate({ to: "/homework/$id", params: { id: item.id } })}225 onRowClick={(item) => void navigate({ to: "/homework/$id", params: { id: item.id } })}
226 actions={props.canManage ? (226 actions={props.canManage ? (
227- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => props.onCreateOpenChange(true)}>227+ <Button type="button" size="sm" onClick={() => props.onCreateOpenChange(true)}>
228 <IconPlus class="h-4 w-4" />{t("homework.add")}228 <IconPlus class="h-4 w-4" />{t("homework.add")}
229 </Button>229 </Button>
230 ) : undefined}230 ) : undefined}
src/components/insights/insight-run-report.tsxmodified+6 -5
@@ -443,16 +443,18 @@ export function InsightRunReport(props: { run: InsightRun }) {
443 443
444 return (444 return (
445 <div class="space-y-5">445 <div class="space-y-5">
446- <div class="flex flex-wrap items-center justify-end gap-2">446+ {/* Report actions are toolbar pills: touch-sized (h-10) below `sm` and on
447- <Button variant="outline" size="sm" class="rounded-lg" disabled={loading()} onClick={() => void copyReport()}>447+ touch screens, h-8 above. */}
448+ <div class="flex flex-wrap items-center justify-end gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10">
449+ <Button variant="outline" size="sm" disabled={loading()} onClick={() => void copyReport()}>
448 <IconCopy class="h-4 w-4" />450 <IconCopy class="h-4 w-4" />
449 {tx("copy")}451 {tx("copy")}
450 </Button>452 </Button>
451- <Button variant="outline" size="sm" class="rounded-lg" disabled={loading()} onClick={downloadReport}>453+ <Button variant="outline" size="sm" disabled={loading()} onClick={downloadReport}>
452 <IconDownload class="h-4 w-4" />454 <IconDownload class="h-4 w-4" />
453 {tx("download")}455 {tx("download")}
454 </Button>456 </Button>
455- <Button variant="outline" size="sm" class="rounded-lg" disabled={loading()} onClick={() => window.print()}>457+ <Button variant="outline" size="sm" disabled={loading()} onClick={() => window.print()}>
456 <IconFileText class="h-4 w-4" />458 <IconFileText class="h-4 w-4" />
457 {tx("print")}459 {tx("print")}
458 </Button>460 </Button>
@@ -460,7 +462,6 @@ export function InsightRunReport(props: { run: InsightRun }) {
460 <Button462 <Button
461 variant="outline"463 variant="outline"
462 size="sm"464 size="sm"
463- class="rounded-lg"
464 disabled={generatingReport()}465 disabled={generatingReport()}
465 aria-busy={generatingReport()}466 aria-busy={generatingReport()}
466 onClick={() => void generateSchoolReport()}467 onClick={() => void generateSchoolReport()}
src/components/insights/insight-runs-table.tsxmodified+1 -1
@@ -159,7 +159,7 @@ export function InsightRunsTable(props: { runs: InsightRun[] }) {
159 </div>159 </div>
160 <button160 <button
161 type="button"161 type="button"
162- class="rounded-lg border border-border/70 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"162+ class="inline-flex h-10 items-center rounded-full border border-border/70 px-3.5 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground sm:h-8 touch:h-10"
163 onClick={() => setSelectedRun(null)}163 onClick={() => setSelectedRun(null)}
164 >164 >
165 {tx("common.close")}165 {tx("common.close")}
src/components/instances/exam-weights-editor.tsxmodified+6 -3
@@ -1,4 +1,4 @@
1-import { For, Show, createEffect, createMemo, createSignal } from "solid-js";1+import { For, Show, createEffect, createMemo, createSignal, type JSX } from "solid-js";
2 import type { ColumnDef } from "@tanstack/solid-table";2 import type { ColumnDef } from "@tanstack/solid-table";
3 import { formatApiError } from "@/api/client";3 import { formatApiError } from "@/api/client";
4 import type { ExamWeightEntry } from "@/api/client";4 import type { ExamWeightEntry } from "@/api/client";
@@ -16,7 +16,8 @@ import { useT } from "@/stores/preferences-context";
16 16
17 /**17 /**
18 * An exam-kind weight map. `editing` opens the set-a-weight panel (the parent18 * An exam-kind weight map. `editing` opens the set-a-weight panel (the parent
19- * owns its header button); rows can be edited or removed when `canEdit`.19+ * passes its add button through `actions`, into the table toolbar beside
20+ * "Sütunlar"); rows can be edited or removed when `canEdit`.
20 */21 */
21 export function ExamWeightsEditor(props: {22 export function ExamWeightsEditor(props: {
22 weights: ExamWeightEntry[];23 weights: ExamWeightEntry[];
@@ -27,6 +28,8 @@ export function ExamWeightsEditor(props: {
27 onRemove?: (kind: string) => Promise<void>;28 onRemove?: (kind: string) => Promise<void>;
28 editing: ExamWeightEntry | "new" | null;29 editing: ExamWeightEntry | "new" | null;
29 onEditingChange: (entry: ExamWeightEntry | "new" | null) => void;30 onEditingChange: (entry: ExamWeightEntry | "new" | null) => void;
31+ /** Toolbar controls (add, reset), rendered in the table's toolbar card. */
32+ actions?: JSX.Element;
30 }) {33 }) {
31 const t = useT();34 const t = useT();
32 const [kind, setKind] = createSignal("");35 const [kind, setKind] = createSignal("");
@@ -108,7 +111,7 @@ export function ExamWeightsEditor(props: {
108 return (111 return (
109 <>112 <>
110 <Show when={removeError()}><Alert variant="destructive">{removeError()}</Alert></Show>113 <Show when={removeError()}><Alert variant="destructive">{removeError()}</Alert></Show>
111- <DataTable columns={columns()} data={props.weights} empty={t("common.noMatches")} />114+ <DataTable columns={columns()} data={props.weights} empty={t("common.noMatches")} actions={props.actions} />
112 <SidePanel115 <SidePanel
113 open={props.editing !== null}116 open={props.editing !== null}
114 onOpenChange={(open) => !open && props.onEditingChange(null)}117 onOpenChange={(open) => !open && props.onEditingChange(null)}
src/components/instances/instance-settings-panel.tsxmodified+12 -12
@@ -137,7 +137,7 @@ export function InstanceSettingsPanel(props: {
137 description={t("instances.contentHelp")}137 description={t("instances.contentHelp")}
138 actions={138 actions={
139 <Show when={props.canManage}>139 <Show when={props.canManage}>
140- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setEditingContent(true)}>140+ <Button type="button" size="sm" variant="outline" onClick={() => setEditingContent(true)}>
141 <IconEdit class="h-4 w-4" />141 <IconEdit class="h-4 w-4" />
142 {t("instances.editContent")}142 {t("instances.editContent")}
143 </Button>143 </Button>
@@ -179,17 +179,6 @@ export function InstanceSettingsPanel(props: {
179 <DataSection179 <DataSection
180 title={t("instances.examWeightsTitle")}180 title={t("instances.examWeightsTitle")}
181 description={`${t("instances.examWeightsHelp")} ${props.instance.exam_weights_inherited ? t("instances.examWeightsInheritedHint") : t("instances.examWeightsOwnHint")}`}181 description={`${t("instances.examWeightsHelp")} ${props.instance.exam_weights_inherited ? t("instances.examWeightsInheritedHint") : t("instances.examWeightsOwnHint")}`}
182- actions={
183- <Show when={props.canManage}>
184- <Show when={!props.instance.exam_weights_inherited}>
185- {resetButton({ fields: ["exam_weights"], label: t("instances.examWeightsTitle"), run: () => deleteInstanceExamWeights(props.instance.id) })}
186- </Show>
187- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setWeightEditing("new")}>
188- <IconPlus class="h-4 w-4" />
189- {t("instances.addWeight")}
190- </Button>
191- </Show>
192- }
193 >182 >
194 <OverrideBadge own={!props.instance.exam_weights_inherited} />183 <OverrideBadge own={!props.instance.exam_weights_inherited} />
195 <ExamWeightsEditor184 <ExamWeightsEditor
@@ -200,6 +189,17 @@ export function InstanceSettingsPanel(props: {
200 onEditingChange={setWeightEditing}189 onEditingChange={setWeightEditing}
201 onSet={(entry) => mutate(() => patchInstanceExamWeight(props.instance.id, entry))}190 onSet={(entry) => mutate(() => patchInstanceExamWeight(props.instance.id, entry))}
202 onRemove={props.instance.exam_weights_inherited ? undefined : (kind) => mutate(() => deleteInstanceExamWeightByKind(props.instance.id, kind))}191 onRemove={props.instance.exam_weights_inherited ? undefined : (kind) => mutate(() => deleteInstanceExamWeightByKind(props.instance.id, kind))}
192+ actions={
193+ <Show when={props.canManage}>
194+ <Show when={!props.instance.exam_weights_inherited}>
195+ {resetButton({ fields: ["exam_weights"], label: t("instances.examWeightsTitle"), run: () => deleteInstanceExamWeights(props.instance.id) })}
196+ </Show>
197+ <Button type="button" size="sm" onClick={() => setWeightEditing("new")}>
198+ <IconPlus class="h-4 w-4" />
199+ {t("instances.addWeight")}
200+ </Button>
201+ </Show>
202+ }
203 />203 />
204 </DataSection>204 </DataSection>
205 205
src/components/instances/instance-weekly-plan-panel.tsxmodified+31 -29
@@ -52,40 +52,42 @@ export function InstanceWeeklyPlanPanel(props: {
52 <DataSection52 <DataSection
53 title={t("weeklyPlan.title")}53 title={t("weeklyPlan.title")}
54 description={own() ? t("weeklyPlan.ownHint") : t("weeklyPlan.inheritedHint")}54 description={own() ? t("weeklyPlan.ownHint") : t("weeklyPlan.inheritedHint")}
55- actions={
56- <Show when={props.canManage}>
57- <Show when={own()}>
58- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setResetOpen(true)}>
59- <IconRotateCcw class="h-4 w-4" />
60- {t("override.reset")}
61- </Button>
62- </Show>
63- <Show when={props.canGenerate}>
64- <Button
65- type="button"
66- size="sm"
67- variant="outline"
68- class="rounded-lg"
69- disabled={props.instance.weekly_plan.length === 0 || props.instance.teachers.length === 0}
70- title={props.instance.teachers.length === 0 ? t("weeklyPlan.noTeacherHint") : undefined}
71- onClick={() => setGenerating(true)}
72- >
73- <IconCalendarCheck class="h-4 w-4" />
74- {t("weeklyPlan.generate")}
75- </Button>
76- </Show>
77- <Button type="button" size="sm" class="rounded-lg" onClick={() => setAdding(true)}>
78- <IconPlus class="h-4 w-4" />
79- {t("weeklyPlan.addSlot")}
80- </Button>
81- </Show>
82- }
83 >55 >
84 <div class="flex items-center gap-2">56 <div class="flex items-center gap-2">
85 <OverrideBadge own={own()} />57 <OverrideBadge own={own()} />
86 </div>58 </div>
87 <Show when={error()}><Alert variant="destructive">{error()}</Alert></Show>59 <Show when={error()}><Alert variant="destructive">{error()}</Alert></Show>
88- <WeeklyPlanTable slots={props.instance.weekly_plan} onRemove={props.canManage ? (slot) => void remove(slot) : undefined} />60+ <WeeklyPlanTable
61+ slots={props.instance.weekly_plan}
62+ onRemove={props.canManage ? (slot) => void remove(slot) : undefined}
63+ actions={
64+ <Show when={props.canManage}>
65+ <Show when={own()}>
66+ <Button type="button" size="sm" variant="outline" onClick={() => setResetOpen(true)}>
67+ <IconRotateCcw class="h-4 w-4" />
68+ {t("override.reset")}
69+ </Button>
70+ </Show>
71+ <Show when={props.canGenerate}>
72+ <Button
73+ type="button"
74+ size="sm"
75+ variant="outline"
76+ disabled={props.instance.weekly_plan.length === 0 || props.instance.teachers.length === 0}
77+ title={props.instance.teachers.length === 0 ? t("weeklyPlan.noTeacherHint") : undefined}
78+ onClick={() => setGenerating(true)}
79+ >
80+ <IconCalendarCheck class="h-4 w-4" />
81+ {t("weeklyPlan.generate")}
82+ </Button>
83+ </Show>
84+ <Button type="button" size="sm" onClick={() => setAdding(true)}>
85+ <IconPlus class="h-4 w-4" />
86+ {t("weeklyPlan.addSlot")}
87+ </Button>
88+ </Show>
89+ }
90+ />
89 91
90 <WeeklySlotForm92 <WeeklySlotForm
91 open={adding()}93 open={adding()}
src/components/instances/subject-set-editor.tsxmodified+6 -2
@@ -3,8 +3,10 @@ import { formatApiError } from "@/api/client";
3 import type { Subject } from "@/api/client";3 import type { Subject } from "@/api/client";
4 import { Alert } from "@/components/ui/alert";4 import { Alert } from "@/components/ui/alert";
5 import { Button } from "@/components/ui/button";5 import { Button } from "@/components/ui/button";
6+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
6 import { IconPlus, IconX } from "@/components/ui/icons";7 import { IconPlus, IconX } from "@/components/ui/icons";
7 import { SearchableSelect } from "@/components/ui/searchable-select";8 import { SearchableSelect } from "@/components/ui/searchable-select";
9+import { cn } from "@/lib/cn";
8 import { useT } from "@/stores/preferences-context";10 import { useT } from "@/stores/preferences-context";
9 11
10 /**12 /**
@@ -67,9 +69,11 @@ export function SubjectSetEditor(props: {
67 </Show>69 </Show>
68 <Show when={props.canEdit}>70 <Show when={props.canEdit}>
69 <Show when={addable().length > 0} fallback={<p class="text-xs text-muted-foreground">{t("instances.allSubjectsSelected")}</p>}>71 <Show when={addable().length > 0} fallback={<p class="text-xs text-muted-foreground">{t("instances.allSubjectsSelected")}</p>}>
72+ {/* Picker and button are one control row: both take the toolbar
73+ pill so the button is not a 26px chip beside a 36px field. */}
70 <div class="flex flex-wrap items-center gap-2">74 <div class="flex flex-wrap items-center gap-2">
71 <SearchableSelect75 <SearchableSelect
72- class="min-w-56 flex-1 sm:max-w-sm"76+ class={cn(TOOLBAR_CONTROL, "min-w-56 flex-1 sm:max-w-sm [&_input]:text-[13px]")}
73 value={pick()}77 value={pick()}
74 onChange={setPick}78 onChange={setPick}
75 placeholder={t("instances.addSubject")}79 placeholder={t("instances.addSubject")}
@@ -79,7 +83,7 @@ export function SubjectSetEditor(props: {
79 type="button"83 type="button"
80 size="sm"84 size="sm"
81 variant="outline"85 variant="outline"
82- class="rounded-lg"86+ class={cn(TOOLBAR_CONTROL, "px-3.5")}
83 disabled={!pick() || pending()}87 disabled={!pick() || pending()}
84 onClick={() => void run(async () => { await props.onAdd(pick()); setPick(""); })}88 onClick={() => void run(async () => { await props.onAdd(pick()); setPick(""); })}
85 >89 >
src/components/instances/weekly-plan-table.tsxmodified+8 -4
@@ -1,4 +1,4 @@
1-import { createMemo } from "solid-js";1+import { createMemo, type JSX } from "solid-js";
2 import type { ColumnDef } from "@tanstack/solid-table";2 import type { ColumnDef } from "@tanstack/solid-table";
3 import type { WeeklySlot } from "@/api/client";3 import type { WeeklySlot } from "@/api/client";
4 import { DataTable } from "@/components/ui/data-table";4 import { DataTable } from "@/components/ui/data-table";
@@ -7,8 +7,12 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
7 import { minutesToHHmm, sortSlots, weekdayLabel } from "@/lib/weekly-plan";7 import { minutesToHHmm, sortSlots, weekdayLabel } from "@/lib/weekly-plan";
8 import { usePreferences, useT } from "@/stores/preferences-context";8 import { usePreferences, useT } from "@/stores/preferences-context";
9 9
10-/** A weekly plan's slots, weekday first; removable when `onRemove` is given. */10+/**
11-export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot: WeeklySlot) => void; empty?: string }) {11+ * A weekly plan's slots, weekday first; removable when `onRemove` is given.
12+ * `actions` (add slot, generate, reset) sit in the table's toolbar card beside
13+ * "Sütunlar", not in a header row above it.
14+ */
15+export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot: WeeklySlot) => void; empty?: string; actions?: JSX.Element }) {
12 const t = useT();16 const t = useT();
13 const { locale } = usePreferences();17 const { locale } = usePreferences();
14 const rows = createMemo(() => sortSlots(props.slots));18 const rows = createMemo(() => sortSlots(props.slots));
@@ -50,5 +54,5 @@ export function WeeklyPlanTable(props: { slots: WeeklySlot[]; onRemove?: (slot:
50 ]54 ]
51 : []),55 : []),
52 ]);56 ]);
53- return <DataTable columns={columns()} data={rows()} empty={props.empty ?? t("weeklyPlan.empty")} />;57+ return <DataTable columns={columns()} data={rows()} empty={props.empty ?? t("weeklyPlan.empty")} actions={props.actions} />;
54 }58 }
src/components/meals/meal-dish-list.tsxmodified+3 -1
@@ -2,8 +2,10 @@ import { For, Show } from "solid-js";
2 import type { MealDish } from "@/api/client";2 import type { MealDish } from "@/api/client";
3 import { MealDishRow } from "@/components/meals/meal-dish-row";3 import { MealDishRow } from "@/components/meals/meal-dish-row";
4 import { Button } from "@/components/ui/button";4 import { Button } from "@/components/ui/button";
5+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
5 import { EmptyInline } from "@/components/ui/empty-inline";6 import { EmptyInline } from "@/components/ui/empty-inline";
6 import { IconAlert, IconPlus } from "@/components/ui/icons";7 import { IconAlert, IconPlus } from "@/components/ui/icons";
8+import { cn } from "@/lib/cn";
7 import { dietaryTagLabel, formatTry } from "@/lib/meals";9 import { dietaryTagLabel, formatTry } from "@/lib/meals";
8 import { useT } from "@/stores/preferences-context";10 import { useT } from "@/stores/preferences-context";
9 11
@@ -27,7 +29,7 @@ export function MealDishList(props: {
27 <p class="mt-1 text-sm text-muted-foreground">{t("meals.dishCount", { count: props.dishes.length })}</p>29 <p class="mt-1 text-sm text-muted-foreground">{t("meals.dishCount", { count: props.dishes.length })}</p>
28 </div>30 </div>
29 <Show when={props.canManage}>31 <Show when={props.canManage}>
30- <Button variant="outline" size="sm" class="rounded-lg" onClick={props.onAdd}>32+ <Button variant="outline" size="sm" class={cn(TOOLBAR_CONTROL, "px-3.5")} onClick={props.onAdd}>
31 <IconPlus class="h-4 w-4" />33 <IconPlus class="h-4 w-4" />
32 {t("meals.addDish")}34 {t("meals.addDish")}
33 </Button>35 </Button>
src/components/meals/meal-week-nav.tsxmodified+12 -7
@@ -3,12 +3,15 @@ import type { MealSlot } from "@/api/client";
3 import { Button } from "@/components/ui/button";3 import { Button } from "@/components/ui/button";
4 import { DatePicker } from "@/components/ui/date-picker";4 import { DatePicker } from "@/components/ui/date-picker";
5 import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons";5 import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons";
6+import { TOOLBAR_CARD, TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
6 import { Select } from "@/components/ui/select";7 import { Select } from "@/components/ui/select";
8+import { cn } from "@/lib/cn";
7 import { inputDateToIso } from "@/lib/datetime-input";9 import { inputDateToIso } from "@/lib/datetime-input";
8 import { addDaysIso, formatMealWeek, mealSlotLabel, weekStartIso } from "@/lib/meals";10 import { addDaysIso, formatMealWeek, mealSlotLabel, weekStartIso } from "@/lib/meals";
9 import { useT } from "@/stores/preferences-context";11 import { useT } from "@/stores/preferences-context";
10 12
11-/** Week stepper, a date jump and the slot filter — the list's whole toolbar. */13+/** Week stepper, a date jump and the slot filter — the list's whole toolbar,
14+ * on its own card with every control at the shared toolbar height. */
12 export function MealWeekNav(props: {15 export function MealWeekNav(props: {
13 weekStart: string;16 weekStart: string;
14 thisWeek: string;17 thisWeek: string;
@@ -19,29 +22,31 @@ export function MealWeekNav(props: {
19 onSlotChange: (slot: string) => void;22 onSlotChange: (slot: string) => void;
20 }) {23 }) {
21 const t = useT();24 const t = useT();
25+ const step = "h-10 w-10 rounded-full sm:h-8 sm:w-8 touch:h-10 touch:w-10";
22 return (26 return (
23- <div class="flex flex-wrap items-center gap-2">27+ <div class={cn("flex flex-wrap items-center gap-2", TOOLBAR_CARD)}>
24 <div class="flex items-center gap-1">28 <div class="flex items-center gap-1">
25- <Button variant="outline" size="icon" class="h-8 w-8 rounded-lg" aria-label={t("meals.prevWeek")} onClick={() => props.onWeekChange(addDaysIso(props.weekStart, -7))}>29+ <Button variant="outline" size="icon" class={step} aria-label={t("meals.prevWeek")} onClick={() => props.onWeekChange(addDaysIso(props.weekStart, -7))}>
26 <IconChevronLeft class="h-4 w-4" />30 <IconChevronLeft class="h-4 w-4" />
27 </Button>31 </Button>
28- <Button variant="outline" size="icon" class="h-8 w-8 rounded-lg" aria-label={t("meals.nextWeek")} onClick={() => props.onWeekChange(addDaysIso(props.weekStart, 7))}>32+ <Button variant="outline" size="icon" class={step} aria-label={t("meals.nextWeek")} onClick={() => props.onWeekChange(addDaysIso(props.weekStart, 7))}>
29 <IconChevronRight class="h-4 w-4" />33 <IconChevronRight class="h-4 w-4" />
30 </Button>34 </Button>
31 </div>35 </div>
32 <p class="min-w-0 text-sm font-medium text-text-strong tabular-nums" aria-live="polite">{formatMealWeek(props.weekStart, props.locale)}</p>36 <p class="min-w-0 text-sm font-medium text-text-strong tabular-nums" aria-live="polite">{formatMealWeek(props.weekStart, props.locale)}</p>
33- <Button variant="ghost" size="sm" class="h-8 rounded-lg text-[13px]" disabled={props.weekStart === props.thisWeek} onClick={() => props.onWeekChange(props.thisWeek)}>37+ <Button variant="ghost" size="sm" class={cn(TOOLBAR_CONTROL, "px-3.5")} disabled={props.weekStart === props.thisWeek} onClick={() => props.onWeekChange(props.thisWeek)}>
34 {t("meals.thisWeek")}38 {t("meals.thisWeek")}
35 </Button>39 </Button>
36 <div class="flex w-full flex-wrap items-center gap-2 sm:ml-auto sm:w-auto">40 <div class="flex w-full flex-wrap items-center gap-2 sm:ml-auto sm:w-auto">
37 <DatePicker41 <DatePicker
38 id="menus-week"42 id="menus-week"
39- class="h-8 w-40"43+ // 16px on touch screens: below that iOS zooms into the focused field.
44+ class={cn(TOOLBAR_CONTROL, "w-40 text-base sm:text-[13px] md:text-[13px] touch:text-base")}
40 placeholder={t("meals.goToDate")}45 placeholder={t("meals.goToDate")}
41 value=""46 value=""
42 onChange={(value) => { const iso = inputDateToIso(value); if (iso) props.onWeekChange(weekStartIso(iso), iso); }}47 onChange={(value) => { const iso = inputDateToIso(value); if (iso) props.onWeekChange(weekStartIso(iso), iso); }}
43 />48 />
44- <Select id="menus-slot" aria-label={t("meals.slot")} wrapperClass="w-auto" class="h-8 rounded-lg text-[13px]" value={props.slot} onChange={(e) => props.onSlotChange(e.currentTarget.value)}>49+ <Select id="menus-slot" aria-label={t("meals.slot")} wrapperClass="w-auto" class={TOOLBAR_CONTROL} value={props.slot} onChange={(e) => props.onSlotChange(e.currentTarget.value)}>
45 <option value="all">{t("meals.slot")}: {t("common.all")}</option>50 <option value="all">{t("meals.slot")}: {t("common.all")}</option>
46 <For each={props.slots}>{(item) => <option value={item.name}>{mealSlotLabel(item.name, t)}</option>}</For>51 <For each={props.slots}>{(item) => <option value={item.name}>{mealSlotLabel(item.name, t)}</option>}</For>
47 </Select>52 </Select>
src/components/sessions/course-sessions-panel.tsxmodified+1 -1
@@ -286,7 +286,7 @@ export function CourseSessionsPanel(props: {
286 empty={t("sessions.empty")}286 empty={t("sessions.empty")}
287 onRowClick={setDetailSession}287 onRowClick={setDetailSession}
288 actions={props.canManage ? (288 actions={props.canManage ? (
289- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => props.onCreateOpenChange(true)}>289+ <Button type="button" size="sm" onClick={() => props.onCreateOpenChange(true)}>
290 <IconPlus class="h-4 w-4" />{t("sessions.add")}290 <IconPlus class="h-4 w-4" />{t("sessions.add")}
291 </Button>291 </Button>
292 ) : undefined}292 ) : undefined}
src/components/ui/button.tsxmodified+10 -3
@@ -9,11 +9,18 @@ export const buttonVariants = cva(
9 variants: {9 variants: {
10 variant: {10 variant: {
11 // Flat (no shadows), neutral fills, subtle hairline outlines.11 // Flat (no shadows), neutral fills, subtle hairline outlines.
12- default: "bg-primary text-primary-foreground hover:bg-primary/90",12+ // Filled variants carry a transparent 1px border and clip their fill
13- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",13+ // to the padding box: the box matches an outline button's height, and
14+ // the visible fill sits 1px inside it like an outline's hairline, so a
15+ // filled pill never reads bigger than the bordered pill next to it.
16+ // A filled button never gets a border in its own fill colour.
17+ default: "border border-transparent bg-primary bg-clip-padding text-primary-foreground hover:bg-primary/90",
18+ destructive:
19+ "border border-transparent bg-destructive bg-clip-padding text-destructive-foreground hover:bg-destructive/90",
14 outline:20 outline:
15 "border border-border/70 bg-transparent hover:border-border hover:bg-muted/60 hover:text-foreground",21 "border border-border/70 bg-transparent hover:border-border hover:bg-muted/60 hover:text-foreground",
16- secondary: "border border-border/60 bg-secondary text-secondary-foreground hover:bg-secondary/80",22+ secondary:
23+ "border border-transparent bg-secondary bg-clip-padding text-secondary-foreground hover:bg-secondary/80",
17 ghost: "text-foreground/75 hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",24 ghost: "text-foreground/75 hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",
18 link: "text-primary-text underline-offset-4 hover:underline active:scale-100",25 link: "text-primary-text underline-offset-4 hover:underline active:scale-100",
19 },26 },
src/components/ui/data-section.tsxmodified+4 -1
@@ -1,4 +1,5 @@
1 import { Show, type JSX, type ParentProps } from "solid-js";1 import { Show, type JSX, type ParentProps } from "solid-js";
2+import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
2 import { cn } from "@/lib/cn";3 import { cn } from "@/lib/cn";
3 4
4 /**5 /**
@@ -22,7 +23,9 @@ export function DataSection(
22 </Show>23 </Show>
23 </div>24 </div>
24 <Show when={props.actions}>25 <Show when={props.actions}>
25- <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:h-9 [&_button]:rounded-md">{props.actions}</div>26+ {/* Header actions are toolbar controls too: the same pill and height
27+ as a DataTable toolbar, never a taller h-9 button of their own. */}
28+ <div class={cn("flex min-w-0 flex-wrap items-center gap-2", TOOLBAR_SLOT)}>{props.actions}</div>
26 </Show>29 </Show>
27 </div>30 </div>
28 </Show>31 </Show>
src/components/ui/data-table-search.tsxmodified+2 -1
@@ -51,7 +51,8 @@ export function DataTableSearch(props: DataTableSearchProps) {
51 aria-describedby={props.hint ? hintId : undefined}51 aria-describedby={props.hint ? hintId : undefined}
52 // Touch screens get a touch-sized box at 16px (index.css): below that52 // Touch screens get a touch-sized box at 16px (index.css): below that
53 // iOS Safari zooms the page into a focused field. Compact otherwise.53 // iOS Safari zooms the page into a focused field. Compact otherwise.
54- 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")}54+ // A pill, like every other toolbar control beside it.
55+ 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")}
55 />56 />
56 <Show when={props.value}>57 <Show when={props.value}>
57 <button58 <button
src/components/ui/data-table-view-menu.tsxmodified+1 -1
@@ -26,7 +26,7 @@ export function DataTableViewMenu(props: DataTableViewMenuProps) {
26 26
27 return (27 return (
28 <DropdownMenu placement="bottom-end" gutter={6}>28 <DropdownMenu placement="bottom-end" gutter={6}>
29- <DropdownMenuTrigger class="ml-auto inline-flex h-8 touch:h-10 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-border/70 bg-muted/40 px-3 text-[13px] font-medium transition-all hover:bg-muted active:scale-[0.98] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">29+ <DropdownMenuTrigger class="ml-auto inline-flex h-10 sm:h-8 touch:h-10 items-center justify-center gap-2 whitespace-nowrap rounded-full border border-border/70 bg-muted/40 px-3 text-[13px] font-medium transition-all hover:border-border hover:bg-muted/60 active:scale-[0.98] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">
30 {t("common.columns")}30 {t("common.columns")}
31 <IconChevronDown class="h-3.5 w-3.5 opacity-60" />31 <IconChevronDown class="h-3.5 w-3.5 opacity-60" />
32 </DropdownMenuTrigger>32 </DropdownMenuTrigger>
src/components/ui/data-table.test.tsxmodified+99 -50
@@ -82,28 +82,25 @@ test("freezes the meta.stickyLeft column and centres headers and left-aligns cel
82 expect(roleCell.classList).toContain("text-left");82 expect(roleCell.classList).toContain("text-left");
83 });83 });
84 84
85-test("paginates tables by default", () => {85+/** Stand-in IntersectionObserver whose callback a test fires by hand. */
86- const rows = Array.from({ length: 11 }, (_, index) => ({ name: `Person ${index + 1}` }));86+function stubIntersectionObserver() {
87- render(() => (87+ const callbacks: IntersectionObserverCallback[] = [];
88- <PreferencesProvider>88+ class FakeObserver {
89- <DataTable columns={[columns[0]]} data={rows} enableColumnVisibility={false} />89+ constructor(callback: IntersectionObserverCallback) {
90- </PreferencesProvider>90+ callbacks.push(callback);
91- ));91+ }
92-92+ observe() {}
93- expect(screen.getByText("Person 10")).toBeTruthy();93+ disconnect() {}
94- expect(screen.queryByText("Person 11")).toBeNull();94+ }
95- fireEvent.click(screen.getByRole("button", { name: "Next" }));95+ vi.stubGlobal("IntersectionObserver", FakeObserver);
96- expect(screen.getByText("Person 11")).toBeTruthy();96+ return () => {
97-});97+ for (const callback of callbacks) callback([{ isIntersecting: true } as IntersectionObserverEntry], {} as IntersectionObserver);
98-98+ };
99-test("halves the page on a phone", () => {99+}
100- vi.stubGlobal("matchMedia", (query: string) => ({100+
101- matches: true,101+test("reveals rows in steps instead of paging", async () => {
102- media: query,102+ const reachEnd = stubIntersectionObserver();
103- addEventListener: () => undefined,103+ const rows = Array.from({ length: 120 }, (_, index) => ({ name: `Person ${index + 1}` }));
104- removeEventListener: () => undefined,
105- }));
106- const rows = Array.from({ length: 11 }, (_, index) => ({ name: `Person ${index + 1}` }));
107 try {104 try {
108 render(() => (105 render(() => (
109 <PreferencesProvider>106 <PreferencesProvider>
@@ -111,26 +108,35 @@ test("halves the page on a phone", () => {
111 </PreferencesProvider>108 </PreferencesProvider>
112 ));109 ));
113 110
114- expect(screen.getByText("Person 5")).toBeTruthy();111+ expect(screen.getByText("Person 50")).toBeTruthy();
115- expect(screen.queryByText("Person 6")).toBeNull();112+ expect(screen.queryByText("Person 51")).toBeNull();
116- expect(screen.getByText("1 / 3")).toBeTruthy();113+ expect(screen.getByText(/(Showing 50 of 120|120 kayıttan 50)/)).toBeTruthy();
114+ expect(screen.queryByRole("button", { name: "Next" })).toBeNull();
115+ reachEnd();
116+ // jsdom lays nothing out, so the sentinel always reads as near the end
117+ // and each reveal chains into the next until the list is complete.
118+ await new Promise((resolve) => setTimeout(resolve, 0));
119+ expect(screen.getByText("Person 120")).toBeTruthy();
117 } finally {120 } finally {
118 vi.unstubAllGlobals();121 vi.unstubAllGlobals();
119 }122 }
120 });123 });
121 124
122-test("a single page keeps the row count but drops the page buttons", () => {125+test("without IntersectionObserver every row renders, with the total under the list", () => {
123- render(() => (126+ vi.stubGlobal("IntersectionObserver", undefined);
124- <PreferencesProvider>127+ const rows = Array.from({ length: 60 }, (_, index) => ({ name: `Person ${index + 1}` }));
125- <DataTable columns={[columns[0]]} data={[{ name: "Ada" }]} enableColumnVisibility={false} />128+ try {
126- </PreferencesProvider>129+ render(() => (
127- ));130+ <PreferencesProvider>
128-131+ <DataTable columns={[columns[0]]} data={rows} enableColumnVisibility={false} />
129- expect(screen.getByText("1-1 / 1")).toBeTruthy();132+ </PreferencesProvider>
130- expect(screen.queryByRole("button", { name: "Previous" })).toBeNull();133+ ));
131- expect(screen.queryByRole("button", { name: "Next" })).toBeNull();134+ expect(screen.getByText("Person 60")).toBeTruthy();
135+ expect(screen.getByText(/^(Total|Toplam): 60$/)).toBeTruthy();
136+ } finally {
137+ vi.unstubAllGlobals();
138+ }
132 });139 });
133-
134 test("a display column renders its own cell instead of the empty dash", () => {140 test("a display column renders its own cell instead of the empty dash", () => {
135 // A column with no accessorFn has no value to be empty, so the empty-cell141 // A column with no accessorFn has no value to be empty, so the empty-cell
136 // fallback must not swallow its render function.142 // fallback must not swallow its render function.
@@ -309,30 +315,48 @@ test("an empty list narrowed by the caller's filters offers to clear them", () =
309 expect(onClearFilters).toHaveBeenCalledOnce();315 expect(onClearFilters).toHaveBeenCalledOnce();
310 });316 });
311 317
312-test("the next page holds when the caller hands over a fresh data array", async () => {318+test("revealed rows hold when the caller hands over a fresh data array", async () => {
319+ const reachEnd = stubIntersectionObserver();
313 const [tick, setTick] = createSignal(0);320 const [tick, setTick] = createSignal(0);
314- const people = Array.from({ length: 12 }, (_, i) => ({ name: `P${String(i).padStart(2, "0")}` }));321+ const people = Array.from({ length: 70 }, (_, i) => ({ name: `P${String(i).padStart(2, "0")}` }));
315- render(() => (322+ try {
323+ render(() => (
324+ <PreferencesProvider>
325+ {/* A new array on every read, like a page that maps rows inline. */}
326+ <DataTable columns={[{ accessorKey: "name", header: "Name" }]} data={(tick(), people.map((row) => ({ ...row })))} enableColumnVisibility={false} />
327+ </PreferencesProvider>
328+ ));
329+ reachEnd();
330+ await new Promise((resolve) => setTimeout(resolve, 0));
331+ expect(screen.getByText("P69")).toBeTruthy();
332+ setTick(1);
333+ expect(screen.getByText("P69")).toBeTruthy();
334+ } finally {
335+ vi.unstubAllGlobals();
336+ }
337+});
338+test("a toolbar holding only the column menu still gets its card", () => {
339+ const { container } = render(() => (
316 <PreferencesProvider>340 <PreferencesProvider>
317- {/* A new array on every read, like a page that maps rows inline. */}341+ <DataTable columns={[{ accessorKey: "name", header: "Name" }, { accessorKey: "role", header: "Role" }]} data={[{ name: "Ada", role: "a" }]} />
318- <DataTable columns={[{ accessorKey: "name", header: "Name" }]} data={(tick(), people.map((row) => ({ ...row })))} enableColumnVisibility={false} />
319 </PreferencesProvider>342 </PreferencesProvider>
320 ));343 ));
321- fireEvent.click(screen.getByRole("button", { name: /Next|Sonraki/ }));344+ const toolbar = container.querySelector(".space-y-3 > div");
322- expect(screen.getByText("P10")).toBeTruthy();345+ expect(toolbar?.className).toContain("rounded-xl");
323- setTick(1);
324- expect(screen.getByText("P10")).toBeTruthy();
325- expect(screen.queryByText("P00")).toBeNull();
326 });346 });
327 347
328-test("a toolbar holding only the column menu is not boxed", () => {348+test("page actions in the toolbar take the shared control height", () => {
329 const { container } = render(() => (349 const { container } = render(() => (
330 <PreferencesProvider>350 <PreferencesProvider>
331- <DataTable columns={[{ accessorKey: "name", header: "Name" }, { accessorKey: "role", header: "Role" }]} data={[{ name: "Ada", role: "a" }]} />351+ <DataTable
352+ columns={[{ accessorKey: "name", header: "Name" }, { accessorKey: "role", header: "Role" }]}
353+ data={[{ name: "Ada", role: "a" }]}
354+ actions={<button type="button">Add</button>}
355+ />
332 </PreferencesProvider>356 </PreferencesProvider>
333 ));357 ));
334- const toolbar = container.querySelector(".space-y-3 > div");358+ const add = [...container.querySelectorAll("button")].find((el) => el.textContent === "Add");
335- expect(toolbar?.className).not.toContain("rounded-xl");359+ expect(add?.parentElement?.className).toContain("sm:[&_button]:h-8");
336 });360 });
337 361
338 test("meta.headerInfo puts a labelled info icon beside the header that opens without sorting", async () => {362 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
359 // No always-visible copy of the note is left in the table.383 // No always-visible copy of the note is left in the table.
360 expect(document.querySelector("table")?.textContent).not.toContain("Filled in for small schools only.");384 expect(document.querySelector("table")?.textContent).not.toContain("Filled in for small schools only.");
361 });385 });
386+
387+test("an infinite table asks for the next page near its end and does not sort", async () => {
388+ const reachEnd = stubIntersectionObserver();
389+ const onLoadMore = vi.fn();
390+ const rows = Array.from({ length: 50 }, (_, index) => ({ name: `Person ${index + 1}` }));
391+ try {
392+ render(() => (
393+ <PreferencesProvider>
394+ <DataTable
395+ columns={[columns[0]]}
396+ data={rows}
397+ enableColumnVisibility={false}
398+ infinite={{ hasMore: true, loading: false, total: 120, onLoadMore }}
399+ />
400+ </PreferencesProvider>
401+ ));
402+ expect(screen.getByText("Person 50")).toBeTruthy();
403+ expect(screen.getByText(/(Showing 50 of 120|120 kayıttan 50)/)).toBeTruthy();
404+ expect(screen.getByRole("columnheader").getAttribute("aria-sort")).not.toBe("ascending");
405+ reachEnd();
406+ expect(onLoadMore).toHaveBeenCalledTimes(1);
407+ } finally {
408+ vi.unstubAllGlobals();
409+ }
410+});
src/components/ui/data-table.tsxmodified+127 -58
@@ -11,7 +11,6 @@ import {
11 flexRender,11 flexRender,
12 getCoreRowModel,12 getCoreRowModel,
13 getFilteredRowModel,13 getFilteredRowModel,
14- getPaginationRowModel,
15 getSortedRowModel,14 getSortedRowModel,
16 } from "@tanstack/solid-table";15 } from "@tanstack/solid-table";
17 import { Illustration } from "@/components/ui/illustration";16 import { Illustration } from "@/components/ui/illustration";
@@ -24,9 +23,9 @@ import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/
24 import { InfoTip } from "@/components/ui/info-tip";23 import { InfoTip } from "@/components/ui/info-tip";
25 import { cn } from "@/lib/cn";24 import { cn } from "@/lib/cn";
26 import { createMediaQuery } from "@/lib/create-media-query";25 import { createMediaQuery } from "@/lib/create-media-query";
27-import { COMPACT_SCREEN_QUERY, createResponsivePageSize } from "@/lib/create-page-size";26+import { COMPACT_SCREEN_QUERY } from "@/lib/create-page-size";
28 import { createTablePreferences } from "@/lib/table-preferences";27 import { createTablePreferences } from "@/lib/table-preferences";
29-import { createUrlPageIndex, createUrlParam, createUrlString, decodeSort, encodeSort, listParamKeys } from "@/lib/url-state";28+import { createUrlParam, createUrlString, decodeSort, encodeSort, listParamKeys } from "@/lib/url-state";
30 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";29 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
31 import { useT } from "@/stores/preferences-context";30 import { useT } from "@/stores/preferences-context";
32 31
@@ -78,6 +77,19 @@ export type DataTableProps<TData, TValue = unknown> = {
78 total: number;77 total: number;
79 onPageChange: (pageIndex: number) => void;78 onPageChange: (pageIndex: number) => void;
80 };79 };
80+ /**
81+ * Fetch-as-you-scroll: `data` holds the rows loaded so far and the table
82+ * asks for the next page (`onLoadMore`) as the reader nears its end. Pair
83+ * with `createInfiniteList` (lib/infinite-list); search must reach the
84+ * server through `onSearchInput`, and sorting is off (the backend takes no
85+ * sort parameter, so a header sort would order the loaded rows alone).
86+ */
87+ infinite?: {
88+ hasMore: boolean;
89+ loading: boolean;
90+ total: number;
91+ onLoadMore: () => void;
92+ };
81 /**93 /**
82 * Below the `sm` breakpoint rows render as cards (first column as the94 * Below the `sm` breakpoint rows render as cards (first column as the
83 * title, actions top-right, the rest as label/value pairs) instead of a95 * title, actions top-right, the rest as label/value pairs) instead of a
@@ -86,7 +98,10 @@ export type DataTableProps<TData, TValue = unknown> = {
86 mobileLayout?: "cards" | "scroll";98 mobileLayout?: "cards" | "scroll";
87 onRowClick?: (row: TData) => void;99 onRowClick?: (row: TData) => void;
88 onSearchInput?: (value: string) => void;100 onSearchInput?: (value: string) => void;
89- /** Rows per page on a wide screen; phones get `compactPageSize` of it. */101+ /**
102+ * Server-paged tables only: rows per page on a wide screen. A client-side
103+ * table has no pages — it reveals rows as the reader scrolls.
104+ */
90 pageSize?: number;105 pageSize?: number;
91 searchPredicate?: (row: TData, query: string) => boolean;106 searchPredicate?: (row: TData, query: string) => boolean;
92 searchValue?: string;107 searchValue?: string;
@@ -105,7 +120,7 @@ export type DataTableProps<TData, TValue = unknown> = {
105 * `searchValue` / `onSearchInput` keeps its own.120 * `searchValue` / `onSearchInput` keeps its own.
106 */121 */
107 urlState?: boolean | string;122 urlState?: boolean | string;
108- /** Back to page one whenever this changes — pass the caller's own filters. */123+ /** Back to the top of the list whenever this changes — pass the caller's own filters. */
109 pageResetKey?: unknown;124 pageResetKey?: unknown;
110 /**125 /**
111 * The caller's own filters narrow the list. An empty result then offers126 * The caller's own filters narrow the list. An empty result then offers
@@ -120,6 +135,15 @@ const resolveUpdater = <T,>(updater: Updater<T>, old: T): T =>
120 135
121 const alignClass = { left: "text-left", center: "text-center", right: "text-right" } as const;136 const alignClass = { left: "text-left", center: "text-center", right: "text-right" } as const;
122 137
138+/**
139+ * A client-side table renders this many rows, then this many more each time
140+ * the reader nears the end. The data is already in memory, so sorting, search
141+ * and filters still see every row — only the DOM is paced.
142+ */
143+const REVEAL_STEP = 50;
144+/** Start revealing the next rows this far before the list's end comes into view. */
145+const REVEAL_MARGIN_PX = 600;
146+
123 export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, TValue>) {147 export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, TValue>) {
124 const t = useT();148 const t = useT();
125 const paginationEnabled = props.enablePagination ?? true;149 const paginationEnabled = props.enablePagination ?? true;
@@ -132,15 +156,12 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
132 ? createUrlParam<SortingState>(urlKeys.sort, { parse: decodeSort, serialize: encodeSort })156 ? createUrlParam<SortingState>(urlKeys.sort, { parse: decodeSort, serialize: encodeSort })
133 : createSignal<SortingState>([]);157 : createSignal<SortingState>([]);
134 const [otherColumnFilters, setOtherColumnFilters] = createSignal<ColumnFiltersState>([]);158 const [otherColumnFilters, setOtherColumnFilters] = createSignal<ColumnFiltersState>([]);
135- const clientPageSize = createResponsivePageSize(props.pageSize ?? 10);159+ // Client-side tables drop page numbers for scroll-to-reveal; only a
136- const [clientPageIndex, setClientPageIndex] = urlKeys && !props.manualPagination160+ // server-paged table (`manualPagination`) still pages.
137- ? createUrlPageIndex(urlKeys.page)161+ const revealing = () => paginationEnabled && !props.manualPagination && !props.infinite;
138- : createSignal(0);162+ const [revealed, setRevealed] = createSignal(REVEAL_STEP);
139- const pagination = (): PaginationState => ({ pageIndex: clientPageIndex(), pageSize: clientPageSize() });163+ const resetReveal = () => setRevealed(REVEAL_STEP);
140- // A page index means nothing once the page size changes under it (a phone164+ createEffect(on(() => props.pageResetKey, resetReveal, { defer: true }));
141- // rotated, a window narrowed): start over rather than land mid-list.
142- createEffect(on(clientPageSize, () => setClientPageIndex(0), { defer: true }));
143- createEffect(on(() => props.pageResetKey, () => setClientPageIndex(0), { defer: true }));
144 // The search box's text when the table owns it — the `searchPredicate`165 // The search box's text when the table owns it — the `searchPredicate`
145 // query, or the `filterColumn` filter value.166 // query, or the `filterColumn` filter value.
146 const [search, setSearch] = urlKeys && props.searchValue === undefined && !props.onSearchInput167 const [search, setSearch] = urlKeys && props.searchValue === undefined && !props.onSearchInput
@@ -164,16 +185,17 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
164 const own = next.find((filter) => filter.id === column);185 const own = next.find((filter) => filter.id === column);
165 setSearch(typeof own?.value === "string" ? own.value : "");186 setSearch(typeof own?.value === "string" ? own.value : "");
166 setOtherColumnFilters(next.filter((filter) => filter.id !== column));187 setOtherColumnFilters(next.filter((filter) => filter.id !== column));
188+ resetReveal();
167 };189 };
168- // A sort order reshuffles every page: start from the first one.190+ // A new sort order is a new list: start again from its top.
169 const setSorting = (next: SortingState) => {191 const setSorting = (next: SortingState) => {
170 setSortingState(next);192 setSortingState(next);
171- setClientPageIndex(0);193+ resetReveal();
172 };194 };
173 // Sorting is client-side only, and the backend takes no sort parameter: on195 // Sorting is client-side only, and the backend takes no sort parameter: on
174 // a server-paged table it would reorder the visible page alone while the196 // a server-paged table it would reorder the visible page alone while the
175 // header claimed the whole list. Off there unless a caller opts in.197 // header claimed the whole list. Off there unless a caller opts in.
176- const sortingEnabled = () => props.enableSorting ?? !props.manualPagination;198+ const sortingEnabled = () => props.enableSorting ?? !(props.manualPagination || props.infinite);
177 const tableData = () => {199 const tableData = () => {
178 const query = searchValue().trim();200 const query = searchValue().trim();
179 if (!query || !props.searchPredicate) return props.data;201 if (!query || !props.searchPredicate) return props.data;
@@ -195,17 +217,12 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
195 getCoreRowModel: getCoreRowModel(),217 getCoreRowModel: getCoreRowModel(),
196 getSortedRowModel: getSortedRowModel(),218 getSortedRowModel: getSortedRowModel(),
197 getFilteredRowModel: getFilteredRowModel(),219 getFilteredRowModel: getFilteredRowModel(),
198- ...(paginationEnabled && !props.manualPagination ? { getPaginationRowModel: getPaginationRowModel() } : {}),220+ // Server paging is the caller's; the table itself never slices pages.
199- // The page index is ours, not the table's: an automatic reset on every
200- // new `data` array sent a page that rebuilds its rows on each read (a
201- // clock tick, a fresh map) straight back to page one on "Sonraki", and
202- // would wipe a page restored from the URL on the first refetch.
203 autoResetPageIndex: false,221 autoResetPageIndex: false,
204 onSortingChange: (updater) => setSorting(resolveUpdater(updater, sorting())),222 onSortingChange: (updater) => setSorting(resolveUpdater(updater, sorting())),
205 onColumnFiltersChange: (updater) => setColumnFilters(resolveUpdater(updater, columnFilters())),223 onColumnFiltersChange: (updater) => setColumnFilters(resolveUpdater(updater, columnFilters())),
206 onColumnVisibilityChange: (updater) =>224 onColumnVisibilityChange: (updater) =>
207 prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)),225 prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)),
208- onPaginationChange: (updater) => setClientPageIndex(resolveUpdater(updater, pagination()).pageIndex),
209 state: {226 state: {
210 get sorting() {227 get sorting() {
211 return sorting();228 return sorting();
@@ -216,10 +233,10 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
216 get columnVisibility() {233 get columnVisibility() {
217 return prefs.preferences().visibility;234 return prefs.preferences().visibility;
218 },235 },
219- get pagination() {236+ get pagination(): PaginationState {
220 return props.manualPagination237 return props.manualPagination
221 ? { pageIndex: props.manualPagination.pageIndex, pageSize: props.manualPagination.pageSize }238 ? { pageIndex: props.manualPagination.pageIndex, pageSize: props.manualPagination.pageSize }
222- : pagination();239+ : { pageIndex: 0, pageSize: Number.MAX_SAFE_INTEGER };
223 },240 },
224 },241 },
225 });242 });
@@ -303,28 +320,56 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
303 const sectioned = () => props.surfaceSections !== false;320 const sectioned = () => props.surfaceSections !== false;
304 const showHeader = () => false;321 const showHeader = () => false;
305 const showToolbar = () => showSearch() || props.filters != null || showColumnMenu() || props.actions != null;322 const showToolbar = () => showSearch() || props.filters != null || showColumnMenu() || props.actions != null;
306- // A lone "Sütunlar" button does not need a card of its own: a full-width323+ // Toolbar controls — search, filters, actions, "Sütunlar" — are one pill
307- // box with one button at its far end only adds a layer (a third nested box324+ // shape and one height on every page: touch-sized (h-10) below `sm` and on touch screens, h-8
308- // inside a detail tab). It sits bare at the right edge instead.325+ // above. Page actions arrive as plain Buttons (size="sm" is 26px), so the
309- const columnMenuOnly = () => showColumnMenu() && !showSearch() && props.filters == null && props.actions == null;326+ // slot sizes them rather than trusting each page to.
310- const pageCount = () => props.manualPagination ? Math.max(1, Math.ceil(props.manualPagination.total / props.manualPagination.pageSize)) : table.getPageCount();327+ const TOOLBAR_ACTIONS =
311- const pageIndex = () => props.manualPagination?.pageIndex ?? table.getState().pagination.pageIndex;328+ "[&_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";
312- const pageSize = () => props.manualPagination?.pageSize ?? table.getState().pagination.pageSize;329+ const totalRows = () => props.manualPagination?.total ?? props.infinite?.total ?? table.getRowModel().rows.length;
313- const totalRows = () => props.manualPagination?.total ?? table.getFilteredRowModel().rows.length;
314 const setPageIndex = (next: number) => {330 const setPageIndex = (next: number) => {
315 if (props.manualPagination) props.manualPagination.onPageChange(next);331 if (props.manualPagination) props.manualPagination.onPageChange(next);
316- else setClientPageIndex(next);332+ else resetReveal();
333+ };
334+ /** The rows actually rendered: all of them, or the revealed head of the list. */
335+ const visibleRows = () => {
336+ const rows = table.getRowModel().rows;
337+ return revealing() ? rows.slice(0, revealed()) : rows;
338+ };
339+ const hasHidden = () => revealing() && table.getRowModel().rows.length > revealed();
340+ // A sentinel under the list reveals the next rows as it nears the viewport.
341+ // Without IntersectionObserver (old engines, jsdom) everything renders.
342+ let sentinel: HTMLDivElement | undefined;
343+ const observing = typeof IntersectionObserver !== "undefined";
344+ const nearEnd = () => !!sentinel && sentinel.getBoundingClientRect().top < window.innerHeight + REVEAL_MARGIN_PX;
345+ const revealMore = () => {
346+ if (!nearEnd()) return;
347+ const infinite = props.infinite;
348+ if (infinite) {
349+ if (infinite.hasMore && !infinite.loading) infinite.onLoadMore();
350+ return;
351+ }
352+ if (hasHidden()) setRevealed((count) => count + REVEAL_STEP);
317 };353 };
318- // A page past the end — rows deleted, a filter narrowed the list, a stale
319- // `?page=` — slides back to the last page there is. Only once rows exist:
320- // before the data arrives every page is "past the end".
321 createEffect(() => {354 createEffect(() => {
322- if (props.manualPagination || !paginationEnabled) return;355+ if (!(revealing() || props.infinite) || !observing) return;
323- const rows = table.getFilteredRowModel().rows.length;356+ const node = sentinel;
324- if (rows === 0) return;357+ if (!node) return;
325- const last = Math.max(0, Math.ceil(rows / clientPageSize()) - 1);358+ const observer = new IntersectionObserver((entries) => {
326- if (clientPageIndex() > last) setClientPageIndex(last);359+ if (entries.some((entry) => entry.isIntersecting)) revealMore();
360+ }, { rootMargin: `0px 0px ${REVEAL_MARGIN_PX}px 0px` });
361+ observer.observe(node);
362+ onCleanup(() => observer.disconnect());
327 });363 });
364+ // The observer only fires when the sentinel crosses the margin; after a
365+ // reveal of short rows it can still sit inside it, so check again.
366+ createEffect(on(revealed, () => queueMicrotask(revealMore), { defer: true }));
367+ // Same for a fetched page: once it lands, a short page may leave the end
368+ // in view, so ask for the next one straight away.
369+ createEffect(on(() => props.infinite?.loading, (busy) => {
370+ if (busy === false && observing) queueMicrotask(revealMore);
371+ }, { defer: true }));
372+ if (!observing) setRevealed(Number.MAX_SAFE_INTEGER);
328 const searchFieldValue = () => {373 const searchFieldValue = () => {
329 if (props.onSearchInput || props.searchPredicate || props.filterColumn) return searchValue();374 if (props.onSearchInput || props.searchPredicate || props.filterColumn) return searchValue();
330 return "";375 return "";
@@ -333,6 +378,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
333 if (props.onSearchInput) props.onSearchInput(value);378 if (props.onSearchInput) props.onSearchInput(value);
334 else setSearch(value);379 else setSearch(value);
335 setPageIndex(0);380 setPageIndex(0);
381+ resetReveal();
336 };382 };
337 const isInteractiveTarget = (target: EventTarget | null, row: EventTarget | null) => {383 const isInteractiveTarget = (target: EventTarget | null, row: EventTarget | null) => {
338 if (!(target instanceof Element)) return false;384 if (!(target instanceof Element)) return false;
@@ -451,7 +497,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
451 </Show>497 </Show>
452 </div>498 </div>
453 <Show when={props.actions}>499 <Show when={props.actions}>
454- <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md">{props.actions}</div>500+ <div class={cn("flex min-w-0 flex-wrap items-center gap-2", TOOLBAR_ACTIONS)}>{props.actions}</div>
455 </Show>501 </Show>
456 </div>502 </div>
457 </Show>503 </Show>
@@ -461,7 +507,9 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
461 sideways instead of stacking one control per line. From `lg`:507 sideways instead of stacking one control per line. From `lg`:
462 search, filters, then actions pushed to the right edge. Controls508 search, filters, then actions pushed to the right edge. Controls
463 are touch-sized (h-10) below `sm` and compact (h-8) above it. */}509 are touch-sized (h-10) below `sm` and compact (h-8) above it. */}
464- <div class={cn("flex flex-wrap items-center gap-2", sectioned() && !columnMenuOnly() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}>510+ {/* Always a card when sectioned, even when "Sütunlar" is its only
511+ control, so every list page's toolbar reads the same. */}
512+ <div class={cn("flex flex-wrap items-center gap-2", sectioned() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}>
465 <Show when={showSearch()}>513 <Show when={showSearch()}>
466 <DataTableSearch514 <DataTableSearch
467 class="order-1 w-auto min-w-40 flex-1 grow-[100] sm:max-w-xs"515 class="order-1 w-auto min-w-40 flex-1 grow-[100] sm:max-w-xs"
@@ -472,7 +520,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
472 />520 />
473 </Show>521 </Show>
474 <Show when={props.filters}>522 <Show when={props.filters}>
475- <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 touch:[&_button]:h-10 [&_select]:h-10 [&_select]:rounded-lg [&_select]:text-[13px] sm:[&_select]:h-8 touch:[&_select]:h-10 max-sm:[&>*]:flex-nowrap max-sm:[&>*]:shrink-0">{props.filters}</div>523+ <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-full [&_button]:px-3 [&_button]:text-[13px] [&_[data-filter-active]]:border-primary [&_[data-filter-active]]:text-primary-text sm:[&_button]:h-8 touch:[&_button]:h-10 [&_select]:h-10 [&_select]:rounded-full [&_select]:text-[13px] sm:[&_select]:h-8 touch:[&_select]:h-10 max-sm:[&>*]:flex-nowrap max-sm:[&>*]:shrink-0">{props.filters}</div>
476 </Show>524 </Show>
477 <Show when={props.actions || showColumnMenu()}>525 <Show when={props.actions || showColumnMenu()}>
478 {/* Beside the search the actions keep their own width (the search526 {/* Beside the search the actions keep their own width (the search
@@ -481,7 +529,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
481 the button stretches instead of hanging off the right edge. */}529 the button stretches instead of hanging off the right edge. */}
482 <div class="order-2 ml-auto flex shrink-0 grow flex-wrap items-center justify-end gap-2 sm:grow-0 lg:order-3">530 <div class="order-2 ml-auto flex shrink-0 grow flex-wrap items-center justify-end gap-2 sm:grow-0 lg:order-3">
483 <Show when={props.actions}>531 <Show when={props.actions}>
484- <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:flex-1 touch:[&_button]:h-10 max-sm:[&_button]:flex-1">{props.actions}</div>532+ <div class={cn("flex min-w-0 flex-wrap items-center gap-2 max-sm:flex-1 max-sm:[&_button]:flex-1", TOOLBAR_ACTIONS)}>{props.actions}</div>
485 </Show>533 </Show>
486 <Show when={showColumnMenu()}>534 <Show when={showColumnMenu()}>
487 <DataTableViewMenu columns={viewMenuColumns()} />535 <DataTableViewMenu columns={viewMenuColumns()} />
@@ -493,10 +541,10 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
493 <Show when={useCards()}>541 <Show when={useCards()}>
494 <ul class="space-y-2" aria-label={props.title}>542 <ul class="space-y-2" aria-label={props.title}>
495 <Show543 <Show
496- when={table.getRowModel().rows.length > 0}544+ when={visibleRows().length > 0}
497 fallback={<li class="rounded-lg border border-border-line bg-surface-base px-4 py-8 text-center text-sm text-muted-foreground">{emptyContent()}</li>}545 fallback={<li class="rounded-lg border border-border-line bg-surface-base px-4 py-8 text-center text-sm text-muted-foreground">{emptyContent()}</li>}
498 >546 >
499- <For each={table.getRowModel().rows}>547+ <For each={visibleRows()}>
500 {(row, rowIndex) => {548 {(row, rowIndex) => {
501 const cells = () =>549 const cells = () =>
502 row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards);550 row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards);
@@ -610,7 +658,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
610 </TableHeader>658 </TableHeader>
611 <TableBody>659 <TableBody>
612 <Show660 <Show
613- when={table.getRowModel().rows.length > 0}661+ when={visibleRows().length > 0}
614 fallback={662 fallback={
615 <TableRow>663 <TableRow>
616 <TableCell colSpan={colSpan()} class="py-8 text-center text-muted-foreground">664 <TableCell colSpan={colSpan()} class="py-8 text-center text-muted-foreground">
@@ -619,7 +667,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
619 </TableRow>667 </TableRow>
620 }668 }
621 >669 >
622- <For each={table.getRowModel().rows}>670+ <For each={visibleRows()}>
623 {(row) => (671 {(row) => (
624 <TableRow672 <TableRow
625 data-state={row.getIsSelected() ? "selected" : undefined}673 data-state={row.getIsSelected() ? "selected" : undefined}
@@ -693,14 +741,35 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
693 </Table>741 </Table>
694 </DataTableFrame>742 </DataTableFrame>
695 </Show>743 </Show>
696- <Show when={paginationEnabled && totalRows() > 0}>744+ <Show when={props.manualPagination}>
697- <TablePagination745+ {(manual) => (
698- pageIndex={pageIndex()}746+ <Show when={manual().total > 0}>
699- pageCount={pageCount()}747+ <TablePagination
700- pageSize={pageSize()}748+ pageIndex={manual().pageIndex}
701- total={totalRows()}749+ pageCount={Math.max(1, Math.ceil(manual().total / manual().pageSize))}
702- onPageChange={setPageIndex}750+ pageSize={manual().pageSize}
703- />751+ total={manual().total}
752+ onPageChange={setPageIndex}
753+ />
754+ </Show>
755+ )}
756+ </Show>
757+ <Show when={(revealing() || props.infinite) && totalRows() > 0}>
758+ <div ref={sentinel} aria-hidden="true" class="h-px" />
759+ <p class="px-1 text-xs font-medium tabular-nums text-muted-foreground sm:text-[11px]" aria-live="polite">
760+ {props.infinite?.loading
761+ ? t("common.loadingMore")
762+ : props.infinite?.hasMore
763+ ? t("common.showingOf", { shown: props.data.length, total: totalRows() })
764+ : hasHidden()
765+ ? t("common.showingOf", { shown: revealed(), total: totalRows() })
766+ : t("common.rowCount", { total: totalRows() })}
767+ </p>
768+ <Show when={!observing && props.infinite?.hasMore && !props.infinite.loading}>
769+ <Button type="button" variant="outline" size="sm" class="self-start" onClick={() => props.infinite?.onLoadMore()}>
770+ {t("common.loadMore")}
771+ </Button>
772+ </Show>
704 </Show>773 </Show>
705 </div>774 </div>
706 );775 );
src/components/ui/data-toolbar.tsxmodified+20 -2
@@ -3,6 +3,24 @@ import type { JSX } from "solid-js";
3 import { DataTableSearch } from "@/components/ui/data-table-search";3 import { DataTableSearch } from "@/components/ui/data-table-search";
4 import { cn } from "@/lib/cn";4 import { cn } from "@/lib/cn";
5 5
6+/** The card a list toolbar sits on — the same box DataTable draws. */
7+export const TOOLBAR_CARD = "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs";
8+
9+/**
10+ * One toolbar control: a pill, touch-sized (h-10) below `sm` and on touch
11+ * screens, h-8 from `sm` up, at 13px. For controls a page places by hand
12+ * (a stepper, a date jump) beside the slot-sized ones.
13+ */
14+export const TOOLBAR_CONTROL = "h-10 rounded-full text-[13px] sm:h-8 touch:h-10";
15+
16+/**
17+ * The same standard applied to every button and link inside a slot, so the
18+ * page's plain `<Button size="sm">` (26px) lands at the toolbar height.
19+ * Mirrors DataTable's actions/filters slots.
20+ */
21+export const TOOLBAR_SLOT =
22+ "[&_button]:h-10 [&_button]:shrink-0 [&_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 [&_[data-filter-active]]:border-primary [&_[data-filter-active]]:text-primary-text";
23+
6 export function DataToolbar(props: {24 export function DataToolbar(props: {
7 searchValue?: string;25 searchValue?: string;
8 searchPlaceholder?: string;26 searchPlaceholder?: string;
@@ -33,10 +51,10 @@ export function DataToolbar(props: {
33 />51 />
34 </Show>52 </Show>
35 <Show when={props.filters}>53 <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>54+ <div class={cn("order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto", TOOLBAR_SLOT)}>{props.filters}</div>
37 </Show>55 </Show>
38 <Show when={props.actions}>56 <Show when={props.actions}>
39- <div class="order-2 ml-auto flex shrink-0 grow items-center justify-end gap-2 sm:order-3 sm:grow-0 touch:[&_button]:h-10 max-sm:[&_button]:flex-1">{props.actions}</div>57+ <div class={cn("order-2 ml-auto flex shrink-0 grow items-center justify-end gap-2 sm:order-3 sm:grow-0 max-sm:[&_button]:flex-1", TOOLBAR_SLOT)}>{props.actions}</div>
40 </Show>58 </Show>
41 </div>59 </div>
42 );60 );
src/components/ui/infinite-sentinel.tsxadded+66 -0
@@ -0,0 +1,66 @@
1+import { Show, createEffect, on, onCleanup } from "solid-js";
2+import { Button } from "@/components/ui/button";
3+import { cn } from "@/lib/cn";
4+import { useT } from "@/stores/preferences-context";
5+
6+/** Ask for the next page this far before the list's end scrolls into view. */
7+const LOAD_MARGIN_PX = 600;
8+
9+/**
10+ * The end of a fetch-as-you-scroll list that is not a DataTable (card grids,
11+ * message lists). Sits under the last item, asks for the next page as it
12+ * nears the viewport, and says how much of the list is loaded. Pair with
13+ * `createInfiniteList`; DataTable has the same behaviour built in (`infinite`).
14+ */
15+export function InfiniteSentinel(props: {
16+ hasMore: boolean;
17+ loading: boolean;
18+ onLoadMore: () => void;
19+ /** Rows loaded so far. */
20+ shown: number;
21+ total: number;
22+ class?: string;
23+}) {
24+ const t = useT();
25+ let sentinel: HTMLDivElement | undefined;
26+ // Without IntersectionObserver there is no reliable "near the end" signal,
27+ // so the next page waits for a button instead of chaining in on its own.
28+ const observing = typeof IntersectionObserver !== "undefined";
29+
30+ const nearEnd = () => !!sentinel && sentinel.getBoundingClientRect().top < window.innerHeight + LOAD_MARGIN_PX;
31+ const maybeLoad = () => {
32+ if (props.hasMore && !props.loading && nearEnd()) props.onLoadMore();
33+ };
34+
35+ createEffect(() => {
36+ if (!observing || !sentinel) return;
37+ const observer = new IntersectionObserver((entries) => {
38+ if (entries.some((entry) => entry.isIntersecting)) maybeLoad();
39+ }, { rootMargin: `0px 0px ${LOAD_MARGIN_PX}px 0px` });
40+ observer.observe(sentinel);
41+ onCleanup(() => observer.disconnect());
42+ });
43+ // A page that lands short of filling the screen leaves the sentinel in
44+ // view, where the observer will not fire again: check once more.
45+ createEffect(on(() => props.loading, (busy) => {
46+ if (!busy && observing) queueMicrotask(maybeLoad);
47+ }, { defer: true }));
48+
49+ return (
50+ <Show when={props.total > 0}>
51+ <div ref={sentinel} aria-hidden="true" class="h-px" />
52+ <p class={cn("px-1 text-xs font-medium tabular-nums text-muted-foreground sm:text-[11px]", props.class)} aria-live="polite">
53+ {props.loading
54+ ? t("common.loadingMore")
55+ : props.hasMore
56+ ? t("common.showingOf", { shown: props.shown, total: props.total })
57+ : t("common.rowCount", { total: props.total })}
58+ </p>
59+ <Show when={!observing && props.hasMore && !props.loading}>
60+ <Button type="button" variant="outline" size="sm" onClick={() => props.onLoadMore()}>
61+ {t("common.loadMore")}
62+ </Button>
63+ </Show>
64+ </Show>
65+ );
66+}
src/components/ui/select.tsxmodified+4 -1
@@ -10,7 +10,7 @@ import { cn } from "@/lib/cn";
10 10
11 /** Shared trigger look for every dropdown-style picker (Select, DropdownSelect). */11 /** Shared trigger look for every dropdown-style picker (Select, DropdownSelect). */
12 const SELECT_TRIGGER =12 const SELECT_TRIGGER =
13- "inline-flex items-center justify-between gap-2.5 rounded-lg border border-border/70 bg-muted/40 px-2.5 text-[13px] font-medium text-foreground transition-colors hover:border-border hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50 data-expanded:border-border data-expanded:bg-muted";13+ "inline-flex items-center justify-between gap-2.5 rounded-lg border border-border/70 bg-muted/40 px-2.5 text-[13px] font-medium text-foreground transition-colors hover:border-border hover:bg-muted/60 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50 data-expanded:border-border data-expanded:bg-muted/60";
14 14
15 export type SelectOption<T extends string | number = string> = {15 export type SelectOption<T extends string | number = string> = {
16 value: T;16 value: T;
@@ -37,6 +37,9 @@ export function DropdownSelect<T extends string | number = string>(props: Dropdo
37 <DropdownMenu placement="bottom-start" gutter={6}>37 <DropdownMenu placement="bottom-start" gutter={6}>
38 <DropdownMenuTrigger38 <DropdownMenuTrigger
39 disabled={props.disabled}39 disabled={props.disabled}
40+ // A prefixed picker is a filter chip, whose first option is its "all"
41+ // default; any other value marks it active so the toolbar can tint it.
42+ data-filter-active={props.labelPrefix && props.options.length > 0 && props.value !== props.options[0].value ? "" : undefined}
40 class={cn(43 class={cn(
41 SELECT_TRIGGER,44 SELECT_TRIGGER,
42 "h-8",45 "h-8",
src/components/ui/table-row-actions.tsxmodified+1 -1
@@ -52,7 +52,7 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[
52 <DropdownMenuTrigger52 <DropdownMenuTrigger
53 class={props.compact53 class={props.compact
54 ? "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"54 ? "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"
55- : "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"}55+ : "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-border hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-border data-expanded:bg-primary/10 data-expanded:text-primary-text"}
56 data-row-actions-trigger56 data-row-actions-trigger
57 aria-label={props.label}57 aria-label={props.label}
58 title={props.label}58 title={props.label}
src/i18n/locales/en.tsmodified+4 -0
@@ -657,6 +657,10 @@ export const en: Dict = {
657 "common.columns": "Columns",657 "common.columns": "Columns",
658 "common.visibleColumns": "Visible columns",658 "common.visibleColumns": "Visible columns",
659 "common.pageRange": "{start}-{end} / {total}",659 "common.pageRange": "{start}-{end} / {total}",
660+ "common.showingOf": "Showing {shown} of {total} — scroll for more",
661+ "common.rowCount": "Total: {total}",
662+ "common.loadingMore": "Loading more…",
663+ "common.loadMore": "Load more",
660 "common.rowsPerPage": "{size} / page",664 "common.rowsPerPage": "{size} / page",
661 "common.moreFilters": "More filters",665 "common.moreFilters": "More filters",
662 "common.lessFilters": "Less filters",666 "common.lessFilters": "Less filters",
src/i18n/locales/tr.tsmodified+4 -0
@@ -653,6 +653,10 @@ export const tr: Dict = {
653 "common.columns": "Sütunlar",653 "common.columns": "Sütunlar",
654 "common.visibleColumns": "Görünür sütunlar",654 "common.visibleColumns": "Görünür sütunlar",
655 "common.pageRange": "{start}-{end} / {total}",655 "common.pageRange": "{start}-{end} / {total}",
656+ "common.showingOf": "{total} kayıttan {shown} tanesi gösteriliyor — kaydırdıkça devamı gelir",
657+ "common.rowCount": "Toplam: {total}",
658+ "common.loadingMore": "Devamı yükleniyor…",
659+ "common.loadMore": "Devamını yükle",
656 "common.rowsPerPage": "{size} / sayfa",660 "common.rowsPerPage": "{size} / sayfa",
657 "common.moreFilters": "Daha fazla filtre",661 "common.moreFilters": "Daha fazla filtre",
658 "common.lessFilters": "Daha az filtre",662 "common.lessFilters": "Daha az filtre",
src/i18n/messages.tsmodified+4 -0
@@ -641,6 +641,10 @@ export type MessageKey =
641 | "common.columns"641 | "common.columns"
642 | "common.visibleColumns"642 | "common.visibleColumns"
643 | "common.pageRange"643 | "common.pageRange"
644+ | "common.showingOf"
645+ | "common.rowCount"
646+ | "common.loadingMore"
647+ | "common.loadMore"
644 | "common.rowsPerPage"648 | "common.rowsPerPage"
645 | "common.moreFilters"649 | "common.moreFilters"
646 | "common.lessFilters"650 | "common.lessFilters"
src/index.cssmodified+5 -2
@@ -160,9 +160,12 @@
160 @apply border border-border/70 bg-transparent text-muted-foreground transition-colors hover:border-border hover:bg-muted/60 hover:text-foreground;160 @apply border border-border/70 bg-transparent text-muted-foreground transition-colors hover:border-border hover:bg-muted/60 hover:text-foreground;
161 }161 }
162 162
163-/* AI action button uses the landing-page brand blue. */163+/* AI action button uses the landing-page brand blue. The border is
164+ transparent and the tint is clipped inside it: a brand/20 rim on a
165+ brand/10 fill read as one blob that looked bigger than the h-9 icon
166+ controls beside it. */
164 @utility topbar-ai-control {167 @utility topbar-ai-control {
165- @apply border border-brand/20 bg-brand/10 text-brand transition-colors hover:bg-brand/16 hover:text-brand;168+ @apply border border-transparent bg-brand/10 bg-clip-padding text-brand transition-colors hover:bg-brand/16 hover:text-brand;
166 }169 }
167 170
168 @utility data-shell {171 @utility data-shell {
src/lib/infinite-list.test.tsxadded+95 -0
@@ -0,0 +1,95 @@
1+import { createRoot, createSignal } from "solid-js";
2+import { describe, expect, it, vi } from "vitest";
3+import type { Page, PageParams } from "@/api/client";
4+import { createInfiniteList } from "./infinite-list";
5+
6+const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
7+
8+function server(total: number) {
9+ const rows = Array.from({ length: total }, (_, i) => i);
10+ return vi.fn(async (query: string, params: PageParams): Promise<Page<string>> => {
11+ const offset = params.offset ?? 0;
12+ const limit = params.limit ?? total;
13+ return { items: rows.slice(offset, offset + limit).map((n) => `${query}${n}`), total, limit, offset };
14+ });
15+}
16+
17+describe("createInfiniteList", () => {
18+ it("fetches only the first page, then one page per loadMore", async () => {
19+ const fetch = server(120);
20+ await createRoot(async (dispose) => {
21+ const list = createInfiniteList(() => "r", fetch, { pageSize: 50 });
22+ await flush();
23+ expect(fetch).toHaveBeenCalledTimes(1);
24+ expect(fetch).toHaveBeenLastCalledWith("r", { limit: 50, offset: 0 });
25+ expect(list.items()).toHaveLength(50);
26+ expect(list.total()).toBe(120);
27+ expect(list.hasMore()).toBe(true);
28+
29+ list.loadMore();
30+ list.loadMore(); // ignored while the first is in flight
31+ await flush();
32+ expect(fetch).toHaveBeenCalledTimes(2);
33+ expect(fetch).toHaveBeenLastCalledWith("r", { limit: 50, offset: 50 });
34+
35+ list.loadMore();
36+ await flush();
37+ expect(list.items()).toHaveLength(120);
38+ expect(list.hasMore()).toBe(false);
39+ list.loadMore();
40+ await flush();
41+ expect(fetch).toHaveBeenCalledTimes(3);
42+ dispose();
43+ });
44+ });
45+
46+ it("starts over from offset 0 when the query changes and drops a stale reply", async () => {
47+ let release: (() => void) | undefined;
48+ const fetch = vi.fn(async (query: string, params: PageParams): Promise<Page<string>> => {
49+ if (query === "slow") await new Promise<void>((resolve) => (release = resolve));
50+ return { items: [`${query}-${params.offset}`], total: 1, limit: params.limit ?? 50, offset: params.offset ?? 0 };
51+ });
52+ await createRoot(async (dispose) => {
53+ const [query, setQuery] = createSignal("slow");
54+ const list = createInfiniteList(query, fetch);
55+ await flush();
56+ setQuery("fast");
57+ await flush();
58+ release?.();
59+ await flush();
60+ expect(list.items()).toEqual(["fast-0"]);
61+ dispose();
62+ });
63+ });
64+
65+ it("fetches nothing until the source is ready", async () => {
66+ const fetch = server(5);
67+ await createRoot(async (dispose) => {
68+ const [ready, setReady] = createSignal<string | null>(null);
69+ const list = createInfiniteList(ready, fetch);
70+ await flush();
71+ expect(fetch).not.toHaveBeenCalled();
72+ expect(list.initialLoading()).toBe(false);
73+ setReady("x");
74+ await flush();
75+ expect(list.items()).toHaveLength(5);
76+ dispose();
77+ });
78+ });
79+
80+ it("ends the list on a short page even if the total disagrees", async () => {
81+ const fetch = vi.fn(async (_: string, params: PageParams): Promise<Page<number>> => ({
82+ items: [1, 2],
83+ total: 999,
84+ limit: params.limit ?? 50,
85+ offset: params.offset ?? 0,
86+ }));
87+ await createRoot(async (dispose) => {
88+ const list = createInfiniteList(() => "q", fetch, { pageSize: 50 });
89+ await flush();
90+ expect(list.total()).toBe(2);
91+ expect(list.hasMore()).toBe(false);
92+ dispose();
93+ });
94+ });
95+});
src/lib/infinite-list.tsadded+112 -0
@@ -0,0 +1,112 @@
1+import { createEffect, createSignal, on, onCleanup } from "solid-js";
2+import type { Page, PageParams } from "@/api/client";
3+
4+/** Rows fetched per request while the reader scrolls a server-paged list. */
5+export const INFINITE_PAGE_SIZE = 50;
6+
7+export type InfiniteList<T> = {
8+ /** Every row fetched so far, in server order. */
9+ items: () => T[];
10+ /** Row count on the server for the current query. */
11+ total: () => number;
12+ /** True until the first page of the current query lands. */
13+ initialLoading: () => boolean;
14+ /** A page request is in flight (the first or a later one). */
15+ loading: () => boolean;
16+ error: () => unknown;
17+ hasMore: () => boolean;
18+ /** Fetch the next page; a no-op while one is in flight or none is left. */
19+ loadMore: () => void;
20+ /** Start the current query over from its first page (after a create/delete). */
21+ reload: () => void;
22+ /** Patch the loaded rows in place (an edit that needs no refetch). */
23+ mutate: (update: (items: T[]) => T[]) => void;
24+};
25+
26+/**
27+ * A list that fetches page by page as the reader scrolls, instead of reading
28+ * every row up front. `source` is the query: search text and server filters.
29+ * A new value (compared with `equals`) drops the rows and starts from offset
30+ * 0; `null`/`undefined`/`false` means "not ready" and fetches nothing.
31+ *
32+ * Only fit for a list whose every search and filter the backend applies —
33+ * the backend takes no sort parameter, so the order is the server's, and a
34+ * filter applied in the browser would only see the rows loaded so far.
35+ */
36+export function createInfiniteList<T, K>(
37+ source: () => K | null | undefined | false,
38+ fetchPage: (key: K, params: PageParams) => Promise<Page<T>>,
39+ options: { pageSize?: number; equals?: (a: K, b: K) => boolean } = {},
40+): InfiniteList<T> {
41+ const pageSize = options.pageSize ?? INFINITE_PAGE_SIZE;
42+ const [items, setItems] = createSignal<T[]>([]);
43+ const [total, setTotal] = createSignal(0);
44+ const [loading, setLoading] = createSignal(false);
45+ const [loaded, setLoaded] = createSignal(false);
46+ const [error, setError] = createSignal<unknown>(undefined);
47+ // Bumped on every new query so a slow response for an old one is dropped.
48+ let generation = 0;
49+ let key: K | null = null;
50+
51+ const fetchNext = async () => {
52+ if (key === null || loading()) return;
53+ const run = generation;
54+ const current = key;
55+ const offset = items().length;
56+ setLoading(true);
57+ setError(undefined);
58+ try {
59+ const page = await fetchPage(current, { limit: pageSize, offset });
60+ if (run !== generation) return;
61+ const rows = Array.isArray(page.items) ? page.items : [];
62+ setItems((prev) => (offset === 0 ? rows : [...prev, ...rows]));
63+ const next = offset + rows.length;
64+ // A short page ends the list even if `total` says otherwise, so a stale
65+ // count never keeps asking for pages that are not there.
66+ setTotal(rows.length < pageSize ? next : Math.max(typeof page.total === "number" ? page.total : next, next));
67+ setLoaded(true);
68+ } catch (err) {
69+ if (run === generation) setError(err);
70+ } finally {
71+ if (run === generation) setLoading(false);
72+ }
73+ };
74+
75+ const start = () => {
76+ generation += 1;
77+ setItems([]);
78+ setTotal(0);
79+ setLoaded(false);
80+ setLoading(false);
81+ setError(undefined);
82+ if (key !== null) void fetchNext();
83+ };
84+
85+ createEffect(
86+ on(source, (next) => {
87+ const ready = next !== null && next !== undefined && next !== false;
88+ if (ready && key !== null && (options.equals ? options.equals(key, next as K) : key === next)) return;
89+ key = ready ? (next as K) : null;
90+ start();
91+ }),
92+ );
93+ onCleanup(() => {
94+ generation += 1;
95+ });
96+
97+ const hasMore = () => loaded() && error() === undefined && items().length < total();
98+
99+ return {
100+ items,
101+ total,
102+ initialLoading: () => key !== null && !loaded() && error() === undefined,
103+ loading,
104+ error,
105+ hasMore,
106+ loadMore: () => {
107+ if (hasMore()) void fetchNext();
108+ },
109+ reload: start,
110+ mutate: (update) => setItems((prev) => update(prev)),
111+ };
112+}
src/pages/academic-years-page.tsxmodified+1 -4
@@ -23,7 +23,6 @@ import { ErrorAlert } from "@/components/ui/error-alert";
23 import { IconArchive, IconEdit, IconEye, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons";23 import { IconArchive, IconEdit, IconEye, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons";
24 import { Input } from "@/components/ui/input";24 import { Input } from "@/components/ui/input";
25 import { Label } from "@/components/ui/label";25 import { Label } from "@/components/ui/label";
26-import { PageHeader } from "@/components/layout/page-header";
27 import { Select } from "@/components/ui/select";26 import { Select } from "@/components/ui/select";
28 import { SidePanel } from "@/components/ui/side-panel";27 import { SidePanel } from "@/components/ui/side-panel";
29 import { TableRowActions } from "@/components/ui/table-row-actions";28 import { TableRowActions } from "@/components/ui/table-row-actions";
@@ -246,8 +245,6 @@ function AcademicYearsContent() {
246 245
247 return (246 return (
248 <div class="space-y-6">247 <div class="space-y-6">
249- <PageHeader title={t("academicYears.title")} description={t("academicYears.subtitle")} />
250-
251 <Show when={flash()}>248 <Show when={flash()}>
252 <Alert variant="success">{flash()}</Alert>249 <Alert variant="success">{flash()}</Alert>
253 </Show>250 </Show>
@@ -265,7 +262,7 @@ function AcademicYearsContent() {
265 title={t("academicYears.title")}262 title={t("academicYears.title")}
266 description={t("academicYears.subtitle")}263 description={t("academicYears.subtitle")}
267 actions={264 actions={
268- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCreate}>265+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={openCreate}>
269 <IconPlus class="h-4 w-4" />266 <IconPlus class="h-4 w-4" />
270 {t("academicYears.new")}267 {t("academicYears.new")}
271 </Button>268 </Button>
src/pages/admin-users-page.tsxmodified+1 -1
@@ -98,7 +98,7 @@ function AdminUsersContent() {
98 title={t("admin.title")}98 title={t("admin.title")}
99 description={t("admin.subtitle")}99 description={t("admin.subtitle")}
100 actions={100 actions={
101- <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}>101+ <Button size="sm" class="min-w-[7.5rem]" onClick={() => setCreating(true)}>
102 <IconPlus class="mr-1.5 h-4 w-4" />102 <IconPlus class="mr-1.5 h-4 w-4" />
103 {t("admin.createUser")}103 {t("admin.createUser")}
104 </Button>104 </Button>
src/pages/ai-insight-student-page.tsxmodified+3 -2
@@ -158,9 +158,10 @@ function AiInsightStudentContent() {
158 </Show>158 </Show>
159 </div>159 </div>
160 </div>160 </div>
161- <div class="flex flex-wrap items-center gap-2">161+ {/* Header actions are toolbar pills: h-10 below `sm` and on touch, h-8 above. */}
162+ <div class="flex flex-wrap items-center gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10">
162 <Show when={canRecompute()}>163 <Show when={canRecompute()}>
163- <Button size="sm" class="rounded-lg" disabled={queuing()} onClick={() => void recompute()}>164+ <Button size="sm" disabled={queuing()} onClick={() => void recompute()}>
164 <IconSparkles class="h-4 w-4" />165 <IconSparkles class="h-4 w-4" />
165 {queuing() ? t("insights.recomputing") : t("insights.recompute")}166 {queuing() ? t("insights.recomputing") : t("insights.recompute")}
166 </Button>167 </Button>
src/pages/bank-question-detail-page.tsxmodified+9 -3
@@ -28,6 +28,12 @@ import { useAuth } from "@/stores/auth-context";
28 import { usePreferences, useT } from "@/stores/preferences-context";28 import { usePreferences, useT } from "@/stores/preferences-context";
29 import { TableRowActions } from "@/components/ui/table-row-actions";29 import { TableRowActions } from "@/components/ui/table-row-actions";
30 30
31+// Edit and the actions menu share one row: the toolbar pill, touch-sized
32+// (h-10) below `sm` and on touch screens, h-8 above. The menu trigger is a
33+// <button> too, so one rule sizes both.
34+const HEADER_CONTROLS =
35+ "flex flex-wrap items-center gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10";
36+
31 export default function BankQuestionDetailPage() {37 export default function BankQuestionDetailPage() {
32 return (38 return (
33 <RouteGuard minRole="teacher">39 <RouteGuard minRole="teacher">
@@ -107,9 +113,9 @@ function BankQuestionDetailContent() {
107 title={current().text}113 title={current().text}
108 description={current().subject_name || undefined}114 description={current().subject_name || undefined}
109 actions={115 actions={
110- <>116+ <div class={HEADER_CONTROLS}>
111 <Show when={canEdit()}>117 <Show when={canEdit()}>
112- <Button variant="outline" size="sm" class="rounded-lg" onClick={() => setEditing(true)}>118+ <Button variant="outline" size="sm" onClick={() => setEditing(true)}>
113 <IconEdit class="h-4 w-4" />119 <IconEdit class="h-4 w-4" />
114 {t("common.edit")}120 {t("common.edit")}
115 </Button>121 </Button>
@@ -123,7 +129,7 @@ function BankQuestionDetailContent() {
123 }]}129 }]}
124 />130 />
125 </Show>131 </Show>
126- </>132+ </div>
127 }133 }
128 />134 />
129 </div>135 </div>
src/pages/builder-school-detail-page.tsxmodified+6 -4
@@ -104,17 +104,19 @@ function BuilderSchoolDetailContent() {
104 title={current().name}104 title={current().name}
105 description={`${current().id} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}105 description={`${current().id} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}
106 actions={106 actions={
107- <div class="flex flex-wrap items-center gap-2">107+ // One pill height for every header control: the buttons and
108+ // the row-actions trigger (h-8 on its own) sit in one row.
109+ <div class="flex flex-wrap items-center gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10">
108 <SchoolStatusBadge status={current().status} />110 <SchoolStatusBadge status={current().status} />
109- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={openEdit}>111+ <Button type="button" variant="outline" size="sm" onClick={openEdit}>
110 <IconEdit class="h-4 w-4" />112 <IconEdit class="h-4 w-4" />
111 {t("common.edit")}113 {t("common.edit")}
112 </Button>114 </Button>
113- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setAccessMode("password")}>115+ <Button type="button" variant="outline" size="sm" onClick={() => setAccessMode("password")}>
114 <IconLock class="h-4 w-4" />116 <IconLock class="h-4 w-4" />
115 {t("builder.resetAdminPassword")}117 {t("builder.resetAdminPassword")}
116 </Button>118 </Button>
117- <Button type="button" size="sm" class="rounded-lg" disabled={current().status === "suspended"} title={current().status === "suspended" ? t("builder.enterSuspendedHint") : undefined} onClick={() => setAccessMode("enter")}>119+ <Button type="button" size="sm" disabled={current().status === "suspended"} title={current().status === "suspended" ? t("builder.enterSuspendedHint") : undefined} onClick={() => setAccessMode("enter")}>
118 <IconExternalLink class="h-4 w-4" />120 <IconExternalLink class="h-4 w-4" />
119 {t("builder.enterSchool")}121 {t("builder.enterSchool")}
120 </Button>122 </Button>
src/pages/builder-schools-page.tsxmodified+1 -1
@@ -144,7 +144,7 @@ function BuilderSchoolsContent() {
144 title={t("builder.schools")}144 title={t("builder.schools")}
145 description={t("builder.schoolsSubtitle")}145 description={t("builder.schoolsSubtitle")}
146 actions={146 actions={
147- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreateOpen(true)}>147+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={() => setCreateOpen(true)}>
148 <IconPlus class="h-4 w-4" />148 <IconPlus class="h-4 w-4" />
149 {t("builder.createSchool")}149 {t("builder.createSchool")}
150 </Button>150 </Button>
src/pages/calendar-page.tsxmodified+6 -5
@@ -437,18 +437,19 @@ function CalendarContent() {
437 <div class="min-w-0">437 <div class="min-w-0">
438 <h1 class="truncate text-lg font-semibold tracking-tight text-foreground sm:text-xl">{t("calendar.title")}</h1>438 <h1 class="truncate text-lg font-semibold tracking-tight text-foreground sm:text-xl">{t("calendar.title")}</h1>
439 <div class="mt-1.5 flex items-center gap-1 sm:gap-2">439 <div class="mt-1.5 flex items-center gap-1 sm:gap-2">
440- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={goPrev} aria-label={t("common.prev")}>440+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-full p-0" onClick={goPrev} aria-label={t("common.prev")}>
441 <IconChevronLeft class="h-4 w-4" />441 <IconChevronLeft class="h-4 w-4" />
442 </Button>442 </Button>
443 <span class="truncate text-sm font-semibold tracking-tight sm:text-base">{rangeLabel()}</span>443 <span class="truncate text-sm font-semibold tracking-tight sm:text-base">{rangeLabel()}</span>
444- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={goNext} aria-label={t("common.next")}>444+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-full p-0" onClick={goNext} aria-label={t("common.next")}>
445 <IconChevronRight class="h-4 w-4" />445 <IconChevronRight class="h-4 w-4" />
446 </Button>446 </Button>
447 </div>447 </div>
448 </div>448 </div>
449 <div class="flex items-center gap-2">449 <div class="flex items-center gap-2">
450 {/* Day / week / month, the way a phone calendar switches zoom. */}450 {/* Day / week / month, the way a phone calendar switches zoom. */}
451- <div class="inline-flex shrink-0 rounded-lg border border-border bg-muted/40 p-0.5">451+ {/* Same height and pill as the "Bugün" button beside it. */}
452+ <div class="inline-flex h-10 shrink-0 items-center rounded-full border border-border bg-muted/40 p-0.5 sm:h-8 touch:h-10">
452 <For each={VIEWS}>453 <For each={VIEWS}>
453 {(entry) => (454 {(entry) => (
454 <button455 <button
@@ -456,7 +457,7 @@ function CalendarContent() {
456 aria-pressed={view() === entry.id}457 aria-pressed={view() === entry.id}
457 onClick={() => setView(entry.id)}458 onClick={() => setView(entry.id)}
458 class={cn(459 class={cn(
459- "rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",460+ "h-full rounded-full px-3 text-[13px] font-semibold transition-colors",
460 view() === entry.id ? "bg-background text-foreground shadow-xs" : "text-muted-foreground",461 view() === entry.id ? "bg-background text-foreground shadow-xs" : "text-muted-foreground",
461 )}462 )}
462 >463 >
@@ -465,7 +466,7 @@ function CalendarContent() {
465 )}466 )}
466 </For>467 </For>
467 </div>468 </div>
468- <Button type="button" variant="outline" size="sm" class="h-9 shrink-0 rounded-lg gap-1 text-sm font-semibold" onClick={goToday}>469+ <Button type="button" variant="outline" size="sm" class="h-10 shrink-0 gap-1 rounded-full px-3.5 text-[13px] font-semibold sm:h-8 touch:h-10" onClick={goToday}>
469 <IconCalendarDays class="h-3.5 w-3.5" />470 <IconCalendarDays class="h-3.5 w-3.5" />
470 <span class="hidden sm:inline">{t("calendar.today")}</span>471 <span class="hidden sm:inline">{t("calendar.today")}</span>
471 </Button>472 </Button>
src/pages/class-detail-page.tsxmodified+5 -4
@@ -61,8 +61,9 @@ const TILE = "min-w-0 rounded-xl border border-border-hairline bg-surface-tint p
61 const TILE_LABEL = "text-xs font-medium uppercase tracking-[0.08em] text-text-subtle";61 const TILE_LABEL = "text-xs font-medium uppercase tracking-[0.08em] text-text-subtle";
62 const TILE_VALUE = "mt-1 break-words font-medium text-text-default";62 const TILE_VALUE = "mt-1 break-words font-medium text-text-default";
63 63
64-// Header and section buttons share the row-actions trigger's box (h-8,64+// Header buttons share the row-actions trigger's box (h-8, rounded-lg) so a
65-// rounded-lg) so a button and the ⋮ menu beside it line up.65+// button and the ⋮ menu beside it line up. Tab toolbar actions go through
66+// DataTable's `actions` slot, which sizes them as pills like "Sütunlar".
66 const ACTION_BUTTON = "h-8 min-w-[7.5rem] rounded-lg! px-3 text-[13px]";67 const ACTION_BUTTON = "h-8 min-w-[7.5rem] rounded-lg! px-3 text-[13px]";
67 68
68 function ClassDetailContent() {69 function ClassDetailContent() {
@@ -383,7 +384,7 @@ function ClassDetailContent() {
383 <DataTable384 <DataTable
384 title={t("classGroups.membersTab")}385 title={t("classGroups.membersTab")}
385 actions={canManage() ? (386 actions={canManage() ? (
386- <Button type="button" size="sm" variant="outline" class={ACTION_BUTTON} onClick={() => setShowAddMember(true)}>387+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={() => setShowAddMember(true)}>
387 <IconPlus class="h-4 w-4" />{t("classGroups.addStudent")}388 <IconPlus class="h-4 w-4" />{t("classGroups.addStudent")}
388 </Button>389 </Button>
389 ) : undefined}390 ) : undefined}
@@ -406,7 +407,7 @@ function ClassDetailContent() {
406 <DataTable407 <DataTable
407 title={t("classGroups.coursesTab")}408 title={t("classGroups.coursesTab")}
408 actions={canManage() ? (409 actions={canManage() ? (
409- <Button type="button" size="sm" variant="outline" class={ACTION_BUTTON} onClick={() => setShowAttachCourse(true)}>410+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={() => setShowAttachCourse(true)}>
410 <IconPlus class="h-4 w-4" />{t("classGroups.attachCourse")}411 <IconPlus class="h-4 w-4" />{t("classGroups.attachCourse")}
411 </Button>412 </Button>
412 ) : undefined}413 ) : undefined}
src/pages/classes-page.tsxmodified+1 -1
@@ -427,7 +427,7 @@ function ClassesContent() {
427 }427 }
428 actions={428 actions={
429 <Show when={canManage()}>429 <Show when={canManage()}>
430- <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}>430+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={() => setShowForm(true)}>
431 <IconPlus class="h-4 w-4" />431 <IconPlus class="h-4 w-4" />
432 {t("classGroups.newClass")}432 {t("classGroups.newClass")}
433 </Button>433 </Button>
src/pages/course-detail-page.tsxmodified+1 -1
@@ -466,7 +466,7 @@ function CourseDetailContent() {
466 empty={t("exams.emptyRoster")}466 empty={t("exams.emptyRoster")}
467 emptyIllustration="people"467 emptyIllustration="people"
468 actions={468 actions={
469- <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowMemberForm(true)}>469+ <Button type="button" size="sm" onClick={() => setShowMemberForm(true)}>
470 <IconPlus class="h-4 w-4" />{t("courses.addMember")}470 <IconPlus class="h-4 w-4" />{t("courses.addMember")}
471 </Button>471 </Button>
472 }472 }
src/pages/courses-page.test.tsxmodified+8 -4
@@ -124,14 +124,18 @@ test("student course list filters on the server via kind, q and taught", async (
124 expect(screen.queryByRole("button", { name: /^Robotics/ })).toBeNull();124 expect(screen.queryByRole("button", { name: /^Robotics/ })).toBeNull();
125 });125 });
126 126
127-test("course search checks returned rows when the backend ignores q", async () => {127+test("course search goes to the server and starts again from the first page", async () => {
128- getCourses.mockResolvedValue({ items: catalog, total: catalog.length, limit: 100, offset: 0 });128+ getCourses.mockImplementation(async (params: { q?: string; offset?: number }) =>
129+ params.q
130+ ? { items: [], total: 0, limit: 50, offset: 0 }
131+ : { items: catalog, total: catalog.length, limit: 50, offset: 0 },
132+ );
129 render(() => <PreferencesProvider><CoursesPage /></PreferencesProvider>);133 render(() => <PreferencesProvider><CoursesPage /></PreferencesProvider>);
130 134
131 expect(await screen.findByRole("button", { name: /^Algebra/ })).toBeTruthy();135 expect(await screen.findByRole("button", { name: /^Algebra/ })).toBeTruthy();
136+ expect(getCourses.mock.calls[0][0]).toMatchObject({ limit: 50, offset: 0 });
132 fireEvent.input(screen.getByPlaceholderText("Search…"), { target: { value: "no-such-course" } });137 fireEvent.input(screen.getByPlaceholderText("Search…"), { target: { value: "no-such-course" } });
133 138
134- await waitFor(() => expect(getCourses.mock.calls.at(-1)[0].q).toBe("no-such-course"), { timeout: 2000 });139+ await waitFor(() => expect(getCourses.mock.calls.at(-1)[0]).toMatchObject({ q: "no-such-course", limit: 50, offset: 0 }), { timeout: 2000 });
135 await waitFor(() => expect(screen.queryByRole("button", { name: /^Algebra/ })).toBeNull());140 await waitFor(() => expect(screen.queryByRole("button", { name: /^Algebra/ })).toBeNull());
136- expect(screen.queryByRole("button", { name: /^Study Lab/ })).toBeNull();
137 });141 });
src/pages/courses-page.tsxmodified+28 -72
@@ -1,7 +1,6 @@
1-import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";1+import { Show, createEffect, createMemo, createSignal } from "solid-js";
2-import { createResponsivePageSize } from "@/lib/create-page-size";
3-import { loadAllPages } from "@/lib/capped-list";
4 import { createResource } from "@/lib/create-resource";2 import { createResource } from "@/lib/create-resource";
3+import { createInfiniteList } from "@/lib/infinite-list";
5 import { useNavigate, useSearch } from "@tanstack/solid-router";4 import { useNavigate, useSearch } from "@tanstack/solid-router";
6 import type { ColumnDef } from "@tanstack/solid-table";5 import type { ColumnDef } from "@tanstack/solid-table";
7 import { deleteCourseById, getCourses, postCourse } from "@/api/courses";6 import { deleteCourseById, getCourses, postCourse } from "@/api/courses";
@@ -28,13 +27,10 @@ import { createDebouncedSignal } from "@/lib/create-debounced-signal";
28 import { createFlash } from "@/lib/flash";27 import { createFlash } from "@/lib/flash";
29 import { personLabel } from "@/lib/person";28 import { personLabel } from "@/lib/person";
30 import { hasMinRole } from "@/lib/roles";29 import { hasMinRole } from "@/lib/roles";
31-import { matchesSearch } from "@/lib/search-text";30+import { createUrlEnum, readString } from "@/lib/url-state";
32-import { createUrlEnum, readPageIndex, readString } from "@/lib/url-state";
33 import { useAuth } from "@/stores/auth-context";31 import { useAuth } from "@/stores/auth-context";
34 import { usePreferences, useT } from "@/stores/preferences-context";32 import { usePreferences, useT } from "@/stores/preferences-context";
35 33
36-const PAGE_SIZE = 10;
37-
38 export default function CoursesPage() {34 export default function CoursesPage() {
39 return <RouteGuard><CoursesContent /></RouteGuard>;35 return <RouteGuard><CoursesContent /></RouteGuard>;
40 }36 }
@@ -55,14 +51,9 @@ function CoursesContent() {
55 const [showForm, setShowForm] = createSignal(routeSearch().action === "new");51 const [showForm, setShowForm] = createSignal(routeSearch().action === "new");
56 const [title, setTitle] = createSignal("");52 const [title, setTitle] = createSignal("");
57 const [description, setDescription] = createSignal("");53 const [description, setDescription] = createSignal("");
58- // URL parameters restore the kind, search, taught filter and page on reload.54+ // URL parameters restore the kind, search and taught filter on reload.
59- // Deployed backends can ignore list filters, so filtered results are checked
60- // locally after fetching the complete list.
61 const [taughtFilter, setTaughtFilter] = createUrlEnum("taught", ["all", "taught", "untaught"] as const, "all");55 const [taughtFilter, setTaughtFilter] = createUrlEnum("taught", ["all", "taught", "untaught"] as const, "all");
62 const taughtParam = () => (taughtFilter() === "taught" ? true : taughtFilter() === "untaught" ? false : undefined);56 const taughtParam = () => (taughtFilter() === "taught" ? true : taughtFilter() === "untaught" ? false : undefined);
63- const pageSize = createResponsivePageSize(PAGE_SIZE);
64- const [page, setPage] = createSignal(readPageIndex(routeSearch().page));
65- createEffect(on(pageSize, () => setPage(0), { defer: true }));
66 const [search, setSearch, debouncedSearch] = createDebouncedSignal(readString(routeSearch().q));57 const [search, setSearch, debouncedSearch] = createDebouncedSignal(readString(routeSearch().q));
67 const [error, setError] = createSignal("");58 const [error, setError] = createSignal("");
68 const [pending, setPending] = createSignal(false);59 const [pending, setPending] = createSignal(false);
@@ -76,50 +67,24 @@ function CoursesContent() {
76 });67 });
77 68
78 const [limits, { refetch: refetchLimits }] = createResource(() => canCreate() ? getLimits() : null);69 const [limits, { refetch: refetchLimits }] = createResource(() => canCreate() ? getLimits() : null);
79- const filtersActive = () => pageKind() != null || debouncedSearch().trim() !== "" || taughtParam() != null;70+ // Scoped server-side: a student reads only the courses they take. Kind,
80- // Scoped server-side: a student reads only the courses they take. The71+ // search and the taught filter are all applied by the backend (checked
81- // source carries every input the fetch reads. Filtered lists are read in72+ // live on 2026-09-26), so the catalog loads a page at a time as the reader
82- // full and checked locally because the current deployment accepts filter73+ // scrolls and any filter change starts again from the top.
83- // query keys but can return the unfiltered page and total.74+ const list = createInfiniteList(
84- const [list, { refetch }] = createResource(75+ () => auth.user()
85- () => ({76+ ? { role: auth.user()!.role, kind: pageKind(), q: debouncedSearch().trim(), taught: taughtParam() }
86- role: auth.user()?.role ?? null,77+ : null,
87- kind: pageKind(),78+ (filters, paging) =>
88- q: debouncedSearch().trim(),79+ getCourses({
89- taught: taughtParam(),80+ ...paging,
90- page: filtersActive() ? 0 : page(),
91- size: pageSize(),
92- }),
93- async (filters) => {
94- const requested = {
95 ...(filters.kind ? { kind: filters.kind } : {}),81 ...(filters.kind ? { kind: filters.kind } : {}),
96 ...(filters.q ? { q: filters.q } : {}),82 ...(filters.q ? { q: filters.q } : {}),
97 ...(filters.taught != null ? { taught: filters.taught } : {}),83 ...(filters.taught != null ? { taught: filters.taught } : {}),
98- };84+ }),
99- if (!filters.kind && !filters.q && filters.taught == null) {85+ { equals: (a, b) => a.role === b.role && a.kind === b.kind && a.q === b.q && a.taught === b.taught },
100- return getCourses({ limit: filters.size, offset: filters.page * filters.size });
101- }
102- const all = await loadAllPages((paging) => getCourses({ ...requested, ...paging }));
103- const items = all.filter((course) =>
104- (!filters.kind || course.kind === filters.kind) &&
105- (!filters.q || matchesSearch(filters.q, course.title, course.description)) &&
106- (filters.taught == null || (course.class_course_count > 0) === filters.taught),
107- );
108- return { items, total: items.length, limit: filters.size, offset: 0 };
109- },
110 );86 );
111- const listData = () => list.latest ?? list();87+ const refetch = () => list.reload();
112- const total = () => listData()?.total ?? 0;
113- const visibleItems = () => {
114- const items = listData()?.items ?? [];
115- return filtersActive() ? items.slice(page() * pageSize(), (page() + 1) * pageSize()) : items;
116- };
117- // Deleting the last row of the last page shrinks the page count under the
118- // current page; clamp instead of stranding the user off the end.
119- const pageCount = () => Math.max(1, Math.ceil(total() / pageSize()));
120- createEffect(() => {
121- if (page() >= pageCount()) setPage(pageCount() - 1);
122- });
123 const openCourse = (course: Course) => void navigate({ to: "/courses/$id", params: { id: course.id } });88 const openCourse = (course: Course) => void navigate({ to: "/courses/$id", params: { id: course.id } });
124 // Catalog rights, as on the detail page: the creator or a manager+.89 // Catalog rights, as on the detail page: the creator or a manager+.
125 const canManageCatalog = (course: Course) => {90 const canManageCatalog = (course: Course) => {
@@ -129,9 +94,7 @@ function CoursesContent() {
129 const [editTarget, setEditTarget] = createSignal<Course | null>(null);94 const [editTarget, setEditTarget] = createSignal<Course | null>(null);
130 const [deleteTarget, setDeleteTarget] = createSignal<Course | null>(null);95 const [deleteTarget, setDeleteTarget] = createSignal<Course | null>(null);
131 const [rowError, setRowError] = createSignal("");96 const [rowError, setRowError] = createSignal("");
132- const refreshList = async () => {97+ const refreshList = async () => refetch();
133- try { await refetch(); } catch { /* stale rows until the next load */ }
134- };
135 const columns = createMemo<ColumnDef<Course>[]>(() => [98 const columns = createMemo<ColumnDef<Course>[]>(() => [
136 {99 {
137 accessorKey: "title",100 accessorKey: "title",
@@ -294,7 +257,6 @@ function CoursesContent() {
294 onChange={(value) => {257 onChange={(value) => {
295 const kind = value === "course" || value === "study" || value === "club" ? value : undefined;258 const kind = value === "course" || value === "study" || value === "club" ? value : undefined;
296 setPageKind(kind);259 setPageKind(kind);
297- setPage(0);
298 void navigate({260 void navigate({
299 to: "/courses",261 to: "/courses",
300 search: (prev) => ({ q: prev.q, taught: prev.taught, sort: prev.sort, action: undefined, kind, page: undefined }),262 search: (prev) => ({ q: prev.q, taught: prev.taught, sort: prev.sort, action: undefined, kind, page: undefined }),
@@ -310,27 +272,22 @@ function CoursesContent() {
310 </TabsList>272 </TabsList>
311 273
312 <TabsContent value={pageKind() ?? "all"} class="mt-4 space-y-4 border-0 bg-transparent p-0 shadow-none">274 <TabsContent value={pageKind() ?? "all"} class="mt-4 space-y-4 border-0 bg-transparent p-0 shadow-none">
313- <Suspense fallback={<DataTableSkeleton columns={5} rows={8} />}>275+ <Show when={list.error()}>
314- <Show when={list.error}>276+ {(err) => <ErrorAlert message={formatApiError(err())} onRetry={refetch} />}
315- <ErrorAlert message={formatApiError(list.error)} onRetry={() => void refetch()} />277+ </Show>
316- </Show>278+ <Show when={!list.initialLoading()} fallback={<DataTableSkeleton columns={5} rows={8} />}>
317 <DataTable279 <DataTable
318 columns={columns()}280 columns={columns()}
319- data={visibleItems()}281+ data={list.items()}
320 tableClass="table-fixed min-w-[44rem]"282 tableClass="table-fixed min-w-[44rem]"
321 filterPlaceholder={t("common.searchPlaceholder")}283 filterPlaceholder={t("common.searchPlaceholder")}
322 filterHint={t("search.hint.courses")}284 filterHint={t("search.hint.courses")}
323 searchValue={search()}285 searchValue={search()}
324- onSearchInput={(value) => {286+ onSearchInput={setSearch}
325- setSearch(value);287+ infinite={{ hasMore: list.hasMore(), loading: list.loading(), total: list.total(), onLoadMore: list.loadMore }}
326- setPage(0);
327- }}
328- enablePagination
329- manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }}
330 filtersActive={taughtFilter() !== "all"}288 filtersActive={taughtFilter() !== "all"}
331 onClearFilters={() => {289 onClearFilters={() => {
332 setTaughtFilter("all");290 setTaughtFilter("all");
333- setPage(0);
334 }}291 }}
335 empty={t("courses.empty", { item: kindInSentence() })}292 empty={t("courses.empty", { item: kindInSentence() })}
336 onRowClick={openCourse}293 onRowClick={openCourse}
@@ -341,7 +298,6 @@ function CoursesContent() {
341 value={taughtFilter()}298 value={taughtFilter()}
342 onChange={(value) => {299 onChange={(value) => {
343 setTaughtFilter(value === "taught" || value === "untaught" ? value : "all");300 setTaughtFilter(value === "taught" || value === "untaught" ? value : "all");
344- setPage(0);
345 }}301 }}
346 options={[302 options={[
347 { value: "all", label: t("common.all") },303 { value: "all", label: t("common.all") },
@@ -352,14 +308,14 @@ function CoursesContent() {
352 }308 }
353 actions={309 actions={
354 <Show when={canCreate()}>310 <Show when={canCreate()}>
355- <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}>311+ <Button type="button" size="sm" onClick={() => setShowForm(true)}>
356 <IconPlus class="h-4 w-4" />312 <IconPlus class="h-4 w-4" />
357 {t("common.createItem", { item: kindInSentence() })}313 {t("common.createItem", { item: kindInSentence() })}
358 </Button>314 </Button>
359 </Show>315 </Show>
360 }316 }
361 />317 />
362- </Suspense>318+ </Show>
363 </TabsContent>319 </TabsContent>
364 </Tabs>320 </Tabs>
365 </div>321 </div>
src/pages/event-detail-page.tsxmodified+3 -2
@@ -21,6 +21,7 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs";
21 import { Alert } from "@/components/ui/alert";21 import { Alert } from "@/components/ui/alert";
22 import { Badge } from "@/components/ui/badge";22 import { Badge } from "@/components/ui/badge";
23 import { Button } from "@/components/ui/button";23 import { Button } from "@/components/ui/button";
24+import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
24 import { ConfirmDialog } from "@/components/ui/confirm-dialog";25 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
25 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";26 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
26 import { EmptyState } from "@/components/ui/empty-state";27 import { EmptyState } from "@/components/ui/empty-state";
@@ -185,8 +186,8 @@ function EventDetailContent() {
185 description={ev().description || undefined}186 description={ev().description || undefined}
186 actions={187 actions={
187 canManage() ? (188 canManage() ? (
188- <div class="detail-action-group">189+ <div class={cn("detail-action-group", TOOLBAR_SLOT)}>
189- <Button type="button" variant="outline" size="sm" class="flex-1 rounded-xl sm:flex-none" onClick={() => setEditing(true)}>190+ <Button type="button" variant="outline" size="sm" class="flex-1 sm:flex-none" onClick={() => setEditing(true)}>
190 <IconEdit class="h-4 w-4" />191 <IconEdit class="h-4 w-4" />
191 {t("common.edit")}192 {t("common.edit")}
192 </Button>193 </Button>
src/pages/exam-detail-page.tsxmodified+13 -7
@@ -29,6 +29,7 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs";
29 import { Alert } from "@/components/ui/alert";29 import { Alert } from "@/components/ui/alert";
30 import { Badge } from "@/components/ui/badge";30 import { Badge } from "@/components/ui/badge";
31 import { Button } from "@/components/ui/button";31 import { Button } from "@/components/ui/button";
32+import { TOOLBAR_CONTROL, TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
32 import { ConfirmDialog } from "@/components/ui/confirm-dialog";33 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
33 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";34 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
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";
@@ -408,13 +409,16 @@ function ExamDetailContent() {
408 title={ex().title}409 title={ex().title}
409 description={ex().description || undefined}410 description={ex().description || undefined}
410 actions={411 actions={
411- <div class="flex flex-wrap items-center gap-2">412+ // Header buttons and the ⋮ menu are toolbar controls: one pill
413+ // height. The Links are `contents` so the slot sizes the Button
414+ // inside rather than padding the anchor around it.
415+ <div class={cn("flex flex-wrap items-center gap-2", TOOLBAR_SLOT)}>
412 <Show when={isStudent() && !isDraft() && isSittable()}>416 <Show when={isStudent() && !isDraft() && isSittable()}>
413 <Show when={!isUpcoming() && !isFinished()}>417 <Show when={!isUpcoming() && !isFinished()}>
414 <Show when={noAttemptsLeft()}418 <Show when={noAttemptsLeft()}
415 fallback={419 fallback={
416- <Link to="/exam-room/$id" params={{ id: id() }}>420+ <Link to="/exam-room/$id" params={{ id: id() }} class="contents">
417- <Button size="sm" class="flex-1 rounded-lg sm:flex-none">421+ <Button size="sm" class="flex-1 sm:flex-none">
418 <IconExam class="h-4 w-4" />422 <IconExam class="h-4 w-4" />
419 {ownAttempt()?.status === "in_progress" && !ownAttemptClosedByExit() ? t("attempt.resume") : t("attempt.openRoom")}423 {ownAttempt()?.status === "in_progress" && !ownAttemptClosedByExit() ? t("attempt.resume") : t("attempt.openRoom")}
420 </Button>424 </Button>
@@ -428,8 +432,8 @@ function ExamDetailContent() {
428 </Show>432 </Show>
429 </Show>433 </Show>
430 <Show when={hasCourseManagementRights() && !isDraft() && !isUpcoming() && isSittable()}>434 <Show when={hasCourseManagementRights() && !isDraft() && !isUpcoming() && isSittable()}>
431- <Link to="/exams/$id/live" params={{ id: id() }}>435+ <Link to="/exams/$id/live" params={{ id: id() }} class="contents">
432- <Button size="sm" class="flex-1 rounded-lg sm:flex-none">436+ <Button size="sm" class="flex-1 sm:flex-none">
433 <IconEye class="h-4 w-4" />437 <IconEye class="h-4 w-4" />
434 {isFinished() ? t("exams.finalState") : t("exams.liveMonitor")}438 {isFinished() ? t("exams.finalState") : t("exams.liveMonitor")}
435 </Button>439 </Button>
@@ -737,7 +741,9 @@ function ExamDetailContent() {
737 <Show when={isFinished()}>741 <Show when={isFinished()}>
738 <label742 <label
739 class={cn(743 class={cn(
740- "inline-flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-muted/50",744+ // Sits in the toolbar beside "Sütunlar": same pill height.
745+ "inline-flex cursor-pointer items-center gap-2 px-3 transition-colors hover:bg-muted/50",
746+ TOOLBAR_CONTROL,
741 reviewOn() && "text-primary-text",747 reviewOn() && "text-primary-text",
742 )}748 )}
743 title={t("exams.allowReviewHelp")}749 title={t("exams.allowReviewHelp")}
@@ -756,7 +762,7 @@ function ExamDetailContent() {
756 </span>762 </span>
757 </label>763 </label>
758 </Show>764 </Show>
759- <Button type="button" variant="outline" size="sm" class="rounded-lg" disabled={isDraft()} onClick={() => setGradeOpen(true)}>765+ <Button type="button" size="sm" disabled={isDraft()} onClick={() => setGradeOpen(true)}>
760 <IconEdit class="h-4 w-4" />766 <IconEdit class="h-4 w-4" />
761 {t("exams.gradeStudent")}767 {t("exams.gradeStudent")}
762 </Button>768 </Button>
src/pages/exams-page.tsxmodified+7 -3
@@ -17,6 +17,7 @@ import { Badge } from "@/components/ui/badge";
17 import { Button } from "@/components/ui/button";17 import { Button } from "@/components/ui/button";
18 import { ConfirmDialog } from "@/components/ui/confirm-dialog";18 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
19 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";19 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
20+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
20 import { IconChart, IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons";21 import { IconChart, IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons";
21 import { DropdownSelect } from "@/components/ui/select";22 import { DropdownSelect } from "@/components/ui/select";
22 import { SearchableSelect } from "@/components/ui/searchable-select";23 import { SearchableSelect } from "@/components/ui/searchable-select";
@@ -40,6 +41,9 @@ import { useAuth } from "@/stores/auth-context";
40 import { usePreferences, useT } from "@/stores/preferences-context";41 import { usePreferences, useT } from "@/stores/preferences-context";
41 42
42 const EXAM_PAGE_SIZE = 10;43 const EXAM_PAGE_SIZE = 10;
44+// The course combobox is a bordered div, not a <button>, so the DataTable
45+// filters slot cannot size it: it takes the toolbar pill by hand.
46+const COURSE_FILTER_CLASS = cn(TOOLBAR_CONTROL, "min-w-[12rem] max-w-[18rem] [&_input]:text-[13px]");
43 47
44 type ExamRow = Exam & { displayStatus: ExamDisplayStatus };48 type ExamRow = Exam & { displayStatus: ExamDisplayStatus };
45 49
@@ -397,7 +401,7 @@ function ExamsContent() {
397 description={t("exams.subtitle")}401 description={t("exams.subtitle")}
398 actions={402 actions={
399 canCreate() ? (403 canCreate() ? (
400- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCreateModal}>404+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={openCreateModal}>
401 <IconPlus class="h-4 w-4" />405 <IconPlus class="h-4 w-4" />
402 {t("exams.create")}406 {t("exams.create")}
403 </Button>407 </Button>
@@ -422,7 +426,7 @@ function ExamsContent() {
422 <label for="exams-course-filter" class="text-xs font-semibold text-muted-foreground">{t("nav.courses")}:</label>426 <label for="exams-course-filter" class="text-xs font-semibold text-muted-foreground">{t("nav.courses")}:</label>
423 <SearchableSelect427 <SearchableSelect
424 id="exams-course-filter"428 id="exams-course-filter"
425- class="h-8 min-w-[12rem] max-w-[18rem]"429+ class={cn(COURSE_FILTER_CLASS, courseFilter() !== "all" && "border-primary text-primary-text")}
426 value={courseFilter()}430 value={courseFilter()}
427 onChange={(val) => setCourseFilter(val)}431 onChange={(val) => setCourseFilter(val)}
428 options={[432 options={[
@@ -446,7 +450,7 @@ function ExamsContent() {
446 type="button"450 type="button"
447 variant="ghost"451 variant="ghost"
448 size="sm"452 size="sm"
449- class="h-8 rounded-lg px-3 text-[13px] font-medium text-muted-foreground hover:text-foreground"453+ class="font-medium text-muted-foreground hover:text-foreground"
450 onClick={clearFilters}454 onClick={clearFilters}
451 >455 >
452 <IconRotateCcw class="h-3.5 w-3.5 mr-1" />456 <IconRotateCcw class="h-3.5 w-3.5 mr-1" />
src/pages/holidays-page.tsxmodified+1 -1
@@ -158,7 +158,7 @@ function HolidaysContent() {
158 title={t("holidays.title")}158 title={t("holidays.title")}
159 description={t("holidays.subtitle")}159 description={t("holidays.subtitle")}
160 actions={160 actions={
161- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => openForm(null)}>161+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={() => openForm(null)}>
162 <IconPlus class="h-4 w-4" />162 <IconPlus class="h-4 w-4" />
163 {t("holidays.new")}163 {t("holidays.new")}
164 </Button>164 </Button>
src/pages/homework-page.tsxmodified+9 -3
@@ -14,6 +14,7 @@ import { RouteGuard } from "@/components/layout/route-guard";
14 import { Alert } from "@/components/ui/alert";14 import { Alert } from "@/components/ui/alert";
15 import { Button } from "@/components/ui/button";15 import { Button } from "@/components/ui/button";
16 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";16 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
17+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
17 import { DatePicker } from "@/components/ui/date-picker";18 import { DatePicker } from "@/components/ui/date-picker";
18 import { IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons";19 import { IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons";
19 import { Input } from "@/components/ui/input";20 import { Input } from "@/components/ui/input";
@@ -27,6 +28,7 @@ import { Textarea } from "@/components/ui/textarea";
27 import { formatDateTime } from "@/lib/format";28 import { formatDateTime } from "@/lib/format";
28 import { hasMinRole } from "@/lib/roles";29 import { hasMinRole } from "@/lib/roles";
29 import { createUrlString } from "@/lib/url-state";30 import { createUrlString } from "@/lib/url-state";
31+import { cn } from "@/lib/cn";
30 import { useAuth } from "@/stores/auth-context";32 import { useAuth } from "@/stores/auth-context";
31 import { usePreferences, useT } from "@/stores/preferences-context";33 import { usePreferences, useT } from "@/stores/preferences-context";
32 34
@@ -46,6 +48,10 @@ function dateInputToMs(date: string, time: string): number | null {
46 return d.getTime();48 return d.getTime();
47 }49 }
48 50
51+// The course combobox is a bordered div, not a <button>, so the DataTable
52+// filters slot cannot size it: it takes the toolbar pill by hand.
53+const COURSE_FILTER_CLASS = cn(TOOLBAR_CONTROL, "min-w-[12rem] max-w-[18rem] [&_input]:text-[13px]");
54+
49 export default function HomeworkPage() {55 export default function HomeworkPage() {
50 return (56 return (
51 <RouteGuard>57 <RouteGuard>
@@ -304,7 +310,7 @@ function HomeworkContent() {
304 <label for="homework-course-filter" class="text-xs font-semibold text-muted-foreground">{t("nav.courses")}:</label>310 <label for="homework-course-filter" class="text-xs font-semibold text-muted-foreground">{t("nav.courses")}:</label>
305 <SearchableSelect311 <SearchableSelect
306 id="homework-course-filter"312 id="homework-course-filter"
307- class="h-8 min-w-[12rem] max-w-[18rem]"313+ class={cn(COURSE_FILTER_CLASS, courseFilter() !== "all" && "border-primary text-primary-text")}
308 value={courseFilter()}314 value={courseFilter()}
309 onChange={(val) => setCourseFilter(val)}315 onChange={(val) => setCourseFilter(val)}
310 options={courseFilterOptions()}316 options={courseFilterOptions()}
@@ -314,7 +320,7 @@ function HomeworkContent() {
314 type="button"320 type="button"
315 variant="ghost"321 variant="ghost"
316 size="sm"322 size="sm"
317- class="h-8 rounded-lg px-3 text-[13px] font-medium text-muted-foreground hover:text-foreground"323+ class="font-medium text-muted-foreground hover:text-foreground"
318 onClick={() => setCourseFilter("all")}324 onClick={() => setCourseFilter("all")}
319 >325 >
320 <IconRotateCcw class="mr-1 h-3.5 w-3.5" />326 <IconRotateCcw class="mr-1 h-3.5 w-3.5" />
@@ -325,7 +331,7 @@ function HomeworkContent() {
325 }331 }
326 actions={332 actions={
327 <Show when={canCreate()}>333 <Show when={canCreate()}>
328- <Button type="button" size="sm" class="rounded-lg" onClick={() => { setSelectedCourseId(preferredCourseId()); setCreateOpen(true); }}>334+ <Button type="button" size="sm" onClick={() => { setSelectedCourseId(preferredCourseId()); setCreateOpen(true); }}>
329 <IconPlus class="h-4 w-4" />335 <IconPlus class="h-4 w-4" />
330 {t("homework.add")}336 {t("homework.add")}
331 </Button>337 </Button>
src/pages/instance-detail-page.tsxmodified+2 -2
@@ -673,7 +673,7 @@ function InstanceDetailContent() {
673 pageSize={10}673 pageSize={10}
674 empty={t("exams.empty")}674 empty={t("exams.empty")}
675 actions={canManage() ? (675 actions={canManage() ? (
676- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowExamForm(true)}>676+ <Button type="button" size="sm" onClick={() => setShowExamForm(true)}>
677 <IconPlus class="h-4 w-4" />{t("courses.addExam")}677 <IconPlus class="h-4 w-4" />{t("courses.addExam")}
678 </Button>678 </Button>
679 ) : undefined}679 ) : undefined}
@@ -752,7 +752,7 @@ function InstanceDetailContent() {
752 empty={t("exams.emptyRoster")}752 empty={t("exams.emptyRoster")}
753 emptyIllustration="people"753 emptyIllustration="people"
754 actions={754 actions={
755- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowEnrollPanel(true)}>755+ <Button type="button" size="sm" onClick={() => setShowEnrollPanel(true)}>
756 <IconPlus class="h-4 w-4" />{t("courses.enroll")}756 <IconPlus class="h-4 w-4" />{t("courses.enroll")}
757 </Button>757 </Button>
758 }758 }
src/pages/live-monitor-page.tsxmodified+7 -3
@@ -13,6 +13,7 @@ import { Alert } from "@/components/ui/alert";
13 import { Badge } from "@/components/ui/badge";13 import { Badge } from "@/components/ui/badge";
14 import { Button } from "@/components/ui/button";14 import { Button } from "@/components/ui/button";
15 import { DataTable } from "@/components/ui/data-table";15 import { DataTable } from "@/components/ui/data-table";
16+import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
16 import { DetailField } from "@/components/ui/detail-field";17 import { DetailField } from "@/components/ui/detail-field";
17 import { IconAlert, IconCheck, IconChevronLeft, IconClock, IconExam, IconEye, IconUsers } from "@/components/ui/icons";18 import { IconAlert, IconCheck, IconChevronLeft, IconClock, IconExam, IconEye, IconUsers } from "@/components/ui/icons";
18 import { PageSpinner } from "@/components/ui/page-spinner";19 import { PageSpinner } from "@/components/ui/page-spinner";
@@ -263,9 +264,12 @@ function LiveMonitorContent() {
263 title={ex().title}264 title={ex().title}
264 description={isFinished() ? t("exams.finalStateDesc") : t("exams.liveMonitorDesc")}265 description={isFinished() ? t("exams.finalStateDesc") : t("exams.liveMonitorDesc")}
265 actions={266 actions={
266- <div class="flex w-full flex-wrap items-center gap-1 rounded-lg border bg-background/80 p-1 shadow-xs sm:w-auto">267+ // A header control takes the toolbar pill, not a 26px ghost
267- <Link to="/exams/$id" params={{ id: id() }}>268+ // button inside a box of its own. The Link is `contents` so
268- <Button variant="ghost" size="sm" class="w-full rounded-md sm:w-auto">269+ // the slot sizes the Button, not the anchor around it.
270+ <div class={cn("flex w-full flex-wrap items-center gap-2 sm:w-auto", TOOLBAR_SLOT)}>
271+ <Link to="/exams/$id" params={{ id: id() }} class="contents">
272+ <Button variant="outline" size="sm" class="w-full sm:w-auto">
269 <IconChevronLeft class="h-4 w-4" />273 <IconChevronLeft class="h-4 w-4" />
270 {t("common.back")}274 {t("common.back")}
271 </Button>275 </Button>
src/pages/meal-detail-page.tsxmodified+5 -3
@@ -47,11 +47,13 @@ import { RouteGuard } from "@/components/layout/route-guard";
47 import { Alert } from "@/components/ui/alert";47 import { Alert } from "@/components/ui/alert";
48 import { Badge } from "@/components/ui/badge";48 import { Badge } from "@/components/ui/badge";
49 import { Button } from "@/components/ui/button";49 import { Button } from "@/components/ui/button";
50+import { TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
50 import { ConfirmDialog } from "@/components/ui/confirm-dialog";51 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
51 import { ErrorAlert } from "@/components/ui/error-alert";52 import { ErrorAlert } from "@/components/ui/error-alert";
52 import { IconEdit, IconTrash, IconUsers } from "@/components/ui/icons";53 import { IconEdit, IconTrash, IconUsers } from "@/components/ui/icons";
53 import { PageSpinner } from "@/components/ui/page-spinner";54 import { PageSpinner } from "@/components/ui/page-spinner";
54 import { TableRowActions } from "@/components/ui/table-row-actions";55 import { TableRowActions } from "@/components/ui/table-row-actions";
56+import { cn } from "@/lib/cn";
55 import { formatDateTime } from "@/lib/format";57 import { formatDateTime } from "@/lib/format";
56 import { formatMealDay, formatTry, mealCutoffAt, mealSlotLabel } from "@/lib/meals";58 import { formatMealDay, formatTry, mealCutoffAt, mealSlotLabel } from "@/lib/meals";
57 import { personLabel } from "@/lib/person";59 import { personLabel } from "@/lib/person";
@@ -214,12 +216,12 @@ function MealDetailContent() {
214 description={formatMealDay(current().date, moneyLocale(), true)}216 description={formatMealDay(current().date, moneyLocale(), true)}
215 actions={217 actions={
216 canManage() ? (218 canManage() ? (
217- <div class="detail-action-group">219+ <div class={cn("detail-action-group", TOOLBAR_SLOT)}>
218- <Button variant="outline" size="sm" class="flex-1 rounded-lg sm:flex-none" onClick={() => { setError(""); setShowRecord(true); }}>220+ <Button variant="outline" size="sm" class="flex-1 sm:flex-none" onClick={() => { setError(""); setShowRecord(true); }}>
219 <IconUsers class="h-4 w-4" />221 <IconUsers class="h-4 w-4" />
220 {t("meals.studentRecord")}222 {t("meals.studentRecord")}
221 </Button>223 </Button>
222- <Button variant="outline" size="sm" class="flex-1 rounded-lg sm:flex-none" onClick={() => { setError(""); setShowMenuEdit(true); }}>224+ <Button variant="outline" size="sm" class="flex-1 sm:flex-none" onClick={() => { setError(""); setShowMenuEdit(true); }}>
223 <IconEdit class="h-4 w-4" />225 <IconEdit class="h-4 w-4" />
224 {t("common.edit")}226 {t("common.edit")}
225 </Button>227 </Button>
src/pages/meals-page.tsxmodified+1 -1
@@ -95,7 +95,7 @@ function MealsContent() {
95 description={t("meals.subtitle")}95 description={t("meals.subtitle")}
96 actions={96 actions={
97 <Show when={canManage()}>97 <Show when={canManage()}>
98- <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowCreate(true)}>98+ <Button size="sm" class="min-w-[7.5rem]" onClick={() => setShowCreate(true)}>
99 <IconPlus class="h-4 w-4" />99 <IconPlus class="h-4 w-4" />
100 {t("meals.publish")}100 {t("meals.publish")}
101 </Button>101 </Button>
src/pages/messages-page.test.tsxmodified+8 -7
@@ -46,8 +46,9 @@ afterEach(() => {
46 test("emptying trash waits for confirmation and names what it deletes", async () => {46 test("emptying trash waits for confirmation and names what it deletes", async () => {
47 getMessages.mockImplementation(async (folder: string) =>47 getMessages.mockImplementation(async (folder: string) =>
48 folder === "trash"48 folder === "trash"
49- ? { items: [message(1), message(2)], total: 5, limit: 30, offset: 0 }49+ // A full first page (50) of a 55-message trash: the rest is not loaded yet.
50- : { items: [], total: 0, limit: 30, offset: 0 },50+ ? { items: Array.from({ length: 50 }, (_, i) => message(i + 1)), total: 55, limit: 50, offset: 0 }
51+ : { items: [], total: 0, limit: 50, offset: 0 },
51 );52 );
52 deleteMessageById.mockResolvedValue(undefined);53 deleteMessageById.mockResolvedValue(undefined);
53 54
@@ -62,16 +63,16 @@ test("emptying trash waits for confirmation and names what it deletes", async ()
62 fireEvent.click(await screen.findByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ }));63 fireEvent.click(await screen.findByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ }));
63 64
64 const dialog = await screen.findByRole("alertdialog");65 const dialog = await screen.findByRole("alertdialog");
65- expect(dialog.textContent).toMatch(/2 mesaj|2 messages/);66+ expect(dialog.textContent).toMatch(/50 mesaj|50 messages/);
66- expect(dialog.textContent).toMatch(/toplam 5|5 in trash/);67+ expect(dialog.textContent).toMatch(/toplam 55|55 in trash/);
67 expect(deleteMessageById).not.toHaveBeenCalled();68 expect(deleteMessageById).not.toHaveBeenCalled();
68 69
69 fireEvent.click(within(dialog).getByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ }));70 fireEvent.click(within(dialog).getByRole("button", { name: /Empty trash|Çöp kutusunu boşalt/ }));
70- await waitFor(() => expect(deleteMessageById).toHaveBeenCalledTimes(2));71+ await waitFor(() => expect(deleteMessageById).toHaveBeenCalledTimes(50));
71 });72 });
72 73
73 test("searching hits the server with a trimmed q at first-page offset", async () => {74 test("searching hits the server with a trimmed q at first-page offset", async () => {
74- getMessages.mockResolvedValue({ items: [message(1)], total: 1, limit: 30, offset: 0 });75+ getMessages.mockResolvedValue({ items: [message(1)], total: 1, limit: 50, offset: 0 });
75 76
76 render(() => (77 render(() => (
77 <PreferencesProvider>78 <PreferencesProvider>
@@ -83,6 +84,6 @@ test("searching hits the server with a trimmed q at first-page offset", async ()
83 fireEvent.input(search, { target: { value: " Subject 7 " } });84 fireEvent.input(search, { target: { value: " Subject 7 " } });
84 85
85 await waitFor(() =>86 await waitFor(() =>
86- expect(getMessages).toHaveBeenCalledWith("inbox", { limit: 30, offset: 0, q: "Subject 7" }),87+ expect(getMessages).toHaveBeenCalledWith("inbox", { limit: 50, offset: 0, q: "Subject 7" }),
87 );88 );
88 });89 });
src/pages/messages-page.tsxmodified+27 -46
@@ -2,14 +2,14 @@ import {
2 For,2 For,
3 Show,3 Show,
4 createMemo,4 createMemo,
5- createEffect,
6 createSignal,5 createSignal,
7 Suspense,6 Suspense,
8 useTransition,7 useTransition,
9 } from "solid-js";8 } from "solid-js";
10 import { createResource } from "@/lib/create-resource";9 import { createResource } from "@/lib/create-resource";
11 import { RouteGuard } from "@/components/layout/route-guard";10 import { RouteGuard } from "@/components/layout/route-guard";
12-import { TablePagination } from "@/components/ui/table-pagination";11+import { InfiniteSentinel } from "@/components/ui/infinite-sentinel";
12+import { createInfiniteList } from "@/lib/infinite-list";
13 import { Button } from "@/components/ui/button";13 import { Button } from "@/components/ui/button";
14 import {14 import {
15 IconArchive,15 IconArchive,
@@ -20,6 +20,7 @@ import {
20 IconRefresh,20 IconRefresh,
21 } from "@/components/ui/icons";21 } from "@/components/ui/icons";
22 import { DataTableSearch } from "@/components/ui/data-table-search";22 import { DataTableSearch } from "@/components/ui/data-table-search";
23+import { TOOLBAR_CONTROL } from "@/components/ui/data-toolbar";
23 import { GmailMailRow } from "@/components/messages/gmail-mail-row";24 import { GmailMailRow } from "@/components/messages/gmail-mail-row";
24 import { GmailMailDetail } from "@/components/messages/gmail-mail-detail";25 import { GmailMailDetail } from "@/components/messages/gmail-mail-detail";
25 import { GmailComposeBox } from "@/components/messages/gmail-compose-box";26 import { GmailComposeBox } from "@/components/messages/gmail-compose-box";
@@ -49,8 +50,6 @@ export default function MessagesPage() {
49 const t = useT();50 const t = useT();
50 const auth = useAuth();51 const auth = useAuth();
51 const [folder, setFolder] = createSignal<MessageFolder>("inbox");52 const [folder, setFolder] = createSignal<MessageFolder>("inbox");
52- const [page, setPage] = createSignal(1);
53- const limit = 30;
54 const [selectedId, setSelectedId] = createSignal<string>("");53 const [selectedId, setSelectedId] = createSignal<string>("");
55 const [query, setQuery, debouncedQuery] = createDebouncedSignal();54 const [query, setQuery, debouncedQuery] = createDebouncedSignal();
56 const [composeOpen, setComposeOpen] = createSignal(false);55 const [composeOpen, setComposeOpen] = createSignal(false);
@@ -58,27 +57,20 @@ export default function MessagesPage() {
58 const [isPending, startTransition] = useTransition();57 const [isPending, startTransition] = useTransition();
59 const [, setFlash] = createFlash();58 const [, setFlash] = createFlash();
60 59
61- const [messagePage, { refetch }] = createResource(60+ // Folder and search are both applied by the backend, so the list loads a
62- () => ({ f: folder(), p: page(), q: debouncedQuery().trim() }),61+ // page at a time as the reader scrolls and starts over on either change.
63- async (args) =>62+ const messageList = createInfiniteList(
64- await getMessages(args.f, {63+ () => ({ f: folder(), q: debouncedQuery().trim() }),
65- limit,64+ (args, paging) => getMessages(args.f, { ...paging, ...(args.q ? { q: args.q } : {}) }),
66- offset: (args.p - 1) * limit,65+ { equals: (a, b) => a.f === b.f && a.q === b.q },
67- ...(args.q ? { q: args.q } : {}),
68- })
69 );66 );
70- createEffect(() => {67+ const refetch = async () => messageList.reload();
71- const total = messagePage()?.total;
72- if (total === undefined) return;
73- const lastPage = Math.max(1, Math.ceil(total / limit));
74- if (page() > lastPage) setPage(lastPage);
75- });
76 68
77 const [unreadCount, { refetch: refetchUnread }] = createResource(69 const [unreadCount, { refetch: refetchUnread }] = createResource(
78 async () => (await getMessages("inbox", { read: false, limit: 1 })).total70 async () => (await getMessages("inbox", { read: false, limit: 1 })).total
79 );71 );
80 72
81- const rawMessages = createMemo(() => messagePage()?.items ?? []);73+ const rawMessages = createMemo(() => messageList.items());
82 74
83 // En yeni mesaj en üstte sıralama75 // En yeni mesaj en üstte sıralama
84 const messages = createMemo(() =>76 const messages = createMemo(() =>
@@ -155,7 +147,7 @@ export default function MessagesPage() {
155 /** Empty trash deletes the loaded page only; the summary says so when more remain. */147 /** Empty trash deletes the loaded page only; the summary says so when more remain. */
156 const emptyTrashSummary = () => {148 const emptyTrashSummary = () => {
157 const count = messages().length;149 const count = messages().length;
158- const total = messagePage()?.total ?? count;150+ const total = messageList.total() || count;
159 return total > count151 return total > count
160 ? t("messages.emptyTrashPageSummary", { count, total })152 ? t("messages.emptyTrashPageSummary", { count, total })
161 : t("messages.emptyTrashSummary", { count });153 : t("messages.emptyTrashSummary", { count });
@@ -202,7 +194,7 @@ export default function MessagesPage() {
202 type="button"194 type="button"
203 aria-current={active() ? "page" : undefined}195 aria-current={active() ? "page" : undefined}
204 class={cn(196 class={cn(
205- "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",197+ "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]",
206 active()198 active()
207 ? entry.id === "trash"199 ? entry.id === "trash"
208 ? "bg-destructive/10 text-destructive-text"200 ? "bg-destructive/10 text-destructive-text"
@@ -212,7 +204,6 @@ export default function MessagesPage() {
212 onClick={() =>204 onClick={() =>
213 startTransition(() => {205 startTransition(() => {
214 setFolder(entry.id);206 setFolder(entry.id);
215- setPage(1);
216 setSelectedId("");207 setSelectedId("");
217 })208 })
218 }209 }
@@ -239,7 +230,7 @@ export default function MessagesPage() {
239 </nav>230 </nav>
240 <Button231 <Button
241 size="sm"232 size="sm"
242- class="w-full shrink-0 rounded-lg sm:w-auto"233+ class={cn(TOOLBAR_CONTROL, "w-full shrink-0 px-3.5 sm:w-auto")}
243 onClick={() => setComposeOpen(true)}234 onClick={() => setComposeOpen(true)}
244 >235 >
245 <IconPlus class="h-4 w-4" />236 <IconPlus class="h-4 w-4" />
@@ -257,7 +248,7 @@ export default function MessagesPage() {
257 <Button248 <Button
258 variant="outline"249 variant="outline"
259 size="sm"250 size="sm"
260- class="h-8 px-3 rounded-lg text-[13px] font-semibold shrink-0"251+ class={cn(TOOLBAR_CONTROL, "shrink-0 px-3.5 font-semibold")}
261 onClick={handleRefresh}252 onClick={handleRefresh}
262 disabled={isRefreshing()}253 disabled={isRefreshing()}
263 title={t("messages.refreshList")}254 title={t("messages.refreshList")}
@@ -275,11 +266,7 @@ export default function MessagesPage() {
275 class="max-w-none"266 class="max-w-none"
276 placeholder={t("messages.search")}267 placeholder={t("messages.search")}
277 value={query()}268 value={query()}
278- onChange={(value) => {269+ onChange={setQuery}
279- setQuery(value);
280- // The server filters from the first row; offset restarts with each search.
281- setPage(1);
282- }}
283 />270 />
284 </div>271 </div>
285 272
@@ -288,7 +275,7 @@ export default function MessagesPage() {
288 <Button275 <Button
289 variant="outline"276 variant="outline"
290 size="sm"277 size="sm"
291- class="h-8 rounded-lg text-[13px] text-destructive-text hover:bg-destructive/10"278+ class={cn(TOOLBAR_CONTROL, "px-3.5 text-destructive-text hover:bg-destructive/10")}
292 onClick={() => setConfirmEmptyTrash(true)}279 onClick={() => setConfirmEmptyTrash(true)}
293 >280 >
294 <IconTrash class="mr-1.5 h-3.5 w-3.5" />281 <IconTrash class="mr-1.5 h-3.5 w-3.5" />
@@ -296,13 +283,7 @@ export default function MessagesPage() {
296 </Button>283 </Button>
297 </Show>284 </Show>
298 285
299- <Show when={messagePage()}>286+
300- <span class="font-mono text-xs text-text-subtle shrink-0">
301- {messagePage()!.total > 0
302- ? `${(page() - 1) * limit + 1}-${Math.min(page() * limit, messagePage()!.total)} / ${messagePage()!.total}`
303- : "0 / 0"}
304- </span>
305- </Show>
306 </div>287 </div>
307 </div>288 </div>
308 </Show>289 </Show>
@@ -368,15 +349,15 @@ export default function MessagesPage() {
368 </Show>349 </Show>
369 </Suspense>350 </Suspense>
370 351
371- <Show when={messagePage() && messagePage()!.total > limit}>352+ <div class="border-t border-border-hairline px-4 py-3">
372- <div class="p-4 border-t border-border-hairline">353+ <InfiniteSentinel
373- <TablePagination354+ hasMore={messageList.hasMore()}
374- pageIndex={page()}355+ loading={messageList.loading()}
375- onPageChange={setPage}356+ onLoadMore={messageList.loadMore}
376- pageCount={Math.ceil((messagePage()?.total ?? 0) / limit)}357+ shown={messages().length}
377- />358+ total={messageList.total()}
378- </div>359+ />
379- </Show>360+ </div>
380 </div>361 </div>
381 }362 }
382 >363 >
src/pages/my-students-page.tsxmodified+8 -4
@@ -17,6 +17,7 @@ import { PageSpinner } from "@/components/ui/page-spinner";
17 import { SidePanel } from "@/components/ui/side-panel";17 import { SidePanel } from "@/components/ui/side-panel";
18 import { Button } from "@/components/ui/button";18 import { Button } from "@/components/ui/button";
19 import { DataTable, DataTableEmpty } from "@/components/ui/data-table";19 import { DataTable, DataTableEmpty } from "@/components/ui/data-table";
20+import { cn } from "@/lib/cn";
20 import { personLabel } from "@/lib/person";21 import { personLabel } from "@/lib/person";
21 import { useT } from "@/stores/preferences-context";22 import { useT } from "@/stores/preferences-context";
22 import { IconChart, IconChevronRight, IconClipboardCheck, IconClock, IconExam, IconExternalLink, IconHomework, IconMessage } from "@/components/ui/icons";23 import { IconChart, IconChevronRight, IconClipboardCheck, IconClock, IconExam, IconExternalLink, IconHomework, IconMessage } from "@/components/ui/icons";
@@ -28,6 +29,11 @@ import { examKindLabel } from "@/lib/exam-labels";
28 29
29 type StudentTab = "marks" | "attendance" | "exams" | "homework" | "study";30 type StudentTab = "marks" | "attendance" | "exams" | "homework" | "study";
30 31
32+// The panel's action and tab buttons are toolbar pills: touch-sized (h-10)
33+// below `sm` and on touch screens, h-8 above, so both rows read as one set.
34+const PANEL_CONTROLS =
35+ "[&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10";
36+
31 // /students opens a child on the progress report; the parent sidebar's37 // /students opens a child on the progress report; the parent sidebar's
32 // Devamsızlık / Sınav sonuçları / Çalışma planı entries are the same page38 // Devamsızlık / Sınav sonuçları / Çalışma planı entries are the same page
33 // landing on another tab (/students/attendance, /students/exams, /students/study).39 // landing on another tab (/students/attendance, /students/exams, /students/study).
@@ -198,7 +204,7 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud
198 <SidePanel open={!!props.student} onOpenChange={(open) => !open && props.onClose()} title={props.student ? personLabel(props.student) : ""} description={`@${props.student?.username}`}>204 <SidePanel open={!!props.student} onOpenChange={(open) => !open && props.onClose()} title={props.student ? personLabel(props.student) : ""} description={`@${props.student?.username}`}>
199 <div class="flex h-full flex-col">205 <div class="flex h-full flex-col">
200 <div class="border-b border-border-hairline p-4">206 <div class="border-b border-border-hairline p-4">
201- <div class="mb-3 flex flex-wrap items-center justify-between gap-2">207+ <div class={cn("mb-3 flex flex-wrap items-center justify-between gap-2", PANEL_CONTROLS)}>
202 {/* A parent may read their linked students' profiles, so this is safe208 {/* A parent may read their linked students' profiles, so this is safe
203 — it 403s only for someone else's child. Close the panel before209 — it 403s only for someone else's child. Close the panel before
204 navigating: a click that stays inside this modal never leaves it. */}210 navigating: a click that stays inside this modal never leaves it. */}
@@ -207,7 +213,6 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud
207 <Button213 <Button
208 variant="outline"214 variant="outline"
209 size="sm"215 size="sm"
210- class="rounded-lg"
211 onClick={() => {216 onClick={() => {
212 props.onClose();217 props.onClose();
213 void navigate({ to: "/profile/$userId", params: { userId: s().id } });218 void navigate({ to: "/profile/$userId", params: { userId: s().id } });
@@ -227,7 +232,6 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud
227 </Show>232 </Show>
228 <Button233 <Button
229 size="sm"234 size="sm"
230- class="rounded-lg"
231 onClick={() => {235 onClick={() => {
232 props.onClose();236 props.onClose();
233 void navigate({ to: "/messages" });237 void navigate({ to: "/messages" });
@@ -237,7 +241,7 @@ function StudentDetailPanel(props: { student: PersonRef | null; initialTab: Stud
237 {t("messages.newMessage")}241 {t("messages.newMessage")}
238 </Button>242 </Button>
239 </div>243 </div>
240- <div class="flex flex-wrap gap-2">244+ <div class={cn("flex flex-wrap gap-2", PANEL_CONTROLS)}>
241 <For each={tabs()}>245 <For each={tabs()}>
242 {(tab) => {246 {(tab) => {
243 const Icon = tab.icon;247 const Icon = tab.icon;
src/pages/notes-page.tsxmodified+5 -3
@@ -12,10 +12,12 @@ import { RouteGuard } from "@/components/layout/route-guard";
12 import { NoteImportPanel } from "@/components/notes/note-import-panel";12 import { NoteImportPanel } from "@/components/notes/note-import-panel";
13 import { NoteList } from "@/components/notes/note-list";13 import { NoteList } from "@/components/notes/note-list";
14 import { Button } from "@/components/ui/button";14 import { Button } from "@/components/ui/button";
15+import { TOOLBAR_CARD, TOOLBAR_SLOT } from "@/components/ui/data-toolbar";
15 import { IconPlus, IconUploadCloud } from "@/components/ui/icons";16 import { IconPlus, IconUploadCloud } from "@/components/ui/icons";
16 import { PageSpinner } from "@/components/ui/page-spinner";17 import { PageSpinner } from "@/components/ui/page-spinner";
17 import { TablePagination } from "@/components/ui/table-pagination";18 import { TablePagination } from "@/components/ui/table-pagination";
18 import { SidePanel } from "@/components/ui/side-panel";19 import { SidePanel } from "@/components/ui/side-panel";
20+import { cn } from "@/lib/cn";
19 import { createFlash } from "@/lib/flash";21 import { createFlash } from "@/lib/flash";
20 import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";22 import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";
21 import { personalNoteFiles } from "@/lib/note-source";23 import { personalNoteFiles } from "@/lib/note-source";
@@ -93,12 +95,12 @@ function NotesContent() {
93 </SidePanel>95 </SidePanel>
94 96
95 <div class="space-y-4">97 <div class="space-y-4">
96- <div class="flex flex-wrap items-center justify-end gap-2 rounded-xl border border-border-line bg-surface-base p-3 shadow-xs">98+ <div class={cn("flex flex-wrap items-center justify-end gap-2 max-sm:[&_button]:flex-1", TOOLBAR_CARD, TOOLBAR_SLOT)}>
97- <Button type="button" size="sm" class="rounded-lg" onClick={() => void navigate({ to: "/notes/new" })}>99+ <Button type="button" size="sm" onClick={() => void navigate({ to: "/notes/new" })}>
98 <IconPlus class="h-4 w-4" />100 <IconPlus class="h-4 w-4" />
99 {t("notes.new")}101 {t("notes.new")}
100 </Button>102 </Button>
101- <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setImportOpen(true)}>103+ <Button type="button" variant="outline" size="sm" onClick={() => setImportOpen(true)}>
102 <IconUploadCloud class="h-4 w-4" />104 <IconUploadCloud class="h-4 w-4" />
103 {t("notes.import")}105 {t("notes.import")}
104 </Button>106 </Button>
src/pages/payments-page.tsxmodified+38 -26
@@ -36,7 +36,7 @@ import { ErrorAlert } from "@/components/ui/error-alert";
36 import { IconChevronLeft, IconEdit, IconEye, IconPlus, IconTrash } from "@/components/ui/icons";36 import { IconChevronLeft, IconEdit, IconEye, IconPlus, IconTrash } from "@/components/ui/icons";
37 import { Input } from "@/components/ui/input";37 import { Input } from "@/components/ui/input";
38 import { Label } from "@/components/ui/label";38 import { Label } from "@/components/ui/label";
39-import { Select } from "@/components/ui/select";39+import { DropdownSelect, Select } from "@/components/ui/select";
40 import { SidePanel } from "@/components/ui/side-panel";40 import { SidePanel } from "@/components/ui/side-panel";
41 import { TableRowActions } from "@/components/ui/table-row-actions";41 import { TableRowActions } from "@/components/ui/table-row-actions";
42 import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";42 import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
@@ -628,11 +628,15 @@ function PaymentsContent() {
628 description={t("payments.subtitle")}628 description={t("payments.subtitle")}
629 empty={t("form.noStudents")}629 empty={t("form.noStudents")}
630 filters={630 filters={
631- <Select value={planFilter()} onChange={(e) => { setPlanFilter(e.currentTarget.value); setStudentPage(0); }} wrapperClass="w-56">631+ <DropdownSelect
632- <option value="">{t("payments.allPlans")}</option>632+ labelPrefix={t("payments.plan")}
633- <For each={planList()}>{(plan) => <option value={plan.id}>{plan.name}</option>}</For>633+ value={planFilter()}
634- </Select>634+ onChange={(value) => { setPlanFilter(value); setStudentPage(0); }}
635+ options={[{ value: "", label: t("common.all") }, ...planList().map((plan) => ({ value: plan.id, label: plan.name }))]}
636+ />
635 }637 }
638+ filtersActive={planFilter() !== ""}
639+ onClearFilters={() => { setPlanFilter(""); setStudentPage(0); }}
636 tableClass="min-w-160"640 tableClass="min-w-160"
637 storageKey="payment-students"641 storageKey="payment-students"
638 enableSorting642 enableSorting
@@ -655,7 +659,7 @@ function PaymentsContent() {
655 <h2 class="text-lg font-semibold">{personLabel(current())}</h2>659 <h2 class="text-lg font-semibold">{personLabel(current())}</h2>
656 <p class="text-sm text-muted-foreground">@{current().username}</p>660 <p class="text-sm text-muted-foreground">@{current().username}</p>
657 </div>661 </div>
658- <Button variant="outline" size="sm" class="rounded-lg" onClick={() => navigate({ to: "/management/payments" })}>662+ <Button variant="outline" size="sm" class="h-10 rounded-full px-3.5 text-[13px] sm:h-8 touch:h-10" onClick={() => navigate({ to: "/management/payments" })}>
659 <IconChevronLeft class="h-4 w-4" />{t("payments.allStudents")}663 <IconChevronLeft class="h-4 w-4" />{t("payments.allStudents")}
660 </Button>664 </Button>
661 </div>665 </div>
@@ -682,25 +686,33 @@ function PaymentsContent() {
682 </div>686 </div>
683 }687 }
684 >688 >
685- <div class="space-y-3">689+ {/* The status filter is a chip in the table's own toolbar card,
686- <Tabs value={entryTab()} onChange={setEntryTab}>690+ beside "Sütunlar", so both share one row and one height. */}
687- <TabsList>691+ <DataTable
688- <TabsTrigger value="all">{t("payments.entryTabAll")}</TabsTrigger>692+ columns={statementColumns()}
689- <TabsTrigger value="overdue">{t("payments.entryTabOverdue")}</TabsTrigger>693+ data={tabFilteredEntries()}
690- <TabsTrigger value="month">{t("payments.entryTabMonth")}</TabsTrigger>694+ tableClass="min-w-160"
691- <TabsTrigger value="closed">{t("payments.entryTabClosed")}</TabsTrigger>695+ storageKey="payment-statement"
692- </TabsList>696+ filters={
693- </Tabs>697+ <DropdownSelect
694- <DataTable698+ labelPrefix={t("payments.status")}
695- columns={statementColumns()}699+ value={entryTab()}
696- data={tabFilteredEntries()}700+ onChange={setEntryTab}
697- tableClass="min-w-160"701+ options={[
698- storageKey="payment-statement"702+ { value: "all", label: t("payments.entryTabAll") },
699- enablePagination703+ { value: "overdue", label: t("payments.entryTabOverdue") },
700- pageSize={STATEMENT_PAGE_SIZE}704+ { value: "month", label: t("payments.entryTabMonth") },
701- onRowClick={setViewEntry}705+ { value: "closed", label: t("payments.entryTabClosed") },
702- />706+ ]}
703- </div>707+ />
708+ }
709+ filtersActive={entryTab() !== "all"}
710+ pageResetKey={entryTab()}
711+ onClearFilters={() => setEntryTab("all")}
712+ enablePagination
713+ pageSize={STATEMENT_PAGE_SIZE}
714+ onRowClick={setViewEntry}
715+ />
704 </Show>716 </Show>
705 </Suspense>717 </Suspense>
706 </section>718 </section>
@@ -756,7 +768,7 @@ function PaymentsContent() {
756 title={t("payments.tabPlans")}768 title={t("payments.tabPlans")}
757 description={t("payments.subtitle")}769 description={t("payments.subtitle")}
758 actions={770 actions={
759- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCreate}>771+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={openCreate}>
760 <IconPlus class="h-4 w-4" />772 <IconPlus class="h-4 w-4" />
761 {t("payments.createPlan")}773 {t("payments.createPlan")}
762 </Button>774 </Button>
src/pages/profile-page.tsxmodified+4 -3
@@ -202,15 +202,16 @@ function ProfileContent() {
202 </Show>202 </Show>
203 </div>203 </div>
204 </div>204 </div>
205- <div class="mt-3 flex flex-wrap gap-2">205+ {/* Header actions are toolbar pills: h-10 below `sm` and on touch, h-8 above. */}
206+ <div class="mt-3 flex flex-wrap gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10">
206 <Show when={infoSource(p())}>207 <Show when={infoSource(p())}>
207- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setInfoOpen(true)}>208+ <Button type="button" size="sm" variant="outline" onClick={() => setInfoOpen(true)}>
208 <IconUserCircle class="mr-1.5 h-4 w-4" />209 <IconUserCircle class="mr-1.5 h-4 w-4" />
209 {t("profile.studentInfo")}210 {t("profile.studentInfo")}
210 </Button>211 </Button>
211 </Show>212 </Show>
212 <Show when={isSelf(p()) && auth.user()}>213 <Show when={isSelf(p()) && auth.user()}>
213- <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setEditing(true)}>214+ <Button type="button" size="sm" variant="outline" onClick={() => setEditing(true)}>
214 <IconEdit class="mr-1.5 h-4 w-4" />215 <IconEdit class="mr-1.5 h-4 w-4" />
215 {t("profile.edit")}216 {t("profile.edit")}
216 </Button>217 </Button>
src/pages/question-bank-page.test.tsxmodified+11 -10
@@ -3,8 +3,8 @@ import { Show } from "solid-js";
3 import QuestionBankPage from "@/pages/question-bank-page";3 import QuestionBankPage from "@/pages/question-bank-page";
4 import { PreferencesProvider } from "@/stores/preferences-context";4 import { PreferencesProvider } from "@/stores/preferences-context";
5 5
6-// 11 templates, page size 10: the last page holds exactly one row.6+// More templates than one scroll page (50) holds.
7-let templates = Array.from({ length: 11 }, (_, index) => ({7+let templates = Array.from({ length: 60 }, (_, index) => ({
8 id: `bq-${index}`,8 id: `bq-${index}`,
9 text: `Template ${index}`,9 text: `Template ${index}`,
10 kind: "text",10 kind: "text",
@@ -59,23 +59,24 @@ const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
59 59
60 afterEach(() => vi.restoreAllMocks());60 afterEach(() => vi.restoreAllMocks());
61 61
62-test("deleting the last row of the last page clamps back instead of stranding the user", async () => {62+test("fetches one page at a time and starts over from the top after a delete", async () => {
63 render(() => (63 render(() => (
64 <PreferencesProvider>64 <PreferencesProvider>
65 <QuestionBankPage />65 <QuestionBankPage />
66 </PreferencesProvider>66 </PreferencesProvider>
67 ));67 ));
68 68
69- fireEvent.click(await screen.findByRole("button", { name: "Next" }));69+ // Only the first page is fetched until the reader scrolls.
70- expect(await screen.findByText("Template 10")).toBeTruthy();70+ expect(await screen.findByText("Template 49")).toBeTruthy();
71- expect(screen.getByText("2 / 2")).toBeTruthy();71+ expect(screen.queryByText("Template 50")).toBeNull();
72 72
73- fireEvent.click(screen.getByRole("button", { name: "delete-row" }));73+ fireEvent.click(screen.getAllByRole("button", { name: "delete-row" })[0]);
74 fireEvent.click(screen.getByRole("button", { name: "confirm-delete" }));74 fireEvent.click(screen.getByRole("button", { name: "confirm-delete" }));
75 await tick();75 await tick();
76 await tick();76 await tick();
77 77
78- // 10 left → one page: the user must be on it, not on the vanished page 2.78+ // The list reloads from offset 0: the deleted row is gone and the next one
79- expect(screen.queryByText("Template 10")).toBeNull();79+ // moves up into the first page.
80- expect(await screen.findByText("Template 0")).toBeTruthy();80+ expect(screen.queryByText("Template 0")).toBeNull();
81+ expect(await screen.findByText("Template 50")).toBeTruthy();
81 });82 });
src/pages/question-bank-page.tsxmodified+20 -39
@@ -1,7 +1,7 @@
1 import { useNavigate } from "@tanstack/solid-router";1 import { useNavigate } from "@tanstack/solid-router";
2-import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";2+import { Show, createMemo, createSignal } from "solid-js";
3-import { createResponsivePageSize } from "@/lib/create-page-size";
4 import { createResource } from "@/lib/create-resource";3 import { createResource } from "@/lib/create-resource";
4+import { createInfiniteList } from "@/lib/infinite-list";
5 import type { ColumnDef } from "@tanstack/solid-table";5 import type { ColumnDef } from "@tanstack/solid-table";
6 import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions";6 import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions";
7 import { getCourses } from "@/api/courses";7 import { getCourses } from "@/api/courses";
@@ -25,8 +25,6 @@ import { hasMinRole } from "@/lib/roles";
25 import { useAuth } from "@/stores/auth-context";25 import { useAuth } from "@/stores/auth-context";
26 import { useT } from "@/stores/preferences-context";26 import { useT } from "@/stores/preferences-context";
27 27
28-const BANK_PAGE_SIZE = 10;
29-
30 export default function QuestionBankPage() {28 export default function QuestionBankPage() {
31 return (29 return (
32 <RouteGuard minRole="teacher">30 <RouteGuard minRole="teacher">
@@ -43,9 +41,6 @@ function QuestionBankContent() {
43 const ownerFilter = () => (bankTab() === "mine" ? "me" : "all") as "all" | "me";41 const ownerFilter = () => (bankTab() === "mine" ? "me" : "all") as "all" | "me";
44 const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school";42 const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school";
45 const [subjectFilter, setSubjectFilter] = createSignal("all");43 const [subjectFilter, setSubjectFilter] = createSignal("all");
46- const [page, setPage] = createSignal(0);
47- const pageSize = createResponsivePageSize(BANK_PAGE_SIZE);
48- createEffect(on(pageSize, () => setPage(0), { defer: true }));
49 const [query, setQuery, debouncedQuery] = createDebouncedSignal();44 const [query, setQuery, debouncedQuery] = createDebouncedSignal();
50 const [createOpen, setCreateOpen] = createSignal(false);45 const [createOpen, setCreateOpen] = createSignal(false);
51 const [editing, setEditing] = createSignal<BankQuestion | null>(null);46 const [editing, setEditing] = createSignal<BankQuestion | null>(null);
@@ -56,19 +51,18 @@ function QuestionBankContent() {
56 const [flash, setFlash] = createFlash();51 const [flash, setFlash] = createFlash();
57 const [error, setError] = createSignal("");52 const [error, setError] = createSignal("");
58 53
59- const [list, { refetch }] = createResource(54+ // Every filter here is applied by the backend, so the bank loads a page at
55+ // a time as the reader scrolls; a new filter starts again from the top.
56+ const list = createInfiniteList(
60 () => ({57 () => ({
61- page: page(),
62- size: pageSize(),
63 owner: ownerFilter(),58 owner: ownerFilter(),
64 subject: subjectFilter(),59 subject: subjectFilter(),
65 visibility: visibilityFilter(),60 visibility: visibilityFilter(),
66 q: debouncedQuery().trim(),61 q: debouncedQuery().trim(),
67 }),62 }),
68- async (filters) => {63+ async (filters, paging) => {
69 const result = await getBankQuestions({64 const result = await getBankQuestions({
70- limit: filters.size,65+ ...paging,
71- offset: filters.page * filters.size,
72 ...(filters.owner === "me" ? { owner: "me" } : {}),66 ...(filters.owner === "me" ? { owner: "me" } : {}),
73 ...(filters.subject !== "all" ? { subject: filters.subject } : {}),67 ...(filters.subject !== "all" ? { subject: filters.subject } : {}),
74 ...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}),68 ...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}),
@@ -81,15 +75,10 @@ function QuestionBankContent() {
81 });75 });
82 return result;76 return result;
83 },77 },
78+ { equals: (a, b) => JSON.stringify(a) === JSON.stringify(b) },
84 );79 );
85- const total = () => list.latest?.total ?? 0;80+ const total = () => list.total();
86- // Deleting the last row of the last page shrinks the page count under the81+ const refetch = () => list.reload();
87- // current page; the table then hides its pagination bar entirely and the user
88- // is stranded with no control to get back. Same clamp as exam-questions-panel.
89- const pageCount = () => Math.max(1, Math.ceil(total() / pageSize()));
90- createEffect(() => {
91- if (page() >= pageCount()) setPage(pageCount() - 1);
92- });
93 82
94 // Only courses the teacher can author in supply subjects for a new template.83 // Only courses the teacher can author in supply subjects for a new template.
95 const [courses] = createResource(async () => (await getCourses({ limit: 100 })).items);84 const [courses] = createResource(async () => (await getCourses({ limit: 100 })).items);
@@ -220,7 +209,6 @@ function QuestionBankContent() {
220 value={bankTab()}209 value={bankTab()}
221 onChange={(value) => {210 onChange={(value) => {
222 setBankTab(value as "all" | "mine" | "school");211 setBankTab(value as "all" | "mine" | "school");
223- setPage(0);
224 }}212 }}
225 >213 >
226 <TabsList aria-label={t("bank.title")}>214 <TabsList aria-label={t("bank.title")}>
@@ -231,33 +219,29 @@ function QuestionBankContent() {
231 219
232 <TabsContent value={bankTab()} class="mt-4 border-0 bg-transparent p-0 shadow-none">220 <TabsContent value={bankTab()} class="mt-4 border-0 bg-transparent p-0 shadow-none">
233 <section class="space-y-4 p-0">221 <section class="space-y-4 p-0">
234- <Suspense fallback={<DataTableSkeleton columns={5} rows={8} />}>222+ <Show when={list.error()}>
235- <Show when={list.error}>223+ {(err) => <Alert variant="destructive">{formatApiError(err())}</Alert>}
236- <Alert variant="destructive">{formatApiError(list.error)}</Alert>224+ </Show>
237- </Show>225+ <Show when={!list.initialLoading()} fallback={<DataTableSkeleton columns={5} rows={8} />}>
238 <DataTable226 <DataTable
239 title={t("bank.title")}227 title={t("bank.title")}
240 description={t("bank.countTotal", { total: total() })}228 description={t("bank.countTotal", { total: total() })}
241 actions={229 actions={
242 <Show when={manageableCourses().length > 0}>230 <Show when={manageableCourses().length > 0}>
243- <Button type="button" size="sm" class="rounded-lg" onClick={() => setCreateOpen(true)}>231+ <Button type="button" size="sm" onClick={() => setCreateOpen(true)}>
244 <IconPlus class="h-4 w-4" />232 <IconPlus class="h-4 w-4" />
245 {t("bank.create")}233 {t("bank.create")}
246 </Button>234 </Button>
247 </Show>235 </Show>
248 }236 }
249 columns={columns()}237 columns={columns()}
250- data={list()?.items ?? []}238+ data={list.items()}
251 tableClass="min-w-[40rem]"239 tableClass="min-w-[40rem]"
252 filterPlaceholder={t("bank.search")}240 filterPlaceholder={t("bank.search")}
253 filterHint={t("search.hint.bank")}241 filterHint={t("search.hint.bank")}
254 searchValue={query()}242 searchValue={query()}
255- onSearchInput={(value) => {243+ onSearchInput={setQuery}
256- setQuery(value);244+ infinite={{ hasMore: list.hasMore(), loading: list.loading(), total: total(), onLoadMore: list.loadMore }}
257- setPage(0);
258- }}
259- enablePagination
260- manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }}
261 empty={t("bank.empty")}245 empty={t("bank.empty")}
262 storageKey="question-bank"246 storageKey="question-bank"
263 onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })}247 onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })}
@@ -266,16 +250,13 @@ function QuestionBankContent() {
266 <DropdownSelect250 <DropdownSelect
267 labelPrefix={t("subjects.subject")}251 labelPrefix={t("subjects.subject")}
268 value={subjectFilter()}252 value={subjectFilter()}
269- onChange={(value) => {253+ onChange={setSubjectFilter}
270- setSubjectFilter(value);
271- setPage(0);
272- }}
273 options={subjectOptions()}254 options={subjectOptions()}
274 />255 />
275 </div>256 </div>
276 }257 }
277 />258 />
278- </Suspense>259+ </Show>
279 </section>260 </section>
280 </TabsContent>261 </TabsContent>
281 </Tabs>262 </Tabs>
src/pages/question-detail-page.tsxmodified+8 -2
@@ -29,6 +29,12 @@ import { formatBytes, maxUploadBytes } from "@/lib/upload-limits";
29 // Lazy so the drawing pad rides its own chunk, off the question detail's initial load.29 // Lazy so the drawing pad rides its own chunk, off the question detail's initial load.
30 const DrawCanvas = lazy(() => import("@/components/ui/draw-canvas").then((m) => ({ default: m.DrawCanvas })));30 const DrawCanvas = lazy(() => import("@/components/ui/draw-canvas").then((m) => ({ default: m.DrawCanvas })));
31 31
32+// Approve and the actions menu share one row: the toolbar pill, touch-sized
33+// (h-10) below `sm` and on touch screens, h-8 above. The menu trigger is a
34+// <button> too, so one rule sizes both.
35+const HEADER_CONTROLS =
36+ "flex flex-wrap items-center gap-2 [&_button]:h-10 [&_button]:rounded-full [&_button]:px-3.5 [&_button]:text-[13px] sm:[&_button]:h-8 touch:[&_button]:h-10";
37+
32 export default function QuestionDetailPage() {38 export default function QuestionDetailPage() {
33 return (39 return (
34 <RouteGuard minRole="student">40 <RouteGuard minRole="student">
@@ -131,9 +137,9 @@ function QuestionDetailContent() {
131 <span>{new Date(q().asked_at).toLocaleString()}</span>137 <span>{new Date(q().asked_at).toLocaleString()}</span>
132 </div>138 </div>
133 </div>139 </div>
134- <div class="flex flex-wrap items-center gap-2">140+ <div class={HEADER_CONTROLS}>
135 <Show when={q().status === "pending" && isModerator()}>141 <Show when={q().status === "pending" && isModerator()}>
136- <Button onClick={handleApprove}>142+ <Button size="sm" onClick={handleApprove}>
137 <IconCheck class="mr-2 h-4 w-4" />143 <IconCheck class="mr-2 h-4 w-4" />
138 {t("common.approve")}144 {t("common.approve")}
139 </Button>145 </Button>
src/pages/questions-page.tsxmodified+24 -9
@@ -1,5 +1,7 @@
1 import { For, Show, Suspense, createEffect, createSignal, lazy } from "solid-js";1 import { For, Show, Suspense, createEffect, createSignal, lazy } from "solid-js";
2 import { createResource } from "@/lib/create-resource";2 import { createResource } from "@/lib/create-resource";
3+import { createInfiniteList } from "@/lib/infinite-list";
4+import { InfiniteSentinel } from "@/components/ui/infinite-sentinel";
3 import { Link, useLocation, useNavigate, useSearch } from "@tanstack/solid-router";5 import { Link, useLocation, useNavigate, useSearch } from "@tanstack/solid-router";
4 import { getQuestions, postQuestion, deleteQuestionById } from "@/api/shared";6 import { getQuestions, postQuestion, deleteQuestionById } from "@/api/shared";
5 import { getSettings } from "@/api/settings";7 import { getSettings } from "@/api/settings";
@@ -45,10 +47,14 @@ function QuestionsContent() {
45 47
46 const statusFilter = () => ((searchParams() as any).status === "pending" ? "pending" : "approved");48 const statusFilter = () => ((searchParams() as any).status === "pending" ? "pending" : "approved");
47 49
48- const [list, { refetch }] = createResource(50+ // The status is the only filter and the backend applies it, so the pool
49- () => ({ status: statusFilter(), limit: 50, offset: 0 }),51+ // loads a page at a time as the reader scrolls (it used to stop at 50).
50- async (params) => (await getQuestions(params.status as "pending" | "approved", params)).items52+ const questions = createInfiniteList(
53+ () => statusFilter(),
54+ (status, paging) => getQuestions(status, paging),
51 );55 );
56+ const list = () => questions.items();
57+ const refetch = () => questions.reload();
52 58
53 const [askOpen, setAskOpen] = createSignal(location().searchStr.includes("action=new"));59 const [askOpen, setAskOpen] = createSignal(location().searchStr.includes("action=new"));
54 const [questionToDelete, setQuestionToDelete] = createSignal<any | null>(null);60 const [questionToDelete, setQuestionToDelete] = createSignal<any | null>(null);
@@ -100,7 +106,7 @@ function QuestionsContent() {
100 description={t("pool.subtitle")}106 description={t("pool.subtitle")}
101 actions={107 actions={
102 <Show when={auth.user()?.role === "student"}>108 <Show when={auth.user()?.role === "student"}>
103- <Button type="button" size="sm" class="rounded-lg" onClick={() => setAskOpen(true)}>109+ <Button type="button" size="sm" onClick={() => setAskOpen(true)}>
104 <IconPlus class="h-4 w-4" />110 <IconPlus class="h-4 w-4" />
105 {t("pool.ask")}111 {t("pool.ask")}
106 </Button>112 </Button>
@@ -108,9 +114,11 @@ function QuestionsContent() {
108 }114 }
109 >115 >
110 <div class="-mx-4 -mb-4 border-t border-border-hairline">116 <div class="-mx-4 -mb-4 border-t border-border-hairline">
111- <Suspense fallback={<PageSpinner />}>117+ <Show when={questions.error()}>
112- <Show when={list()}>118+ {(err) => <p class="p-4 text-sm text-destructive-text">{formatApiError(err())}</p>}
113- <Show when={list()!.length > 0} fallback={<EmptyState kind="search" title={t("pool.noQuestions")} />}>119+ </Show>
120+ <Show when={!questions.initialLoading()} fallback={<PageSpinner />}>
121+ <Show when={list().length > 0} fallback={<EmptyState kind="search" title={t("pool.noQuestions")} />}>
114 <div class="divide-y divide-border">122 <div class="divide-y divide-border">
115 <For each={list()}>123 <For each={list()}>
116 {(question) => (124 {(question) => (
@@ -164,9 +172,16 @@ function QuestionsContent() {
164 )}172 )}
165 </For>173 </For>
166 </div>174 </div>
175+ <InfiniteSentinel
176+ class="px-4 py-3"
177+ hasMore={questions.hasMore()}
178+ loading={questions.loading()}
179+ onLoadMore={questions.loadMore}
180+ shown={list().length}
181+ total={questions.total()}
182+ />
167 </Show>183 </Show>
168- </Show>184+ </Show>
169- </Suspense>
170 </div>185 </div>
171 </DataSection>186 </DataSection>
172 187
src/pages/students-roster-page.tsxmodified+1 -1
@@ -139,7 +139,7 @@ function StudentsRosterContent() {
139 title={t("nav.studentsRoster")}139 title={t("nav.studentsRoster")}
140 description={t("roster.studentsSubtitle")}140 description={t("roster.studentsSubtitle")}
141 actions={<><Show when={auth.user()?.role === "admin"}>141 actions={<><Show when={auth.user()?.role === "admin"}>
142- <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}>142+ <Button size="sm" class="min-w-[7.5rem]" onClick={() => setCreating(true)}>
143 <IconPlus class="h-4 w-4" />143 <IconPlus class="h-4 w-4" />
144 {t("roster.addStudent")}144 {t("roster.addStudent")}
145 </Button>145 </Button>
src/pages/teachers-roster-page.tsxmodified+1 -1
@@ -130,7 +130,7 @@ function TeachersRosterContent() {
130 title={t("nav.teachersRoster")}130 title={t("nav.teachersRoster")}
131 description={t("roster.teachersSubtitle")}131 description={t("roster.teachersSubtitle")}
132 actions={<><Show when={auth.user()?.role === "admin"}>132 actions={<><Show when={auth.user()?.role === "admin"}>
133- <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}>133+ <Button size="sm" class="min-w-[7.5rem]" onClick={() => setCreating(true)}>
134 <IconPlus class="h-4 w-4" />134 <IconPlus class="h-4 w-4" />
135 {t("roster.addTeacher")}135 {t("roster.addTeacher")}
136 </Button>136 </Button>
src/pages/terms-page.tsxmodified+1 -1
@@ -260,7 +260,7 @@ function TermsContent() {
260 title={t("terms.title")}260 title={t("terms.title")}
261 description={t("terms.subtitle")}261 description={t("terms.subtitle")}
262 actions={262 actions={
263- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCreate}>263+ <Button type="button" size="sm" class="min-w-[7.5rem]" onClick={openCreate}>
264 <IconPlus class="h-4 w-4" />264 <IconPlus class="h-4 w-4" />
265 {t("terms.create")}265 {t("terms.create")}
266 </Button>266 </Button>
src/pages/whiteboards-page.tsxmodified+27 -46
@@ -1,13 +1,12 @@
1 import { useNavigate } from "@tanstack/solid-router";1 import { useNavigate } from "@tanstack/solid-router";
2-import { For, Show, Suspense, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js";2+import { For, Show, createEffect, createMemo, createSignal, onCleanup } from "solid-js";
3-import { createResponsivePageSize } from "@/lib/create-page-size";
4 import { createDebouncedSignal } from "@/lib/create-debounced-signal";3 import { createDebouncedSignal } from "@/lib/create-debounced-signal";
5-import { createResource } from "@/lib/create-resource";4+import { createInfiniteList } from "@/lib/infinite-list";
6 import { getBoards, postBoard, type Board } from "@/api/boards";5 import { getBoards, postBoard, type Board } from "@/api/boards";
7 import { getUserSearch } from "@/api/users";6 import { getUserSearch } from "@/api/users";
8 import { formatApiError, type PersonRef } from "@/api/client";7 import { formatApiError, type PersonRef } from "@/api/client";
9 import { RouteGuard } from "@/components/layout/route-guard";8 import { RouteGuard } from "@/components/layout/route-guard";
10-import { DataToolbar } from "@/components/ui/data-toolbar";9+import { DataToolbar, TOOLBAR_CARD } from "@/components/ui/data-toolbar";
11 import { Badge } from "@/components/ui/badge";10 import { Badge } from "@/components/ui/badge";
12 import { Button } from "@/components/ui/button";11 import { Button } from "@/components/ui/button";
13 import { EmptyState } from "@/components/ui/empty-state";12 import { EmptyState } from "@/components/ui/empty-state";
@@ -17,7 +16,7 @@ import { Input } from "@/components/ui/input";
17 import { Label } from "@/components/ui/label";16 import { Label } from "@/components/ui/label";
18 import { PageSpinner } from "@/components/ui/page-spinner";17 import { PageSpinner } from "@/components/ui/page-spinner";
19 import { SidePanel } from "@/components/ui/side-panel";18 import { SidePanel } from "@/components/ui/side-panel";
20-import { TablePagination } from "@/components/ui/table-pagination";19+import { InfiniteSentinel } from "@/components/ui/infinite-sentinel";
21 import { cn } from "@/lib/cn";20 import { cn } from "@/lib/cn";
22 import { formatDate } from "@/lib/format";21 import { formatDate } from "@/lib/format";
23 import { personLabel } from "@/lib/person";22 import { personLabel } from "@/lib/person";
@@ -39,57 +38,41 @@ function WhiteboardsContent() {
39 const auth = useAuth();38 const auth = useAuth();
40 const navigate = useNavigate();39 const navigate = useNavigate();
41 40
42- const pageSize = createResponsivePageSize(12);
43- const [page, setPage] = createSignal(0);
44- createEffect(on(pageSize, () => setPage(0), { defer: true }));
45 const [query, setQuery, debouncedQuery] = createDebouncedSignal();41 const [query, setQuery, debouncedQuery] = createDebouncedSignal();
46- const [boards, { refetch }] = createResource(42+ // The server narrows by title via `q`, so boards load a page at a time as
47- () => ({ page: page(), size: pageSize(), q: debouncedQuery().trim() }),43+ // the reader scrolls; a new search starts again from the first board.
48- (source) =>44+ const boards = createInfiniteList(
49- getBoards({45+ () => debouncedQuery().trim(),
50- limit: source.size,46+ (q, paging) => getBoards({ ...paging, ...(q ? { q } : {}) }),
51- offset: source.page * source.size,
52- ...(source.q ? { q: source.q } : {}),
53- }),
54 );47 );
55 const [createOpen, setCreateOpen] = createSignal(false);48 const [createOpen, setCreateOpen] = createSignal(false);
56- const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / pageSize())));49+ const visibleBoards = () => boards.items();
57- createEffect(() => {
58- if (boards.latest && page() >= pageCount()) setPage(pageCount() - 1);
59- });
60- // The server narrows by title via `q`; the page holds whatever the current
61- // query matched, so totals and pagination already reflect the search.
62- const visibleBoards = createMemo(() => boards()?.items ?? []);
63 50
64 const meId = () => auth.user()?.id ?? "";51 const meId = () => auth.user()?.id ?? "";
65 52
66 return (53 return (
67 <div class="space-y-5">54 <div class="space-y-5">
68 <div class="space-y-4">55 <div class="space-y-4">
69- <div class="rounded-xl border border-border-line bg-surface-base p-3 shadow-xs" aria-label={t("common.search")}>56+ <div class={TOOLBAR_CARD} aria-label={t("common.search")}>
70 <DataToolbar57 <DataToolbar
71 searchValue={query()}58 searchValue={query()}
72 searchPlaceholder={t("whiteboard.searchPlaceholder")}59 searchPlaceholder={t("whiteboard.searchPlaceholder")}
73 searchHint={t("search.hint.whiteboards")}60 searchHint={t("search.hint.whiteboards")}
74- onSearchInput={(value) => {61+ onSearchInput={setQuery}
75- setQuery(value);
76- // The server filters from the first row; offset restarts with each search.
77- setPage(0);
78- }}
79 actions={62 actions={
80- <Button type="button" size="sm" class="rounded-lg" onClick={() => setCreateOpen(true)}>63+ <Button type="button" size="sm" onClick={() => setCreateOpen(true)}>
81 <IconPlus class="h-4 w-4" />64 <IconPlus class="h-4 w-4" />
82 {t("whiteboard.create")}65 {t("whiteboard.create")}
83 </Button>66 </Button>
84 }67 }
85 />68 />
86 </div>69 </div>
87- <Suspense fallback={<PageSpinner />}>70+ <Show when={boards.error()}>
88- <Show when={boards.error}>71+ {(err) => <ErrorAlert message={formatApiError(err(), locale())} />}
89- <ErrorAlert message={formatApiError(boards.error, locale())} />72+ </Show>
90- </Show>73+ <Show when={!boards.initialLoading()} fallback={<PageSpinner />}>
91 <Show74 <Show
92- when={query().trim() || (boards()?.items ?? []).length > 0}75+ when={query().trim() || visibleBoards().length > 0}
93 fallback={<EmptyState kind="whiteboard" title={t("whiteboard.empty")} description={t("whiteboard.subtitle")} />}76 fallback={<EmptyState kind="whiteboard" title={t("whiteboard.empty")} description={t("whiteboard.subtitle")} />}
94 >77 >
95 <div class="space-y-3">78 <div class="space-y-3">
@@ -107,18 +90,16 @@ function WhiteboardsContent() {
107 </For>90 </For>
108 </div>91 </div>
109 </Show>92 </Show>
110- <Show when={(boards()?.total ?? 0) > pageSize()}>93+ <InfiniteSentinel
111- <TablePagination94+ hasMore={boards.hasMore()}
112- pageIndex={page()}95+ loading={boards.loading()}
113- pageCount={pageCount()}96+ onLoadMore={boards.loadMore}
114- pageSize={pageSize()}97+ shown={visibleBoards().length}
115- total={boards()?.total ?? 0}98+ total={boards.total()}
116- onPageChange={setPage}99+ />
117- />
118- </Show>
119 </div>100 </div>
120 </Show>101 </Show>
121- </Suspense>102+ </Show>
122 </div>103 </div>
123 104
124 <CreateBoardPanel105 <CreateBoardPanel
@@ -126,7 +107,7 @@ function WhiteboardsContent() {
126 onOpenChange={setCreateOpen}107 onOpenChange={setCreateOpen}
127 onCreated={(board) => {108 onCreated={(board) => {
128 setCreateOpen(false);109 setCreateOpen(false);
129- void refetch();110+ boards.reload();
130 navigate({ to: "/whiteboards/$id", params: { id: board.id } });111 navigate({ to: "/whiteboards/$id", params: { id: board.id } });
131 }}112 }}
132 />113 />
src/pages/work-log-page.tsxmodified+1 -1
@@ -106,7 +106,7 @@ function WorkLogContent() {
106 title={openEntry() ? t("work.checkedIn") : t("work.notCheckedIn")}106 title={openEntry() ? t("work.checkedIn") : t("work.notCheckedIn")}
107 description={openEntry() ? t("work.since", { time: formatDateTime(openEntry()!.check_in, locale()) }) : t("work.subtitle")}107 description={openEntry() ? t("work.since", { time: formatDateTime(openEntry()!.check_in, locale()) }) : t("work.subtitle")}
108 actions={108 actions={
109- <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" variant={openEntry() ? "destructive" : "default"} disabled={pending()} onClick={() => void toggle()}>109+ <Button type="button" size="sm" class="min-w-[7.5rem]" variant={openEntry() ? "destructive" : "default"} disabled={pending()} onClick={() => void toggle()}>
110 {openEntry() ? t("work.finish") : t("work.start")}110 {openEntry() ? t("work.finish") : t("work.start")}
111 </Button>111 </Button>
112 }112 }