-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
/
PopperPopupState.js
46 lines (41 loc) · 1.32 KB
/
PopperPopupState.js
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
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import Popper from '@material-ui/core/Popper';
import PopupState, { bindToggle, bindPopper } from 'material-ui-popup-state/index';
import Fade from '@material-ui/core/Fade';
import Paper from '@material-ui/core/Paper';
const styles = theme => ({
typography: {
padding: theme.spacing(2),
},
});
function PopperPopupState(props) {
const { classes } = props;
return (
<PopupState variant="popper" popupId="demo-popup-popper">
{popupState => (
<div>
<Button variant="contained" {...bindToggle(popupState)}>
Toggle Popper
</Button>
<Popper {...bindPopper(popupState)} transition>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper>
<Typography className={classes.typography}>The content of the Popper.</Typography>
</Paper>
</Fade>
)}
</Popper>
</div>
)}
</PopupState>
);
}
PopperPopupState.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(PopperPopupState);