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:
33
apps/web/src/lib/immersive-routes.ts
Normal file
33
apps/web/src/lib/immersive-routes.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Rutas "immersive": las que arman su propia barra de navegación con
|
||||
`LargeTitle` (título grande que colapsa) y por eso no muestran el header
|
||||
global con logo + toggle de tema + avatar.
|
||||
|
||||
El patrón se resuelve a mano y no con `matchRoute` porque las dos rutas
|
||||
llevan parámetros (`matchRoute` los exige) y porque las rutas hijas NO son
|
||||
immersive aunque compartan prefijo: `/groups/:id/attendees/new` sigue usando
|
||||
el header global. */
|
||||
|
||||
const IMMERSIVE_SEGMENTS: ReadonlyArray<readonly string[]> = [
|
||||
['groups', ':id'],
|
||||
['groups', ':id', 'analytics'],
|
||||
['class', ':id', 'attendance'],
|
||||
]
|
||||
|
||||
/* Rutas estáticas que ocupan el lugar de un parámetro. Sin esta lista
|
||||
`/groups/new` (crear grupo) se tomaría por una ficha de grupo y perdería el
|
||||
header global. */
|
||||
const STATIC_SEGMENTS: ReadonlySet<string> = new Set(['new'])
|
||||
|
||||
export function isImmersiveRoute(pathname: string) {
|
||||
const segments = pathname.split('/').filter(Boolean)
|
||||
|
||||
return IMMERSIVE_SEGMENTS.some(
|
||||
(pattern) =>
|
||||
pattern.length === segments.length &&
|
||||
pattern.every((part, index) => {
|
||||
const segment = segments[index]
|
||||
if (part.startsWith(':')) return !STATIC_SEGMENTS.has(segment)
|
||||
return part === segment
|
||||
}),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user