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

Function BottomSheet

web/components/mobile/BottomSheet.tsx:22–100  ·  view source on GitHub ↗
({ isOpen, onClose, title, children, className }: BottomSheetProps)

Source from the content-addressed store, hash-verified

20 * - Locks body scroll while open
21 */
22export function BottomSheet({ isOpen, onClose, title, children, className }: BottomSheetProps) {
23 const sheetRef = useRef<HTMLDivElement>(null);
24
25 const swipeHandlers = useTouchGesture({ onSwipeDown: onClose });
26
27 // Lock body scroll while open
28 useEffect(() => {
29 if (isOpen) {
30 document.body.style.overflow = "hidden";
31 } else {
32 document.body.style.overflow = "";
33 }
34 return () => {
35 document.body.style.overflow = "";
36 };
37 }, [isOpen]);
38
39 // Close on Escape
40 useEffect(() => {
41 if (!isOpen) return;
42 const onKey = (e: KeyboardEvent) => {
43 if (e.key === "Escape") onClose();
44 };
45 document.addEventListener("keydown", onKey);
46 return () => document.removeEventListener("keydown", onKey);
47 }, [isOpen, onClose]);
48
49 return (
50 <>
51 {/* Backdrop */}
52 <div
53 className={cn(
54 "fixed inset-0 z-40 bg-black/60",
55 "transition-opacity duration-300",
56 isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
57 )}
58 onClick={onClose}
59 aria-hidden="true"
60 />
61
62 {/* Sheet */}
63 <div
64 ref={sheetRef}
65 role="dialog"
66 aria-modal="true"
67 aria-label={title ?? "Options"}
68 className={cn(
69 "fixed bottom-0 left-0 right-0 z-50",
70 "bg-surface-900 border-t border-surface-800 rounded-t-2xl",
71 "max-h-[85dvh] flex flex-col",
72 "transition-transform duration-300 ease-out",
73 isOpen ? "translate-y-0" : "translate-y-full",
74 className
75 )}
76 {...swipeHandlers}
77 >
78 {/* Drag handle */}
79 <div className="flex justify-center pt-3 pb-1 flex-shrink-0 cursor-grab active:cursor-grabbing">

Callers

nothing calls this directly

Calls 2

useTouchGestureFunction · 0.90
cnFunction · 0.90

Tested by

no test coverage detected