diff options
author | eug-vs <eug-vs@keemail.me> | 2020-10-07 23:51:45 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-10-07 23:51:45 +0300 |
commit | a283d4310c11f03fe9ff889c6274798b70cf6a19 (patch) | |
tree | 8c21d1ea50d615a466ddd88143bde274abf14256 /src/components/ModalScreen | |
parent | 4471fef74dfe312a8cf6a1440f5a703e897af136 (diff) | |
download | which-ui-a283d4310c11f03fe9ff889c6274798b70cf6a19.tar.gz |
feat: create ModalScreen component
Diffstat (limited to 'src/components/ModalScreen')
-rw-r--r-- | src/components/ModalScreen/ModalScreen.tsx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/ModalScreen/ModalScreen.tsx b/src/components/ModalScreen/ModalScreen.tsx new file mode 100644 index 0000000..6b7c52c --- /dev/null +++ b/src/components/ModalScreen/ModalScreen.tsx @@ -0,0 +1,39 @@ +import React, { useCallback } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + Dialog, + Toolbar, + Typography, + IconButton, + useMediaQuery, + useTheme +} from '@material-ui/core'; +import CloseIcon from '@material-ui/icons/Close'; + +interface PropTypes { + title: string; +} + +const ModalScreen: React.FC<PropTypes> = ({ title, children }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const history = useHistory(); + + const handleClose = useCallback(() => history.goBack(), [history]); + + return ( + <Dialog fullScreen={isMobile} fullWidth open> + <Toolbar color="primary"> + <IconButton edge="start" onClick={handleClose}> + <CloseIcon /> + </IconButton> + <Typography variant="h6"> + { title } + </Typography> + </Toolbar> + { children } + </Dialog> + ); +}; + +export default ModalScreen; |