feat(ST-1134): LandscapeGuard component (T-319)
Toont rotate-overlay in portrait, niets in landscape. Kinderen blijven altijd in DOM — geen unmount zodat SSE-streams overleven bij rotatie. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bdd8c1e53a
commit
e68552bcfd
2 changed files with 105 additions and 0 deletions
32
components/mobile/landscape-guard.tsx
Normal file
32
components/mobile/landscape-guard.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { RotateCw } from 'lucide-react'
|
||||
|
||||
export function LandscapeGuard({ children }: { children: React.ReactNode }) {
|
||||
const [isPortrait, setIsPortrait] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia('(orientation: portrait)')
|
||||
const update = () => setIsPortrait(mq.matches)
|
||||
update()
|
||||
mq.addEventListener('change', update)
|
||||
return () => mq.removeEventListener('change', update)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
{isPortrait && (
|
||||
<div
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
className="fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-background text-foreground p-6"
|
||||
>
|
||||
<RotateCw className="size-12 text-primary" />
|
||||
<p className="text-base font-medium text-center">Draai je telefoon naar landscape</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue