@@ -11,6 +11,7 @@ import Paper from "@material-ui/core/Paper";
11
11
import ClickAwayListener from "@material-ui/core/ClickAwayListener" ;
12
12
import Hidden from "@material-ui/core/Hidden" ;
13
13
import Poppers from "@material-ui/core/Popper" ;
14
+ import Divider from "@material-ui/core/Divider" ;
14
15
// @material -ui/icons
15
16
import Person from "@material-ui/icons/Person" ;
16
17
import Notifications from "@material-ui/icons/Notifications" ;
@@ -24,23 +25,30 @@ import headerLinksStyle from "assets/jss/material-dashboard-react/components/hea
24
25
25
26
class AdminNavbarLinks extends React . Component {
26
27
state = {
27
- open : false
28
+ openNotifcation : false ,
29
+ openProfile : false
28
30
} ;
29
- handleToggle = ( ) => {
30
- this . setState ( state => ( { open : ! state . open } ) ) ;
31
+ handleToggleNotification = ( ) => {
32
+ this . setState ( state => ( { openNotifcation : ! state . openNotifcation } ) ) ;
31
33
} ;
32
-
33
- handleClose = event => {
34
- if ( this . anchorEl . contains ( event . target ) ) {
34
+ handleCloseNotification = event => {
35
+ if ( this . anchorNotification . contains ( event . target ) ) {
35
36
return ;
36
37
}
37
-
38
- this . setState ( { open : false } ) ;
38
+ this . setState ( { openNotifcation : false } ) ;
39
+ } ;
40
+ handleToggleProfile = ( ) => {
41
+ this . setState ( state => ( { openProfile : ! state . openProfile } ) ) ;
42
+ } ;
43
+ handleCloseProfile = event => {
44
+ if ( this . anchorProfile . contains ( event . target ) ) {
45
+ return ;
46
+ }
47
+ this . setState ( { openProfile : false } ) ;
39
48
} ;
40
-
41
49
render ( ) {
42
50
const { classes } = this . props ;
43
- const { open } = this . state ;
51
+ const { openNotifcation , openProfile } = this . state ;
44
52
return (
45
53
< div >
46
54
< div className = { classes . searchWrapper } >
@@ -74,14 +82,14 @@ class AdminNavbarLinks extends React.Component {
74
82
< div className = { classes . manager } >
75
83
< Button
76
84
buttonRef = { node => {
77
- this . anchorEl = node ;
85
+ this . anchorNotification = node ;
78
86
} }
79
87
color = { window . innerWidth > 959 ? "transparent" : "white" }
80
88
justIcon = { window . innerWidth > 959 }
81
89
simple = { ! ( window . innerWidth > 959 ) }
82
- aria-owns = { open ? "menu-list-grow" : null }
90
+ aria-owns = { openNotifcation ? "notification- menu-list-grow" : null }
83
91
aria-haspopup = "true"
84
- onClick = { this . handleToggle }
92
+ onClick = { this . handleToggleNotification }
85
93
className = { classes . buttonLink }
86
94
>
87
95
< Notifications className = { classes . icons } />
@@ -93,54 +101,54 @@ class AdminNavbarLinks extends React.Component {
93
101
</ Hidden >
94
102
</ Button >
95
103
< Poppers
96
- open = { open }
97
- anchorEl = { this . anchorEl }
104
+ open = { openNotifcation }
105
+ anchorEl = { this . anchorNotification }
98
106
transition
99
107
disablePortal
100
108
className = {
101
- classNames ( { [ classes . popperClose ] : ! open } ) +
109
+ classNames ( { [ classes . popperClose ] : ! openNotifcation } ) +
102
110
" " +
103
111
classes . popperNav
104
112
}
105
113
>
106
114
{ ( { TransitionProps, placement } ) => (
107
115
< Grow
108
116
{ ...TransitionProps }
109
- id = "menu-list-grow"
117
+ id = "notification- menu-list-grow"
110
118
style = { {
111
119
transformOrigin :
112
120
placement === "bottom" ? "center top" : "center bottom"
113
121
} }
114
122
>
115
123
< Paper >
116
- < ClickAwayListener onClickAway = { this . handleClose } >
124
+ < ClickAwayListener onClickAway = { this . handleCloseNotification } >
117
125
< MenuList role = "menu" >
118
126
< MenuItem
119
- onClick = { this . handleClose }
127
+ onClick = { this . handleCloseNotification }
120
128
className = { classes . dropdownItem }
121
129
>
122
130
Mike John responded to your email
123
131
</ MenuItem >
124
132
< MenuItem
125
- onClick = { this . handleClose }
133
+ onClick = { this . handleCloseNotification }
126
134
className = { classes . dropdownItem }
127
135
>
128
136
You have 5 new tasks
129
137
</ MenuItem >
130
138
< MenuItem
131
- onClick = { this . handleClose }
139
+ onClick = { this . handleCloseNotification }
132
140
className = { classes . dropdownItem }
133
141
>
134
142
You{ "'" } re now friend with Andrew
135
143
</ MenuItem >
136
144
< MenuItem
137
- onClick = { this . handleClose }
145
+ onClick = { this . handleCloseNotification }
138
146
className = { classes . dropdownItem }
139
147
>
140
148
Another Notification
141
149
</ MenuItem >
142
150
< MenuItem
143
- onClick = { this . handleClose }
151
+ onClick = { this . handleCloseNotification }
144
152
className = { classes . dropdownItem }
145
153
>
146
154
Another One
@@ -152,18 +160,73 @@ class AdminNavbarLinks extends React.Component {
152
160
) }
153
161
</ Poppers >
154
162
</ div >
155
- < Button
156
- color = { window . innerWidth > 959 ? "transparent" : "white" }
157
- justIcon = { window . innerWidth > 959 }
158
- simple = { ! ( window . innerWidth > 959 ) }
159
- aria-label = "Person"
160
- className = { classes . buttonLink }
161
- >
162
- < Person className = { classes . icons } />
163
- < Hidden mdUp implementation = "css" >
164
- < p className = { classes . linkText } > Profile</ p >
165
- </ Hidden >
166
- </ Button >
163
+ < div className = { classes . manager } >
164
+ < Button
165
+ buttonRef = { node => {
166
+ this . anchorProfile = node ;
167
+ } }
168
+ color = { window . innerWidth > 959 ? "transparent" : "white" }
169
+ justIcon = { window . innerWidth > 959 }
170
+ simple = { ! ( window . innerWidth > 959 ) }
171
+ aria-owns = { openNotifcation ? "profile-menu-list-grow" : null }
172
+ aria-haspopup = "true"
173
+ onClick = { this . handleToggleProfile }
174
+ className = { classes . buttonLink }
175
+ >
176
+ < Person className = { classes . icons } />
177
+ < Hidden mdUp implementation = "css" >
178
+ < p className = { classes . linkText } > Profile</ p >
179
+ </ Hidden >
180
+ </ Button >
181
+ < Poppers
182
+ open = { openProfile }
183
+ anchorEl = { this . anchorProfile }
184
+ transition
185
+ disablePortal
186
+ className = {
187
+ classNames ( { [ classes . popperClose ] : ! openProfile } ) +
188
+ " " +
189
+ classes . popperNav
190
+ }
191
+ >
192
+ { ( { TransitionProps, placement } ) => (
193
+ < Grow
194
+ { ...TransitionProps }
195
+ id = "profile-menu-list-grow"
196
+ style = { {
197
+ transformOrigin :
198
+ placement === "bottom" ? "center top" : "center bottom"
199
+ } }
200
+ >
201
+ < Paper >
202
+ < ClickAwayListener onClickAway = { this . handleCloseProfile } >
203
+ < MenuList role = "menu" >
204
+ < MenuItem
205
+ onClick = { this . handleCloseProfile }
206
+ className = { classes . dropdownItem }
207
+ >
208
+ Profile
209
+ </ MenuItem >
210
+ < MenuItem
211
+ onClick = { this . handleCloseProfile }
212
+ className = { classes . dropdownItem }
213
+ >
214
+ Settings
215
+ </ MenuItem >
216
+ < Divider light />
217
+ < MenuItem
218
+ onClick = { this . handleCloseProfile }
219
+ className = { classes . dropdownItem }
220
+ >
221
+ Logout
222
+ </ MenuItem >
223
+ </ MenuList >
224
+ </ ClickAwayListener >
225
+ </ Paper >
226
+ </ Grow >
227
+ ) }
228
+ </ Poppers >
229
+ </ div >
167
230
</ div >
168
231
) ;
169
232
}
0 commit comments