@@ -3,21 +3,29 @@ import ListSubheader from "@mui/material/ListSubheader/ListSubheader";
33import * as React from "react" ;
44import { RightMenuProps } from "./RightMenuProps" ;
55import "./RightMenu.scss" ;
6+ import { UserContext } from "../../globals/contexts/UserContext" ;
67const RightMenu : React . FC < RightMenuProps > = ( props : RightMenuProps ) => {
7- const { items, width } = props ;
8- const [ selectedItem , setSelectedItem ] = React . useState < number > ( 0 ) ;
9- const handleChangeSelectedItem = ( newIndex : number ) =>
10- setSelectedItem ( newIndex ) ;
8+ const { items, width, selectedItemProp : selectedItem = 0 } = props ;
9+ const [ usuario , ] = React . useContext ( UserContext ) ;
10+ const darkMode = usuario . darkMode ;
11+
1112 const handleClickAnchor = (
1213 e : React . MouseEvent < HTMLAnchorElement , MouseEvent > ,
1314 onClick : Function | undefined ,
1415 id : number
1516 ) => {
1617 onClick ?.( ) ;
17- handleChangeSelectedItem ( id ) ;
1818 } ;
19+
20+ const finalSelectedId = selectedItem ;
21+
22+ const darkmodeClassName = darkMode
23+ ? "right-menu-anchor-item darkmode"
24+ : "right-menu-anchor-item" ;
25+ //const darkmodeClassName = darkMode?"":"";
1926 return (
2027 < List
28+ // className="section-container"
2129 sx = { { width : "100%" , maxWidth : width , bgcolor : "background.paper" } }
2230 component = "nav"
2331 aria-labelledby = "nested-list-subheader"
@@ -31,14 +39,13 @@ const RightMenu: React.FC<RightMenuProps> = (props: RightMenuProps) => {
3139 { items &&
3240 items . map ( ( { isSelected, label, onClick, referTo, id } , index ) => {
3341 const classNameForAnchor : string =
34- selectedItem === id
35- ? "right-menu-anchor-item selected"
36- : "right-menu-anchor-item" ;
42+ finalSelectedId === id
43+ ? ` ${ darkmodeClassName } selected`
44+ : darkmodeClassName ;
3745 return (
3846 < li key = { index } style = { { listStyle : "none" , margin : 0 } } >
3947 < a
4048 className = { classNameForAnchor }
41- //href={`${baseUrl}/#${referTo}` }
4249 href = { `${ referTo } ` }
4350 onClick = { ( e ) => handleClickAnchor ( e , onClick , id ) }
4451 >
0 commit comments