feat(renderer): lib/toast.ts typed wrappers over sonner

This commit is contained in:
2026-06-05 22:46:45 +05:30
parent 6762b5f9af
commit 8160ac05e0
2 changed files with 70 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { toast as sonnerToast } from 'sonner';
/**
* Typed wrappers over sonner's toast API. Centralizing the import gives us
* a single surface to evolve (e.g., add brand colors, action buttons,
* analytics) without touching every call site.
*/
export const toast = {
success: (message: string) => sonnerToast.success(message),
error: (message: string) => sonnerToast.error(message),
info: (message: string) => sonnerToast.info(message),
warning: (message: string) => sonnerToast.warning(message),
promise: <T>(
promise: Promise<T>,
msgs: {
loading: string;
success: string | ((data: T) => string);
error: string | ((err: unknown) => string);
}
) => sonnerToast.promise(promise, msgs),
dismiss: (id?: string | number) => sonnerToast.dismiss(id),
};