11import { cn } from "@/lib/utils.ts" ;
2- import React , { forwardRef , useImperativeHandle , useRef } from "react" ;
32import { Menu , X } from "lucide-react" ;
3+ import React , { forwardRef , useImperativeHandle , useRef } from "react" ;
44
55interface ResponsiveLayoutProps {
66 leftContent : React . ReactNode ;
@@ -12,6 +12,13 @@ interface ResponsiveLayoutRef {
1212 closeSidebar : ( ) => void ;
1313}
1414
15+ const ResponsiveLayoutWrapper = forwardRef < HTMLDivElement , React . HTMLAttributes < HTMLDivElement > > (
16+ ( args : React . HTMLAttributes < HTMLDivElement > , ref ) => {
17+ const { className, ...props } = args ;
18+ return < div ref = { ref } className = { cn ( 'p-5 lg:px-6"' , className ) } { ...props } /> ;
19+ } ,
20+ ) ;
21+
1522const ResponsiveLayout = forwardRef < ResponsiveLayoutRef , ResponsiveLayoutProps > ( ( props , ref ) => {
1623 const { leftContent, rightContent, title } = props ;
1724 const sidebarRef = useRef < HTMLDivElement > ( null ) ;
@@ -56,12 +63,13 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
5663 className = "absolute inset-0 bg-black opacity-0 pointer-events-none transition-opacity duration-100 z-[5] lg:hidden"
5764 />
5865
59- < div
66+ < ResponsiveLayoutWrapper
6067 ref = { sidebarRef }
6168 className = { cn (
62- "h-full w-3/12 min-w-[240px] -translate-x-full transition-transform duration-100" ,
63- "absolute top-0 left-0 z-10 bg-background p-5" ,
64- "lg:relative lg:block lg:bg-transparent lg:translate-x-0 lg:px-6" ,
69+ "h-full w-3/12 lg:w-2/12 min-w-[240px] md:min-w-fit -translate-x-full transition-transform duration-100" ,
70+ "absolute top-0 left-0 z-10 bg-background" ,
71+ "lg:relative lg:block lg:bg-transparent lg:translate-x-0" ,
72+ "p-5 lg:px-6" ,
6573 ) }
6674 >
6775 < div className = "flex justify-end lg:hidden" >
@@ -70,9 +78,9 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
7078 </ button >
7179 </ div >
7280 < div > { leftContent } </ div >
73- </ div >
81+ </ ResponsiveLayoutWrapper >
7482
75- < div className = "w-full lg:w-9 /12 p-5 lg:px-6 " >
83+ < ResponsiveLayoutWrapper className = "w-full lg:10 /12" >
7684 < div className = "flex items-center gap-3 mb-4" >
7785 < button
7886 onClick = { handleToggle }
@@ -87,12 +95,13 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
8795 ) }
8896 </ div >
8997 < div > { rightContent } </ div >
90- </ div >
98+ </ ResponsiveLayoutWrapper >
9199 </ div >
92100 ) ;
93101} ) ;
94102
95103ResponsiveLayout . displayName = "ResponsiveLayout" ;
104+ ResponsiveLayoutWrapper . displayName = "ResponsiveLayoutWrapper" ;
96105
97- export default ResponsiveLayout ;
106+ export { ResponsiveLayout , ResponsiveLayoutWrapper } ;
98107export type { ResponsiveLayoutRef } ;
0 commit comments