MCPcopy Create free account
hub / github.com/codeaashu/claude-code / MobileSidebar

Function MobileSidebar

web/components/mobile/MobileSidebar.tsx:20–75  ·  view source on GitHub ↗
({ isOpen, onClose }: MobileSidebarProps)

Source from the content-addressed store, hash-verified

18 * - Locks body scroll while open
19 */
20export function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) {
21 // Swipe left on the drawer to close
22 const swipeHandlers = useTouchGesture({ onSwipeLeft: onClose });
23
24 // Lock body scroll while drawer is open
25 useEffect(() => {
26 if (isOpen) {
27 document.body.style.overflow = "hidden";
28 } else {
29 document.body.style.overflow = "";
30 }
31 return () => {
32 document.body.style.overflow = "";
33 };
34 }, [isOpen]);
35
36 // Close on Escape
37 useEffect(() => {
38 if (!isOpen) return;
39 const onKey = (e: KeyboardEvent) => {
40 if (e.key === "Escape") onClose();
41 };
42 document.addEventListener("keydown", onKey);
43 return () => document.removeEventListener("keydown", onKey);
44 }, [isOpen, onClose]);
45
46 return (
47 <>
48 {/* Backdrop */}
49 <div
50 className={cn(
51 "fixed inset-0 z-40 bg-black/60 lg:hidden",
52 "transition-opacity duration-300",
53 isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
54 )}
55 onClick={onClose}
56 aria-hidden="true"
57 />
58
59 {/* Drawer */}
60 <div
61 className={cn(
62 "fixed top-0 left-0 bottom-0 z-50 w-72 lg:hidden",
63 "transition-transform duration-300 ease-in-out",
64 isOpen ? "translate-x-0" : "-translate-x-full"
65 )}
66 role="dialog"
67 aria-modal="true"
68 aria-label="Navigation"
69 {...swipeHandlers}
70 >
71 <Sidebar onNavigate={onClose} />
72 </div>
73 </>
74 );
75}

Callers

nothing calls this directly

Calls 2

useTouchGestureFunction · 0.90
cnFunction · 0.90

Tested by

no test coverage detected