Form verticalVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Form verticalVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
ImageViewer backgroundVue demo works fine 1`] = `
ImageViewer backgroundVue demo works fine 1`] = `
>
diff --git a/src/overlay/__test__/__snapshots__/demo.test.jsx.snap b/src/overlay/__test__/__snapshots__/demo.test.jsx.snap
index 4b6e78017..a3f8ec3c1 100644
--- a/src/overlay/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/overlay/__test__/__snapshots__/demo.test.jsx.snap
@@ -8,7 +8,6 @@ exports[`Overlay > Overlay baseVue demo works fine 1`] = `
-
@@ -48,25 +31,6 @@ exports[`Overlay > Overlay baseVue demo works fine 1`] = `
>
-
-
-
-
@@ -96,7 +60,7 @@ exports[`Overlay > Overlay mobileVue demo works fine 1`] = `
- 01 类型
+ 01 组件类型
Overlay mobileVue demo works fine 1`] = `
-
@@ -155,25 +102,6 @@ exports[`Overlay > Overlay mobileVue demo works fine 1`] = `
>
-
-
-
-
diff --git a/src/overlay/__test__/index.test.jsx b/src/overlay/__test__/index.test.jsx
index a63f7c5ee..d85333245 100644
--- a/src/overlay/__test__/index.test.jsx
+++ b/src/overlay/__test__/index.test.jsx
@@ -33,19 +33,6 @@ describe('Overlay', () => {
expect(event.stopPropagation).toHaveBeenCalledTimes(1);
});
- it(': transparent', async () => {
- const wrapper = mount(Overlay, {
- props: {
- visible: true,
- },
- });
- expect(wrapper.find('.t-overlay--transparent').exists()).toEqual(false);
- await wrapper.setProps({
- transparent: true,
- });
- expect(wrapper.find('.t-overlay--transparent').exists()).toEqual(true);
- });
-
it(': duration', async () => {
const wrapper = mount(Overlay, {
props: {
diff --git a/src/overlay/demos/base.vue b/src/overlay/demos/base.vue
index 89e67691e..d4fe35269 100644
--- a/src/overlay/demos/base.vue
+++ b/src/overlay/demos/base.vue
@@ -1,28 +1,10 @@
- 基础遮罩
- 内嵌内容的遮罩
-
-
-
-
+ 基础用法
+
-
-
diff --git a/src/overlay/demos/mobile.vue b/src/overlay/demos/mobile.vue
index 0cfbfbd4c..e039e7de8 100644
--- a/src/overlay/demos/mobile.vue
+++ b/src/overlay/demos/mobile.vue
@@ -2,7 +2,7 @@
Overlay 遮罩层
通过遮罩层,可以强调部分内容
-
+
diff --git a/src/overlay/overlay.en-US.md b/src/overlay/overlay.en-US.md
new file mode 100644
index 000000000..39f5e33ff
--- /dev/null
+++ b/src/overlay/overlay.en-US.md
@@ -0,0 +1,20 @@
+:: BASE_DOC ::
+
+## API
+### Overlay Props
+
+name | type | default | description | required
+-- | -- | -- | -- | --
+backgroundColor | String | - | \- | N
+customStyle | String | - | \- | N
+duration | Number | 300 | \- | N
+preventScrollThrough | Boolean | true | \- | N
+visible | Boolean | false | \- | N
+zIndex | Number | 1000 | \- | N
+onClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`
| N
+
+### Overlay Events
+
+name | params | description
+-- | -- | --
+click | `(context: { e: MouseEvent })` | \-
diff --git a/src/overlay/overlay.md b/src/overlay/overlay.md
index e72390b7e..c45a218d3 100644
--- a/src/overlay/overlay.md
+++ b/src/overlay/overlay.md
@@ -5,12 +5,12 @@
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
-duration | Number | 300 | 动画时长,单位毫秒 | N
-preventScrollThrough | Boolean | true | 防止滚动穿透 | N
-transparent | Boolean | false | 遮罩层是否透明 | N
-visible | Boolean | true | 必需。是否展示 | Y
+backgroundColor | String | - | 遮罩层的背景色 | N
+customStyle | String | - | 遮罩层自定义样式。优先级低于其他属性 | N
+duration | Number | 300 | 背景色过渡时间,单位毫秒 | N
+preventScrollThrough | Boolean | true | 防止滚动穿透,即不允许点击和滚动 | N
+visible | Boolean | false | 是否展示 | N
zIndex | Number | 1000 | 遮罩的层级 | N
-customStyle | String | '' | 弹出层的自定义样式 | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
遮罩层的点击事件 | N
### Overlay Events
diff --git a/src/overlay/overlay.vue b/src/overlay/overlay.vue
index f75c51ffe..15b4347d9 100644
--- a/src/overlay/overlay.vue
+++ b/src/overlay/overlay.vue
@@ -21,16 +21,25 @@ export default defineComponent({
const classes = computed(() => ({
[`${name}`]: true,
[`${name}--active`]: props.visible,
- [`${name}--transparent`]: props.transparent,
}));
- const rootStyles = computed(() =>
- props.customStyle || props.zIndex || props.duration
- ? (props.customStyle && `${props.customStyle};`) +
- (props.zIndex && `z-index:${props.zIndex};`) +
- (props.duration && `transition-duration:${props.duration}ms;`)
- : undefined,
- );
+ const rootStyles = computed(() => {
+ const arr = [];
+
+ if (props.customStyle) {
+ arr.push(props.customStyle);
+ }
+ if (props.zIndex) {
+ arr.push(`z-index: ${props.zIndex}`);
+ }
+ if (props.duration) {
+ arr.push(`transition-duration: ${props.duration}ms`);
+ }
+ if (props.backgroundColor) {
+ arr.push(`background-color: ${props.backgroundColor}`);
+ }
+ return arr.join('; ');
+ });
const handleTouchMove = (e: TouchEvent) => {
if (props.preventScrollThrough) {
diff --git a/src/overlay/props.ts b/src/overlay/props.ts
index 826be00f6..410481257 100644
--- a/src/overlay/props.ts
+++ b/src/overlay/props.ts
@@ -8,34 +8,33 @@ import { TdOverlayProps } from './type';
import { PropType } from 'vue';
export default {
- /** 动画时长,单位毫秒 */
+ /** 遮罩层的背景色 */
+ backgroundColor: {
+ type: String,
+ default: '',
+ },
+ /** 遮罩层自定义样式。优先级低于其他属性 */
+ customStyle: {
+ type: String,
+ default: '',
+ },
+ /** 背景色过渡时间,单位毫秒 */
duration: {
type: Number,
default: 300,
},
- /** 防止滚动穿透 */
+ /** 防止滚动穿透,即不允许点击和滚动 */
preventScrollThrough: {
type: Boolean,
default: true,
},
- /** 遮罩层是否透明 */
- transparent: Boolean,
/** 是否展示 */
- visible: {
- type: Boolean,
- default: true,
- required: true,
- },
+ visible: Boolean,
/** 遮罩的层级 */
zIndex: {
type: Number,
default: 1000,
},
- /** 遮罩的自定义样式 */
- customStyle: {
- type: String,
- default: '',
- },
/** 遮罩层的点击事件 */
onClick: Function as PropType,
};
diff --git a/src/overlay/type.ts b/src/overlay/type.ts
index 7e5eb5f4e..809f61c1a 100644
--- a/src/overlay/type.ts
+++ b/src/overlay/type.ts
@@ -6,35 +6,35 @@
export interface TdOverlayProps {
/**
- * 动画时长,单位毫秒
+ * 遮罩层的背景色
+ * @default ''
+ */
+ backgroundColor?: string;
+ /**
+ * 遮罩层自定义样式。优先级低于其他属性
+ * @default ''
+ */
+ customStyle?: string;
+ /**
+ * 背景色过渡时间,单位毫秒
* @default 300
*/
duration?: number;
/**
- * 防止滚动穿透
+ * 防止滚动穿透,即不允许点击和滚动
* @default true
*/
preventScrollThrough?: boolean;
- /**
- * 遮罩层是否透明
- * @default false
- */
- transparent?: boolean;
/**
* 是否展示
- * @default true
+ * @default false
*/
- visible: boolean;
+ visible?: boolean;
/**
* 遮罩的层级
* @default 1000
*/
zIndex?: number;
- /**
- * 遮罩的自定义样式
- * @default ''
- */
- customStyle?: string;
/**
* 遮罩层的点击事件
*/
diff --git a/src/picker/__test__/__snapshots__/demo.test.jsx.snap b/src/picker/__test__/__snapshots__/demo.test.jsx.snap
index 17b59ece2..241917325 100644
--- a/src/picker/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/picker/__test__/__snapshots__/demo.test.jsx.snap
@@ -59,6 +59,7 @@ exports[`Picker > Picker areaVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker baseVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker baseVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker cascadeVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Picker titleVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup customAnimationVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup mobileVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup placementBottomVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup placementCenterVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup placementLeftVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup placementRightVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
Popup placementTopVue demo works fine 1`] = `
css="true"
name="t-overlay"
persisted="true"
+ transparent="false"
>
{
expect(wrapper.find('.t-popup--content').classes()).toContain(`t-popup--content-${wrapper.vm.placement}`);
});
- it(': showOverlay ', async () => {
- const wrapper = mount(Popup, {
- props: {
- showOverlay: false,
- },
- });
- expect(wrapper.find('.t-overlay').classes('t-overlay--transparent')).toBe(true);
- await wrapper.setProps({
- showOverlay: true,
- });
- expect(wrapper.find('.t-overlay').classes('t-overlay--transparent')).toBe(false);
- });
-
it(': zIndex', async () => {
const wrapper = mount(Popup, {
props: {
diff --git a/src/toast/demos/overlay.vue b/src/toast/demos/overlay.vue
index 5993f6dc8..a449d4e4e 100644
--- a/src/toast/demos/overlay.vue
+++ b/src/toast/demos/overlay.vue
@@ -14,7 +14,7 @@ const showOverlayProps = () => {
theme: 'loading',
message: '加载中...',
showOverlay: true,
- overlayProps: { transparent: true, visible: true },
+ overlayProps: { backgroundColor: 'transparent', visible: true },
preventScrollThrough: false,
});
};