♻️ replace PageSpinner table fallbacks with DataTableSkeleton
Browse files at this commit7ac6d45df16a4e284d7d613a4f8bd734a2c46fb8Parent: 58e7f7f- refactor
- ♻️ replace PageSpinner table fallbacks with DataTableSkeleton
7 changed files +32 -21
- src/components/layout/app-shell.tsx +2 -2
- src/components/layout/side-nav.tsx +7 -7
- src/components/layout/sidebar-account.tsx +2 -2
- src/components/ui/data-table.tsx +13 -2
- src/pages/course-detail-page.tsx +3 -3
- src/pages/event-detail-page.tsx +3 -3
- src/pages/exam-detail-page.tsx +2 -2
src/components/layout/app-shell.tsxmodified+2 -2
| @@ -13,7 +13,7 @@ import { useAuth } from "@/stores/auth-context"; | |||
| 13 | import { usePreferences, useT } from "@/stores/preferences-context"; | 13 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 14 | import { cn } from "@/lib/cn"; | 14 | import { cn } from "@/lib/cn"; |
| 15 | 15 | ||
| 16 | -const SIDEBAR_EXPANDED = "w-56"; | 16 | +const SIDEBAR_EXPANDED = "w-56 2xl:w-64"; |
| 17 | const SIDEBAR_COLLAPSED = "w-16"; | 17 | const SIDEBAR_COLLAPSED = "w-16"; |
| 18 | 18 | ||
| 19 | export function AppShell(props: ParentProps) { | 19 | export function AppShell(props: ParentProps) { |
| @@ -88,7 +88,7 @@ export function AppShell(props: ParentProps) { | |||
| 88 | H | 88 | H |
| 89 | </span> | 89 | </span> |
| 90 | <Show when={!collapsed()}> | 90 | <Show when={!collapsed()}> |
| 91 | - <span class="truncate font-display text-base font-semibold tracking-tight text-foreground">{t("app.name")}</span> | 91 | + <span class="truncate font-display text-base font-semibold tracking-tight text-foreground 2xl:text-lg">{t("app.name")}</span> |
| 92 | </Show> | 92 | </Show> |
| 93 | </Link> | 93 | </Link> |
| 94 | <Button | 94 | <Button |
src/components/layout/side-nav.tsxmodified+7 -7
| @@ -172,8 +172,8 @@ function NavLink(props: { | |||
| 172 | title={t(props.item.labelKey)} | 172 | title={t(props.item.labelKey)} |
| 173 | aria-current={active() ? "page" : undefined} | 173 | aria-current={active() ? "page" : undefined} |
| 174 | class={cn( | 174 | class={cn( |
| 175 | - "relative flex h-9 w-full items-center rounded-xl outline-none transition-all duration-200 ease-out active:scale-[0.97]", | 175 | + "relative flex h-9 w-full items-center rounded-xl outline-none transition-all duration-200 ease-out active:scale-[0.97] 2xl:h-10", |
| 176 | - props.standalone ? "text-xs font-semibold" : "text-[13px] font-medium", | 176 | + props.standalone ? "text-xs font-semibold 2xl:text-[13px]" : "text-[13px] font-medium 2xl:text-sm", |
| 177 | props.collapsed ? "justify-center px-0 h-10 w-10 mx-auto" : props.standalone ? "gap-2.5 px-3" : "gap-2.5 pl-8 pr-3", | 177 | props.collapsed ? "justify-center px-0 h-10 w-10 mx-auto" : props.standalone ? "gap-2.5 px-3" : "gap-2.5 pl-8 pr-3", |
| 178 | active() | 178 | active() |
| 179 | ? "bg-primary/12 text-primary font-semibold shadow-[inset_0_0_0_1px_hsl(var(--primary)/0.14),0_1px_6px_hsl(var(--primary)/0.08)]" | 179 | ? "bg-primary/12 text-primary font-semibold shadow-[inset_0_0_0_1px_hsl(var(--primary)/0.14),0_1px_6px_hsl(var(--primary)/0.08)]" |
| @@ -183,7 +183,7 @@ function NavLink(props: { | |||
| 183 | <Show when={active() && !props.collapsed}> | 183 | <Show when={active() && !props.collapsed}> |
| 184 | <span class="absolute left-1 top-1/2 h-5 w-1 -translate-y-1/2 rounded-full bg-primary shadow-[0_0_10px_hsl(var(--primary)/0.35)]" /> | 184 | <span class="absolute left-1 top-1/2 h-5 w-1 -translate-y-1/2 rounded-full bg-primary shadow-[0_0_10px_hsl(var(--primary)/0.35)]" /> |
| 185 | </Show> | 185 | </Show> |
| 186 | - <props.item.Icon class={cn("h-4 w-4 shrink-0 transition-colors", active() ? "text-primary" : "text-muted-foreground")} /> | 186 | + <props.item.Icon class={cn("h-4 w-4 shrink-0 transition-colors 2xl:h-[18px] 2xl:w-[18px]", active() ? "text-primary" : "text-muted-foreground")} /> |
| 187 | <span class={cn("truncate", props.collapsed ? "sr-only" : "block min-w-0 flex-1 text-left")}>{t(props.item.labelKey)}</span> | 187 | <span class={cn("truncate", props.collapsed ? "sr-only" : "block min-w-0 flex-1 text-left")}>{t(props.item.labelKey)}</span> |
| 188 | </Link> | 188 | </Link> |
| 189 | ); | 189 | ); |
| @@ -260,7 +260,7 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 260 | > | 260 | > |
| 261 | <div class="flex items-center gap-2 px-2 pb-1 pt-3"> | 261 | <div class="flex items-center gap-2 px-2 pb-1 pt-3"> |
| 262 | <span class="h-px flex-1 bg-border" /> | 262 | <span class="h-px flex-1 bg-border" /> |
| 263 | - <span class="text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground"> | 263 | + <span class="text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground 2xl:text-[11px]"> |
| 264 | {t("nav.admin")} | 264 | {t("nav.admin")} |
| 265 | </span> | 265 | </span> |
| 266 | <span class="h-px flex-1 bg-border" /> | 266 | <span class="h-px flex-1 bg-border" /> |
| @@ -275,16 +275,16 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 275 | <button | 275 | <button |
| 276 | type="button" | 276 | type="button" |
| 277 | class={cn( | 277 | class={cn( |
| 278 | - "flex h-8 w-full items-center gap-2 rounded-lg px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground", | 278 | + "flex h-8 w-full items-center gap-2 rounded-lg px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground 2xl:h-9 2xl:text-xs", |
| 279 | groupActive() ? "bg-primary/[0.06] text-foreground" : open() && "text-foreground", | 279 | groupActive() ? "bg-primary/[0.06] text-foreground" : open() && "text-foreground", |
| 280 | )} | 280 | )} |
| 281 | title={t(group.labelKey)} | 281 | title={t(group.labelKey)} |
| 282 | aria-expanded={open()} | 282 | aria-expanded={open()} |
| 283 | onClick={() => toggleGroup(group.id)} | 283 | onClick={() => toggleGroup(group.id)} |
| 284 | > | 284 | > |
| 285 | - <group.Icon class="h-3.5 w-3.5" /> | 285 | + <group.Icon class="h-3.5 w-3.5 2xl:h-4 2xl:w-4" /> |
| 286 | <span class="min-w-0 flex-1 truncate text-left">{t(group.labelKey)}</span> | 286 | <span class="min-w-0 flex-1 truncate text-left">{t(group.labelKey)}</span> |
| 287 | - <IconChevronRight class={cn("h-3.5 w-3.5 transition-transform duration-150", open() && "rotate-90")} /> | 287 | + <IconChevronRight class={cn("h-3.5 w-3.5 transition-transform duration-150 2xl:h-4 2xl:w-4", open() && "rotate-90")} /> |
| 288 | </button> | 288 | </button> |
| 289 | <Show when={open()}> | 289 | <Show when={open()}> |
| 290 | <div class="mt-1 grid gap-0.5 overflow-hidden transition-all duration-150"> | 290 | <div class="mt-1 grid gap-0.5 overflow-hidden transition-all duration-150"> |
src/components/layout/sidebar-account.tsxmodified+2 -2
| @@ -61,8 +61,8 @@ export function SidebarAccount(props: { collapsed?: boolean; onLogout: () => voi | |||
| 61 | </span> | 61 | </span> |
| 62 | <Show when={!props.collapsed}> | 62 | <Show when={!props.collapsed}> |
| 63 | <span class="min-w-0 flex-1"> | 63 | <span class="min-w-0 flex-1"> |
| 64 | - <span class="block truncate text-[13px] font-semibold leading-4">{name()}</span> | 64 | + <span class="block truncate text-[13px] font-semibold leading-4 2xl:text-sm">{name()}</span> |
| 65 | - <span class="block truncate text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground"> | 65 | + <span class="block truncate text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground 2xl:text-[11px]"> |
| 66 | {t(`role.${u().role}` as MessageKey)} | 66 | {t(`role.${u().role}` as MessageKey)} |
| 67 | </span> | 67 | </span> |
| 68 | </span> | 68 | </span> |
src/components/ui/data-table.tsxmodified+13 -2
| @@ -287,8 +287,19 @@ export function DataTableSkeleton(props: { rows?: number; columns?: number }) { | |||
| 287 | const rows = () => Array.from({ length: props.rows ?? 6 }); | 287 | const rows = () => Array.from({ length: props.rows ?? 6 }); |
| 288 | const columns = () => Array.from({ length: props.columns ?? 5 }); | 288 | const columns = () => Array.from({ length: props.columns ?? 5 }); |
| 289 | return ( | 289 | return ( |
| 290 | - <DataTableFrame> | 290 | + <DataTableFrame class="animate-pulse"> |
| 291 | <table class="data-table"> | 291 | <table class="data-table"> |
| 292 | + <thead> | ||
| 293 | + <tr> | ||
| 294 | + <For each={columns()}> | ||
| 295 | + {() => ( | ||
| 296 | + <th> | ||
| 297 | + <div class="h-2.5 w-20 rounded-full bg-muted" /> | ||
| 298 | + </th> | ||
| 299 | + )} | ||
| 300 | + </For> | ||
| 301 | + </tr> | ||
| 302 | + </thead> | ||
| 292 | <tbody> | 303 | <tbody> |
| 293 | <For each={rows()}> | 304 | <For each={rows()}> |
| 294 | {() => ( | 305 | {() => ( |
| @@ -296,7 +307,7 @@ export function DataTableSkeleton(props: { rows?: number; columns?: number }) { | |||
| 296 | <For each={columns()}> | 307 | <For each={columns()}> |
| 297 | {() => ( | 308 | {() => ( |
| 298 | <td> | 309 | <td> |
| 299 | - <div class="h-3 w-full max-w-32 animate-pulse rounded-sm bg-muted" /> | 310 | + <div class="h-3 w-full max-w-32 rounded-full bg-muted/80" /> |
| 300 | </td> | 311 | </td> |
| 301 | )} | 312 | )} |
| 302 | </For> | 313 | </For> |
src/pages/course-detail-page.tsxmodified+3 -3
| @@ -27,7 +27,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 27 | import { Badge } from "@/components/ui/badge"; | 27 | import { Badge } from "@/components/ui/badge"; |
| 28 | import { Button } from "@/components/ui/button"; | 28 | import { Button } from "@/components/ui/button"; |
| 29 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 29 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 30 | -import { DataTable } from "@/components/ui/data-table"; | 30 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 31 | import { EmptyState } from "@/components/ui/empty-state"; | 31 | import { EmptyState } from "@/components/ui/empty-state"; |
| 32 | import { IconChevronLeft, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; | 32 | import { IconChevronLeft, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; |
| 33 | import { createFlash } from "@/lib/flash"; | 33 | import { createFlash } from "@/lib/flash"; |
| @@ -603,7 +603,7 @@ function CourseDetailContent() { | |||
| 603 | </Button> | 603 | </Button> |
| 604 | </Show> | 604 | </Show> |
| 605 | </div> | 605 | </div> |
| 606 | - <Suspense fallback={<PageSpinner />}> | 606 | + <Suspense fallback={<DataTableSkeleton />}> |
| 607 | <DataTable columns={examColumns()} data={exams() ?? []} filterColumn="title" enablePagination pageSize={10} empty={t("exams.empty")} onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} /> | 607 | <DataTable columns={examColumns()} data={exams() ?? []} filterColumn="title" enablePagination pageSize={10} empty={t("exams.empty")} onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} /> |
| 608 | </Suspense> | 608 | </Suspense> |
| 609 | </TabsContent> | 609 | </TabsContent> |
| @@ -632,7 +632,7 @@ function CourseDetailContent() { | |||
| 632 | </Button> | 632 | </Button> |
| 633 | </Show> | 633 | </Show> |
| 634 | </div> | 634 | </div> |
| 635 | - <Suspense fallback={<PageSpinner />}> | 635 | + <Suspense fallback={<DataTableSkeleton />}> |
| 636 | <Show when={(roster() ?? []).length > 0} fallback={<EmptyState kind="courses" title={t("exams.emptyRoster")} />}> | 636 | <Show when={(roster() ?? []).length > 0} fallback={<EmptyState kind="courses" title={t("exams.emptyRoster")} />}> |
| 637 | <DataTable columns={rosterColumns()} data={roster() ?? []} filterColumn="username" enablePagination pageSize={10} /> | 637 | <DataTable columns={rosterColumns()} data={roster() ?? []} filterColumn="username" enablePagination pageSize={10} /> |
| 638 | </Show> | 638 | </Show> |
src/pages/event-detail-page.tsxmodified+3 -3
| @@ -22,7 +22,7 @@ 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 { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 24 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 25 | -import { DataTable } from "@/components/ui/data-table"; | 25 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 26 | import { EmptyState } from "@/components/ui/empty-state"; | 26 | import { EmptyState } from "@/components/ui/empty-state"; |
| 27 | import { IconChevronLeft, IconEdit, IconTrash } from "@/components/ui/icons"; | 27 | import { IconChevronLeft, IconEdit, IconTrash } from "@/components/ui/icons"; |
| 28 | import { PageSpinner } from "@/components/ui/page-spinner"; | 28 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| @@ -304,7 +304,7 @@ function EventDetailContent() { | |||
| 304 | {t("events.registerStudent")} | 304 | {t("events.registerStudent")} |
| 305 | </Button> | 305 | </Button> |
| 306 | </div> | 306 | </div> |
| 307 | - <Suspense fallback={<PageSpinner />}> | 307 | + <Suspense fallback={<DataTableSkeleton columns={4} />}> |
| 308 | <Show when={roster()}> | 308 | <Show when={roster()}> |
| 309 | {(rows) => ( | 309 | {(rows) => ( |
| 310 | <Show when={rows().length > 0} fallback={<EmptyState kind="events" title={t("events.noRoster")} />}> | 310 | <Show when={rows().length > 0} fallback={<EmptyState kind="events" title={t("events.noRoster")} />}> |
| @@ -345,7 +345,7 @@ function EventDetailContent() { | |||
| 345 | 345 | ||
| 346 | <TabsContent value="attendanceRecords" forceMount class="space-y-3"> | 346 | <TabsContent value="attendanceRecords" forceMount class="space-y-3"> |
| 347 | <p class="tab-panel-note">{t("events.attendanceRecordsHelp")}</p> | 347 | <p class="tab-panel-note">{t("events.attendanceRecordsHelp")}</p> |
| 348 | - <Suspense fallback={<PageSpinner />}> | 348 | + <Suspense fallback={<DataTableSkeleton columns={4} />}> |
| 349 | <Show when={attendance()}> | 349 | <Show when={attendance()}> |
| 350 | {(rows) => ( | 350 | {(rows) => ( |
| 351 | <AttendanceTable | 351 | <AttendanceTable |
src/pages/exam-detail-page.tsxmodified+2 -2
| @@ -26,7 +26,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 26 | import { Badge } from "@/components/ui/badge"; | 26 | import { Badge } from "@/components/ui/badge"; |
| 27 | import { Button } from "@/components/ui/button"; | 27 | import { Button } from "@/components/ui/button"; |
| 28 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 28 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 29 | -import { DataTable } from "@/components/ui/data-table"; | 29 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 30 | import { EmptyState } from "@/components/ui/empty-state"; | 30 | import { EmptyState } from "@/components/ui/empty-state"; |
| 31 | import { IconChevronDown, IconChevronLeft, IconEdit, IconExam, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; | 31 | import { IconChevronDown, IconChevronLeft, IconEdit, IconExam, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; |
| 32 | import { Input } from "@/components/ui/input"; | 32 | import { Input } from "@/components/ui/input"; |
| @@ -619,7 +619,7 @@ function ExamDetailContent() { | |||
| 619 | <Show when={hasCourseManagementRights()}> | 619 | <Show when={hasCourseManagementRights()}> |
| 620 | <TabsContent value="statistics" forceMount> | 620 | <TabsContent value="statistics" forceMount> |
| 621 | <div class="tab-panel-note mb-4">{t("exams.examStatistics")}</div> | 621 | <div class="tab-panel-note mb-4">{t("exams.examStatistics")}</div> |
| 622 | - <Suspense fallback={<PageSpinner />}> | 622 | + <Suspense fallback={<DataTableSkeleton columns={4} />}> |
| 623 | <Show when={stats()}> | 623 | <Show when={stats()}> |
| 624 | {(s) => ( | 624 | {(s) => ( |
| 625 | <div class="grid gap-3 text-sm sm:grid-cols-4"> | 625 | <div class="grid gap-3 text-sm sm:grid-cols-4"> |