-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add visual indicator for apply changes --> patient info reroute (#2532)
* toast implementation * [pre-commit.ci] auto fixes from pre-commit hooks * remove debug param --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9a6e4b6
commit 37b19b0
Showing
8 changed files
with
130 additions
and
17 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
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
77 changes: 77 additions & 0 deletions
77
containers/tefca-viewer/src/app/query/components/RedirectionToast.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,77 @@ | ||
import { Alert, HeadingLevel } from "@trussworks/react-uswds"; | ||
import { toast } from "react-toastify"; | ||
|
||
import styles from "./redirectToast.module.css"; | ||
|
||
export type AlertType = "info" | "success" | "warning" | "error"; | ||
|
||
type RedirectionToastProps = { | ||
toastVariant: AlertType; | ||
heading: string; | ||
body: string; | ||
headingLevel?: HeadingLevel; | ||
}; | ||
/** | ||
* Redirection toast to be invoked when there's a need to confirm with the user | ||
* something has occurred | ||
* @param root0 - The config object to specify content / styling of the toast | ||
* @param root0.toastVariant - A string from the enum set "info" | "success" | "warning" | "error" | ||
* indicating what type of toast variant we want. Will style the USWDS component accordingly | ||
* @param root0.heading - The heading / title of the alert | ||
* @param root0.body - The body content of the alert | ||
* @param root0.headingLevel - string of h1-6 indicating which heading level the alert will be. | ||
* defaults to h4 | ||
* @returns A toast component using the USWDS alert | ||
*/ | ||
const RedirectionToast: React.FC<RedirectionToastProps> = ({ | ||
toastVariant, | ||
heading, | ||
body, | ||
headingLevel, | ||
}) => { | ||
return ( | ||
<Alert | ||
type={toastVariant} | ||
heading={heading} | ||
headingLevel={headingLevel ? headingLevel : "h4"} | ||
> | ||
{body} | ||
</Alert> | ||
); | ||
}; | ||
|
||
const options = { | ||
hideProgressBar: false, | ||
position: "bottom-left" as const, | ||
closeOnClick: true, | ||
closeButton: false, | ||
className: styles.padding0, | ||
bodyClassName: styles.padding0, | ||
pauseOnFocusLoss: false, | ||
}; | ||
|
||
/** | ||
* | ||
* @param content - content object to configure the redirect confirmation toast | ||
* @param content.heading - heading of the redirect toast | ||
* @param content.body - body text of the redirect toast | ||
* @param content.headingLevel - h1-6 level of the heading tag associated with | ||
* content.heading. defaults to h4 | ||
*/ | ||
export function showRedirectConfirmation(content: { | ||
heading: string; | ||
body: string; | ||
headingLevel?: HeadingLevel; | ||
}) { | ||
toast.success( | ||
<RedirectionToast | ||
toastVariant="success" | ||
heading={content.heading} | ||
headingLevel={content.headingLevel} | ||
body={content.body} | ||
/>, | ||
options, | ||
); | ||
} | ||
|
||
export default RedirectionToast; |
7 changes: 7 additions & 0 deletions
7
containers/tefca-viewer/src/app/query/components/redirectToast.module.css
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,7 @@ | ||
.toastWidth { | ||
width: 35%; | ||
} | ||
|
||
.padding0 { | ||
padding: 0 !important; | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.