- Notifications
You must be signed in to change notification settings - Fork1.1k
refactor(site): Refactor alerts#7587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
26d7edd550959e40994774831c6dd56172c8fe971998b97e3709b1ed94ba2ea21aa9a2669527d112aa1200b5e4eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,122 +1,64 @@ | ||
| import { useState, FC,ReactNode, PropsWithChildren } from "react" | ||
| import Collapse from "@mui/material/Collapse" | ||
| import { Stack } from "components/Stack/Stack" | ||
| import Alert, { AlertProps } from "@mui/material/Alert" | ||
| import Button from "@mui/material/Button" | ||
| export interface AlertBannerProps { | ||
| severity: AlertProps["severity"] | ||
| actions?: ReactNode[] | ||
| dismissible?: boolean | ||
| onRetry?: () => void | ||
| onDismiss?: () => void | ||
| } | ||
| export const AlertBanner: FC<PropsWithChildren<AlertBannerProps>> = ({ | ||
| children, | ||
| actions = [], | ||
| onRetry, | ||
| dismissible, | ||
| severity, | ||
| onDismiss, | ||
| }) => { | ||
| const [open, setOpen] = useState(true) | ||
| return ( | ||
| <Collapse in={open}> | ||
| <Alert | ||
| severity={severity} | ||
| action={ | ||
| <Stack direction="row"> | ||
| {/* CTAs passed in by the consumer */} | ||
| {actions.length > 0 && | ||
| actions.map((action) => <div key={String(action)}>{action}</div>)} | ||
| {/* retry CTA */} | ||
| {onRetry && ( | ||
| <div> | ||
| <Button size="small" onClick={onRetry}> | ||
| Retry | ||
| </Button> | ||
| </div> | ||
| )} | ||
| {/* close CTA */} | ||
| {dismissible && ( | ||
| <Button | ||
| size="small" | ||
| onClick={() => { | ||
| setOpen(false) | ||
| onDismiss && onDismiss() | ||
| }} | ||
| data-testid="dismiss-banner-btn" | ||
| > | ||
| Dismiss | ||
| </Button> | ||
| )} | ||
| </Stack> | ||
| } | ||
| > | ||
| {children} | ||
| </Alert> | ||
| </Collapse> | ||
| ) | ||
| } | ||
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.