mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 21:25:45 +08:00
feat: modify toast interface
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user