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;
};
export type ToastOptions = {
duration: number;
};
/**
* @example
* ```ts
* toast('Hello World');
* ```
*/
export const toast = (message: string, duration = 2500) => {
export const toast = (message: string, { duration = 2500 }: ToastOptions) => {
if (!ToastContainer) {
ToastContainer = createToastContainer();
}
@@ -101,4 +105,5 @@ export const toast = (message: string, duration = 2500) => {
return element;
};
export default toast;