@@ -35,6 +35,12 @@ const useStyles = makeStyles((theme) => ({
3535 minHeight : "30px" ,
3636 transition : "transform 0.3s ease-in-out" ,
3737 } ,
38+ buttonHover : {
39+ "&:hover" : {
40+ backgroundColor : "rgba(255, 255, 255, 0.1)" ,
41+ transition : "background-color 0.3s ease" ,
42+ } ,
43+ } ,
3844} ) ) ;
3945
4046const IconRenderer = ( { icon, text, size = "25px" } ) => (
@@ -60,22 +66,19 @@ const LogoRenderer = ({ logo, title, size = "20px", borderRadius = "8px" }) => (
6066 </ div >
6167) ;
6268
63- const ButtonWithText = ( { text, icon, more, handler } ) => (
69+ const ButtonWithText = ( { text, icon, more, handler, classes } ) => (
6470 < span key = { text } >
6571 { ! more
6672 && (
6773 < Button
6874 key = { text }
75+ className = { classes . buttonHover }
6976 sx = { {
7077 width : "100%" ,
7178 display : "flex" ,
7279 flexDirection : "row" ,
7380 justifyContent : "flex-start" ,
7481 padding : "8px 40px 8px 16px" ,
75- "&:hover" : {
76- backgroundColor : "rgba(255, 255, 255, 0.1)" , // subtle white overlay on hover
77- transition : "background-color 0.3s ease" ,
78- } ,
7982 } }
8083 onClick = { ( event ) => handler ( event ) }
8184 >
@@ -122,10 +125,7 @@ const ButtonWithText = ({ text, icon, more, handler }) => (
122125 sx = { {
123126 justifyContent : "flex-start" ,
124127 marginLeft : "20px" ,
125- "&:hover" : {
126- backgroundColor : "rgba(255, 255, 255, 0.1)" ,
127- transition : "background-color 0.3s ease" ,
128- } ,
128+ ...classes . buttonHover ,
129129 } }
130130 onClick = { el . handler }
131131 >
@@ -143,21 +143,18 @@ const ButtonWithText = ({ text, icon, more, handler }) => (
143143 </ span >
144144) ;
145145
146- const ButtonSimple = ( { text, icon, handler, ind } ) => (
146+ const ButtonSimple = ( { text, icon, handler, ind, classes } ) => (
147147 < Button
148148 key = { text }
149+ className = { classes . buttonHover }
149150 sx = { {
150151 minWidth : "30px!important" ,
151152 padding : "8px" ,
152153 position : "absolute" ,
153- top : `${ ind * 40 } px` , // Fixed position based on index (adjust the multiplier as needed)
154+ top : `${ ind * 40 } px` ,
154155 left : "50%" ,
155156 transform : "translateX(-50%)" ,
156157 transition : "top 0.5s ease-in-out, background-color 0.3s ease" ,
157- "&:hover" : {
158- backgroundColor : "rgba(255, 255, 255, 0.1)" ,
159- transition : "background-color 0.3s ease" ,
160- } ,
161158 } }
162159 onClick = { ( event ) => handler ( event ) }
163160 >
@@ -179,38 +176,32 @@ const Sidebar = ({ isSmall: sidebarIsSmall, onToggleSidebar }) => {
179176
180177 useEffect ( ( ) => setIsSmall ( sidebarIsSmall ) , [ sidebarIsSmall ] ) ;
181178
179+ // Create a wrapper handler
180+ const createNavigationHandler = ( path ) => ( ) => {
181+ handleServicesMenuClose ( ) ;
182+ navigate ( path ) ;
183+ } ;
184+
182185 const buttons = [
183186 {
184187 icon : < HomeRounded /> ,
185- text : "Overview" ,
186- handler : ( ) => {
187- handleServicesMenuClose ( ) ;
188- navigate ( "/home" ) ;
189- } ,
188+ text : "Home" ,
189+ handler : createNavigationHandler ( "/home" ) ,
190190 } ,
191191 {
192192 icon : < AgricultureRounded /> ,
193193 text : "Products" ,
194- handler : ( ) => {
195- handleServicesMenuClose ( ) ;
196- navigate ( "/products" ) ;
197- } ,
194+ handler : createNavigationHandler ( "/products" ) ,
198195 } ,
199196 {
200197 icon : < MapRounded /> ,
201198 text : "Map" ,
202- handler : ( ) => {
203- handleServicesMenuClose ( ) ;
204- navigate ( "/Map" ) ;
205- } ,
199+ handler : createNavigationHandler ( "/Map" ) ,
206200 } ,
207201 {
208202 icon : < CrisisAlertRounded /> ,
209203 text : "Contaminants" ,
210- handler : ( ) => {
211- handleServicesMenuClose ( ) ;
212- navigate ( "/contaminants" ) ;
213- } ,
204+ handler : createNavigationHandler ( "/contaminants" ) ,
214205 } ,
215206 {
216207 icon : < SpaRounded /> ,
@@ -277,6 +268,7 @@ const Sidebar = ({ isSmall: sidebarIsSmall, onToggleSidebar }) => {
277268 className = { classes . toggleButton }
278269 sx = { {
279270 transform : isSmall ? "rotate(-90deg)" : "rotate(90deg)" ,
271+ ...classes . buttonHover ,
280272 } }
281273 onClick = { toggleSidebar }
282274 >
@@ -289,6 +281,7 @@ const Sidebar = ({ isSmall: sidebarIsSmall, onToggleSidebar }) => {
289281 text = { button . text }
290282 handler = { button . handler }
291283 more = { button . more }
284+ classes = { classes }
292285 />
293286 ) ) }
294287 { isSmall && (
@@ -310,6 +303,7 @@ const Sidebar = ({ isSmall: sidebarIsSmall, onToggleSidebar }) => {
310303 handler = { button . handler }
311304 more = { button . more }
312305 ind = { ind }
306+ classes = { classes }
313307 />
314308 ) ) }
315309 </ div >
0 commit comments