11import { User } from '@idea2app/data-server' ;
22import {
33 Box ,
4- Drawer ,
54 IconButton ,
65 List ,
76 ListItem ,
87 ListItemButton ,
98 ListItemText ,
109 Modal ,
11- useMediaQuery ,
12- useTheme ,
1310} from '@mui/material' ;
1411import { observable } from 'mobx' ;
1512import { observer } from 'mobx-react' ;
1613import Link from 'next/link' ;
1714import { JWTProps } from 'next-ssr-middleware' ;
18- import { Component , FC , HTMLAttributes , JSX } from 'react' ;
15+ import { Component , HTMLAttributes , JSX } from 'react' ;
1916
2017import { SymbolIcon } from '../Icon' ;
18+ import { ResponsiveDrawer } from './ResponsiveDrawer' ;
2119import { SessionForm } from './SessionForm' ;
2220
2321export type MenuItem = Pick < JSX . IntrinsicElements [ 'a' ] , 'href' | 'title' > ;
@@ -27,43 +25,6 @@ export interface SessionBoxProps extends HTMLAttributes<HTMLDivElement>, JWTProp
2725 menu ?: MenuItem [ ] ;
2826}
2927
30- interface ResponsiveDrawerProps {
31- open : boolean ;
32- onClose : ( ) => void ;
33- children : JSX . Element ;
34- }
35-
36- const ResponsiveDrawer : FC < ResponsiveDrawerProps > = ( { open, onClose, children } ) => {
37- const theme = useTheme ( ) ;
38- const isMobile = useMediaQuery ( theme . breakpoints . down ( 'md' ) ) ;
39-
40- return (
41- < Drawer
42- anchor = "left"
43- open = { isMobile ? open : true }
44- variant = { isMobile ? 'temporary' : 'permanent' }
45- onClose = { onClose }
46- sx = { {
47- display : { xs : isMobile ? 'block' : 'none' , md : isMobile ? 'none' : 'block' } ,
48- '& .MuiDrawer-paper' : {
49- width : 250 ,
50- ...( isMobile
51- ? { }
52- : {
53- position : 'sticky' ,
54- top : '5rem' ,
55- height : 'calc(100vh - 5rem)' ,
56- border : 'none' ,
57- boxShadow : 'none' ,
58- } ) ,
59- } ,
60- } }
61- >
62- { children }
63- </ Drawer >
64- ) ;
65- } ;
66-
6728@observer
6829export class SessionBox extends Component < SessionBoxProps > {
6930 @observable
@@ -110,27 +71,9 @@ export class SessionBox extends Component<SessionBoxProps> {
11071 const { className = '' , children, jwtPayload, ...props } = this . props ;
11172
11273 return (
113- < Box
114- sx = { {
115- display : 'flex' ,
116- flexDirection : { xs : 'column' , md : 'row' } ,
117- } }
118- className = { className }
119- { ...props }
120- >
74+ < div className = { `flex flex-col md:flex-row ${ className } ` } { ...props } >
12175 { /* Mobile Menu Button */ }
122- < Box
123- sx = { {
124- display : { xs : 'flex' , md : 'none' } ,
125- position : 'sticky' ,
126- top : 0 ,
127- zIndex : 1100 ,
128- bgcolor : 'background.paper' ,
129- borderBottom : 1 ,
130- borderColor : 'divider' ,
131- p : 1 ,
132- } }
133- >
76+ < div className = "sticky top-0 z-[1100] flex border-b p-1 md:hidden bg-background-paper border-divider" >
13477 < IconButton
13578 edge = "start"
13679 color = "inherit"
@@ -139,43 +82,27 @@ export class SessionBox extends Component<SessionBoxProps> {
13982 >
14083 < SymbolIcon name = "menu" />
14184 </ IconButton >
142- </ Box >
85+ </ div >
14386
14487 { /* Unified Responsive Drawer */ }
14588 < ResponsiveDrawer open = { this . drawerOpen } onClose = { this . closeDrawer } >
146- < Box sx = { { width : 250 } } > { this . renderMenuItems ( ) } </ Box >
89+ < div className = "w-[250px]" > { this . renderMenuItems ( ) } </ div >
14790 </ ResponsiveDrawer >
14891
14992 { /* Main Content */ }
150- < Box
151- component = "main"
152- sx = { {
153- flex : 1 ,
154- pb : 3 ,
155- px : { xs : 2 , sm : 3 } ,
156- } }
157- >
93+ < main className = "flex-1 px-2 pb-3 sm:px-3" >
15894 { children }
15995
16096 < Modal open = { this . modalShown } >
16197 < Box
162- sx = { {
163- position : 'absolute' ,
164- top : '50%' ,
165- left : '50%' ,
166- transform : 'translate(-50%, -50%)' ,
167- width : { xs : '90vw' , sm : 400 } ,
168- bgcolor : 'background.paper' ,
169- borderRadius : 1 ,
170- boxShadow : 24 ,
171- p : 4 ,
172- } }
98+ className = "absolute left-1/2 top-1/2 w-[90vw] -translate-x-1/2 -translate-y-1/2 rounded p-4 shadow-2xl sm:w-[400px] bg-background-paper"
99+ sx = { { boxShadow : 24 } }
173100 >
174101 < SessionForm onSignIn = { ( ) => ( this . modalShown = false ) } />
175102 </ Box >
176103 </ Modal >
177- </ Box >
178- </ Box >
104+ </ main >
105+ </ div >
179106 ) ;
180107 }
181108}
0 commit comments