@@ -16,6 +16,7 @@ import { Menu as DefaultMenu, MenuProps } from './Menu';
16
16
import { Error , ErrorProps } from './Error' ;
17
17
import { SkipNavigationButton } from '../button' ;
18
18
import { useSidebarState } from './useSidebarState' ;
19
+ import { useScrollTrigger } from '@mui/material' ;
19
20
20
21
export const Layout = ( props : LayoutProps ) => {
21
22
const {
@@ -32,6 +33,7 @@ export const Layout = (props: LayoutProps) => {
32
33
33
34
const [ open ] = useSidebarState ( ) ;
34
35
const [ errorInfo , setErrorInfo ] = useState < ErrorInfo > ( null ) ;
36
+ let trigger = useScrollTrigger ( ) ;
35
37
36
38
const handleError = ( error : Error , info : ErrorInfo ) => {
37
39
setErrorInfo ( info ) ;
@@ -40,7 +42,11 @@ export const Layout = (props: LayoutProps) => {
40
42
return (
41
43
< StyledLayout className = { clsx ( 'layout' , className ) } { ...rest } >
42
44
< SkipNavigationButton />
43
- < div className = { LayoutClasses . appFrame } >
45
+ < div
46
+ className = { clsx ( LayoutClasses . appFrame , {
47
+ 'appbar-is-collapsed' : trigger ,
48
+ } ) }
49
+ >
44
50
< AppBar open = { open } title = { title } />
45
51
< main className = { LayoutClasses . contentWithSidebar } >
46
52
< Sidebar >
@@ -109,13 +115,15 @@ const StyledLayout = styled('div', {
109
115
display : 'flex' ,
110
116
flexDirection : 'column' ,
111
117
flexGrow : 1 ,
112
- [ theme . breakpoints . up ( 'xs' ) ] : {
113
- marginTop : theme . spacing ( 6 ) ,
114
- } ,
118
+ marginTop : theme . spacing ( 6 ) ,
119
+ transition : 'margin 0.25s ease-in-out' ,
115
120
[ theme . breakpoints . down ( 'sm' ) ] : {
116
121
marginTop : theme . spacing ( 7 ) ,
117
122
} ,
118
123
} ,
124
+ [ `& .${ LayoutClasses . appFrame } .appbar-is-collapsed` ] : {
125
+ marginTop : 0 ,
126
+ } ,
119
127
[ `& .${ LayoutClasses . contentWithSidebar } ` ] : {
120
128
display : 'flex' ,
121
129
flexGrow : 1 ,
@@ -127,12 +135,10 @@ const StyledLayout = styled('div', {
127
135
flexDirection : 'column' ,
128
136
flexGrow : 1 ,
129
137
flexBasis : 0 ,
138
+ padding : 0 ,
130
139
[ theme . breakpoints . up ( 'xs' ) ] : {
131
140
paddingRight : theme . spacing ( 2 ) ,
132
141
paddingLeft : theme . spacing ( 1 ) ,
133
142
} ,
134
- [ theme . breakpoints . down ( 'md' ) ] : {
135
- padding : 0 ,
136
- } ,
137
143
} ,
138
144
} ) ) ;
0 commit comments