1
+ import React from 'react'
2
+ import Button from '@material-ui/core/Button'
3
+ import ClickAwayListener from '@material-ui/core/ClickAwayListener'
4
+ import Grow from '@material-ui/core/Grow'
5
+ import Paper from '@material-ui/core/Paper'
6
+ import Popper from '@material-ui/core/Popper'
7
+ import List from '@material-ui/core/List'
8
+ import ListItem from '@material-ui/core/ListItem'
9
+ import ListItemText from '@material-ui/core/ListItemText'
10
+ import { makeStyles } from '@material-ui/core/styles'
11
+ import NotificationsIcon from '@material-ui/icons/Notifications'
12
+
13
+ const useStyles = makeStyles ( ( theme ) => ( {
14
+ root : {
15
+ display : 'flex' ,
16
+ } ,
17
+ whiteColor : {
18
+ color : '#FFFFFF' ,
19
+ } ,
20
+ paper : {
21
+ marginRight : theme . spacing ( 2 ) ,
22
+ } ,
23
+ btnContainer : {
24
+ position : 'relative' ,
25
+ top : 8 ,
26
+ textTransform : 'none' ,
27
+ color : '#FFFFFF' ,
28
+ } ,
29
+ topElm : {
30
+ zIndex : 9999
31
+ }
32
+ } ) )
33
+
34
+ export default function Lang ( ) {
35
+ const classes = useStyles ( )
36
+ const [ open , setOpen ] = React . useState ( false )
37
+ const anchorRef = React . useRef ( null )
38
+
39
+ const handleToggle = ( ) => {
40
+ setOpen ( ( prevOpen ) => ! prevOpen )
41
+ }
42
+
43
+ const handleClose = ( event ) => {
44
+ if ( anchorRef . current && anchorRef . current . contains ( event . target ) ) {
45
+ return
46
+ }
47
+
48
+ setOpen ( false )
49
+ }
50
+
51
+ // return focus to the button when we transitioned from !open -> open
52
+ const prevOpen = React . useRef ( open )
53
+ React . useEffect ( ( ) => {
54
+ if ( prevOpen . current === true && open === false ) {
55
+ anchorRef . current . focus ( )
56
+ }
57
+
58
+ prevOpen . current = open
59
+ } , [ open ] )
60
+
61
+ return (
62
+ < div className = { classes . root } >
63
+ < div >
64
+ < Button
65
+ ref = { anchorRef }
66
+ aria-controls = { open ? 'menu-list-grow' : undefined }
67
+ aria-haspopup = "true"
68
+ className = { classes . btnContainer }
69
+ onClick = { handleToggle }
70
+ >
71
+ < NotificationsIcon />
72
+ </ Button >
73
+ < Popper open = { open } anchorEl = { anchorRef . current } role = { undefined } transition disablePortal className = { classes . topElm } >
74
+ { ( { TransitionProps, placement } ) => (
75
+ < Grow
76
+ { ...TransitionProps }
77
+ style = { { transformOrigin : placement === 'bottom' ? 'center top' : 'center bottom' } }
78
+ >
79
+ < Paper >
80
+ < ClickAwayListener onClickAway = { handleClose } >
81
+ < List component = "nav" aria-label = "notification" >
82
+ < ListItem button >
83
+ < ListItemText
84
+ primary = "User data has been updated"
85
+ secondary = "User data has been updated text detail description"
86
+ />
87
+ </ ListItem >
88
+ < ListItem button >
89
+ < ListItemText
90
+ primary = "License successfully added"
91
+ secondary = "License successfully added text detail description"
92
+ />
93
+ </ ListItem >
94
+ < ListItem button >
95
+ < ListItemText
96
+ primary = "Service Cache successfully removed"
97
+ secondary = "Service Cache successfully removed text detail description"
98
+ />
99
+ </ ListItem >
100
+ </ List >
101
+ </ ClickAwayListener >
102
+ </ Paper >
103
+ </ Grow >
104
+ ) }
105
+ </ Popper >
106
+ </ div >
107
+ </ div >
108
+ )
109
+ }
0 commit comments