blob: e8cfbc63ee7fd2d99bbbe374352e22d79694222f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
import React from 'react';
import Button from '@material-ui/core/Button';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import Grow from '@material-ui/core/Grow';
import Fade from '@material-ui/core/Fade';
import Zoom from '@material-ui/core/Zoom';
import Grid from '@material-ui/core/Grid';
class MenuTransition extends React.Component {
state = {
anchorFade: null,
anchorGrow: null,
anchorCollapse: null,
anchorZoom: null,
};
handleClick = (event, type) => {
this.setState({ [type]: event.currentTarget });
};
handleClose = type => {
this.setState({ [type]: null });
};
handleToggle = type => {
// eslint-disable-next-line
this.setState({ [type]: !this.state[type] });
};
render() {
const {
anchorFade,
anchorGrow,
anchorZoom
} = this.state;
return (
<Grid container spacing={2}>
<Grid item md={4}>
<Button
aria-owns={anchorFade ? 'fade-menu' : null}
aria-haspopup="true"
onClick={(e) => this.handleClick(e, 'anchorFade')}
>
Open with fade transition
</Button>
<Menu
id="fade-menu"
anchorEl={anchorFade}
open={Boolean(anchorFade)}
onClose={() => this.handleClose('anchorFade')}
TransitionComponent={Fade}
>
<MenuItem onClick={() => this.handleClose('anchorFade')}>Profile</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorFade')}>My account</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorFade')}>Logout</MenuItem>
</Menu>
</Grid>
<Grid item md={4}>
<Button
aria-owns={anchorGrow ? 'grow-menu' : null}
aria-haspopup="true"
onClick={(e) => this.handleClick(e, 'anchorGrow')}
>
Open with grow transition
</Button>
<Menu
id="grow-menu"
anchorEl={anchorGrow}
open={Boolean(anchorGrow)}
onClose={() => this.handleClose('anchorGrow')}
TransitionComponent={Grow}
>
<MenuItem onClick={() => this.handleClose('anchorGrow')}>Profile</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorGrow')}>My account</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorGrow')}>Logout</MenuItem>
</Menu>
</Grid>
<Grid item md={4}>
<div style={{ position: 'relative' }}>
<Button
aria-owns={anchorZoom ? 'zoom-menu' : null}
aria-haspopup="true"
onClick={(e) => this.handleClick(e, 'anchorZoom')}
>
Open with zoom transition
</Button>
<Menu
id="zoom-menu"
anchorEl={anchorZoom}
open={Boolean(anchorZoom)}
onClose={() => this.handleClose('anchorZoom')}
TransitionComponent={Zoom}
>
<MenuItem onClick={() => this.handleClose('anchorZoom')}>Profile</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorZoom')}>My account</MenuItem>
<MenuItem onClick={() => this.handleClose('anchorZoom')}>Logout</MenuItem>
</Menu>
</div>
</Grid>
</Grid>
);
}
}
export default MenuTransition;
|