🎨 extract tab-panel-header and tab-panel-note utility classes
Browse files at this commit58e7f7f1e65792080770d5bc95845a7293ca5d1cParent: 2dc41bb- style
- 🎨 extract tab-panel-header and tab-panel-note utility classes
5 changed files +28 -16
- src/components/ui/data-table.tsx +7 -3
- src/index.css +8 -0
- src/pages/course-detail-page.tsx +5 -5
- src/pages/event-detail-page.tsx +3 -3
- src/pages/exam-detail-page.tsx +5 -5
src/components/ui/data-table.tsxmodified+7 -3
| @@ -126,7 +126,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 126 | 126 | if (props.manualPagination) props.manualPagination.onPageChange(next); |
| 127 | 127 | else table.setPageIndex(next); |
| 128 | 128 | }; |
| 129 | - const isInteractiveTarget = (target: EventTarget | null) => target instanceof Element && target.closest("button,a,input,select,textarea,[role='button']") != null; | |
| 129 | + const isInteractiveTarget = (target: EventTarget | null, row: EventTarget | null) => { | |
| 130 | + if (!(target instanceof Element)) return false; | |
| 131 | + const interactive = target.closest("button,a,input,select,textarea,[role='button']"); | |
| 132 | + return interactive != null && interactive !== row; | |
| 133 | + }; | |
| 130 | 134 | const renderHeader = (header: ReturnType<typeof table.getHeaderGroups>[number]["headers"][number]) => { |
| 131 | 135 | const content = flexRender(header.column.columnDef.header, header.getContext()); |
| 132 | 136 | if (!(props.enableSorting ?? true) || !header.column.getCanSort()) return content; |
| @@ -227,11 +231,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | ||
| 227 | 231 | props.onRowClick && "cursor-pointer outline-none focus-visible:bg-primary/[0.06] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:bg-primary/[0.08]", |
| 228 | 232 | )} |
| 229 | 233 | onClick={(event) => { |
| 230 | - if (!props.onRowClick || isInteractiveTarget(event.target)) return; | |
| 234 | + if (!props.onRowClick || isInteractiveTarget(event.target, event.currentTarget)) return; | |
| 231 | 235 | props.onRowClick(row.original); |
| 232 | 236 | }} |
| 233 | 237 | onKeyDown={(event) => { |
| 234 | - if (!props.onRowClick || isInteractiveTarget(event.target) || (event.key !== "Enter" && event.key !== " ")) return; | |
| 238 | + if (!props.onRowClick || isInteractiveTarget(event.target, event.currentTarget) || (event.key !== "Enter" && event.key !== " ")) return; | |
| 235 | 239 | event.preventDefault(); |
| 236 | 240 | props.onRowClick(row.original); |
| 237 | 241 | }} |
src/index.cssmodified+8 -0
| @@ -220,6 +220,14 @@ | ||
| 220 | 220 | @apply flex flex-1 items-center gap-1.5 border-t border-border pt-1.5 sm:ml-1 sm:flex-none sm:border-l sm:border-t-0 sm:pl-1.5 sm:pt-0; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | + .tab-panel-header { | |
| 224 | + @apply flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-border/60 bg-muted/20 px-3 py-2; | |
| 225 | + } | |
| 226 | + | |
| 227 | + .tab-panel-note { | |
| 228 | + @apply rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-sm text-muted-foreground; | |
| 229 | + } | |
| 230 | + | |
| 223 | 231 | .detail-metric-card { |
| 224 | 232 | @apply relative overflow-hidden rounded-xl border border-black/[0.05] dark:border-white/[0.06] bg-muted/30 p-4 shadow-sm; |
| 225 | 233 | } |
src/pages/course-detail-page.tsxmodified+5 -5
| @@ -567,7 +567,7 @@ function CourseDetailContent() { | ||
| 567 | 567 | |
| 568 | 568 | <Show when={hasCourseManagementRights()}> |
| 569 | 569 | <TabsContent value="teachers" forceMount class="space-y-4"> |
| 570 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 570 | + <div class="tab-panel-header"> | |
| 571 | 571 | <p class="text-sm text-muted-foreground">{countDescription((c().teachers ?? []).length, t("courses.teachers"))}</p> |
| 572 | 572 | <Show when={canStaffCourse()}> |
| 573 | 573 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowTeacherForm(true)}> |
| @@ -581,7 +581,7 @@ function CourseDetailContent() { | ||
| 581 | 581 | </Show> |
| 582 | 582 | |
| 583 | 583 | <TabsContent value="subjects" forceMount class="space-y-4"> |
| 584 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 584 | + <div class="tab-panel-header"> | |
| 585 | 585 | <p class="text-sm text-muted-foreground">{countDescription(subjectCount(), t("subjects.item"))}</p> |
| 586 | 586 | <Show when={canManage()}> |
| 587 | 587 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowSubjectForm(true)}> |
| @@ -594,7 +594,7 @@ function CourseDetailContent() { | ||
| 594 | 594 | </TabsContent> |
| 595 | 595 | |
| 596 | 596 | <TabsContent value="exams" forceMount class="space-y-4"> |
| 597 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 597 | + <div class="tab-panel-header"> | |
| 598 | 598 | <p class="text-sm text-muted-foreground">{countDescription(examCount(), t("courses.examItem"))}</p> |
| 599 | 599 | <Show when={canManage()}> |
| 600 | 600 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowExamForm(true)}> |
| @@ -609,7 +609,7 @@ function CourseDetailContent() { | ||
| 609 | 609 | </TabsContent> |
| 610 | 610 | |
| 611 | 611 | <TabsContent value="sessions" forceMount class="space-y-4"> |
| 612 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 612 | + <div class="tab-panel-header"> | |
| 613 | 613 | <p class="text-sm text-muted-foreground">{countDescription(sessionCount(), t("sessions.item"))}</p> |
| 614 | 614 | <Show when={canManage()}> |
| 615 | 615 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowSessionForm(true)}> |
| @@ -623,7 +623,7 @@ function CourseDetailContent() { | ||
| 623 | 623 | |
| 624 | 624 | <Show when={hasCourseManagementRights()}> |
| 625 | 625 | <TabsContent value="roster" forceMount class="space-y-4"> |
| 626 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 626 | + <div class="tab-panel-header"> | |
| 627 | 627 | <p class="text-sm text-muted-foreground">{countDescription(rosterCount(), t("courses.rosterItem"))}</p> |
| 628 | 628 | <Show when={canManage()}> |
| 629 | 629 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowEnrollPanel(true)}> |
src/pages/event-detail-page.tsxmodified+3 -3
| @@ -281,7 +281,7 @@ function EventDetailContent() { | ||
| 281 | 281 | |
| 282 | 282 | <Show when={ev().audience.kind === "registration"}> |
| 283 | 283 | <TabsContent value="registration" forceMount class="space-y-3"> |
| 284 | - <p class="text-sm text-muted-foreground">{t("events.registrationRosterHelp")}</p> | |
| 284 | + <p class="tab-panel-note">{t("events.registrationRosterHelp")}</p> | |
| 285 | 285 | <div class="grid gap-3 rounded-lg border bg-muted/20 p-3 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end"> |
| 286 | 286 | <UserSearchSelect id="registration-user" label={t("events.attendee")} value={registrationUserId()} placeholder={t("events.selectAttendee")} emptyMessage={t("events.noAttendees")} role="student" onChange={setRegistrationUserId} /> |
| 287 | 287 | <Button |
| @@ -317,7 +317,7 @@ function EventDetailContent() { | ||
| 317 | 317 | </Show> |
| 318 | 318 | |
| 319 | 319 | <TabsContent value="studentAttendance" forceMount class="space-y-3"> |
| 320 | - <p class="text-sm text-muted-foreground">{t("events.studentAttendanceHelp")}</p> | |
| 320 | + <p class="tab-panel-note">{t("events.studentAttendanceHelp")}</p> | |
| 321 | 321 | <div class="grid gap-3"> |
| 322 | 322 | <UserSearchSelect id="other-user" label={t("events.attendee")} value={otherUserId()} placeholder={t("events.selectAttendee")} emptyMessage={t("events.noAttendees")} role="student" onChange={setOtherUserId} /> |
| 323 | 323 | <AttendanceStatusPicker id="other-status" value={status()} onChange={setStatus} label={t("events.status")} /> |
| @@ -344,7 +344,7 @@ function EventDetailContent() { | ||
| 344 | 344 | </TabsContent> |
| 345 | 345 | |
| 346 | 346 | <TabsContent value="attendanceRecords" forceMount class="space-y-3"> |
| 347 | - <p class="text-sm text-muted-foreground">{t("events.attendanceRecordsHelp")}</p> | |
| 347 | + <p class="tab-panel-note">{t("events.attendanceRecordsHelp")}</p> | |
| 348 | 348 | <Suspense fallback={<PageSpinner />}> |
| 349 | 349 | <Show when={attendance()}> |
| 350 | 350 | {(rows) => ( |
src/pages/exam-detail-page.tsxmodified+5 -5
| @@ -584,7 +584,7 @@ function ExamDetailContent() { | ||
| 584 | 584 | </TabsList> |
| 585 | 585 | |
| 586 | 586 | <TabsContent value="schedule" forceMount> |
| 587 | - <div class="mb-4 text-sm text-muted-foreground">{t("exams.details")}</div> | |
| 587 | + <div class="tab-panel-note mb-4">{t("exams.details")}</div> | |
| 588 | 588 | <div class="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-4"> |
| 589 | 589 | <div class="detail-metric-card"> |
| 590 | 590 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.mode")}</p> |
| @@ -607,7 +607,7 @@ function ExamDetailContent() { | ||
| 607 | 607 | |
| 608 | 608 | <Show when={isStudent() && !isScheduled()}> |
| 609 | 609 | <TabsContent value="ownResult" forceMount> |
| 610 | - <div class="mb-4 text-sm text-muted-foreground">{ownResult() ? `${t("form.mark")}: ${ownResult()!.mark}` : t("exams.notGraded")}</div> | |
| 610 | + <div class="tab-panel-note mb-4">{ownResult() ? `${t("form.mark")}: ${ownResult()!.mark}` : t("exams.notGraded")}</div> | |
| 611 | 611 | <Suspense fallback={<PageSpinner />}> |
| 612 | 612 | <Show when={ownResult()} fallback={<ExamResultBadge notGraded />}> |
| 613 | 613 | {(r) => <ExamResultBadge mark={r().mark} />} |
| @@ -618,7 +618,7 @@ function ExamDetailContent() { | ||
| 618 | 618 | |
| 619 | 619 | <Show when={hasCourseManagementRights()}> |
| 620 | 620 | <TabsContent value="statistics" forceMount> |
| 621 | - <div class="mb-4 text-sm text-muted-foreground">{t("exams.examStatistics")}</div> | |
| 621 | + <div class="tab-panel-note mb-4">{t("exams.examStatistics")}</div> | |
| 622 | 622 | <Suspense fallback={<PageSpinner />}> |
| 623 | 623 | <Show when={stats()}> |
| 624 | 624 | {(s) => ( |
| @@ -646,7 +646,7 @@ function ExamDetailContent() { | ||
| 646 | 646 | </TabsContent> |
| 647 | 647 | |
| 648 | 648 | <TabsContent value="questions" forceMount class="space-y-4"> |
| 649 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 649 | + <div class="tab-panel-header"> | |
| 650 | 650 | <p class="text-sm text-muted-foreground">{t("exams.examQuestions")}</p> |
| 651 | 651 | <Show when={hasCourseManagementRights() && !isFinished()}> |
| 652 | 652 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => { setExamTab("questions"); setQuestionCreateOpen(true); }}> |
| @@ -679,7 +679,7 @@ function ExamDetailContent() { | ||
| 679 | 679 | </SidePanel> |
| 680 | 680 | |
| 681 | 681 | <TabsContent value="results" forceMount class="space-y-4"> |
| 682 | - <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 682 | + <div class="tab-panel-header"> | |
| 683 | 683 | <p class="text-sm text-muted-foreground">{`${resultTotal()} ${t("exams.studentResults")}`}</p> |
| 684 | 684 | <Button type="button" variant="outline" size="sm" class="rounded-lg" disabled={isDraft()} onClick={() => setGradeOpen(true)}> |
| 685 | 685 | <IconEdit class="h-4 w-4" /> |