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,21 +1,39 @@
|
||||
import { useLocation } from '@tanstack/react-router'
|
||||
import type { ReactNode } from 'react'
|
||||
import { ImmersiveBarHost, ImmersiveBarProvider } from '../../context/ImmersiveBarProvider'
|
||||
import { isImmersiveRoute } from '../../lib/immersive-routes'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { Header } from './Header'
|
||||
import { Sidebar } from './Sidebar'
|
||||
import { BottomNav } from './BottomNav'
|
||||
|
||||
export function RootLayout({ children }: { children: ReactNode }) {
|
||||
const immersive = useLocation({ select: (location) => isImmersiveRoute(location.pathname) })
|
||||
|
||||
return (
|
||||
<div className="min-h-dvh w-full">
|
||||
<Header />
|
||||
{/* En las rutas immersive la pantalla trae su propia barra (LargeTitle),
|
||||
con el logo y el nombre del grupo: el header global con logo + tema +
|
||||
avatar sería una segunda barra compitiendo por los mismos píxeles. */}
|
||||
{immersive ? null : <Header />}
|
||||
|
||||
<div className="mx-auto flex w-full max-w-7xl gap-6 lg:px-6">
|
||||
<Sidebar />
|
||||
<Sidebar immersive={immersive} />
|
||||
|
||||
{/* pb-24 deja lugar para la BottomNav; en iOS standalone hay que sumar
|
||||
el inset del home indicator o el contenido queda debajo. */}
|
||||
<main className="min-w-0 flex-1 px-4 pb-[calc(6rem+env(safe-area-inset-bottom))] pt-4 lg:px-0 lg:pb-8 lg:pt-8">
|
||||
{children}
|
||||
</main>
|
||||
<ImmersiveBarProvider>
|
||||
{/* pt-0 en immersive: el padding superior lo aporta la caja de la
|
||||
barra, y si no el título grande arrancaría 16px más abajo de la
|
||||
base de la barra y el colapso se mediría corrido. */}
|
||||
<main
|
||||
className={cn(
|
||||
'min-w-0 flex-1 px-4 pb-[calc(6rem+env(safe-area-inset-bottom))] lg:px-0 lg:pb-8',
|
||||
immersive ? 'pt-0' : 'pt-4 lg:pt-8',
|
||||
)}
|
||||
>
|
||||
{immersive ? <ImmersiveBarHost /> : null}
|
||||
{children}
|
||||
</main>
|
||||
</ImmersiveBarProvider>
|
||||
</div>
|
||||
|
||||
<BottomNav />
|
||||
|
||||
Reference in New Issue
Block a user