import { useEffect } from 'react' import { Link } from 'react-router-dom' import { AnimatePresence, motion, useReducedMotion } from 'motion/react' import Brand from '@/components/brand/Brand' import Icon from '@/components/ui/Icon' import ModalDialog from '@/components/ui/ModalDialog' import { DEFAULT_SHELL } from './ShellChrome' import SidebarNav from './SidebarNav' import SignOutButton from './SignOutButton' import UserBadge from './UserBadge' import { useT } from '@/i18n/useT' export interface MobileDrawerProps { open: boolean onClose: () => void /** The sidebar's breakpoint (Tailwind `lg` or `xl`): from there the drawer has no reason * to stay open. */ closesFrom?: '64rem' | '80rem' } /** Left-side navigation drawer for small screens (transform + opacity only). */ export default function MobileDrawer({ open, onClose, closesFrom = DEFAULT_SHELL.closesFrom, }: MobileDrawerProps) { return ( {open && } ) } function DrawerSurface({ onClose, closesFrom }: Required>) { const t = useT() const reduced = useReducedMotion() const slide = reduced ? { x: 0 } : { x: '-100%' } // A modal drawer left open while the window widens would keep the page inert. useEffect(() => { const query = window.matchMedia(`(min-width: ${closesFrom})`) if (query.matches) onClose() const onChange = (event: MediaQueryListEvent) => event.matches && onClose() query.addEventListener('change', onChange) return () => query.removeEventListener('change', onChange) }, [onClose, closesFrom]) return (
) }