bug fix and performance improvements

This commit is contained in:
quantulr
2023-08-18 17:32:18 +08:00
parent 3c6ab550cf
commit e750b9be9c
923 changed files with 46650 additions and 9 deletions

View File

@ -0,0 +1,8 @@
### CSS Variables
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-overlay-bg-color | @font-gray-2 | -
--td-overlay-transition-duration | 300ms | -

View File

@ -0,0 +1,57 @@
---
title: Overlay 遮罩层
description: 通过遮罩层,可以强调部分内容
spline: message
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
<div style="background: #ecf2fe; display: flex; align-items: center; line-height: 20px; padding: 14px 24px; border-radius: 3px; color: #555a65">
<svg fill="none" viewBox="0 0 16 16" width="16px" height="16px" style="margin-right: 5px">
<path fill="#0052d9" d="M8 15A7 7 0 108 1a7 7 0 000 14zM7.4 4h1.2v1.2H7.4V4zm.1 2.5h1V12h-1V6.5z" fillOpacity="0.9"></path>
</svg>
该组件于 0.10.0 版本上线,请留意版本。
</div>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-overlay": "tdesign-miniprogram/overlay/overlay"
}
```
## 代码演示
### 基础使用
{{ base }}
## API
### Overlay Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
visible | Boolean | false | 是否展示 | N
zIndex | Number | 11000 | 遮罩层及 | N
duration | Number | 300 | 背景色过渡时间,单位毫秒 | N
backgroundColor | String | - | 遮罩层的背景色 | N
preventScrollThrough | Boolean | true | 防止滚动穿透,即不允许点击和滚动 | N
### Overlay Events
名称 | 参数 | 描述
-- | -- | --
click | `({ visible: boolean })` | 点击遮罩时触发
### CSS 变量
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-overlay-bg-color | @font-gray-2 | -
--td-overlay-transition-duration | 300ms | -

View File

@ -0,0 +1,36 @@
import { SuperComponent } from '../common/src/index';
export default class Overlay extends SuperComponent {
properties: {
zIndex: {
type: NumberConstructor;
value: number;
};
duration: {
type: NumberConstructor;
value: number;
};
backgroundColor: {
type: StringConstructor;
value: string;
};
preventScrollThrough: {
type: BooleanConstructor;
value: boolean;
};
};
behaviors: string[];
data: {
prefix: string;
classPrefix: string;
computedStyle: string;
_zIndex: number;
};
observers: {
backgroundColor(v: any): void;
zIndex(v: any): void;
};
methods: {
handleClick(): void;
noop(): void;
};
}

View File

@ -0,0 +1,65 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { SuperComponent, wxComponent } from '../common/src/index';
import config from '../common/config';
import transition from '../mixins/transition';
const { prefix } = config;
const name = `${prefix}-overlay`;
let Overlay = class Overlay extends SuperComponent {
constructor() {
super(...arguments);
this.properties = {
zIndex: {
type: Number,
value: 11000,
},
duration: {
type: Number,
value: 300,
},
backgroundColor: {
type: String,
value: '',
},
preventScrollThrough: {
type: Boolean,
value: true,
},
};
this.behaviors = [transition()];
this.data = {
prefix,
classPrefix: name,
computedStyle: '',
_zIndex: 11000,
};
this.observers = {
backgroundColor(v) {
this.setData({
computedStyle: `background-color: ${v};`,
});
},
zIndex(v) {
if (v !== 0) {
this.setData({
_zIndex: v,
});
}
},
};
this.methods = {
handleClick() {
this.triggerEvent('click', { visible: !this.properties.visible });
},
noop() { },
};
}
};
Overlay = __decorate([
wxComponent()
], Overlay);
export default Overlay;

View File

@ -0,0 +1,3 @@
{
"component": true
}

View File

@ -0,0 +1,25 @@
<wxs src="../common/utils.wxs" module="_" />
<view
wx:if="{{realVisible && preventScrollThrough}}"
class="{{prefix}}-overlay {{transitionClass}} class"
style="{{_._style(['--td-overlay-transition-duration:' + duration + 'ms', 'z-index:' + _zIndex, computedStyle, style, customStyle])}}"
bind:tap="handleClick"
catchtouchmove="noop"
bind:transitionend="onTransitionEnd"
aria-role="{{ ariaRole || 'button' }}"
aria-label="{{ ariaLabel || '关闭' }}"
>
<slot />
</view>
<view
wx:elif="{{realVisible}}"
class="{{prefix}}-overlay {{transitionClass}} class"
style="{{_._style(['z-index:' + _zIndex, computedStyle, style, customStyle])}}"
bind:tap="handleClick"
bind:transitionend="onTransitionEnd"
aria-role="{{ ariaRole || 'button' }}"
aria-label="{{ ariaLabel || '关闭' }}"
>
<slot />
</view>

View File

@ -0,0 +1,42 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
.t-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
bottom: 0;
background-color: var(--td-overlay-bg-color, var(--td-font-gray-2, rgba(0, 0, 0, 0.6)));
transition: opacity var(--td-overlay-transition-duration, 300ms) ease;
}
.t-fade-enter {
opacity: 0;
}
.t-fade-leave-to {
opacity: 0;
}