Coerce remaining toast variants (lib)
cgen-f665641441ae43f985cd5062ce48c6b9
This commit is contained in:
parent
67cf45ffbc
commit
26d2767120
1 changed files with 42 additions and 3 deletions
|
|
@ -30,27 +30,66 @@ export const aethexToast = {
|
|||
},
|
||||
|
||||
error: (options: AethexToastOptions) => {
|
||||
const normalize = (d?: any) => {
|
||||
if (d == null) return undefined;
|
||||
if (typeof d === "string") return d;
|
||||
if (typeof d === "object") {
|
||||
if ((d as any).message) return String((d as any).message);
|
||||
try {
|
||||
return JSON.stringify(d);
|
||||
} catch (e) {
|
||||
return String(d);
|
||||
}
|
||||
}
|
||||
return String(d);
|
||||
};
|
||||
return toast({
|
||||
title: `⚡ ${options.title || "Error"}`,
|
||||
description: options.description,
|
||||
description: normalize(options.description),
|
||||
duration: options.duration || 5000,
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
|
||||
warning: (options: AethexToastOptions) => {
|
||||
const normalize = (d?: any) => {
|
||||
if (d == null) return undefined;
|
||||
if (typeof d === "string") return d;
|
||||
if (typeof d === "object") {
|
||||
if ((d as any).message) return String((d as any).message);
|
||||
try {
|
||||
return JSON.stringify(d);
|
||||
} catch (e) {
|
||||
return String(d);
|
||||
}
|
||||
}
|
||||
return String(d);
|
||||
};
|
||||
return toast({
|
||||
title: `⚠️ ${options.title || "Warning"}`,
|
||||
description: options.description,
|
||||
description: normalize(options.description),
|
||||
duration: options.duration || 5000,
|
||||
variant: "warning" as any,
|
||||
});
|
||||
},
|
||||
|
||||
info: (options: AethexToastOptions) => {
|
||||
const normalize = (d?: any) => {
|
||||
if (d == null) return undefined;
|
||||
if (typeof d === "string") return d;
|
||||
if (typeof d === "object") {
|
||||
if ((d as any).message) return String((d as any).message);
|
||||
try {
|
||||
return JSON.stringify(d);
|
||||
} catch (e) {
|
||||
return String(d);
|
||||
}
|
||||
}
|
||||
return String(d);
|
||||
};
|
||||
return toast({
|
||||
title: `ℹ️ ${options.title || "Information"}`,
|
||||
description: options.description,
|
||||
description: normalize(options.description),
|
||||
duration: options.duration || 5000,
|
||||
variant: "info" as any,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue