visual-identity/app/components/toaster.js

58 lines
1.5 KiB
JavaScript

import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Snackbar from '@material-ui/core/Snackbar';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
const styles = theme => ({
close: {
width: theme.spacing.unit * 4,
height: theme.spacing.unit * 4,
},
});
class SimpleSnackbar extends React.Component {
render() {
const { classes, open, handleClose } = this.props;
return (
<Fragment>
<Snackbar
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
open={open}
autoHideDuration={6000}
onClose={handleClose}
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span id="message-id">Transaction Validated</span>}
action={[
<Button key="undo" color="secondary" size="small" onClick={(e) => handleClose(e, 'UNDO')}>
UNDO
</Button>,
<IconButton
key="close"
aria-label="Close"
color="inherit"
className={classes.close}
onClick={handleClose}
>
<CloseIcon />
</IconButton>,
]}
/>
</Fragment>
);
}
}
SimpleSnackbar.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(SimpleSnackbar);