materialuiupgraded
Version:
Material-UI's workspace package
53 lines (45 loc) • 1.4 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Popper from '@material-ui/core/Popper';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
const styles = theme => ({
typography: {
padding: theme.spacing.unit * 2,
},
});
class NoTransitionPopper extends React.Component {
state = {
anchorEl: null,
};
handleClick = event => {
const { currentTarget } = event;
this.setState(state => ({
anchorEl: state.anchorEl ? null : currentTarget,
}));
};
render() {
const { classes } = this.props;
const { anchorEl } = this.state;
const open = Boolean(anchorEl);
const id = open ? 'no-transition-popper' : null;
return (
<div>
<Button aria-describedby={id} variant="contained" onClick={this.handleClick}>
Toggle Popper
</Button>
<Popper id={id} open={open} anchorEl={anchorEl}>
<Paper>
<Typography className={classes.typography}>The content of the Popper.</Typography>
</Paper>
</Popper>
</div>
);
}
}
NoTransitionPopper.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(NoTransitionPopper);