generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
placing the warning modal in a separate component and module
- Loading branch information
1 parent
2c566c7
commit 5164414
Showing
1 changed file
with
99 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import React from "react"; | ||
import { PropTypes } from "prop-types"; | ||
import Button from "../../Button/Button"; | ||
import { createUseStyles } from "react-jss"; | ||
import { MdWarning } from "react-icons/md"; | ||
import ModalDialog from "./ModalDialog"; | ||
|
||
const useStyles = createUseStyles(theme => ({ | ||
buttonFlexBox: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "center", | ||
margin: 0 | ||
}, | ||
heading1: theme.typography.heading1, | ||
instruction: { | ||
fontSize: "20px", | ||
lineHeight: "32px", | ||
textAlign: "center", | ||
color: "#B64E38", | ||
"& span": { | ||
fontStyle: "italic" | ||
} | ||
}, | ||
warningWrapper: { | ||
color: "#B64E38", | ||
display: "flex", | ||
alignItems: "center" | ||
}, | ||
warningMessage: { | ||
verticalAlign: "middle" | ||
}, | ||
modalActions: { | ||
display: "flex", | ||
justifyContent: "center" | ||
}, | ||
warningIcon: { | ||
margin: "0 10px" | ||
}, | ||
modalSubHeader: theme.typography.subHeading, | ||
modalContent: { | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
padding: "1rem", | ||
width: "100%", | ||
maxWidth: "500px" | ||
} | ||
})); | ||
|
||
const WarningModal = ({ | ||
mounted, | ||
handleDoNotDiscard, | ||
handleConfirmDiscard | ||
}) => { | ||
const classes = useStyles(); | ||
|
||
<ModalDialog | ||
mounted={mounted} | ||
underlayClickExits={false} | ||
underlayColor="rgba(0, 0, 0, 0.4)" | ||
escapeExits={false} | ||
initialFocus="#saveButton" | ||
showCloseBox={false} | ||
> | ||
<h2 className={classes.title}> | ||
<strong>You have unsaved changes</strong> | ||
</h2> | ||
<br /> | ||
<p className={classes.warningWrapper}> | ||
<MdWarning alt="Warning" /> | ||
<span className={classes.warningMessage}> | ||
Are you sure you want to continue without saving? | ||
</span> | ||
</p> | ||
<div className={classes.modalActions}> | ||
<Button | ||
color="colorCancel" | ||
variant="outlined" | ||
id="modalCancel" | ||
onClick={handleDoNotDiscard} | ||
> | ||
Keep Editing | ||
</Button> | ||
<Button color="color" variant="error" onClick={handleConfirmDiscard}> | ||
Discard Changes | ||
</Button> | ||
</div> | ||
</ModalDialog>; | ||
}; | ||
|
||
WarningModal.prototypes = { | ||
mounted: PropTypes.bool, | ||
onClose: PropTypes.func, | ||
project: PropTypes.any | ||
}; | ||
|
||
export default WarningModal; |