-
Notifications
You must be signed in to change notification settings - Fork 0
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mantine UI Series] Notification ( Systems) and Alert #24
Comments
Notification System and its ApplicationMantine UI's notification system operates as a toast solution, simplifying the process of programmatically. Mantine UI notification system comprises three primary parts:
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: 'Success'
});
},
info: (message: string, options?: NotificationProps) => {
notifications.show({
...options,
color: 'cyan',
icon: <IconInfoCircle size="1.1rem" />,
message,
title: 'Info'
});
}
}; |
Learnings from Mantine UI Notification SystemThe Animation EffectManage Notifications ProgrammaticallyA general solution
Bellow is the sample code: export const NotificationProvider = ({children}) => {
const [notifications, setNotifications] = useState([]);
const value = useMemo({
notifications,
addNotification: (notification) => setNotifications(prevNotifications => [prevNotifications, notification])
}, [notifications]);
return <NotificationProvider value={value}>{children}</NotificationProvider>
};
// How we use the Notification system
const App = () => {
return <NotificationProvider>{/**some other code**/} </NotificationProvider>
}; While this approach is functional, the drawback are
The Novel Solution ( by Mantine UI)
Mantine UI notification system relies on const { state, queue, update, cleanQueue } = useQueue<NotificationProps>({
initialValues: [],
limit,
});
Mantine Notification System employs window as the cross components communication channel for notifications management. Here are how it works under the hood
Following are some key source code screenshot
|
Overview
This article talks about
Notification Vs Alert
At UI and accessibility level, the Notification and Alert components exhibit a striking similarity. However, their usage differs in the following ways:
The text was updated successfully, but these errors were encountered: