diff --git a/src/components/courses/offering-panel.tsx b/src/components/courses/offering-panel.tsx index 9e58428..29e966f 100644 --- a/src/components/courses/offering-panel.tsx +++ b/src/components/courses/offering-panel.tsx @@ -19,6 +19,7 @@ import { GradeLevelSelect } from "@/components/classes/grade-level-select"; import { ExamWeightsEditor } from "@/components/instances/exam-weights-editor"; import { SubjectSetEditor } from "@/components/instances/subject-set-editor"; import { WeeklyPlanTable } from "@/components/instances/weekly-plan-table"; +import { InfoTip } from "@/components/ui/info-tip"; import { WeeklySlotForm } from "@/components/instances/weekly-slot-form"; import { Alert } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; @@ -184,9 +185,9 @@ export function OfferingPanel(props: { {sectionError()}
-
+

{t("instances.subjectsTitle")}

-

{t("offerings.subjectsHelp")}

+
-
+

{t("weeklyPlan.title")}

-

{t("offerings.weeklyPlanHelp")}

+
); + return ( + + + {sortButton()} + {headerInfoTip(header.column)} + + + ); }; return ( @@ -468,7 +497,7 @@ export function DataTable(props: DataTableProps{emptyContent()}} > - {(row) => { + {(row, rowIndex) => { const cells = () => row.getVisibleCells().filter((cell) => cell.column.id !== "select" && !cell.column.columnDef.meta?.hideInCards); const action = () => cells().find((cell) => cell.column.id === "actions"); @@ -516,7 +545,12 @@ export function DataTable(props: DataTableProps {(cell) => (
-
{headerLabel(cell.column.id)}
+ {/* A column note shows on the first card only: once + per list, like the table header it stands in for. */} +
+ {headerLabel(cell.column.id)} + {headerInfoTip(cell.column)} +
{flexRender(cell.column.columnDef.cell, cell.getContext())}
diff --git a/src/components/ui/icons.tsx b/src/components/ui/icons.tsx index 9388d0d..48c894b 100644 --- a/src/components/ui/icons.tsx +++ b/src/components/ui/icons.tsx @@ -34,6 +34,7 @@ import gearUrl from "@phosphor-icons/core/regular/gear.svg?url"; import userCircleUrl from "@phosphor-icons/core/regular/user-circle.svg?url"; import graduationCapUrl from "@phosphor-icons/core/regular/graduation-cap.svg?url"; import houseUrl from "@phosphor-icons/core/regular/house.svg?url"; +import infoUrl from "@phosphor-icons/core/regular/info.svg?url"; import listUrl from "@phosphor-icons/core/regular/list.svg?url"; import lockSimpleUrl from "@phosphor-icons/core/regular/lock-simple.svg?url"; import magnifyingGlassUrl from "@phosphor-icons/core/regular/magnifying-glass.svg?url"; @@ -353,6 +354,11 @@ export function IconHelpCircle(props: IconProps) { return ; } +/** A circled "i": opens an explanatory note (see `InfoTip`). */ +export function IconInfo(props: IconProps) { + return ; +} + export function IconMessagePlus(props: IconProps) { return ( diff --git a/src/components/ui/info-tip.tsx b/src/components/ui/info-tip.tsx new file mode 100644 index 0000000..ed1c083 --- /dev/null +++ b/src/components/ui/info-tip.tsx @@ -0,0 +1,73 @@ +import { createSignal } from "solid-js"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; +import { IconInfo } from "@/components/ui/icons"; +import { cn } from "@/lib/cn"; +import { useT } from "@/stores/preferences-context"; + +/** + * A circled "i" that reveals an explanatory note — for a line that explains a + * column or a table and would otherwise sit on screen all the time. + * + * Hover and keyboard focus open it like a tooltip; a click or a tap pins it + * open (a tooltip alone never opens on touch), and a second click, Escape, a + * tap elsewhere or moving focus away closes it again. + */ +export function InfoTip(props: { + text: string; + /** Accessible name of the button; defaults to "Bilgi" / "More info". */ + label?: string; + class?: string; +}) { + const t = useT(); + let trigger: HTMLButtonElement | undefined; + const [hoverOpen, setHoverOpen] = createSignal(false); + const [pinned, setPinned] = createSignal(false); + return ( + + { + // Never reach a sortable header or a clickable row around it. + event.stopPropagation(); + setPinned((value) => !value); + }} + onKeyDown={(event: KeyboardEvent) => { + if (event.key === "Enter" || event.key === " ") event.stopPropagation(); + }} + onBlur={() => setPinned(false)} + > + + + setPinned(false)} + onPointerDownOutside={(event) => { + // A tap on the icon itself is its own toggle, not "outside". + const target = event.detail.originalEvent.target as Node | null; + if (trigger && target && trigger.contains(target)) return; + setPinned(false); + }} + > + {props.text} + + + ); +} diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index ada2f39..3594455 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -696,6 +696,8 @@ export const en: Dict = { "common.pagination": "Pagination", "common.noResults": "No results.", "common.scrollHint": "Scroll horizontally", + "common.info": "More info", + "common.infoAbout": "About {item}", "common.noMatches": "Nothing matches your search.", "common.noMatchesFor": "No results for “{query}”.", "common.noFilterMatches": "Nothing matches the selected filters.", diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index 2bfa817..7f84af7 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -692,6 +692,8 @@ export const tr: Dict = { "common.pagination": "Sayfalar", "common.noResults": "Sonuç yok.", "common.scrollHint": "Yatay kaydır", + "common.info": "Bilgi", + "common.infoAbout": "{item} hakkında bilgi", "common.noMatches": "Aramanızla eşleşen kayıt yok.", "common.noMatchesFor": "“{query}” için sonuç yok.", "common.noFilterMatches": "Seçili filtrelerle eşleşen kayıt yok.", diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 082fff4..f33337c 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -680,6 +680,8 @@ export type MessageKey = | "common.pagination" | "common.noResults" | "common.scrollHint" + | "common.info" + | "common.infoAbout" | "common.noMatches" | "common.noMatchesFor" | "common.noFilterMatches" diff --git a/src/pages/classes-page.tsx b/src/pages/classes-page.tsx index b1aac2f..2d89f84 100644 --- a/src/pages/classes-page.tsx +++ b/src/pages/classes-page.tsx @@ -95,7 +95,8 @@ function ClassesContent() { }); return new Map(entries); }); - const memberCountsCapped = () => listData().length > MEMBER_COUNT_FETCH_CAP; + // A memo: the columns read it, and must not rebuild on every list refetch. + const memberCountsCapped = createMemo(() => listData().length > MEMBER_COUNT_FETCH_CAP); // Class by class (9-A, 9-B, 10-A…) until a column header re-sorts it. const gradeFiltered = createMemo(() => { @@ -186,9 +187,15 @@ function ClassesContent() { id: "students", accessorFn: (row) => memberCounts()?.get(row.id) ?? -1, header: t("nav.studentsRoster"), - size: 110, - minSize: 90, - meta: { cellClass: "whitespace-nowrap text-center", align: "center" }, + size: 130, + minSize: 100, + // Why counts stop past the cap — behind the header's "i" rather than a + // notice kept above the table. + meta: { + cellClass: "whitespace-nowrap text-center", + align: "center", + headerInfo: memberCountsCapped() ? t("classGroups.memberCountCapped", { cap: MEMBER_COUNT_FETCH_CAP }) : undefined, + }, cell: (cell) => { const count = memberCounts()?.get(cell.row.original.id); return count == null ? — : t("classGroups.studentsCount", { count: String(count) }); @@ -376,10 +383,6 @@ function ClassesContent() {
- - {t("classGroups.memberCountCapped", { cap: MEMBER_COUNT_FETCH_CAP })} - - }> -

{t("events.studentAttendanceHelp")}

}> @@ -332,6 +331,7 @@ function EventDetailContent() { roster={rows()} open={rollCallOpen()} closedReason={t("events.rollCall.opensAt", { date: formatDateTime(ev().starts_at, locale()) })} + help={t("events.studentAttendanceHelp")} onSaved={() => Promise.all([refetchRoster(), refetchAttendance()])} /> )} @@ -344,11 +344,9 @@ function EventDetailContent() { {(rows) => (
-
- {t("events.attendanceRecordsHelp")} -
{ diff --git a/src/pages/student-marks-page.tsx b/src/pages/student-marks-page.tsx index 2ff3e6b..84a2a96 100644 --- a/src/pages/student-marks-page.tsx +++ b/src/pages/student-marks-page.tsx @@ -71,7 +71,8 @@ function StudentMarksContent() { return Object.fromEntries(pairs) as Record; }, ); - const marksCapped = () => list().length > MARKS_FETCH_CAP; + // A memo: the columns read it, and must not rebuild on every list refetch. + const marksCapped = createMemo(() => !list.loading && (list() ?? []).length > MARKS_FETCH_CAP); const marksOf = (id: string) => marksMapRes()?.[id]; const examCountOf = (id: string) => { const rep = marksOf(id); @@ -113,7 +114,11 @@ function StudentMarksContent() { id: "average", header: t("marks.overall"), accessorFn: (row) => marksOf(row.person.id)?.overall_average ?? -1, - meta: { align: "right" }, + // Room for the label, the sort arrow and the info icon on one line. + size: 160, + // Why the column is blank on a large school — behind the header's "i" + // rather than a notice kept above the table. + meta: { align: "right", headerInfo: marksCapped() ? t("marks.averageCapped", { cap: MARKS_FETCH_CAP }) : undefined }, cell: (cell) => { const average = marksOf(cell.row.original.person.id)?.overall_average; if (average == null) return —; @@ -169,10 +174,6 @@ function StudentMarksContent() { {error()} - - {t("marks.averageCapped", { cap: MARKS_FETCH_CAP })} - - }>