feat: implement immersive routes with Large Title component
- Added Large Title component to manage immersive screen headers. - Created ImmersiveBarProvider to handle the sticky bar for immersive routes. - Updated RootLayout to conditionally render Header based on immersive routes. - Modified Sidebar to adjust its position and height in immersive mode. - Integrated Large Title in ClassAttendanceView and AnalyticsView for consistent header display. - Updated GroupHeader to use Large Title for better layout management. - Implemented isImmersiveRoute function to determine immersive routes. - Added tests for immersive route detection.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft, Loader2 } from 'lucide-react'
|
||||
import { LargeTitle } from '../../components/layout/LargeTitle'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { useAttendance } from './AttendanceProvider'
|
||||
import { StudentRow } from './StudentRow'
|
||||
@@ -16,15 +17,43 @@ export function ClassAttendanceView() {
|
||||
isSaving,
|
||||
} = useAttendance()
|
||||
|
||||
const total = sessionInfo?.students.length ?? 0
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Link
|
||||
to="/"
|
||||
className="mb-3 hidden items-center gap-1 text-sm text-foreground/60 transition-colors hover:text-primary lg:inline-flex"
|
||||
{/* El título grande va siempre, incluso mientras carga la sesión: es lo
|
||||
que orienta y da altura de anclaje a la barra. El contador de
|
||||
presentes, en cambio, solo aparece cuando ya hay alumnos en pantalla. */}
|
||||
<LargeTitle
|
||||
title={sessionInfo?.groupName ?? 'Asistencia'}
|
||||
leading={
|
||||
<Link
|
||||
to="/"
|
||||
className="hidden shrink-0 items-center gap-1 text-sm text-foreground/80 transition-colors hover:text-primary lg:inline-flex"
|
||||
>
|
||||
<ArrowLeft className="size-4" />
|
||||
<span>Volver al inicio</span>
|
||||
</Link>
|
||||
}
|
||||
barTrailing={
|
||||
total > 0 ? (
|
||||
<Badge variant="success" className="text-[11px] tabular-nums">
|
||||
{presentCount}/{total}
|
||||
</Badge>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
<ArrowLeft className="size-4" />
|
||||
<span>Volver al inicio</span>
|
||||
</Link>
|
||||
{sessionInfo ? (
|
||||
<div className="mt-2 flex items-center justify-between gap-3">
|
||||
<p className="text-sm text-foreground/60">
|
||||
{startTime ? `Hoy · ${startTime} hs` : 'Clase de hoy'}
|
||||
</p>
|
||||
<Badge variant="success" className="shrink-0 text-xs tabular-nums">
|
||||
{presentCount}/{total} presentes
|
||||
</Badge>
|
||||
</div>
|
||||
) : null}
|
||||
</LargeTitle>
|
||||
|
||||
{studentsPending ? (
|
||||
<div className="flex items-center justify-center py-16">
|
||||
@@ -43,19 +72,7 @@ export function ClassAttendanceView() {
|
||||
|
||||
{sessionInfo ? (
|
||||
<>
|
||||
<header className="sticky top-16 z-30 -mx-4 border-b border-border bg-background/95 px-4 py-3 backdrop-blur lg:mx-0 lg:rounded-xl lg:border lg:px-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<h1 className="truncate text-lg font-bold text-primary">{sessionInfo.groupName}</h1>
|
||||
<p className="text-xs text-foreground/60">{startTime ? `Hoy · ${startTime} hs` : 'Clase de hoy'}</p>
|
||||
</div>
|
||||
<Badge variant="success" className="shrink-0 text-sm">
|
||||
{presentCount}/{sessionInfo.students.length} presentes
|
||||
</Badge>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{sessionInfo.students.length === 0 ? (
|
||||
{total === 0 ? (
|
||||
<div className="mt-6 rounded-xl border border-dashed border-border bg-surface px-4 py-10 text-center">
|
||||
<p className="text-sm font-medium text-primary">Este grupo no tiene alumnos</p>
|
||||
<p className="mt-1 text-sm text-foreground/60">
|
||||
@@ -70,7 +87,7 @@ export function ClassAttendanceView() {
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{sessionInfo.students.length > 0 ? (
|
||||
{total > 0 ? (
|
||||
<div className="sticky bottom-20 z-30 mt-6 lg:bottom-6">
|
||||
<Button
|
||||
variant="primary"
|
||||
@@ -87,4 +104,4 @@ export function ClassAttendanceView() {
|
||||
) : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user