-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
/
PopoverPopupState.js
48 lines (43 loc) · 1.29 KB
/
PopoverPopupState.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
47
48
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 Popover from '@material-ui/core/Popover';
import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state/index';
const styles = theme => ({
typography: {
margin: theme.spacing(2),
},
});
function PopoverPopupState(props) {
const { classes } = props;
return (
<PopupState variant="popover" popupId="demo-popup-popover">
{popupState => (
<div>
<Button variant="contained" {...bindTrigger(popupState)}>
Open Popover
</Button>
<Popover
{...bindPopover(popupState)}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
>
<Typography className={classes.typography}>The content of the Popover.</Typography>
</Popover>
</div>
)}
</PopupState>
);
}
PopoverPopupState.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(PopoverPopupState);