refactor(core): replace all notification relies on jotai (#6417)

- remove all notification that implemented with jotai and replaced with new `notify`
- Add some notify presets:
  - `notify.error`
  - `notify.success`
  - `notify.warning`
This commit is contained in:
CatsJuice
2024-04-02 03:19:06 +00:00
parent a4cd51e503
commit 9127bfae67
24 changed files with 150 additions and 201 deletions

View File

@@ -1,3 +1,4 @@
import { SingleSelectSelectSolidIcon } from '@blocksuite/icons';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import { type CSSProperties, type FC, useMemo } from 'react';
import { type ExternalToast, toast, Toaster } from 'sonner';
@@ -54,6 +55,29 @@ export function notify(notification: Notification, options?: ExternalToast) {
}, options);
}
notify.error = (notification: Notification, options?: ExternalToast) => {
return notify({ style: 'alert', theme: 'error', ...notification }, options);
};
notify.success = (notification: Notification, options?: ExternalToast) => {
return notify(
{
icon: <SingleSelectSelectSolidIcon />,
style: 'alert',
theme: 'success',
...notification,
},
options
);
};
notify.warning = (notification: Notification, options?: ExternalToast) => {
return notify(
{ style: 'information', theme: 'warning', ...notification },
options
);
};
notify.custom = (
Component: FC<NotificationCustomRendererProps>,
options?: ExternalToast