1
- import React from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
import Drawer from "@material-ui/core/Drawer" ;
3
- import { Grid , Typography } from "@material-ui/core" ;
3
+ import { Grid } from "@material-ui/core" ;
4
4
import List from "@material-ui/core/List" ;
5
5
import AccountBalanceWalletOutlinedIcon from "@material-ui/icons/AccountBalanceWalletOutlined" ;
6
6
import CachedIcon from "@material-ui/icons/Cached" ;
@@ -9,7 +9,8 @@ import RemoveRedEyeOutlinedIcon from "@material-ui/icons/RemoveRedEyeOutlined";
9
9
import SettingsIcon from "@material-ui/icons/Settings" ;
10
10
import SportsEsportsIcon from "@material-ui/icons/SportsEsports" ;
11
11
import TrendingUpIcon from "@material-ui/icons/TrendingUp" ;
12
- import { createStyles , makeStyles , Theme } from "@material-ui/core/styles" ;
12
+ import { makeStyles } from "@material-ui/core/styles" ;
13
+ import { useLocation , useRouteMatch } from "react-router-dom" ;
13
14
import { Path } from "../../../router/Path" ;
14
15
import MenuItem , { MenuItemProps } from "./MenuItem" ;
15
16
import Overview from "../../../dashboard/overview/Overview" ;
@@ -20,6 +21,7 @@ import Console from "../../../dashboard/console/Console";
20
21
import { isElectron , sendMessageToParent } from "../../utils/appUtil" ;
21
22
import Button from "../input/buttons/Button" ;
22
23
import Settings from "../../../settings/Settings" ;
24
+ import { OpenDexMainLogo } from "../icons/OpenDexMainLogo" ;
23
25
24
26
export const menuItems : MenuItemProps [ ] = [
25
27
{
@@ -53,27 +55,44 @@ export const menuItems: MenuItemProps[] = [
53
55
component : Console ,
54
56
icon : SportsEsportsIcon ,
55
57
} ,
58
+ {
59
+ path : Path . SETTINGS ,
60
+ text : "Settings" ,
61
+ component : < Settings /> ,
62
+ icon : SettingsIcon ,
63
+ } ,
56
64
] ;
57
65
58
- export const drawerWidth = 200 ;
66
+ export const drawerWidth = 250 ;
59
67
60
- const useStyles = makeStyles ( ( theme : Theme ) =>
61
- createStyles ( {
62
- drawerPaper : {
63
- width : drawerWidth ,
64
- justifyContent : "space-between" ,
65
- } ,
66
- menuContainer : {
67
- width : "100%" ,
68
- } ,
69
- header : {
70
- padding : "16px" ,
71
- } ,
72
- drawerButton : {
73
- margin : theme . spacing ( 2 ) ,
74
- } ,
75
- } )
76
- ) ;
68
+ const useStyles = makeStyles ( ( theme ) => ( {
69
+ drawerPaper : {
70
+ width : drawerWidth ,
71
+ justifyContent : "space-between" ,
72
+ background : "linear-gradient(#101013, #1c2027, #1a1112, #171011)" ,
73
+ border : "none" ,
74
+ } ,
75
+ menuContainer : {
76
+ width : "100%" ,
77
+ paddingLeft : "10px" ,
78
+ } ,
79
+ drawerButton : {
80
+ margin : theme . spacing ( 2 ) ,
81
+ } ,
82
+ borderRadiusContainer : {
83
+ height : "25px" ,
84
+ } ,
85
+ borderRadiusOfTopContainer : {
86
+ borderRadius : "0px 0px 25px 0px" ,
87
+ boxShadow : "25px 0px 0px #0c0c0c" ,
88
+ transition : "box-shadow 0.1s ease" ,
89
+ } ,
90
+ borderRadiusOfBottomContainer : {
91
+ borderRadius : "0px 25px 0px 0px" ,
92
+ boxShadow : "25px 0px 0px #0c0c0c" ,
93
+ transition : "box-shadow 0.1s ease" ,
94
+ } ,
95
+ } ) ) ;
77
96
78
97
export interface MenuProps {
79
98
syncInProgress : boolean ;
@@ -82,6 +101,22 @@ export interface MenuProps {
82
101
83
102
export const Menu : React . FunctionComponent < MenuProps > = ( props ) => {
84
103
const classes = useStyles ( ) ;
104
+ const { url } = useRouteMatch ( ) ;
105
+ const { pathname } = useLocation ( ) ;
106
+ const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
107
+
108
+ const handleSetSelectedIndex = ( ) => {
109
+ const activeItem = menuItems . findIndex (
110
+ ( item ) =>
111
+ pathname === `${ url } ${ item . path } ` ||
112
+ pathname . startsWith ( `${ url } ${ item . path } /` )
113
+ ) ;
114
+ setSelectedIndex ( activeItem ) ;
115
+ } ;
116
+
117
+ useEffect ( ( ) => {
118
+ handleSetSelectedIndex ( ) ;
119
+ } ) ;
85
120
86
121
const disconnect = ( ) : void => {
87
122
sendMessageToParent ( "disconnect" ) ;
@@ -96,17 +131,21 @@ export const Menu: React.FunctionComponent<MenuProps> = (props) => {
96
131
anchor = "left"
97
132
>
98
133
< Grid container item >
99
- < Typography
100
- className = { classes . header }
101
- variant = "overline"
102
- component = "p"
103
- color = "textSecondary"
104
- >
105
- OpenDEX
106
- </ Typography >
134
+ < OpenDexMainLogo />
107
135
< List className = { classes . menuContainer } >
108
- { menuItems . map ( ( item ) => (
136
+ < div
137
+ className = {
138
+ selectedIndex === 0
139
+ ? `${ classes . borderRadiusOfTopContainer } ${ classes . borderRadiusContainer } `
140
+ : classes . borderRadiusContainer
141
+ }
142
+ > </ div >
143
+
144
+ { menuItems . map ( ( item , i ) => (
109
145
< MenuItem
146
+ isBeforeSelected = { i + 1 === selectedIndex && selectedIndex !== - 1 }
147
+ isAfterSelected = { i - 1 === selectedIndex && selectedIndex !== - 1 }
148
+ selected = { i === selectedIndex }
110
149
path = { item . path }
111
150
text = { item . text }
112
151
component = { item . component }
@@ -117,17 +156,16 @@ export const Menu: React.FunctionComponent<MenuProps> = (props) => {
117
156
tooltipTextRows = { props . menuItemTooltipMsg }
118
157
/>
119
158
) ) }
159
+ < div
160
+ className = {
161
+ selectedIndex === menuItems . length - 1
162
+ ? `${ classes . borderRadiusOfBottomContainer } ${ classes . borderRadiusContainer } `
163
+ : classes . borderRadiusContainer
164
+ }
165
+ > </ div >
120
166
</ List >
121
167
</ Grid >
122
168
< Grid container item direction = "column" justify = "flex-end" >
123
- < Grid item container >
124
- < MenuItem
125
- path = { Path . SETTINGS }
126
- text = { "Settings" }
127
- component = { Settings }
128
- icon = { SettingsIcon }
129
- />
130
- </ Grid >
131
169
{ isElectron ( ) && (
132
170
< Grid item container justify = "center" >
133
171
< Button
0 commit comments