1- import { Toolbar , Grid , Button , Typography , Box , Tooltip } from "@mui/material" ;
1+ import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown" ;
2+ import {
3+ Toolbar ,
4+ Grid ,
5+ Button ,
6+ Typography ,
7+ Box ,
8+ Tooltip ,
9+ Menu ,
10+ MenuItem ,
11+ } from "@mui/material" ;
212import UserButton from "components/User/UserButton" ;
313import UserLogin from "components/User/UserLogin" ;
414import UserSignup from "components/User/UserSignup" ;
@@ -24,21 +34,66 @@ const NavItems: React.FC = () => {
2434 const [ loginOpen , setLoginOpen ] = useState ( false ) ;
2535 const [ signupOpen , setSignupOpen ] = useState ( false ) ;
2636
37+ // Resources dropdown state
38+ const [ resourcesAnchor , setResourcesAnchor ] = useState < null | HTMLElement > (
39+ null
40+ ) ;
41+ const resourcesOpen = Boolean ( resourcesAnchor ) ;
42+
2743 const handleLogout = ( ) => {
2844 dispatch ( logoutUser ( ) ) ;
2945 navigate ( "/" ) ;
3046 } ;
3147
48+ const handleResourcesClick = ( event : React . MouseEvent < HTMLElement > ) => {
49+ setResourcesAnchor ( event . currentTarget ) ;
50+ } ;
51+
52+ const handleResourcesClose = ( ) => {
53+ setResourcesAnchor ( null ) ;
54+ } ;
55+
56+ const resourcesMenu = [
57+ {
58+ category : "Converter" ,
59+ items : [
60+ {
61+ text : "neuroj for Python" ,
62+ url : "https://neurojson.org/Page/python-jdata" ,
63+ } ,
64+ { text : "neuroj for shell" , url : "https://neurojson.org/Page/neuroj" } ,
65+ ] ,
66+ } ,
67+ {
68+ category : "MATLAB/Octave" ,
69+ items : [
70+ { text : "jsonlab" , url : "" } ,
71+ { text : "jdict" , url : "" } ,
72+ { text : "jnifty" , url : "" } ,
73+ { text : "jsnirfy" , url : "" } ,
74+ ] ,
75+ } ,
76+ {
77+ category : "Python" ,
78+ items : [
79+ { text : "jdata" , url : "https://neurojson.org/Page/python-jdata" } ,
80+ { text : "bjdata" , url : "https://neurojson.org/Page/python-bjdata" } ,
81+ ] ,
82+ } ,
83+ {
84+ category : "Format Specifications" ,
85+ items : [
86+ { text : "JData" , url : "" } ,
87+ { text : "BJData" , url : "" } ,
88+ { text : "JNIfTI" , url : "" } ,
89+ { text : "JSNIRF" , url : "" } ,
90+ { text : "JMesh" , url : "" } ,
91+ { text : "JGIFTI" , url : "" } ,
92+ ] ,
93+ } ,
94+ ] ;
95+
3296 return (
33- // <Toolbar sx={{ marginTop: "0.5rem" }}>
34- // <Grid
35- // container
36- // alignItems="center"
37- // sx={{
38- // maxWidth: "100%",
39- // }}
40- // >
41- // <Grid item xs={12} sm={12} md={5} lg={5}>
4297 < >
4398 < Toolbar
4499 sx = { {
@@ -145,7 +200,7 @@ const NavItems: React.FC = () => {
145200 textAlign : "center" ,
146201 } }
147202 >
148- { [
203+ { /* { [
149204 { text: "About", url: RoutesEnum.ABOUT },
150205 { text: "Wiki", url: "https://neurojson.org/Wiki" },
151206 { text: "Search", url: RoutesEnum.SEARCH },
@@ -255,7 +310,113 @@ const NavItems: React.FC = () => {
255310 </Link>
256311 )}
257312 </Grid>
313+ ))} */ }
314+
315+ { [
316+ { text : "About" , url : RoutesEnum . ABOUT } ,
317+ { text : "Wiki" , url : "https://neurojson.org/Wiki" } ,
318+ { text : "Search" , url : RoutesEnum . SEARCH } ,
319+ { text : "Databases" , url : RoutesEnum . DATABASES } ,
320+ ] . map ( ( { text, url } ) => (
321+ < Grid item key = { text } >
322+ { url ?. startsWith ( "https" ) ? (
323+ < a
324+ href = { url }
325+ target = "_blank"
326+ rel = "noopener noreferrer"
327+ style = { { textDecoration : "none" } }
328+ >
329+ < Typography
330+ align = "center"
331+ fontWeight = { 600 }
332+ lineHeight = { "1.5rem" }
333+ letterSpacing = { "0.05rem" }
334+ sx = { {
335+ fontSize : {
336+ xs : "0.8rem" ,
337+ sm : "1rem" ,
338+ } ,
339+ color : Colors . white ,
340+ transition : "color 0.3s ease, transform 0.3s ease" ,
341+ textTransform : "uppercase" ,
342+ "&:hover" : {
343+ transform : "scale(1.2)" ,
344+ cursor : "pointer" ,
345+ } ,
346+ } }
347+ >
348+ { text }
349+ </ Typography >
350+ </ a >
351+ ) : (
352+ < Link to = { url } style = { { textDecoration : "none" } } >
353+ < Typography
354+ align = "center"
355+ fontWeight = { 600 }
356+ lineHeight = { "1.5rem" }
357+ letterSpacing = { "0.05rem" }
358+ sx = { {
359+ fontSize : {
360+ xs : "0.8rem" ,
361+ sm : "1rem" ,
362+ } ,
363+ color : Colors . white ,
364+ transition : "color 0.3s ease, transform 0.3s ease" ,
365+ textTransform : "uppercase" ,
366+ "&:hover" : {
367+ transform : "scale(1.2)" ,
368+ cursor : "pointer" ,
369+ } ,
370+ } }
371+ >
372+ { text }
373+ </ Typography >
374+ </ Link >
375+ ) }
376+ </ Grid >
258377 ) ) }
378+
379+ { /* Resources Dropdown */ }
380+ < Grid item >
381+ < Box
382+ onClick = { handleResourcesClick }
383+ sx = { {
384+ display : "flex" ,
385+ alignItems : "center" ,
386+ gap : 0.5 ,
387+ cursor : "pointer" ,
388+ } }
389+ >
390+ < Typography
391+ align = "center"
392+ fontWeight = { 600 }
393+ lineHeight = { "1.5rem" }
394+ letterSpacing = { "0.05rem" }
395+ sx = { {
396+ fontSize : {
397+ xs : "0.8rem" ,
398+ sm : "1rem" ,
399+ } ,
400+ color : Colors . white ,
401+ transition : "color 0.3s ease, transform 0.3s ease" ,
402+ textTransform : "uppercase" ,
403+ "&:hover" : {
404+ transform : "scale(1.2)" ,
405+ } ,
406+ } }
407+ >
408+ Resources
409+ </ Typography >
410+ < KeyboardArrowDownIcon
411+ sx = { {
412+ color : Colors . white ,
413+ fontSize : "1.2rem" ,
414+ transition : "transform 0.3s ease" ,
415+ transform : resourcesOpen ? "rotate(180deg)" : "rotate(0deg)" ,
416+ } }
417+ />
418+ </ Box >
419+ </ Grid >
259420 </ Box >
260421
261422 { /* User Button */ }
@@ -281,6 +442,73 @@ const NavItems: React.FC = () => {
281442 { /* </Grid> */ }
282443 { /* </Grid> */ }
283444 </ Toolbar >
445+
446+ { /* Resources Dropdown Menu */ }
447+ < Menu
448+ anchorEl = { resourcesAnchor }
449+ open = { resourcesOpen }
450+ onClose = { handleResourcesClose }
451+ PaperProps = { {
452+ sx : {
453+ bgcolor : Colors . darkPurple ,
454+ color : Colors . white ,
455+ minWidth : "280px" ,
456+ maxHeight : "500px" ,
457+ mt : 1 ,
458+ } ,
459+ } }
460+ >
461+ { resourcesMenu . map ( ( section , sectionIndex ) => (
462+ < Box key = { section . category } >
463+ { sectionIndex > 0 && (
464+ < Box
465+ sx = { {
466+ borderTop : `1px solid ${ Colors . lightGray } 40` ,
467+ mx : 1 ,
468+ my : 0.5 ,
469+ } }
470+ />
471+ ) }
472+ < MenuItem
473+ disabled
474+ sx = { {
475+ color : Colors . green ,
476+ fontWeight : 700 ,
477+ fontSize : "0.85rem" ,
478+ opacity : "1 !important" ,
479+ "&.Mui-disabled" : {
480+ opacity : 1 ,
481+ } ,
482+ } }
483+ >
484+ { section . category }
485+ </ MenuItem >
486+ { section . items . map ( ( item ) => (
487+ < MenuItem
488+ key = { item . text }
489+ onClick = { ( ) => {
490+ if ( item . url ) {
491+ window . open ( item . url , "_blank" ) ;
492+ handleResourcesClose ( ) ;
493+ }
494+ } }
495+ sx = { {
496+ pl : 3 ,
497+ fontSize : "0.9rem" ,
498+ color : item . url ? Colors . white : Colors . lightGray ,
499+ cursor : item . url ? "pointer" : "default" ,
500+ "&:hover" : {
501+ bgcolor : item . url ? Colors . purpleGrey : "transparent" ,
502+ color : item . url ? Colors . darkPurple : Colors . lightGray ,
503+ } ,
504+ } }
505+ >
506+ { item . text }
507+ </ MenuItem >
508+ ) ) }
509+ </ Box >
510+ ) ) }
511+ </ Menu >
284512 < UserLogin
285513 open = { loginOpen }
286514 onClose = { ( ) => setLoginOpen ( false ) }
0 commit comments