visual-identity/app/components/toaster.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

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={[
2018-08-13 11:21:05 +00:00
<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);