From f8fb4fa96d724f657430b70245b38b56319ee3ce Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 16 Jan 2021 19:42:06 +0800 Subject: [PATCH] feat(Toast): add overlayClass option (#7925) --- src/toast/README.md | 1 + src/toast/README.zh-CN.md | 1 + src/toast/Toast.js | 2 ++ src/toast/index.js | 1 + types/toast.d.ts | 1 + 5 files changed, 6 insertions(+) diff --git a/src/toast/README.md b/src/toast/README.md index 09bd7254b..ca3a3ea2a 100644 --- a/src/toast/README.md +++ b/src/toast/README.md @@ -161,6 +161,7 @@ Toast.resetDefaultOptions('loading'); | loadingType | Loading icon type, can be set to `spinner` | _string_ | `circular` | | duration | Toast duration(ms), won't disappear if value is 0 | _number_ | `2000` | | className | Custom className | _any_ | - | +| overlayClass `v3.0.4` | Custom overlay class | _string \| string[] \| object_ | - | | overlayStyle `v3.0.4` | Custom overlay style | _object_ | - | | onOpened | Callback function after opened | _Function_ | - | | onClose | Callback function after close | _Function_ | - | diff --git a/src/toast/README.zh-CN.md b/src/toast/README.zh-CN.md index 67c4d7f60..83e6df113 100644 --- a/src/toast/README.zh-CN.md +++ b/src/toast/README.zh-CN.md @@ -174,6 +174,7 @@ Toast.resetDefaultOptions('loading'); | loadingType | [加载图标类型](#/zh-CN/loading), 可选值为 `spinner` | _string_ | `circular` | | duration | 展示时长(ms),值为 0 时,toast 不会消失 | _number_ | `2000` | | className | 自定义类名 | _any_ | - | +| overlayClass `v3.0.4` | 自定义遮罩层类名 | _string \| string[] \| object_ | - | | overlayStyle `v3.0.4` | 自定义遮罩层样式 | _object_ | - | | onOpened | 完全展示后的回调函数 | _Function_ | - | | onClose | 关闭时的回调函数 | _Function_ | - | diff --git a/src/toast/Toast.js b/src/toast/Toast.js index f68b3d7b3..759228029 100644 --- a/src/toast/Toast.js +++ b/src/toast/Toast.js @@ -22,6 +22,7 @@ export default createComponent({ lockScroll: Boolean, loadingType: String, forbidClick: Boolean, + overlayClass: null, overlayStyle: Object, closeOnClick: Boolean, type: { @@ -116,6 +117,7 @@ export default createComponent({ ]} lockScroll={false} transition={props.transition} + overlayClass={props.overlayClass} overlayStyle={props.overlayStyle} onClick={onClick} onClosed={clearTimer} diff --git a/src/toast/index.js b/src/toast/index.js index 953294b01..f52d8f488 100644 --- a/src/toast/index.js +++ b/src/toast/index.js @@ -18,6 +18,7 @@ const defaultOptions = { transition: 'van-fade', forbidClick: false, loadingType: undefined, + overlayClass: '', overlayStyle: null, closeOnClick: false, closeOnClickOverlay: false, diff --git a/types/toast.d.ts b/types/toast.d.ts index 6ddc56cc6..12ad6b3cf 100644 --- a/types/toast.d.ts +++ b/types/toast.d.ts @@ -22,6 +22,7 @@ export type ToastOptions = { loadingType?: ToastLoadingType; forbidClick?: boolean; closeOnClick?: boolean; + overlayClass?: any; overlayStyle?: Record; closeOnClickOverlay?: boolean; };