Skip to content

Commit

Permalink
fix: notify ts 相关类型完善 (#1891)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinelink authored Jan 13, 2022
1 parent c8f6169 commit d6e0c9b
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions packages/zent/src/notify/Notify.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ReactNode } from 'react';
import * as ReactDOM from 'react-dom';
import isBrowser from '../utils/isBrowser';
import createElement from '../utils/dom/createElement';
Expand Down Expand Up @@ -75,7 +76,12 @@ const createNotifyContainerNode = (): HTMLElement => {
* @param {[type]} status notify状态
* @param {Function} callback notify消失时回调
*/
const show = (text, duration, status, callback) => {
const show = (
text: ReactNode,
duration?: number,
status?: string,
callback?: () => void
) => {
if (!isBrowser) return null;

const container = createElement('div');
Expand Down Expand Up @@ -108,19 +114,35 @@ const show = (text, duration, status, callback) => {
return containerId;
};

export function success(text, duration?: number, callback?: () => void) {
export function success(
text: ReactNode,
duration?: number,
callback?: () => void
) {
return show(text, duration, 'success', callback);
}

export function warn(text, duration?: number, callback?: () => void) {
export function warn(
text: ReactNode,
duration?: number,
callback?: () => void
) {
return show(text, duration, 'warn', callback);
}

export function error(text, duration?: number, callback?: () => void) {
export function error(
text: ReactNode,
duration?: number,
callback?: () => void
) {
return show(text, duration, 'error', callback);
}

export function info(text, duration?: number, callback?: () => void) {
export function info(
text: ReactNode,
duration?: number,
callback?: () => void
) {
return show(text, duration, 'info', callback);
}

Expand Down

0 comments on commit d6e0c9b

Please sign in to comment.