generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Toast prompt for user feedback form (#2192)
* completed toast * changed toast to be more simple as discussed
- Loading branch information
1 parent
a247697
commit 5156ef0
Showing
5 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,74 @@ | ||
import * as React from "react"; | ||
import { useState } from "react"; | ||
import { Button } from "@mui/material"; | ||
|
||
import Stack from "@mui/material/Stack"; | ||
import Snackbar from "@mui/material/Snackbar"; | ||
import Box from "@mui/material/Box"; | ||
|
||
const SurveySnackbar = () => { | ||
const [open, setOpen] = useState(() => { | ||
const isClosed = localStorage.getItem("surveySnackbarClosed"); | ||
return isClosed !== "true"; | ||
}); | ||
|
||
const handleClose = (event, reason) => { | ||
if (reason === "clickaway") { | ||
return; | ||
} | ||
setOpen(false); | ||
localStorage.setItem("surveySnackbarClosed", "true"); | ||
}; | ||
|
||
const openForm = () => { | ||
window.open( | ||
"https://docs.google.com/forms/d/e/1FAIpQLSdAhi_nMKQfWVHjfpl1ZkmymBTt8BW7YNqVIOJ4JKYgSL4O3g/viewform", | ||
"_blank" | ||
); | ||
}; | ||
|
||
const action = ( | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
width: "520px", | ||
cursor: "pointer", | ||
}} | ||
> | ||
<span> Participate in a quick survey</span> | ||
<Button onClick={openForm}> Complete Survey </Button> | ||
<Button onClick={handleClose}> OPT OUT </Button> | ||
</Box> | ||
); | ||
|
||
return ( | ||
<Stack spacing={2} sx={{ maxWidth: 700 }}> | ||
<Snackbar | ||
open={open} | ||
onClose={handleClose} | ||
action={action} | ||
anchorOrigin={{ vertical: "bottom", horizontal: "right" }} | ||
sx={{ | ||
"& .MuiSnackbar-root": { | ||
width: "100%", | ||
}, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
backgroundColor: "#323232", | ||
color: "white", | ||
padding: 2, | ||
borderRadius: 1, | ||
}} | ||
> | ||
<Box>{action}</Box> | ||
</Box> | ||
</Snackbar> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default SurveySnackbar; |