forge
Explore
Log in

Don't you dare go Hollow

📊 align table headers with cells, fix page-size + inline averages

Browse files at this commit

72a2390dc677cf4607d9b81a746cf7a8894e4965Burak BoduroğluParent: 23adf31
  • fix
    • 📊 align table headers with cells, fix page-size + inline averages
Show full message
fix: 📊 align table headers with cells, fix page-size + inline averages
- drop text-align from `.data-table th`: the `.data-table th` rule
  out-specified per-column text-right/center utilities and forced every
  header left while cells aligned fine (header/cell mismatch)
- add `meta.align` to DataTable as the single source of alignment for both
  head and cell; sort button offsets by align instead of a blanket -ml-3
- migrate numeric columns (marks/attendance/homework reports, my-students,
  student-marks) off ad-hoc header spans to meta.align
- add opt-in `meta.stickyLeft` frozen-left column + `meta.divider` and a
  directional border/shadow seam; rename sticky-right
  classes; clearer sort icons (ChevronsUpDown → ArrowUp/ArrowDown)
- TablePagination: always include the active page size in the options so
  the selector shows a value instead of blank on non-standard sizes
- standardize the generic 12-row list default to 10 across pages
- student-marks: re-materialize table data when the per-student marks
  resource resolves so the inline average fills in without needing a sort
src/components/attendance/attendance-report-view.tsxmodified+7 -6
@@ -33,16 +33,17 @@ export function AttendanceReportView(props: { report: AttendanceReport; compact?
33 {33 {
34 id: "course",34 id: "course",
35 header: t("nav.courses"),35 header: t("nav.courses"),
36+ meta: { stickyLeft: true },
36 cell: (cell) => (37 cell: (cell) => (
37 <Link to="/courses/$id" params={{ id: cell.row.original.course.id }} class="block truncate font-medium hover:text-primary hover:underline">38 <Link to="/courses/$id" params={{ id: cell.row.original.course.id }} class="block truncate font-medium hover:text-primary hover:underline">
38 {cell.row.original.course.title}39 {cell.row.original.course.title}
39 </Link>40 </Link>
40 ),41 ),
41 },42 },
42- ...ATTENDANCE_STATUSES.map((status) => ({43+ ...ATTENDANCE_STATUSES.map((status, index) => ({
43 id: status.value,44 id: status.value,
44 header: () => <span title={t(status.detailKey)}>{compact() ? t(status.key).slice(0, 1) : t(status.key)}</span>,45 header: () => <span title={t(status.detailKey)}>{compact() ? t(status.key).slice(0, 1) : t(status.key)}</span>,
45- meta: { headerClass: "text-right", cellClass: "text-right" },46+ meta: { align: "right" as const, divider: index === 0 ? ("left" as const) : undefined },
46 cell: (cell) => (47 cell: (cell) => (
47 <span class={cn("mono inline-flex min-w-7 justify-center rounded-md border px-1.5 py-0.5 text-[11px] font-semibold tabular-nums", status.class)}>48 <span class={cn("mono inline-flex min-w-7 justify-center rounded-md border px-1.5 py-0.5 text-[11px] font-semibold tabular-nums", status.class)}>
48 {cell.row.original.counts[status.value]}49 {cell.row.original.counts[status.value]}
@@ -51,14 +52,14 @@ export function AttendanceReportView(props: { report: AttendanceReport; compact?
51 } satisfies ColumnDef<CourseAttendanceRow>)),52 } satisfies ColumnDef<CourseAttendanceRow>)),
52 {53 {
53 id: "total",54 id: "total",
54- header: () => <span class="block text-right">{compact() ? "Σ" : t("common.all")}</span>,55+ header: () => <span>{compact() ? "Σ" : t("common.all")}</span>,
55- meta: { cellClass: "mono text-right" },56+ meta: { align: "right", cellClass: "mono" },
56 cell: (cell) => cell.row.original.counts.total,57 cell: (cell) => cell.row.original.counts.total,
57 },58 },
58 {59 {
59 id: "rate",60 id: "rate",
60- header: () => <span class="block text-right">%</span>,61+ header: () => <span>%</span>,
61- meta: { cellClass: "mono text-right font-semibold" },62+ meta: { align: "right", cellClass: "mono font-semibold" },
62 cell: (cell) => percent(cell.row.original.counts.rate),63 cell: (cell) => percent(cell.row.original.counts.rate),
63 },64 },
64 ]);65 ]);
src/components/homework/homework-report-view.tsxmodified+1 -1
@@ -56,7 +56,7 @@ export function HomeworkReportView(props: { userId: string }) {
56 {56 {
57 id: "mark",57 id: "mark",
58 header: t("form.mark"),58 header: t("form.mark"),
59- meta: { cellClass: "text-right font-medium tabular-nums" },59+ meta: { align: "right", cellClass: "font-medium tabular-nums" },
60 cell: (cell) => cell.row.original.result?.mark ?? "—",60 cell: (cell) => cell.row.original.result?.mark ?? "—",
61 },61 },
62 {62 {
src/components/marks/marks-report-view.tsxmodified+5 -4
@@ -33,6 +33,7 @@ export function MarksReportView(props: { report: MarksReport; compact?: boolean
33 {33 {
34 accessorKey: "title",34 accessorKey: "title",
35 header: t("marks.exam"),35 header: t("marks.exam"),
36+ meta: { stickyLeft: true },
36 cell: (cell) => (37 cell: (cell) => (
37 <span class="min-w-0">38 <span class="min-w-0">
38 <ExamLink examId={cell.row.original.exam} class="block truncate font-medium hover:underline">39 <ExamLink examId={cell.row.original.exam} class="block truncate font-medium hover:underline">
@@ -54,14 +55,14 @@ export function MarksReportView(props: { report: MarksReport; compact?: boolean
54 },55 },
55 {56 {
56 id: "weight",57 id: "weight",
57- header: () => <span class="block text-right">{t("marks.weight")}</span>,58+ header: t("marks.weight"),
58- meta: { cellClass: "mono text-right" },59+ meta: { align: "right", divider: "left", cellClass: "mono" },
59 cell: (cell) => examWeight(cell.row.original, settings()?.exam_kinds) ?? "—",60 cell: (cell) => examWeight(cell.row.original, settings()?.exam_kinds) ?? "—",
60 },61 },
61 {62 {
62 accessorKey: "mark",63 accessorKey: "mark",
63- header: () => <span class="block text-right">{t("marks.mark")}</span>,64+ header: t("marks.mark"),
64- meta: { cellClass: "mono text-right font-semibold" },65+ meta: { align: "right", cellClass: "mono font-semibold" },
65 cell: (cell) => markWithGrade(cell.row.original.mark, cell.row.original.grade),66 cell: (cell) => markWithGrade(cell.row.original.mark, cell.row.original.grade),
66 },67 },
67 ]);68 ]);
src/components/ui/data-table.test.tsxmodified+25 -2
@@ -40,10 +40,33 @@ test("keeps only the rightmost action column sticky", () => {
40 ));40 ));
41 41
42 const actionsHeader = screen.getByRole("columnheader", { name: "Actions" });42 const actionsHeader = screen.getByRole("columnheader", { name: "Actions" });
43- expect(actionsHeader.classList).toContain("table-sticky-head");43+ expect(actionsHeader.classList).toContain("table-sticky-head-right");
44 expect(actionsHeader.classList).toContain("z-30");44 expect(actionsHeader.classList).toContain("z-30");
45 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));45 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));
46- expect(roleHeader?.classList).not.toContain("table-sticky-head");46+ expect(roleHeader?.classList).not.toContain("table-sticky-head-right");
47+});
48+
49+test("freezes the meta.stickyLeft column and aligns head + cell together", () => {
50+ const alignedColumns: ColumnDef<Row>[] = [
51+ { accessorKey: "name", header: "Name", meta: { stickyLeft: true } },
52+ { accessorKey: "role", header: "Role", meta: { align: "right" } },
53+ ];
54+ render(() => (
55+ <PreferencesProvider>
56+ <DataTable columns={alignedColumns} data={[{ name: "Ada", role: "Admin" }]} enableColumnVisibility={false} enableSorting={false} />
57+ </PreferencesProvider>
58+ ));
59+
60+ const headers = screen.getAllByRole("columnheader");
61+ const nameHeader = headers.find((header) => header.textContent?.startsWith("Name"));
62+ expect(nameHeader?.classList).toContain("table-sticky-head-left");
63+ expect(nameHeader?.classList).toContain("left-0");
64+
65+ const roleHeader = headers.find((header) => header.textContent?.startsWith("Role"));
66+ const roleCell = screen.getByRole("cell", { name: "Admin" });
67+ // Same alignment class on head and cell so columns never drift apart.
68+ expect(roleHeader?.classList).toContain("text-right");
69+ expect(roleCell.classList).toContain("text-right");
47 });70 });
48 71
49 test("paginates tables by default", () => {72 test("paginates tables by default", () => {
src/components/ui/data-table.tsxmodified+57 -14
@@ -19,7 +19,7 @@ import { Button } from "@/components/ui/button";
19 import { DataTableSearch } from "@/components/ui/data-table-search";19 import { DataTableSearch } from "@/components/ui/data-table-search";
20 import { DataTableViewMenu, type ViewMenuColumn } from "@/components/ui/data-table-view-menu";20 import { DataTableViewMenu, type ViewMenuColumn } from "@/components/ui/data-table-view-menu";
21 import { TablePagination } from "@/components/ui/table-pagination";21 import { TablePagination } from "@/components/ui/table-pagination";
22-import { IconChevronDown } from "@/components/ui/icons";22+import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/icons";
23 import { cn } from "@/lib/cn";23 import { cn } from "@/lib/cn";
24 import { createTablePreferences } from "@/lib/table-preferences";24 import { createTablePreferences } from "@/lib/table-preferences";
25 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";25 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
@@ -30,6 +30,12 @@ declare module "@tanstack/solid-table" {
30 headerClass?: string;30 headerClass?: string;
31 cellClass?: string;31 cellClass?: string;
32 label?: string;32 label?: string;
33+ /** Header + cell horizontal alignment. Applied to both so they never drift apart. */
34+ align?: "left" | "center" | "right";
35+ /** Freeze this column to the left edge on horizontal scroll (fintables-style). */
36+ stickyLeft?: boolean;
37+ /** Vertical divider on the given edge — separates frozen label from metric columns. */
38+ divider?: "left" | "right";
33 }39 }
34 }40 }
35 41
@@ -70,6 +76,8 @@ export type DataTableProps<TData, TValue = unknown> = {
70 const resolveUpdater = <T,>(updater: Updater<T>, old: T): T =>76 const resolveUpdater = <T,>(updater: Updater<T>, old: T): T =>
71 typeof updater === "function" ? (updater as (value: T) => T)(old) : updater;77 typeof updater === "function" ? (updater as (value: T) => T)(old) : updater;
72 78
79+const alignClass = { left: "text-left", center: "text-center", right: "text-right" } as const;
80+
73 export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, TValue>) {81 export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, TValue>) {
74 const t = useT();82 const t = useT();
75 const paginationEnabled = props.enablePagination ?? true;83 const paginationEnabled = props.enablePagination ?? true;
@@ -129,11 +137,27 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
129 },137 },
130 });138 });
131 const hiddenLocked = (columnId: string) => columnId === "actions" || columnId === "update";139 const hiddenLocked = (columnId: string) => columnId === "actions" || columnId === "update";
132- const stickyLocked = (columnId: string) =>140+ const stickyRightLocked = (columnId: string) =>
133 columnId === "actions" || (columnId === "update" && table.getColumn("actions") == null);141 columnId === "actions" || (columnId === "update" && table.getColumn("actions") == null);
134- const actionColumnClass = (columnId: string) => stickyLocked(columnId) ? "w-28 min-w-28 px-2 text-center whitespace-nowrap" : undefined;142+ const isStickyLeft = (column: Column<TData, unknown>) => column.columnDef.meta?.stickyLeft === true;
135- const stickyHeadClass = (columnId: string) => stickyLocked(columnId) ? "table-sticky-head sticky right-0 z-30" : undefined;143+ const alignOf = (column: Column<TData, unknown>) => column.columnDef.meta?.align ?? "left";
136- const stickyCellClass = (columnId: string) => stickyLocked(columnId) ? "table-sticky-cell sticky right-0 z-10" : undefined;144+ const dividerClass = (column: Column<TData, unknown>) => {
145+ const divider = column.columnDef.meta?.divider;
146+ return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined;
147+ };
148+ const actionColumnClass = (columnId: string) => stickyRightLocked(columnId) ? "w-28 min-w-28 px-2 text-center whitespace-nowrap" : undefined;
149+ const stickyHeadClass = (column: Column<TData, unknown>) =>
150+ isStickyLeft(column)
151+ ? "table-sticky-head-left sticky left-0 z-30"
152+ : stickyRightLocked(column.id)
153+ ? "table-sticky-head-right sticky right-0 z-30"
154+ : undefined;
155+ const stickyCellClass = (column: Column<TData, unknown>) =>
156+ isStickyLeft(column)
157+ ? "table-sticky-left sticky left-0 z-10"
158+ : stickyRightLocked(column.id)
159+ ? "table-sticky-right sticky right-0 z-10"
160+ : undefined;
137 const hideableColumns = () => table.getAllColumns().filter((column) => column.getCanHide() && !hiddenLocked(column.id));161 const hideableColumns = () => table.getAllColumns().filter((column) => column.getCanHide() && !hiddenLocked(column.id));
138 const columnLabel = (column: Column<TData, unknown>) => {162 const columnLabel = (column: Column<TData, unknown>) => {
139 const header = column.columnDef.header;163 const header = column.columnDef.header;
@@ -149,7 +173,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
149 const colSpan = () => Math.max(1, table.getVisibleLeafColumns().length);173 const colSpan = () => Math.max(1, table.getVisibleLeafColumns().length);
150 const tableWidth = () =>174 const tableWidth = () =>
151 table.getVisibleLeafColumns().reduce(175 table.getVisibleLeafColumns().reduce(
152- (total, column) => total + (stickyLocked(column.id) ? 112 : column.getSize()),176+ (total, column) => total + (stickyRightLocked(column.id) ? 112 : column.getSize()),
153 0,177 0,
154 );178 );
155 const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0;179 const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0;
@@ -182,18 +206,33 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
182 };206 };
183 const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => {207 const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => {
184 const content = flexRender(header.column.columnDef.header, header.getContext());208 const content = flexRender(header.column.columnDef.header, header.getContext());
185- if (!(props.enableSorting ?? true) || !header.column.getCanSort()) return content;209+ const align = alignOf(header.column);
210+ if (!(props.enableSorting ?? true) || !header.column.getCanSort()) {
211+ // The th already carries alignClass; the block span makes text-align resolve.
212+ return <span class="block truncate">{content}</span>;
213+ }
186 const sorted = () => header.column.getIsSorted();214 const sorted = () => header.column.getIsSorted();
187 return (215 return (
188 <Button216 <Button
189 type="button"217 type="button"
190 variant="ghost"218 variant="ghost"
191 size="sm"219 size="sm"
192- class={cn("-ml-3 h-8 px-2 uppercase", sorted() && "text-foreground")}220+ // th text-align positions this inline-flex button; -ml-3 only trims the left gutter.
221+ class={cn("h-8 px-2 uppercase", align === "left" && "-ml-3", sorted() && "text-foreground")}
193 onClick={() => header.column.toggleSorting(sorted() === "asc")}222 onClick={() => header.column.toggleSorting(sorted() === "asc")}
194 >223 >
195 {content}224 {content}
196- <IconChevronDown class={cn("h-3.5 w-3.5 opacity-50", sorted() === "asc" && "rotate-180", sorted() && "opacity-100")} />225+ <Show
226+ when={sorted() !== false}
227+ fallback={<IconChevronsUpDown class="h-3.5 w-3.5 opacity-50" />}
228+ >
229+ <Show
230+ when={sorted() === "asc"}
231+ fallback={<IconArrowDown class="h-3.5 w-3.5" />}
232+ >
233+ <IconArrowUp class="h-3.5 w-3.5" />
234+ </Show>
235+ </Show>
197 </Button>236 </Button>
198 );237 );
199 };238 };
@@ -257,14 +296,16 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
257 colSpan={header.colSpan}296 colSpan={header.colSpan}
258 class={cn(297 class={cn(
259 "group/head relative",298 "group/head relative",
299+ alignClass[alignOf(header.column)],
300+ dividerClass(header.column),
260 actionColumnClass(header.column.id),301 actionColumnClass(header.column.id),
261- stickyHeadClass(header.column.id),302+ stickyHeadClass(header.column),
262 header.column.columnDef.meta?.headerClass,303 header.column.columnDef.meta?.headerClass,
263 )}304 )}
264- style={{ width: `${stickyLocked(header.column.id) ? 112 : header.getSize()}px` }}305+ style={{ width: `${stickyRightLocked(header.column.id) ? 112 : header.getSize()}px` }}
265 >306 >
266 <Show when={!header.isPlaceholder}>{renderHeader(header)}</Show>307 <Show when={!header.isPlaceholder}>{renderHeader(header)}</Show>
267- <Show when={header.column.getCanResize() && !stickyLocked(header.column.id)}>308+ <Show when={header.column.getCanResize() && !stickyRightLocked(header.column.id)}>
268 <div309 <div
269 role="separator"310 role="separator"
270 aria-orientation="vertical"311 aria-orientation="vertical"
@@ -333,11 +374,13 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
333 {(cell) => (374 {(cell) => (
334 <TableCell375 <TableCell
335 class={cn(376 class={cn(
377+ alignClass[alignOf(cell.column)],
378+ dividerClass(cell.column),
336 actionColumnClass(cell.column.id),379 actionColumnClass(cell.column.id),
337- stickyCellClass(cell.column.id),380+ stickyCellClass(cell.column),
338 cell.column.columnDef.meta?.cellClass,381 cell.column.columnDef.meta?.cellClass,
339 )}382 )}
340- style={{ width: `${stickyLocked(cell.column.id) ? 112 : cell.column.getSize()}px` }}383+ style={{ width: `${stickyRightLocked(cell.column.id) ? 112 : cell.column.getSize()}px` }}
341 >384 >
342 {flexRender(cell.column.columnDef.cell, cell.getContext())}385 {flexRender(cell.column.columnDef.cell, cell.getContext())}
343 </TableCell>386 </TableCell>
src/components/ui/icons.tsxmodified+27 -0
@@ -345,6 +345,33 @@ export function IconChevronDown(props: IconProps) {
345 );345 );
346 }346 }
347 347
348+export function IconArrowUp(props: IconProps) {
349+ return (
350+ <Svg {...props}>
351+ <path d="M12 19V5" />
352+ <path d="m5 12 7-7 7 7" />
353+ </Svg>
354+ );
355+}
356+
357+export function IconArrowDown(props: IconProps) {
358+ return (
359+ <Svg {...props}>
360+ <path d="M12 5v14" />
361+ <path d="m19 12-7 7-7-7" />
362+ </Svg>
363+ );
364+}
365+
366+export function IconChevronsUpDown(props: IconProps) {
367+ return (
368+ <Svg {...props}>
369+ <path d="m7 15 5 5 5-5" />
370+ <path d="m7 9 5-5 5 5" />
371+ </Svg>
372+ );
373+}
374+
348 export function IconHome(props: IconProps) {375 export function IconHome(props: IconProps) {
349 return (376 return (
350 <Svg {...props}>377 <Svg {...props}>
src/components/ui/table-pagination.tsxmodified+6 -1
@@ -18,7 +18,12 @@ export type TablePaginationProps = {
18 /** Footer: "X kayıttan a-b arası" + page-size select + prev/next + "page / total". */18 /** Footer: "X kayıttan a-b arası" + page-size select + prev/next + "page / total". */
19 export function TablePagination(props: TablePaginationProps) {19 export function TablePagination(props: TablePaginationProps) {
20 const t = useT();20 const t = useT();
21- const options = () => props.pageSizeOptions ?? [10, 25, 50];21+ // Always include the active page size so the select shows a selected value
22+ // instead of rendering blank when a page passes a non-standard size (e.g. 12).
23+ const options = () => {
24+ const base = props.pageSizeOptions ?? [10, 25, 50];
25+ return base.includes(props.pageSize) ? base : [...base, props.pageSize].sort((a, b) => a - b);
26+ };
22 const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1);27 const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1);
23 const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total);28 const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total);
24 29
src/index.cssmodified+27 -6
@@ -141,7 +141,10 @@
141 }141 }
142 142
143 & th {143 & th {
144- @apply h-11 overflow-hidden text-ellipsis whitespace-nowrap px-3 text-left text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground first:pl-4 last:pr-4;144+ /* No text-align here: `.data-table th` would out-specify the per-column
145+ * text-right/center utility on TableHead and force every header left. The
146+ * TableHead base class provides the left default; alignment stays utility-driven. */
147+ @apply h-11 overflow-hidden text-ellipsis whitespace-nowrap px-3 text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground first:pl-4 last:pr-4;
145 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));148 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
146 }149 }
147 150
@@ -172,16 +175,34 @@
172 }175 }
173 176
174 /*177 /*
175- * Yatay kaydırmada sağda sabit kalan aksiyon hücresi. Altındaki içerik görünmesin178+ * Yatay kaydırmada sabit kalan (dondurulmuş) kolonlar. Altındaki içerik görünmesin
176- * diye opak olmalı ama zebra/hover satır tonuyla da eşleşmeli: yarı saydam satır179+ * diye opak olmalı ama zebra/hover satır tonuyla da eşleşmeli: gövde hücresi satır
177- * tonunun kart zemini üzerindeki karşılığı color-mix ile üretiliyor.180+ * tonunu `inherit` ile alır, başlık hücresi başlık tonunu kullanır. Kayan içerikle
181+ * arasında görsel dikiş için kenara ince çizgi + yumuşak gölge eklenir.
178 */182 */
179-@utility table-sticky-cell {183+@utility table-sticky-left {
180 background-color: inherit;184 background-color: inherit;
185+ border-right: 1px solid hsl(var(--border));
186+ box-shadow: 6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
181 }187 }
182 188
183-@utility table-sticky-head {189+@utility table-sticky-right {
190+ background-color: inherit;
191+ border-left: 1px solid hsl(var(--border));
192+ box-shadow: -6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
193+}
194+
195+/* Dondurulmuş başlık hücreleri gövde hücrelerinin üstünde opak kalmalı. */
196+@utility table-sticky-head-left {
197+ background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
198+ border-right: 1px solid hsl(var(--border));
199+ box-shadow: 6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
200+}
201+
202+@utility table-sticky-head-right {
184 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));203 background-color: color-mix(in srgb, hsl(var(--muted)) 55%, hsl(var(--card)));
204+ border-left: 1px solid hsl(var(--border));
205+ box-shadow: -6px 0 8px -6px color-mix(in srgb, hsl(var(--foreground)) 18%, transparent);
185 }206 }
186 207
187 /* Satır yoğunluğu (density). Normal = @utility data-table varsayılanları. */208 /* Satır yoğunluğu (density). Normal = @utility data-table varsayılanları. */
src/pages/courses-page.tsxmodified+1 -1
@@ -28,7 +28,7 @@ import { hasMinRole } from "@/lib/roles";
28 import { useAuth } from "@/stores/auth-context";28 import { useAuth } from "@/stores/auth-context";
29 import { useT } from "@/stores/preferences-context";29 import { useT } from "@/stores/preferences-context";
30 30
31-const PAGE_SIZE = 12;31+const PAGE_SIZE = 10;
32 32
33 export default function CoursesPage() {33 export default function CoursesPage() {
34 return <RouteGuard><CoursesContent /></RouteGuard>;34 return <RouteGuard><CoursesContent /></RouteGuard>;
src/pages/exams-page.tsxmodified+1 -1
@@ -32,7 +32,7 @@ import { cn } from "@/lib/cn";
32 import { useAuth } from "@/stores/auth-context";32 import { useAuth } from "@/stores/auth-context";
33 import { usePreferences, useT } from "@/stores/preferences-context";33 import { usePreferences, useT } from "@/stores/preferences-context";
34 34
35-const EXAM_PAGE_SIZE = 12;35+const EXAM_PAGE_SIZE = 10;
36 36
37 type ExamRow = Exam & { displayStatus: ExamDisplayStatus };37 type ExamRow = Exam & { displayStatus: ExamDisplayStatus };
38 38
src/pages/homework-page.tsxmodified+1 -1
@@ -243,7 +243,7 @@ function HomeworkContent() {
243 tableClass="table-fixed min-w-5xl"243 tableClass="table-fixed min-w-5xl"
244 filterColumn="title"244 filterColumn="title"
245 enablePagination245 enablePagination
246- pageSize={12}246+ pageSize={10}
247 empty={t("homework.empty")}247 empty={t("homework.empty")}
248 storageKey="homework"248 storageKey="homework"
249 onRowClick={(item) => void navigate({ to: "/homework/$id", params: { id: item.id } })}249 onRowClick={(item) => void navigate({ to: "/homework/$id", params: { id: item.id } })}
src/pages/meals-page.tsxmodified+1 -1
@@ -22,7 +22,7 @@ import { hasMinRole } from "@/lib/roles";
22 import { useAuth } from "@/stores/auth-context";22 import { useAuth } from "@/stores/auth-context";
23 import { usePreferences, useT } from "@/stores/preferences-context";23 import { usePreferences, useT } from "@/stores/preferences-context";
24 24
25-const PAGE_SIZE = 12;25+const PAGE_SIZE = 10;
26 const today = () => new Date().toISOString().slice(0, 10);26 const today = () => new Date().toISOString().slice(0, 10);
27 27
28 export default function MealsPage() {28 export default function MealsPage() {
src/pages/my-students-page.tsxmodified+4 -4
@@ -132,14 +132,14 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
132 },132 },
133 {133 {
134 accessorKey: "weight",134 accessorKey: "weight",
135- header: () => <span class="block text-right">{t("marks.weight")}</span>,135+ header: t("marks.weight"),
136- meta: { cellClass: "mono text-right tabular-nums" },136+ meta: { align: "right", cellClass: "mono tabular-nums" },
137 cell: (cell) => cell.row.original.weight,137 cell: (cell) => cell.row.original.weight,
138 },138 },
139 {139 {
140 accessorKey: "mark",140 accessorKey: "mark",
141- header: () => <span class="block text-right">{t("marks.mark")}</span>,141+ header: t("marks.mark"),
142- meta: { cellClass: "mono text-right font-semibold tabular-nums" },142+ meta: { align: "right", cellClass: "mono font-semibold tabular-nums" },
143 cell: (cell) => formatNumber(cell.row.original.mark),143 cell: (cell) => formatNumber(cell.row.original.mark),
144 },144 },
145 ]);145 ]);
src/pages/notes-page.tsxmodified+1 -1
@@ -21,7 +21,7 @@ import { createFlash } from "@/lib/flash";
21 import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";21 import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";
22 import { useT } from "@/stores/preferences-context";22 import { useT } from "@/stores/preferences-context";
23 23
24-const NOTE_PAGE_SIZE = 12;24+const NOTE_PAGE_SIZE = 10;
25 25
26 export default function NotesPage() {26 export default function NotesPage() {
27 return (27 return (
src/pages/payment-statement-page.tsxmodified+1 -1
@@ -28,7 +28,7 @@ import { personLabel } from "@/lib/person";
28 import { useAuth } from "@/stores/auth-context";28 import { useAuth } from "@/stores/auth-context";
29 import { usePreferences, useT } from "@/stores/preferences-context";29 import { usePreferences, useT } from "@/stores/preferences-context";
30 30
31-const STATEMENT_PAGE_SIZE = 12;31+const STATEMENT_PAGE_SIZE = 10;
32 32
33 export default function PaymentStatementPage() {33 export default function PaymentStatementPage() {
34 return (34 return (
src/pages/payments-page.tsxmodified+1 -1
@@ -48,7 +48,7 @@ import { PAYMENT_METHOD_KEYS, sortStatementEntries, statementStatus } from "@/li
48 import { personLabel } from "@/lib/person";48 import { personLabel } from "@/lib/person";
49 import { usePreferences, useT } from "@/stores/preferences-context";49 import { usePreferences, useT } from "@/stores/preferences-context";
50 50
51-const PLAN_PAGE_SIZE = 12;51+const PLAN_PAGE_SIZE = 10;
52 const STATEMENT_PAGE_SIZE = 15;52 const STATEMENT_PAGE_SIZE = 15;
53 const STUDENT_PAGE_SIZE = 10;53 const STUDENT_PAGE_SIZE = 10;
54 54
src/pages/question-bank-page.tsxmodified+1 -1
@@ -22,7 +22,7 @@ import { hasMinRole } from "@/lib/roles";
22 import { useAuth } from "@/stores/auth-context";22 import { useAuth } from "@/stores/auth-context";
23 import { useT } from "@/stores/preferences-context";23 import { useT } from "@/stores/preferences-context";
24 24
25-const BANK_PAGE_SIZE = 12;25+const BANK_PAGE_SIZE = 10;
26 26
27 export default function QuestionBankPage() {27 export default function QuestionBankPage() {
28 return (28 return (
src/pages/staff-work-page.tsxmodified+1 -1
@@ -24,7 +24,7 @@ import { formatDateTime, formatDurationMinutes } from "@/lib/format";
24 import { personLabel } from "@/lib/person";24 import { personLabel } from "@/lib/person";
25 import { usePreferences, useT } from "@/stores/preferences-context";25 import { usePreferences, useT } from "@/stores/preferences-context";
26 26
27-const PEOPLE_PAGE_SIZE = 12;27+const PEOPLE_PAGE_SIZE = 10;
28 const WORK_PAGE_SIZE = 15;28 const WORK_PAGE_SIZE = 15;
29 function msToDateInput(ms: number): string {29 function msToDateInput(ms: number): string {
30 const d = new Date(ms);30 const d = new Date(ms);
src/pages/student-attendance-page.tsxmodified+1 -1
@@ -15,7 +15,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
15 import { personLabel } from "@/lib/person";15 import { personLabel } from "@/lib/person";
16 import { useT } from "@/stores/preferences-context";16 import { useT } from "@/stores/preferences-context";
17 17
18-const PAGE_SIZE = 12;18+const PAGE_SIZE = 10;
19 19
20 export default function StudentAttendancePage() {20 export default function StudentAttendancePage() {
21 return (21 return (
src/pages/student-marks-page.tsxmodified+12 -4
@@ -16,7 +16,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
16 import { personLabel } from "@/lib/person";16 import { personLabel } from "@/lib/person";
17 import { useT } from "@/stores/preferences-context";17 import { useT } from "@/stores/preferences-context";
18 18
19-const PAGE_SIZE = 12;19+const PAGE_SIZE = 10;
20 const round = (n: number) => (Math.round(n * 100) / 100).toString();20 const round = (n: number) => (Math.round(n * 100) / 100).toString();
21 // ponytail: display-only color tiers (70/40 on a 0-100 scale), not a pass/fail rule21 // ponytail: display-only color tiers (70/40 on a 0-100 scale), not a pass/fail rule
22 const avgTone = (v: number) =>22 const avgTone = (v: number) =>
@@ -91,7 +91,15 @@ function StudentMarksContent() {
91 );91 );
92 92
93 const total = () => list().length;93 const total = () => list().length;
94- const rows = () => list();94+ // The inline "average" column reads the separate marksMapRes resource, which
95+ // resolves AFTER this table first renders. TanStack caches cell values by the
96+ // data-array identity, so without a new reference the averages only appear once
97+ // something forces a re-derive (e.g. sorting). Track marksMapRes and hand back a
98+ // fresh array so the column fills in as soon as the marks load.
99+ const rows = () => {
100+ marksMapRes();
101+ return [...list()];
102+ };
95 const listLoading = () => list.loading;103 const listLoading = () => list.loading;
96 const searchPerson = (person: PersonRef, query: string) =>104 const searchPerson = (person: PersonRef, query: string) =>
97 [person.username, person.display_name, person.id].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase());105 [person.username, person.display_name, person.id].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase());
@@ -108,9 +116,9 @@ function StudentMarksContent() {
108 },116 },
109 {117 {
110 id: "average",118 id: "average",
111- header: () => <span class="block text-right">{t("marks.overall")}</span>,119+ header: t("marks.overall"),
112 accessorFn: (user) => marksOf(user.id)?.overall_average ?? -1,120 accessorFn: (user) => marksOf(user.id)?.overall_average ?? -1,
113- meta: { headerClass: "text-right", cellClass: "text-right" },121+ meta: { align: "right" },
114 cell: (cell) => {122 cell: (cell) => {
115 const rep = marksOf(cell.row.original.id);123 const rep = marksOf(cell.row.original.id);
116 if (rep == null) return <span class="text-sm text-muted-foreground">—</span>;124 if (rep == null) return <span class="text-sm text-muted-foreground">—</span>;
src/pages/student-pomodoro-page.tsxmodified+1 -1
@@ -15,7 +15,7 @@ import { formatDateTime, formatDurationClock } from "@/lib/format";
15 import { personLabel } from "@/lib/person";15 import { personLabel } from "@/lib/person";
16 import { usePreferences, useT } from "@/stores/preferences-context";16 import { usePreferences, useT } from "@/stores/preferences-context";
17 17
18-const PAGE_SIZE = 12;18+const PAGE_SIZE = 10;
19 19
20 export default function StudentPomodoroPage() {20 export default function StudentPomodoroPage() {
21 return (21 return (
src/pages/terms-page.tsxmodified+1 -1
@@ -24,7 +24,7 @@ import { createFlash } from "@/lib/flash";
24 import { formatDateTime } from "@/lib/format";24 import { formatDateTime } from "@/lib/format";
25 import { usePreferences, useT } from "@/stores/preferences-context";25 import { usePreferences, useT } from "@/stores/preferences-context";
26 26
27-const TERM_PAGE_SIZE = 12;27+const TERM_PAGE_SIZE = 10;
28 28
29 function dateInputFromMs(ms: number): string {29 function dateInputFromMs(ms: number): string {
30 const date = new Date(ms);30 const date = new Date(ms);