ℹ️ move always-on table notes behind header info icons
Browse files at this commit7eac1f2f4591b682f0d8126c29bde390cb60a0dcParent: 92ceffb- feat
- ℹ️ move always-on table notes behind header info icons
14 changed files +190 -33
- src/components/courses/offering-panel.tsx +7 -6
- src/components/events/attendance-table.tsx +3 -0
- src/components/events/event-roll-call.tsx +9 -3
- src/components/homework/homework-submissions-panel.tsx +3 -2
- src/components/ui/data-table.test.tsx +25 -0
- src/components/ui/data-table.tsx +38 -4
- src/components/ui/icons.tsx +6 -0
- src/components/ui/info-tip.tsx +73 -0
- src/i18n/locales/en.ts +2 -0
- src/i18n/locales/tr.ts +2 -0
- src/i18n/messages.ts +2 -0
- src/pages/classes-page.tsx +11 -8
- src/pages/event-detail-page.tsx +2 -4
- src/pages/student-marks-page.tsx +7 -6
src/components/courses/offering-panel.tsxmodified+7 -6
| @@ -19,6 +19,7 @@ import { GradeLevelSelect } from "@/components/classes/grade-level-select"; | |||
| 19 | import { ExamWeightsEditor } from "@/components/instances/exam-weights-editor"; | 19 | import { ExamWeightsEditor } from "@/components/instances/exam-weights-editor"; |
| 20 | import { SubjectSetEditor } from "@/components/instances/subject-set-editor"; | 20 | import { SubjectSetEditor } from "@/components/instances/subject-set-editor"; |
| 21 | import { WeeklyPlanTable } from "@/components/instances/weekly-plan-table"; | 21 | import { WeeklyPlanTable } from "@/components/instances/weekly-plan-table"; |
| 22 | +import { InfoTip } from "@/components/ui/info-tip"; | ||
| 22 | import { WeeklySlotForm } from "@/components/instances/weekly-slot-form"; | 23 | import { WeeklySlotForm } from "@/components/instances/weekly-slot-form"; |
| 23 | import { Alert } from "@/components/ui/alert"; | 24 | import { Alert } from "@/components/ui/alert"; |
| 24 | import { Button } from "@/components/ui/button"; | 25 | import { Button } from "@/components/ui/button"; |
| @@ -184,9 +185,9 @@ export function OfferingPanel(props: { | |||
| 184 | <Show when={sectionError()}><Alert variant="destructive">{sectionError()}</Alert></Show> | 185 | <Show when={sectionError()}><Alert variant="destructive">{sectionError()}</Alert></Show> |
| 185 | 186 | ||
| 186 | <section class={SECTION}> | 187 | <section class={SECTION}> |
| 187 | - <div> | 188 | + <div class="flex items-center gap-1"> |
| 188 | <h3 class="text-sm font-semibold">{t("instances.subjectsTitle")}</h3> | 189 | <h3 class="text-sm font-semibold">{t("instances.subjectsTitle")}</h3> |
| 189 | - <p class="text-xs text-muted-foreground">{t("offerings.subjectsHelp")}</p> | 190 | + <InfoTip text={t("offerings.subjectsHelp")} label={t("common.infoAbout", { item: t("instances.subjectsTitle") })} /> |
| 190 | </div> | 191 | </div> |
| 191 | <SubjectSetEditor | 192 | <SubjectSetEditor |
| 192 | selected={subjects.latest ?? []} | 193 | selected={subjects.latest ?? []} |
| @@ -199,9 +200,9 @@ export function OfferingPanel(props: { | |||
| 199 | 200 | ||
| 200 | <section class={SECTION}> | 201 | <section class={SECTION}> |
| 201 | <div class={SECTION_HEAD}> | 202 | <div class={SECTION_HEAD}> |
| 202 | - <div> | 203 | + <div class="flex items-center gap-1"> |
| 203 | <h3 class="text-sm font-semibold">{t("weeklyPlan.title")}</h3> | 204 | <h3 class="text-sm font-semibold">{t("weeklyPlan.title")}</h3> |
| 204 | - <p class="text-xs text-muted-foreground">{t("offerings.weeklyPlanHelp")}</p> | 205 | + <InfoTip text={t("offerings.weeklyPlanHelp")} label={t("common.infoAbout", { item: t("weeklyPlan.title") })} /> |
| 205 | </div> | 206 | </div> |
| 206 | <Show when={props.canEdit}> | 207 | <Show when={props.canEdit}> |
| 207 | <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setAddingSlot(true)}> | 208 | <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setAddingSlot(true)}> |
| @@ -218,9 +219,9 @@ export function OfferingPanel(props: { | |||
| 218 | 219 | ||
| 219 | <section class={SECTION}> | 220 | <section class={SECTION}> |
| 220 | <div class={SECTION_HEAD}> | 221 | <div class={SECTION_HEAD}> |
| 221 | - <div> | 222 | + <div class="flex items-center gap-1"> |
| 222 | <h3 class="text-sm font-semibold">{t("instances.examWeightsTitle")}</h3> | 223 | <h3 class="text-sm font-semibold">{t("instances.examWeightsTitle")}</h3> |
| 223 | - <p class="text-xs text-muted-foreground">{t("offerings.weightsHelp")}</p> | 224 | + <InfoTip text={t("offerings.weightsHelp")} label={t("common.infoAbout", { item: t("instances.examWeightsTitle") })} /> |
| 224 | </div> | 225 | </div> |
| 225 | <Show when={props.canEdit}> | 226 | <Show when={props.canEdit}> |
| 226 | <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setWeightEditing("new")}> | 227 | <Button type="button" size="sm" variant="outline" class="rounded-lg" onClick={() => setWeightEditing("new")}> |
src/components/events/attendance-table.tsxmodified+3 -0
| @@ -15,6 +15,8 @@ import { useT } from "@/stores/preferences-context"; | |||
| 15 | export function AttendanceTable(props: { | 15 | export function AttendanceTable(props: { |
| 16 | rows: Attendance[]; | 16 | rows: Attendance[]; |
| 17 | emptyLabel?: string; | 17 | emptyLabel?: string; |
| 18 | + /** A note about the list, behind the "Kaydeden" header's info icon. */ | ||
| 19 | + markedByInfo?: string; | ||
| 18 | canRemove?: boolean; | 20 | canRemove?: boolean; |
| 19 | onRemove?: (userId: string) => Promise<void>; | 21 | onRemove?: (userId: string) => Promise<void>; |
| 20 | }) { | 22 | }) { |
| @@ -46,6 +48,7 @@ export function AttendanceTable(props: { | |||
| 46 | id: "marked_by", | 48 | id: "marked_by", |
| 47 | accessorFn: (row) => personLabel(row.marked_by), | 49 | accessorFn: (row) => personLabel(row.marked_by), |
| 48 | header: t("events.markedBy"), | 50 | header: t("events.markedBy"), |
| 51 | + meta: { headerInfo: props.markedByInfo }, | ||
| 49 | cell: (cell) => <span class="text-sm text-muted-foreground">{personLabel(cell.row.original.marked_by)}</span>, | 52 | cell: (cell) => <span class="text-sm text-muted-foreground">{personLabel(cell.row.original.marked_by)}</span>, |
| 50 | }, | 53 | }, |
| 51 | ...(props.canRemove && props.onRemove | 54 | ...(props.canRemove && props.onRemove |
src/components/events/event-roll-call.tsxmodified+9 -3
| @@ -8,6 +8,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 { EmptyState } from "@/components/ui/empty-state"; | 10 | import { EmptyState } from "@/components/ui/empty-state"; |
| 11 | +import { InfoTip } from "@/components/ui/info-tip"; | ||
| 11 | import { IconCheck } from "@/components/ui/icons"; | 12 | import { IconCheck } from "@/components/ui/icons"; |
| 12 | import { TablePagination } from "@/components/ui/table-pagination"; | 13 | import { TablePagination } from "@/components/ui/table-pagination"; |
| 13 | import { ATTENDANCE_STATUSES, getAttendanceStatusMeta } from "@/lib/attendance-status"; | 14 | import { ATTENDANCE_STATUSES, getAttendanceStatusMeta } from "@/lib/attendance-status"; |
| @@ -37,6 +38,8 @@ export function EventRollCall(props: { | |||
| 37 | /** False before the event starts: statuses show, nothing can be picked. */ | 38 | /** False before the event starts: statuses show, nothing can be picked. */ |
| 38 | open: boolean; | 39 | open: boolean; |
| 39 | closedReason?: string; | 40 | closedReason?: string; |
| 41 | + /** How the roll call works, behind an info icon beside the progress line. */ | ||
| 42 | + help?: string; | ||
| 40 | onSaved: () => void | Promise<unknown>; | 43 | onSaved: () => void | Promise<unknown>; |
| 41 | }) { | 44 | }) { |
| 42 | const t = useT(); | 45 | const t = useT(); |
| @@ -173,9 +176,12 @@ export function EventRollCall(props: { | |||
| 173 | > | 176 | > |
| 174 | <div class="space-y-2.5 rounded-xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4"> | 177 | <div class="space-y-2.5 rounded-xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4"> |
| 175 | <div class="flex flex-wrap items-center justify-between gap-3"> | 178 | <div class="flex flex-wrap items-center justify-between gap-3"> |
| 176 | - <p class="text-sm font-semibold text-text-strong" role="status"> | 179 | + <div class="flex min-w-0 items-center gap-1"> |
| 177 | - {t("rollCall.progress", { marked: markedCount(), total: props.roster.length })} | 180 | + <p class="text-sm font-semibold text-text-strong" role="status"> |
| 178 | - </p> | 181 | + {t("rollCall.progress", { marked: markedCount(), total: props.roster.length })} |
| 182 | + </p> | ||
| 183 | + <Show when={props.help}>{(help) => <InfoTip text={help()} />}</Show> | ||
| 184 | + </div> | ||
| 179 | <div class="flex flex-wrap justify-end gap-1.5"> | 185 | <div class="flex flex-wrap justify-end gap-1.5"> |
| 180 | <For each={statuses()}> | 186 | <For each={statuses()}> |
| 181 | {(status) => ( | 187 | {(status) => ( |
src/components/homework/homework-submissions-panel.tsxmodified+3 -2
| @@ -6,6 +6,7 @@ import { deleteHomeworkResultByUserId, getHomeworkSubmissionFileUrl, getHomework | |||
| 6 | import { formatApiError } from "@/api/client"; | 6 | import { formatApiError } from "@/api/client"; |
| 7 | import type { HomeworkRosterEntry } from "@/api/client"; | 7 | import type { HomeworkRosterEntry } from "@/api/client"; |
| 8 | import { Alert } from "@/components/ui/alert"; | 8 | import { Alert } from "@/components/ui/alert"; |
| 9 | +import { InfoTip } from "@/components/ui/info-tip"; | ||
| 9 | import { Badge } from "@/components/ui/badge"; | 10 | import { Badge } from "@/components/ui/badge"; |
| 10 | import { Button } from "@/components/ui/button"; | 11 | import { Button } from "@/components/ui/button"; |
| 11 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 12 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| @@ -169,9 +170,9 @@ export function HomeworkSubmissionsPanel(props: { homeworkId: string; instanceId | |||
| 169 | 170 | ||
| 170 | return ( | 171 | return ( |
| 171 | <section class="space-y-3"> | 172 | <section class="space-y-3"> |
| 172 | - <div> | 173 | + <div class="flex items-center gap-1.5"> |
| 173 | <h2 class="text-lg font-semibold">{t("homework.submissions")}</h2> | 174 | <h2 class="text-lg font-semibold">{t("homework.submissions")}</h2> |
| 174 | - <p class="mt-1 text-sm text-text-subtle">{t("homework.submissionsHelp")}</p> | 175 | + <InfoTip text={t("homework.submissionsHelp")} label={t("common.infoAbout", { item: t("homework.submissions") })} /> |
| 175 | </div> | 176 | </div> |
| 176 | <Show when={flash()}><Alert variant="success">{flash()}</Alert></Show> | 177 | <Show when={flash()}><Alert variant="success">{flash()}</Alert></Show> |
| 177 | <Show when={error() && !gradeTarget()}><Alert variant="destructive">{error()}</Alert></Show> | 178 | <Show when={error() && !gradeTarget()}><Alert variant="destructive">{error()}</Alert></Show> |
src/components/ui/data-table.test.tsxmodified+25 -0
| @@ -334,3 +334,28 @@ test("a toolbar holding only the column menu is not boxed", () => { | |||
| 334 | const toolbar = container.querySelector(".space-y-3 > div"); | 334 | const toolbar = container.querySelector(".space-y-3 > div"); |
| 335 | expect(toolbar?.className).not.toContain("rounded-xl"); | 335 | expect(toolbar?.className).not.toContain("rounded-xl"); |
| 336 | }); | 336 | }); |
| 337 | + | ||
| 338 | +test("meta.headerInfo puts a labelled info icon beside the header that opens without sorting", async () => { | ||
| 339 | + const withInfo: ColumnDef<Row>[] = [ | ||
| 340 | + { accessorKey: "name", header: "Name" }, | ||
| 341 | + { accessorKey: "role", header: "Average", meta: { headerInfo: "Filled in for small schools only." } }, | ||
| 342 | + ]; | ||
| 343 | + render(() => ( | ||
| 344 | + <PreferencesProvider> | ||
| 345 | + <DataTable columns={withInfo} data={[{ name: "Ada", role: "b" }, { name: "Bo", role: "a" }]} enableColumnVisibility={false} /> | ||
| 346 | + </PreferencesProvider> | ||
| 347 | + )); | ||
| 348 | + const info = screen.getByRole("button", { name: /About Average|Average hakkında bilgi/ }); | ||
| 349 | + const header = info.closest("th"); | ||
| 350 | + expect(header?.getAttribute("aria-sort")).toBe("none"); | ||
| 351 | + // Beside the sort button, never inside it: a button in a button is invalid. | ||
| 352 | + expect(info.parentElement?.closest("button")).toBeNull(); | ||
| 353 | + expect(screen.getAllByRole("columnheader")).toHaveLength(2); | ||
| 354 | + expect(screen.queryByText("Filled in for small schools only.")).toBeNull(); | ||
| 355 | + | ||
| 356 | + fireEvent.click(info); | ||
| 357 | + expect(header?.getAttribute("aria-sort")).toBe("none"); | ||
| 358 | + expect(await screen.findByText("Filled in for small schools only.")).toBeTruthy(); | ||
| 359 | + // 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."); | ||
| 361 | +}); | ||
src/components/ui/data-table.tsxmodified+38 -4
| @@ -21,6 +21,7 @@ import { DataTableSearch } from "@/components/ui/data-table-search"; | |||
| 21 | import { DataTableViewMenu, type ViewMenuColumn } from "@/components/ui/data-table-view-menu"; | 21 | import { DataTableViewMenu, type ViewMenuColumn } from "@/components/ui/data-table-view-menu"; |
| 22 | import { TablePagination } from "@/components/ui/table-pagination"; | 22 | import { TablePagination } from "@/components/ui/table-pagination"; |
| 23 | import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/icons"; | 23 | import { IconArrowDown, IconArrowUp, IconChevronsUpDown } from "@/components/ui/icons"; |
| 24 | +import { InfoTip } from "@/components/ui/info-tip"; | ||
| 24 | import { cn } from "@/lib/cn"; | 25 | import { cn } from "@/lib/cn"; |
| 25 | import { createMediaQuery } from "@/lib/create-media-query"; | 26 | import { createMediaQuery } from "@/lib/create-media-query"; |
| 26 | import { COMPACT_SCREEN_QUERY, createResponsivePageSize } from "@/lib/create-page-size"; | 27 | import { COMPACT_SCREEN_QUERY, createResponsivePageSize } from "@/lib/create-page-size"; |
| @@ -42,6 +43,12 @@ declare module "@tanstack/solid-table" { | |||
| 42 | divider?: "left" | "right"; | 43 | divider?: "left" | "right"; |
| 43 | /** Leave this column out of the phone card layout (e.g. a column that only matters on a wide table). */ | 44 | /** Leave this column out of the phone card layout (e.g. a column that only matters on a wide table). */ |
| 44 | hideInCards?: boolean; | 45 | hideInCards?: boolean; |
| 46 | + /** | ||
| 47 | + * A note that explains this column (what fills it, a limit behind it). | ||
| 48 | + * Renders a circled "i" after the header label that shows the text on | ||
| 49 | + * hover, focus and tap — instead of a line kept on screen above the table. | ||
| 50 | + */ | ||
| 51 | + headerInfo?: string; | ||
| 45 | } | 52 | } |
| 46 | } | 53 | } |
| 47 | 54 | ||
| @@ -377,13 +384,27 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 377 | const sorted = column.getIsSorted(); | 384 | const sorted = column.getIsSorted(); |
| 378 | return sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : "none"; | 385 | return sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : "none"; |
| 379 | }; | 386 | }; |
| 387 | + // The info icon sits beside the label, never inside the sort button: a | ||
| 388 | + // button in a button is invalid, and opening the note must not sort. | ||
| 389 | + const headerInfoTip = (column: Column<TData, unknown>) => ( | ||
| 390 | + <Show when={column.columnDef.meta?.headerInfo}> | ||
| 391 | + {(text) => <InfoTip text={text()} label={t("common.infoAbout", { item: columnLabel(column) })} />} | ||
| 392 | + </Show> | ||
| 393 | + ); | ||
| 380 | const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => { | 394 | const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => { |
| 381 | const content = flexRender(header.column.columnDef.header, header.getContext()); | 395 | const content = flexRender(header.column.columnDef.header, header.getContext()); |
| 382 | if (!sortingEnabled() || !header.column.getCanSort()) { | 396 | if (!sortingEnabled() || !header.column.getCanSort()) { |
| 383 | - return <span class="block truncate whitespace-nowrap text-center">{content}</span>; | 397 | + return ( |
| 398 | + <Show when={header.column.columnDef.meta?.headerInfo} fallback={<span class="block truncate whitespace-nowrap text-center">{content}</span>}> | ||
| 399 | + <span class="flex min-w-0 items-center justify-center gap-1 whitespace-nowrap"> | ||
| 400 | + <span class="min-w-0 truncate">{content}</span> | ||
| 401 | + {headerInfoTip(header.column)} | ||
| 402 | + </span> | ||
| 403 | + </Show> | ||
| 404 | + ); | ||
| 384 | } | 405 | } |
| 385 | const sorted = () => header.column.getIsSorted(); | 406 | const sorted = () => header.column.getIsSorted(); |
| 386 | - return ( | 407 | + const sortButton = () => ( |
| 387 | <Button | 408 | <Button |
| 388 | type="button" | 409 | type="button" |
| 389 | variant="ghost" | 410 | variant="ghost" |
| @@ -407,6 +428,14 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 407 | </Show> | 428 | </Show> |
| 408 | </Button> | 429 | </Button> |
| 409 | ); | 430 | ); |
| 431 | + return ( | ||
| 432 | + <Show when={header.column.columnDef.meta?.headerInfo} fallback={sortButton()}> | ||
| 433 | + <span class="flex min-w-0 items-center justify-center whitespace-nowrap"> | ||
| 434 | + {sortButton()} | ||
| 435 | + {headerInfoTip(header.column)} | ||
| 436 | + </span> | ||
| 437 | + </Show> | ||
| 438 | + ); | ||
| 410 | }; | 439 | }; |
| 411 | 440 | ||
| 412 | return ( | 441 | return ( |
| @@ -468,7 +497,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 468 | 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>} | 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>} |
| 469 | > | 498 | > |
| 470 | <For each={table.getRowModel().rows}> | 499 | <For each={table.getRowModel().rows}> |
| 471 | - {(row) => { | 500 | + {(row, rowIndex) => { |
| 472 | const cells = () => | 501 | const cells = () => |
| 473 | row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards); | 502 | row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards); |
| 474 | const action = () => cells().find((cell) => cell.column.id === "actions"); | 503 | const action = () => cells().find((cell) => cell.column.id === "actions"); |
| @@ -516,7 +545,12 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 516 | <For each={details()}> | 545 | <For each={details()}> |
| 517 | {(cell) => ( | 546 | {(cell) => ( |
| 518 | <div class="min-w-0"> | 547 | <div class="min-w-0"> |
| 519 | - <dt class="truncate text-[11px] leading-4 text-muted-foreground">{headerLabel(cell.column.id)}</dt> | 548 | + {/* A column note shows on the first card only: once |
| 549 | + per list, like the table header it stands in for. */} | ||
| 550 | + <dt class="flex min-w-0 items-center gap-1 text-[11px] leading-4 text-muted-foreground"> | ||
| 551 | + <span class="min-w-0 truncate">{headerLabel(cell.column.id)}</span> | ||
| 552 | + <Show when={rowIndex() === 0}>{headerInfoTip(cell.column)}</Show> | ||
| 553 | + </dt> | ||
| 520 | <dd class="mt-0.5 min-w-0 break-words text-[13px] leading-5 text-foreground text-left [&_*]:text-left [&_.items-center]:items-start [&_.justify-center]:justify-start [&_.justify-end]:justify-start [&_.mx-auto]:mx-0 [&_[data-slot=badge]]:w-auto [&_[data-slot=badge]]:min-w-0 [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:items-center!"> | 554 | <dd class="mt-0.5 min-w-0 break-words text-[13px] leading-5 text-foreground text-left [&_*]:text-left [&_.items-center]:items-start [&_.justify-center]:justify-start [&_.justify-end]:justify-start [&_.mx-auto]:mx-0 [&_[data-slot=badge]]:w-auto [&_[data-slot=badge]]:min-w-0 [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:items-center!"> |
| 521 | {flexRender(cell.column.columnDef.cell, cell.getContext())} | 555 | {flexRender(cell.column.columnDef.cell, cell.getContext())} |
| 522 | </dd> | 556 | </dd> |
src/components/ui/icons.tsxmodified+6 -0
| @@ -34,6 +34,7 @@ import gearUrl from "@phosphor-icons/core/regular/gear.svg?url"; | |||
| 34 | import userCircleUrl from "@phosphor-icons/core/regular/user-circle.svg?url"; | 34 | import userCircleUrl from "@phosphor-icons/core/regular/user-circle.svg?url"; |
| 35 | import graduationCapUrl from "@phosphor-icons/core/regular/graduation-cap.svg?url"; | 35 | import graduationCapUrl from "@phosphor-icons/core/regular/graduation-cap.svg?url"; |
| 36 | import houseUrl from "@phosphor-icons/core/regular/house.svg?url"; | 36 | import houseUrl from "@phosphor-icons/core/regular/house.svg?url"; |
| 37 | +import infoUrl from "@phosphor-icons/core/regular/info.svg?url"; | ||
| 37 | import listUrl from "@phosphor-icons/core/regular/list.svg?url"; | 38 | import listUrl from "@phosphor-icons/core/regular/list.svg?url"; |
| 38 | import lockSimpleUrl from "@phosphor-icons/core/regular/lock-simple.svg?url"; | 39 | import lockSimpleUrl from "@phosphor-icons/core/regular/lock-simple.svg?url"; |
| 39 | import magnifyingGlassUrl from "@phosphor-icons/core/regular/magnifying-glass.svg?url"; | 40 | import magnifyingGlassUrl from "@phosphor-icons/core/regular/magnifying-glass.svg?url"; |
| @@ -353,6 +354,11 @@ export function IconHelpCircle(props: IconProps) { | |||
| 353 | return <PhosphorIcon {...props} src={questionUrl} />; | 354 | return <PhosphorIcon {...props} src={questionUrl} />; |
| 354 | } | 355 | } |
| 355 | 356 | ||
| 357 | +/** A circled "i": opens an explanatory note (see `InfoTip`). */ | ||
| 358 | +export function IconInfo(props: IconProps) { | ||
| 359 | + return <PhosphorIcon {...props} src={infoUrl} />; | ||
| 360 | +} | ||
| 361 | + | ||
| 356 | export function IconMessagePlus(props: IconProps) { | 362 | export function IconMessagePlus(props: IconProps) { |
| 357 | return ( | 363 | return ( |
| 358 | <Svg {...props}> | 364 | <Svg {...props}> |
src/components/ui/info-tip.tsxadded+73 -0
| @@ -0,0 +1,73 @@ | |||
| 1 | +import { createSignal } from "solid-js"; | ||
| 2 | +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; | ||
| 3 | +import { IconInfo } from "@/components/ui/icons"; | ||
| 4 | +import { cn } from "@/lib/cn"; | ||
| 5 | +import { useT } from "@/stores/preferences-context"; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * A circled "i" that reveals an explanatory note — for a line that explains a | ||
| 9 | + * column or a table and would otherwise sit on screen all the time. | ||
| 10 | + * | ||
| 11 | + * Hover and keyboard focus open it like a tooltip; a click or a tap pins it | ||
| 12 | + * open (a tooltip alone never opens on touch), and a second click, Escape, a | ||
| 13 | + * tap elsewhere or moving focus away closes it again. | ||
| 14 | + */ | ||
| 15 | +export function InfoTip(props: { | ||
| 16 | + text: string; | ||
| 17 | + /** Accessible name of the button; defaults to "Bilgi" / "More info". */ | ||
| 18 | + label?: string; | ||
| 19 | + class?: string; | ||
| 20 | +}) { | ||
| 21 | + const t = useT(); | ||
| 22 | + let trigger: HTMLButtonElement | undefined; | ||
| 23 | + const [hoverOpen, setHoverOpen] = createSignal(false); | ||
| 24 | + const [pinned, setPinned] = createSignal(false); | ||
| 25 | + return ( | ||
| 26 | + <Tooltip | ||
| 27 | + open={hoverOpen() || pinned()} | ||
| 28 | + onOpenChange={setHoverOpen} | ||
| 29 | + openDelay={150} | ||
| 30 | + closeDelay={100} | ||
| 31 | + placement="top" | ||
| 32 | + gutter={6} | ||
| 33 | + > | ||
| 34 | + <TooltipTrigger | ||
| 35 | + ref={trigger} | ||
| 36 | + type="button" | ||
| 37 | + aria-label={props.label ?? t("common.info")} | ||
| 38 | + data-info-tip="" | ||
| 39 | + class={cn( | ||
| 40 | + "inline-flex h-5 w-5 shrink-0 cursor-help items-center justify-center rounded-full text-muted-foreground outline-hidden transition-colors", | ||
| 41 | + "hover:text-foreground focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-ring", | ||
| 42 | + // A bigger hit area on touch without changing the header's height. | ||
| 43 | + "touch:relative touch:after:absolute touch:after:-inset-2.5 touch:after:content-['']", | ||
| 44 | + pinned() && "text-foreground", | ||
| 45 | + props.class, | ||
| 46 | + )} | ||
| 47 | + onClick={(event: MouseEvent) => { | ||
| 48 | + // Never reach a sortable header or a clickable row around it. | ||
| 49 | + event.stopPropagation(); | ||
| 50 | + setPinned((value) => !value); | ||
| 51 | + }} | ||
| 52 | + onKeyDown={(event: KeyboardEvent) => { | ||
| 53 | + if (event.key === "Enter" || event.key === " ") event.stopPropagation(); | ||
| 54 | + }} | ||
| 55 | + onBlur={() => setPinned(false)} | ||
| 56 | + > | ||
| 57 | + <IconInfo class="h-3.5 w-3.5" /> | ||
| 58 | + </TooltipTrigger> | ||
| 59 | + <TooltipContent | ||
| 60 | + class="max-w-72 text-left text-xs leading-5 font-normal normal-case tracking-normal whitespace-normal" | ||
| 61 | + onEscapeKeyDown={() => setPinned(false)} | ||
| 62 | + onPointerDownOutside={(event) => { | ||
| 63 | + // A tap on the icon itself is its own toggle, not "outside". | ||
| 64 | + const target = event.detail.originalEvent.target as Node | null; | ||
| 65 | + if (trigger && target && trigger.contains(target)) return; | ||
| 66 | + setPinned(false); | ||
| 67 | + }} | ||
| 68 | + > | ||
| 69 | + {props.text} | ||
| 70 | + </TooltipContent> | ||
| 71 | + </Tooltip> | ||
| 72 | + ); | ||
| 73 | +} | ||
src/i18n/locales/en.tsmodified+2 -0
| @@ -696,6 +696,8 @@ export const en: Dict = { | |||
| 696 | "common.pagination": "Pagination", | 696 | "common.pagination": "Pagination", |
| 697 | "common.noResults": "No results.", | 697 | "common.noResults": "No results.", |
| 698 | "common.scrollHint": "Scroll horizontally", | 698 | "common.scrollHint": "Scroll horizontally", |
| 699 | + "common.info": "More info", | ||
| 700 | + "common.infoAbout": "About {item}", | ||
| 699 | "common.noMatches": "Nothing matches your search.", | 701 | "common.noMatches": "Nothing matches your search.", |
| 700 | "common.noMatchesFor": "No results for “{query}”.", | 702 | "common.noMatchesFor": "No results for “{query}”.", |
| 701 | "common.noFilterMatches": "Nothing matches the selected filters.", | 703 | "common.noFilterMatches": "Nothing matches the selected filters.", |
src/i18n/locales/tr.tsmodified+2 -0
| @@ -692,6 +692,8 @@ export const tr: Dict = { | |||
| 692 | "common.pagination": "Sayfalar", | 692 | "common.pagination": "Sayfalar", |
| 693 | "common.noResults": "Sonuç yok.", | 693 | "common.noResults": "Sonuç yok.", |
| 694 | "common.scrollHint": "Yatay kaydır", | 694 | "common.scrollHint": "Yatay kaydır", |
| 695 | + "common.info": "Bilgi", | ||
| 696 | + "common.infoAbout": "{item} hakkında bilgi", | ||
| 695 | "common.noMatches": "Aramanızla eşleşen kayıt yok.", | 697 | "common.noMatches": "Aramanızla eşleşen kayıt yok.", |
| 696 | "common.noMatchesFor": "“{query}” için sonuç yok.", | 698 | "common.noMatchesFor": "“{query}” için sonuç yok.", |
| 697 | "common.noFilterMatches": "Seçili filtrelerle eşleşen kayıt yok.", | 699 | "common.noFilterMatches": "Seçili filtrelerle eşleşen kayıt yok.", |
src/i18n/messages.tsmodified+2 -0
| @@ -680,6 +680,8 @@ export type MessageKey = | |||
| 680 | | "common.pagination" | 680 | | "common.pagination" |
| 681 | | "common.noResults" | 681 | | "common.noResults" |
| 682 | | "common.scrollHint" | 682 | | "common.scrollHint" |
| 683 | + | "common.info" | ||
| 684 | + | "common.infoAbout" | ||
| 683 | | "common.noMatches" | 685 | | "common.noMatches" |
| 684 | | "common.noMatchesFor" | 686 | | "common.noMatchesFor" |
| 685 | | "common.noFilterMatches" | 687 | | "common.noFilterMatches" |
src/pages/classes-page.tsxmodified+11 -8
| @@ -95,7 +95,8 @@ function ClassesContent() { | |||
| 95 | }); | 95 | }); |
| 96 | return new Map(entries); | 96 | return new Map(entries); |
| 97 | }); | 97 | }); |
| 98 | - const memberCountsCapped = () => listData().length > MEMBER_COUNT_FETCH_CAP; | 98 | + // A memo: the columns read it, and must not rebuild on every list refetch. |
| 99 | + const memberCountsCapped = createMemo(() => listData().length > MEMBER_COUNT_FETCH_CAP); | ||
| 99 | 100 | ||
| 100 | // Class by class (9-A, 9-B, 10-A…) until a column header re-sorts it. | 101 | // Class by class (9-A, 9-B, 10-A…) until a column header re-sorts it. |
| 101 | const gradeFiltered = createMemo(() => { | 102 | const gradeFiltered = createMemo(() => { |
| @@ -186,9 +187,15 @@ function ClassesContent() { | |||
| 186 | id: "students", | 187 | id: "students", |
| 187 | accessorFn: (row) => memberCounts()?.get(row.id) ?? -1, | 188 | accessorFn: (row) => memberCounts()?.get(row.id) ?? -1, |
| 188 | header: t("nav.studentsRoster"), | 189 | header: t("nav.studentsRoster"), |
| 189 | - size: 110, | 190 | + size: 130, |
| 190 | - minSize: 90, | 191 | + minSize: 100, |
| 191 | - meta: { cellClass: "whitespace-nowrap text-center", align: "center" }, | 192 | + // Why counts stop past the cap — behind the header's "i" rather than a |
| 193 | + // notice kept above the table. | ||
| 194 | + meta: { | ||
| 195 | + cellClass: "whitespace-nowrap text-center", | ||
| 196 | + align: "center", | ||
| 197 | + headerInfo: memberCountsCapped() ? t("classGroups.memberCountCapped", { cap: MEMBER_COUNT_FETCH_CAP }) : undefined, | ||
| 198 | + }, | ||
| 192 | cell: (cell) => { | 199 | cell: (cell) => { |
| 193 | const count = memberCounts()?.get(cell.row.original.id); | 200 | const count = memberCounts()?.get(cell.row.original.id); |
| 194 | return count == null ? <span class="text-text-subtle">—</span> : t("classGroups.studentsCount", { count: String(count) }); | 201 | return count == null ? <span class="text-text-subtle">—</span> : t("classGroups.studentsCount", { count: String(count) }); |
| @@ -376,10 +383,6 @@ function ClassesContent() { | |||
| 376 | 383 | ||
| 377 | <TabsContent value="classes"> | 384 | <TabsContent value="classes"> |
| 378 | <div class="space-y-4"> | 385 | <div class="space-y-4"> |
| 379 | - <Show when={memberCountsCapped()}> | ||
| 380 | - <Alert role="status">{t("classGroups.memberCountCapped", { cap: MEMBER_COUNT_FETCH_CAP })}</Alert> | ||
| 381 | - </Show> | ||
| 382 | - | ||
| 383 | <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> | 386 | <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> |
| 384 | <DataTable | 387 | <DataTable |
| 385 | urlState | 388 | urlState |
src/pages/event-detail-page.tsxmodified+2 -4
| @@ -319,7 +319,6 @@ function EventDetailContent() { | |||
| 319 | </Show> | 319 | </Show> |
| 320 | 320 | ||
| 321 | <TabsContent value="studentAttendance" forceMount class="space-y-3"> | 321 | <TabsContent value="studentAttendance" forceMount class="space-y-3"> |
| 322 | - <p class="text-sm text-muted-foreground">{t("events.studentAttendanceHelp")}</p> | ||
| 323 | <Suspense fallback={<DataTableSkeleton columns={2} />}> | 322 | <Suspense fallback={<DataTableSkeleton columns={2} />}> |
| 324 | <Show when={roster()} fallback={ | 323 | <Show when={roster()} fallback={ |
| 325 | <Show when={roster.error}> | 324 | <Show when={roster.error}> |
| @@ -332,6 +331,7 @@ function EventDetailContent() { | |||
| 332 | roster={rows()} | 331 | roster={rows()} |
| 333 | open={rollCallOpen()} | 332 | open={rollCallOpen()} |
| 334 | closedReason={t("events.rollCall.opensAt", { date: formatDateTime(ev().starts_at, locale()) })} | 333 | closedReason={t("events.rollCall.opensAt", { date: formatDateTime(ev().starts_at, locale()) })} |
| 334 | + help={t("events.studentAttendanceHelp")} | ||
| 335 | onSaved={() => Promise.all([refetchRoster(), refetchAttendance()])} | 335 | onSaved={() => Promise.all([refetchRoster(), refetchAttendance()])} |
| 336 | /> | 336 | /> |
| 337 | )} | 337 | )} |
| @@ -344,11 +344,9 @@ function EventDetailContent() { | |||
| 344 | <Show when={attendance()}> | 344 | <Show when={attendance()}> |
| 345 | {(rows) => ( | 345 | {(rows) => ( |
| 346 | <div class="space-y-3"> | 346 | <div class="space-y-3"> |
| 347 | - <div class="rounded-xl border border-border-line bg-surface-base p-3 text-sm text-muted-foreground shadow-xs"> | ||
| 348 | - {t("events.attendanceRecordsHelp")} | ||
| 349 | - </div> | ||
| 350 | <AttendanceTable | 347 | <AttendanceTable |
| 351 | rows={rows()} | 348 | rows={rows()} |
| 349 | + markedByInfo={t("events.attendanceRecordsHelp")} | ||
| 352 | emptyLabel={t("events.noAttendance")} | 350 | emptyLabel={t("events.noAttendance")} |
| 353 | canRemove={isTeacherPlus()} | 351 | canRemove={isTeacherPlus()} |
| 354 | onRemove={async (userId) => { | 352 | onRemove={async (userId) => { |
src/pages/student-marks-page.tsxmodified+7 -6
| @@ -71,7 +71,8 @@ function StudentMarksContent() { | |||
| 71 | return Object.fromEntries(pairs) as Record<string, MarksReport | null>; | 71 | return Object.fromEntries(pairs) as Record<string, MarksReport | null>; |
| 72 | }, | 72 | }, |
| 73 | ); | 73 | ); |
| 74 | - const marksCapped = () => list().length > MARKS_FETCH_CAP; | 74 | + // A memo: the columns read it, and must not rebuild on every list refetch. |
| 75 | + const marksCapped = createMemo(() => !list.loading && (list() ?? []).length > MARKS_FETCH_CAP); | ||
| 75 | const marksOf = (id: string) => marksMapRes()?.[id]; | 76 | const marksOf = (id: string) => marksMapRes()?.[id]; |
| 76 | const examCountOf = (id: string) => { | 77 | const examCountOf = (id: string) => { |
| 77 | const rep = marksOf(id); | 78 | const rep = marksOf(id); |
| @@ -113,7 +114,11 @@ function StudentMarksContent() { | |||
| 113 | id: "average", | 114 | id: "average", |
| 114 | header: t("marks.overall"), | 115 | header: t("marks.overall"), |
| 115 | accessorFn: (row) => marksOf(row.person.id)?.overall_average ?? -1, | 116 | accessorFn: (row) => marksOf(row.person.id)?.overall_average ?? -1, |
| 116 | - meta: { align: "right" }, | 117 | + // Room for the label, the sort arrow and the info icon on one line. |
| 118 | + size: 160, | ||
| 119 | + // Why the column is blank on a large school — behind the header's "i" | ||
| 120 | + // rather than a notice kept above the table. | ||
| 121 | + meta: { align: "right", headerInfo: marksCapped() ? t("marks.averageCapped", { cap: MARKS_FETCH_CAP }) : undefined }, | ||
| 117 | cell: (cell) => { | 122 | cell: (cell) => { |
| 118 | const average = marksOf(cell.row.original.person.id)?.overall_average; | 123 | const average = marksOf(cell.row.original.person.id)?.overall_average; |
| 119 | if (average == null) return <span class="text-sm text-muted-foreground">—</span>; | 124 | if (average == null) return <span class="text-sm text-muted-foreground">—</span>; |
| @@ -169,10 +174,6 @@ function StudentMarksContent() { | |||
| 169 | <Alert variant="destructive">{error()}</Alert> | 174 | <Alert variant="destructive">{error()}</Alert> |
| 170 | </Show> | 175 | </Show> |
| 171 | 176 | ||
| 172 | - <Show when={!listLoading() && marksCapped()}> | ||
| 173 | - <Alert role="status">{t("marks.averageCapped", { cap: MARKS_FETCH_CAP })}</Alert> | ||
| 174 | - </Show> | ||
| 175 | - | ||
| 176 | <Show when={!listLoading()} fallback={<DataTableSkeleton columns={7} rows={6} />}> | 177 | <Show when={!listLoading()} fallback={<DataTableSkeleton columns={7} rows={6} />}> |
| 177 | <DataTable | 178 | <DataTable |
| 178 | urlState | 179 | urlState |