20
20
* SPDX-License-Identifier: Apache-2.0
21
21
********************************************************************************/
22
22
23
- import { useState } from 'react' ;
23
+ import { useState , useEffect } from 'react' ;
24
24
import AppBar from '@mui/material/AppBar' ;
25
25
import Box from '@mui/material/Box' ;
26
26
import Toolbar from '@mui/material/Toolbar' ;
@@ -38,6 +38,7 @@ import { Logout, Settings } from '@mui/icons-material';
38
38
export default function PrimarySearchAppBar ( ) {
39
39
const [ anchorEl , setAnchorEl ] = useState < null | HTMLElement > ( null ) ;
40
40
const [ mobileMoreAnchorEl , setMobileMoreAnchorEl ] = useState < null | HTMLElement > ( null ) ;
41
+ const [ scrolled , setScrolled ] = useState ( false ) ;
41
42
42
43
const isMenuOpen = Boolean ( anchorEl ) ;
43
44
const isMobileMenuOpen = Boolean ( mobileMoreAnchorEl ) ;
@@ -59,6 +60,15 @@ export default function PrimarySearchAppBar() {
59
60
setMobileMoreAnchorEl ( event . currentTarget ) ;
60
61
} ;
61
62
63
+ useEffect ( ( ) => {
64
+ const handleScroll = ( ) => {
65
+ setScrolled ( window . scrollY > 50 ) ;
66
+ } ;
67
+
68
+ window . addEventListener ( "scroll" , handleScroll ) ;
69
+ return ( ) => window . removeEventListener ( "scroll" , handleScroll ) ;
70
+ } , [ ] ) ;
71
+
62
72
const menuId = 'primary-search-account-menu' ;
63
73
const renderMenu = (
64
74
< Menu
@@ -150,7 +160,7 @@ export default function PrimarySearchAppBar() {
150
160
151
161
return (
152
162
< Box sx = { { flexGrow : 1 } } >
153
- < AppBar position = "static" className = ' ichub-header' >
163
+ < AppBar position = "static" className = { ` ichub-header ${ scrolled ? "scrolled" : "" } ` } >
154
164
< Toolbar >
155
165
< a href = "/" >
156
166
< img
0 commit comments