feat(app): editor sidebar hidden below 1 280 px, menu one tap away

AC9: on the draft editor path AppLayout uses the xl class set (sidebar
from 1 280 px, menu button and brand below); other pages keep lg.
AppLayout split: Sidebar and TopBar in ShellChrome.tsx. MobileDrawer
takes closesFrom ('64rem' | '80rem') and also closes at setup when
its query already matches.

Rewritten assertions (R-24):
- shell.AppLayout "opens the mobile drawer" and shell.navigation
  "carries the same entries into the mobile drawer": stub a narrow
  matchMedia, the drawer now closes at setup at the happy-dom width.
New: unit tests (class sets, 64rem/80rem close, setup close, leave
guard on a drawer link) and editor-shell.spec F journeys (sidebar at
1024/1180/1279/1280, one-tap menu, drawer open at 1180, guard).
This commit is contained in:
bchanot committed 2026-11-08 19:25:49 +01:00
1 parent 89da8d3f55
commit 580ff28214
6 files changed
+317 -74

No files matched your search

+12 -8
View File
@@ -12,27 +12,31 @@ 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'
}
/** The sidebar's breakpoint (Tailwind `lg`): from there the drawer has no reason to stay open. */
const LARGE_SCREEN = '(min-width: 64rem)'
/** Left-side navigation drawer for small screens (transform + opacity only). */
export default function MobileDrawer({ open, onClose }: MobileDrawerProps) {
return <AnimatePresence>{open && <DrawerSurface onClose={onClose} />}</AnimatePresence>
export default function MobileDrawer({ open, onClose, closesFrom = '64rem' }: MobileDrawerProps) {
return (
<AnimatePresence>
{open && <DrawerSurface onClose={onClose} closesFrom={closesFrom} />}
</AnimatePresence>
)
}
function DrawerSurface({ onClose }: Pick<MobileDrawerProps, 'onClose'>) {
function DrawerSurface({ onClose, closesFrom }: Required<Omit<MobileDrawerProps, 'open'>>) {
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(LARGE_SCREEN)
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])
}, [onClose, closesFrom])
return (
<ModalDialog onClose={onClose} label={t('shell.nav_label')} className="open:block">