Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(ui): support per-notification class names (#7764)

wpxp123456ee793e17b238
diff --git a/packages/ui/src/services/notification/__tests__/desktop-notification.service.spec.ts b/packages/ui/src/services/notification/__tests__/desktop-notification.service.spec.ts
index 4a8d5a77f4..d3b326c06a 100644
--- a/packages/ui/src/services/notification/__tests__/desktop-notification.service.spec.ts
+++ b/packages/ui/src/services/notification/__tests__/desktop-notification.service.spec.ts
@@ -50,6 +50,10 @@ describe('DesktopNotificationService', () => {
label: 'Reload page',
onClick,
},
+ classNames: {
+ toast: 'notification-toast',
+ actionButton: 'notification-action',
+ },
});
expect(showToast).toHaveBeenCalledWith('Conflict', {
@@ -62,6 +66,10 @@ describe('DesktopNotificationService', () => {
label: 'Reload page',
onClick,
},
+ classNames: {
+ toast: 'notification-toast',
+ actionButton: 'notification-action',
+ },
});
disposable.dispose();
expect(dismissToast).toHaveBeenCalledWith('conflict-toast');
diff --git a/packages/ui/src/views/notification/Notification.tsx b/packages/ui/src/views/notification/Notification.tsx
index c9f0b12a8a..0b178a5aa9 100644
--- a/packages/ui/src/views/notification/Notification.tsx
+++ b/packages/ui/src/views/notification/Notification.tsx
@@ -57,6 +57,9 @@ export interface INotificationOptions {
/** An action rendered inside the notification */
action?: NonNullable<Parameters<typeof toast>[1]>['action'];
+
+ /** Classes applied to parts of this notification */
+ classNames?: NonNullable<Parameters<typeof toast>[1]>['classNames'];
}
export const notification = {
@@ -70,6 +73,7 @@ export const notification = {
dismissible = true,
position = 'top-right',
action,
+ classNames,
} = options;
return toast[type](title, {
@@ -79,6 +83,7 @@ export const notification = {
closeButton: closable,
dismissible,
action,
+ ...(classNames ? { classNames } : {}),
});
},
dismiss: (id: string | number) => toast.dismiss(id),