@@ -14,23 +14,38 @@ const ResponsiveLayout: React.FC<ResponsiveLayoutProps> = ({
1414 title,
1515} ) => {
1616 const sidebarRef = useRef < HTMLDivElement > ( null ) ;
17+ const backdropRef = useRef < HTMLDivElement > ( null ) ;
1718
1819 const handleToggle = ( ) => {
19- if ( sidebarRef . current ) {
20+ if ( sidebarRef . current && backdropRef . current ) {
2021 sidebarRef . current . classList . toggle ( "translate-x-0" ) ;
2122 sidebarRef . current . classList . toggle ( "-translate-x-full" ) ;
23+ backdropRef . current . classList . toggle ( "opacity-50" ) ;
24+ backdropRef . current . classList . toggle ( "opacity-0" ) ;
25+ backdropRef . current . classList . toggle ( "pointer-events-auto" ) ;
26+ backdropRef . current . classList . toggle ( "pointer-events-none" ) ;
2227 }
2328 } ;
2429
2530 const handleClose = ( ) => {
26- if ( sidebarRef . current ) {
31+ if ( sidebarRef . current && backdropRef . current ) {
2732 sidebarRef . current . classList . remove ( "translate-x-0" ) ;
2833 sidebarRef . current . classList . add ( "-translate-x-full" ) ;
34+ backdropRef . current . classList . remove ( "opacity-50" ) ;
35+ backdropRef . current . classList . add ( "opacity-0" ) ;
36+ backdropRef . current . classList . remove ( "pointer-events-auto" ) ;
37+ backdropRef . current . classList . add ( "pointer-events-none" ) ;
2938 }
3039 } ;
3140
3241 return (
3342 < div className = "flex relative min-h-[400px]" >
43+ < div
44+ ref = { backdropRef }
45+ onClick = { handleClose }
46+ className = "absolute inset-0 bg-black opacity-0 pointer-events-none transition-opacity duration-100 z-[5] lg:hidden"
47+ />
48+
3449 < div
3550 ref = { sidebarRef }
3651 className = { cn (
@@ -40,7 +55,10 @@ const ResponsiveLayout: React.FC<ResponsiveLayoutProps> = ({
4055 ) }
4156 >
4257 < div className = "flex justify-end lg:hidden" >
43- < button onClick = { handleClose } className = "hover:bg-red-300 rounded p-1 transition-colors" >
58+ < button
59+ onClick = { handleClose }
60+ className = "hover:bg-destructive/50 rounded p-1 transition-colors"
61+ >
4462 < X className = "h-5 w-5" />
4563 </ button >
4664 </ div >
@@ -51,7 +69,7 @@ const ResponsiveLayout: React.FC<ResponsiveLayoutProps> = ({
5169 < div className = "flex items-center gap-3 mb-4" >
5270 < button
5371 onClick = { handleToggle }
54- className = "lg:hidden shadow hover:shadow-md transition-all"
72+ className = "lg:hidden shadow hover:shadow-md transition-all hover:bg-success/50 "
5573 >
5674 < Menu className = "w-4 h-4" />
5775 </ button >
0 commit comments