Mobile-friendly UI: responsive shell, phone layouts, drawer navigation

The UI was desktop-first: no viewport meta (phones rendered at ~980px CSS
width, killing every breakpoint), an always-inline 240px sidebar squeezing
phone content, fixed p-6/100vh chrome, a 6-column bookmarks table, fixed
w-60/w-72 rails on collections/tags/contacts, a 12-tab settings strip that
overflowed, and w-72 kanban columns. This pass makes every screen usable on
a phone while leaving the desktop layout intact.

- layout.tsx: viewport meta (width=device-width, initial-scale=1).
- app-shell/sidebar: below lg the sidebar is an overlay drawer (closed by
  default, hamburger opens, backdrop/navigation/resize-to-desktop closes);
  at lg+ it is the static expand/collapse rail exactly as before. Separate
  mobileOpen state so closing the drawer never collapses the desktop rail.
  h-screen -> h-dvh; main p-6 -> p-3 sm:p-6.
- lib/use-media-query.ts: hydration-safe useSyncExternalStore media hook
  (server snapshot false) so surfaces swap whole layouts without duplicating
  hidden DOM that would break the suites' strict text locators.
- bookmarks: table swaps to tappable cards below sm (title/host/status/tags/
  updated + open/trash); shared trash handler; detail sheet unchanged.
- collections/tags/contacts: rails become master-detail on phones — full-width
  list first, tap into detail, Back returns; collections no longer auto-jump
  into the first item on mobile; phone padding.
- settings: tab strip scrolls horizontally (triggers shrink-0) instead of
  overflowing the page.
- kanban/collection boards: columns w-[85vw] max-w-72/64 with a peek of the
  next column; dvh heights.
- calendar: compact cells + single-letter weekday headers on phones.
- ui/dialog: max-h-[calc(100dvh-2rem)] + internal scroll + phone width guard
  so tall forms never clip; ui/tabs triggers shrink-0.
- top-bar: alerts panel fits 320px; theme/avatar collapse on the smallest
  widths; hamburger gains an accessible name.
- connector settings (MCP/WebDAV/CalDAV/CardDAV): connection rows wrap and the
  name gets a width floor — the action cluster previously squeezed the name to
  zero width on phones (a real bug the new mobile test caught).

Verification: new mobile regression suite (390x844 context) proves drawer
open/close-on-nav, bookmark cards + sheet, tags master-detail + Back,
scrollable settings tabs reaching WebDAV, kanban column fits, and zero
horizontal overflow on all eight screens; all 19 existing desktop tests still
pass (20/20). Real-stack e2e fully passing. yarn lint / SSR eslint / build:
0 errors.
This commit is contained in:
Andrew S Erwin
2026-11-16 21:05:40 -06:00
parent 9ddbd10933
commit 3fe953c14d
20 changed files with 333 additions and 113 deletions
+33 -4
View File
@@ -58,6 +58,11 @@ export function AppShell({ children }: { children: React.ReactNode }) {
const router = useRouter()
const pathname = usePathname()
const [sidebarOpen, setSidebarOpen] = useState(true)
// Mobile (<lg) navigation is an overlay drawer, closed by default; the
// desktop rail keeps its own expanded/collapsed state. Two states so a
// phone never boots with a 240px rail squeezing the content, and closing
// the drawer never collapses the desktop rail.
const [mobileNavOpen, setMobileNavOpen] = useState(false)
const [addDialogOpen, setAddDialogOpen] = useState(false)
const [quickFindOpen, setQuickFindOpen] = useState(false)
const [alerts, setAlerts] = useState<any[]>([])
@@ -71,6 +76,19 @@ export function AppShell({ children }: { children: React.ReactNode }) {
.catch((e) => console.error('Failed to load account info', e))
}, [session?.user])
// Navigating from the drawer closes it (phone pattern); the desktop rail
// is unaffected because the drawer state is separate.
useEffect(() => { const t = setTimeout(() => setMobileNavOpen(false), 0); return () => clearTimeout(t) }, [pathname])
// Crossing into desktop while the drawer is open must not leave a
// label-expanded drawer stuck over the static rail.
useEffect(() => {
const mql = window.matchMedia('(min-width: 1024px)')
const onChange = () => { if (mql.matches) setMobileNavOpen(false) }
mql.addEventListener('change', onChange)
return () => mql.removeEventListener('change', onChange)
}, [])
const exitViewAs = useCallback(async () => {
try {
await fetch('/api/admin/view-as', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ userId: null }) })
@@ -126,8 +144,19 @@ export function AppShell({ children }: { children: React.ReactNode }) {
if (!session?.user) return null
return (
<div className="flex h-screen overflow-hidden bg-background">
<Sidebar open={sidebarOpen} onToggle={() => setSidebarOpen(!sidebarOpen)} onQuickFind={() => setQuickFindOpen(true)} pathname={pathname} isAdmin={!!me?.isAdmin} />
<div className="flex h-dvh overflow-hidden bg-background">
{mobileNavOpen && (
<div className="fixed inset-0 z-30 bg-black/50 lg:hidden" aria-hidden onClick={() => setMobileNavOpen(false)} />
)}
<Sidebar
open={sidebarOpen}
mobileOpen={mobileNavOpen}
onToggle={() => setSidebarOpen(!sidebarOpen)}
onCloseMobile={() => setMobileNavOpen(false)}
onQuickFind={() => { setMobileNavOpen(false); setQuickFindOpen(true) }}
pathname={pathname}
isAdmin={!!me?.isAdmin}
/>
<div className="flex flex-1 flex-col overflow-hidden">
{me?.viewingAs && (
<div className="flex items-center justify-center gap-3 bg-amber-500 px-4 py-1.5 text-sm font-medium text-amber-950">
@@ -140,10 +169,10 @@ export function AppShell({ children }: { children: React.ReactNode }) {
alerts={alerts}
onDismissAlert={dismissAlert}
onAddBookmark={() => setAddDialogOpen(true)}
onToggleSidebar={() => setSidebarOpen(!sidebarOpen)}
onToggleSidebar={() => setMobileNavOpen(!mobileNavOpen)}
onQuickFind={() => setQuickFindOpen(true)}
/>
<main className="flex-1 overflow-auto p-6">
<main className="flex-1 overflow-auto p-3 sm:p-6">
{children}
</main>
</div>