Skip to content

Commit

Permalink
Ported SnackBar component
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyvugithub committed Jan 18, 2021
1 parent 0188fac commit e176e14
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/frontend/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"next": "^10.0.2",
"react": "^16.13.1",
"react-dom": "^16.13.1"
Expand Down
39 changes: 39 additions & 0 deletions src/frontend/next/src/components/SnackBar/SnackBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState } from 'react';
import Snackbar from '@material-ui/core/Snackbar';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';

type SnackbarProps = {
message: string;
};

const SimpleSnackbar = ({ message }: SnackbarProps) => {
const [open, setOpen] = useState<boolean>(true);

const handleClose = () => {
setOpen(false);
};

return (
<div>
<Snackbar
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
open={open}
autoHideDuration={6000}
message={message}
action={
<>
<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}>
<CloseIcon fontSize="small" />
</IconButton>
</>
}
/>
</div>
);
};

export default SimpleSnackbar;

0 comments on commit e176e14

Please sign in to comment.