feat: modify toast interface

This commit is contained in:
QiShaoXuan
2022-12-21 12:29:14 +08:00
parent b32c6ebc89
commit 3be9dbd4a4
+6 -1
View File
@@ -42,13 +42,17 @@ const createToastContainer = () => {
return element; return element;
}; };
export type ToastOptions = {
duration: number;
};
/** /**
* @example * @example
* ```ts * ```ts
* toast('Hello World'); * toast('Hello World');
* ``` * ```
*/ */
export const toast = (message: string, duration = 2500) => { export const toast = (message: string, { duration = 2500 }: ToastOptions) => {
if (!ToastContainer) { if (!ToastContainer) {
ToastContainer = createToastContainer(); ToastContainer = createToastContainer();
} }
@@ -101,4 +105,5 @@ export const toast = (message: string, duration = 2500) => {
return element; return element;
}; };
export default toast; export default toast;