mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-12 18:53:55 +01:00
Merge pull request #2335 from nickofolas/clickaway-notifications
Allow notifications to be dismissed by clicking
This commit is contained in:
commit
f2fa7a3c2d
@ -19,16 +19,17 @@ export function SnackbarProvider(props: IProps): React.ReactElement {
|
|||||||
export const SnackbarEvents = new EventEmitter<[string, "success" | "warning" | "error" | "info", number]>();
|
export const SnackbarEvents = new EventEmitter<[string, "success" | "warning" | "error" | "info", number]>();
|
||||||
|
|
||||||
export function Snackbar(): React.ReactElement {
|
export function Snackbar(): React.ReactElement {
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
SnackbarEvents.subscribe((s, variant, duration) =>
|
SnackbarEvents.subscribe((s, variant, duration) => {
|
||||||
enqueueSnackbar(<Alert severity={variant}>{s}</Alert>, {
|
const id = enqueueSnackbar(<Alert severity={variant}>{s}</Alert>, {
|
||||||
content: (k, m) => <Paper key={k}>{m}</Paper>,
|
content: (k, m) => <Paper key={k}>{m}</Paper>,
|
||||||
variant: variant,
|
variant: variant,
|
||||||
autoHideDuration: duration,
|
autoHideDuration: duration,
|
||||||
|
onClick: () => closeSnackbar(id),
|
||||||
|
})
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user