Skip to content

Instantly share code, notes, and snippets.

@reboottime
Created August 8, 2023 16:42
Show Gist options
  • Save reboottime/1a7612f048d6934264aecbf5a91bbeb2 to your computer and use it in GitHub Desktop.
Save reboottime/1a7612f048d6934264aecbf5a91bbeb2 to your computer and use it in GitHub Desktop.
import { type NotificationProps } from '@mantine/core';
import { notifications } from '@mantine/notifications';
import { IconCheck, IconInfoCircle, IconX } from '@tabler/icons-react';
const toast = {
error: (message: string, options?: NotificationProps) => {
notifications.show({
...options,
color: 'red',
icon: <IconX size="1.1rem" />,
message,
title: 'Error'
});
},
success: (message: string, options: NotificationProps) => {
notifications.show({
...options,
color: 'green',
icon: <IconCheck size="1.1rem" />,
message,
title: 'Succcess'
});
},
info: (message: string, options?: NotificationProps) => {
notifications.show({
...options,
color: 'cyan',
icon: <IconInfoCircle size="1.1rem" />,
message,
title: 'Info'
});
},
updateNotification: (options: NotificationProps & { id: string; message: string }) => {
notifications.update(options);
}
};
export default toast;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment