-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added popup on small devices (#2501)
- Loading branch information
1 parent
064d0e3
commit 0872ba3
Showing
4 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
verification/curator-service/ui/src/components/PopupSmallScreens.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import CloseIcon from '@material-ui/icons/Close'; | ||
import { | ||
createStyles, | ||
useTheme, | ||
useMediaQuery, | ||
Dialog, | ||
DialogTitle, | ||
IconButton, | ||
DialogContent, | ||
Theme, | ||
Typography, | ||
withStyles, | ||
WithStyles, | ||
} from '@material-ui/core'; | ||
|
||
type Props = WithStyles<typeof styles> & { | ||
rootComponentRef: React.RefObject<HTMLDivElement>; | ||
triggerComponentRef: React.RefObject<HTMLButtonElement>; | ||
isOpen: boolean; | ||
onToggle: () => void; | ||
}; | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
dialogContainer: { | ||
height: '40%', | ||
}, | ||
dialogTitle: { | ||
display: 'flex', | ||
}, | ||
closeButton: { | ||
position: 'absolute', | ||
right: 8, | ||
top: 8, | ||
}, | ||
}); | ||
|
||
const PopupSmallScreens = ({ classes }: Props) => { | ||
const theme = useTheme(); | ||
const [dialogOpen, setDialogOpen] = useState(false); | ||
|
||
/** | ||
@name matches - value of the current browser window in pixels | ||
**/ | ||
|
||
const matches = useMediaQuery(theme.breakpoints.down('md')); | ||
|
||
useEffect(() => { | ||
setDialogOpen(matches); | ||
}, [matches]); | ||
|
||
const handleClose = () => { | ||
setDialogOpen(false); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
open={dialogOpen} | ||
onClose={handleClose} | ||
className={classes.dialogContainer} | ||
id="popup-small-screens" | ||
> | ||
<DialogTitle className={classes.dialogTitle}> | ||
Important | ||
<IconButton | ||
aria-label="close" | ||
onClick={handleClose} | ||
className={classes.closeButton} | ||
id="small-screens-popup-close-btn" | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</DialogTitle> | ||
<DialogContent dividers> | ||
<Typography gutterBottom> | ||
For a better experience please visit this website using a | ||
device with a larger screen | ||
</Typography> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default withStyles(styles, { withTheme: true })(PopupSmallScreens); |