bug fix and performance improvements
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
|
||||
### Empty Props
|
||||
|
||||
name | type | default | description | required
|
||||
-- | -- | -- | -- | --
|
||||
action | Slot | - | \- | N
|
||||
description | String / Slot | - | \- | N
|
||||
external-classes | Array | - | `['t-class', 't-class-description', 't-class-image', 't-class-actions']` | N
|
||||
icon | String | - | \- | N
|
||||
image | String / Slot | - | \- | N
|
||||
|
||||
|
||||
### CSS Variables
|
||||
The component provides the following CSS variables, which can be used to customize styles.
|
||||
Name | Default Value | Description
|
||||
-- | -- | --
|
||||
--td-empty-action-margin-top | @spacer-4 | -
|
||||
--td-empty-description-color | @font-gray-3 | -
|
||||
--td-empty-description-font-size | @font-size-base | -
|
||||
--td-empty-description-line-height | 44rpx | -
|
||||
--td-empty-description-margin-top | @spacer-2 | -
|
||||
--td-empty-icon-color | @font-gray-3 | -
|
||||
@ -0,0 +1,63 @@
|
||||
---
|
||||
title: Empty 空状态
|
||||
description: 用于空状态时的占位提示。
|
||||
spline: data
|
||||
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>
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-empty": "tdesign-miniprogram/empty/empty"
|
||||
}
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 类型
|
||||
|
||||
图标空状态
|
||||
|
||||
{{ base }}
|
||||
|
||||
自定义图片空状态
|
||||
|
||||
{{ imageEmpty }}
|
||||
|
||||
带操作空状态
|
||||
|
||||
{{ buttonEmpty }}
|
||||
|
||||
|
||||
|
||||
## API
|
||||
### Empty Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
action | Slot | - | 操作按钮 | N
|
||||
description | String / Slot | - | 描述文字 | N
|
||||
icon | String / Object | - | 图标名称。值为字符串表示图标名称,值为 `Object` 类型,表示透传至 `icon`。 | N
|
||||
image | String / Slot | - | 图片地址 | N
|
||||
|
||||
### Empty 外部样式类
|
||||
类名 | 说明
|
||||
-- | --
|
||||
t-class | 根节点样式类
|
||||
t-class-description | 描述样式类
|
||||
t-class-image | 图片样式类
|
||||
|
||||
### CSS 变量
|
||||
组件提供了下列 CSS 变量,可用于自定义样式。
|
||||
名称 | 默认值 | 描述
|
||||
-- | -- | --
|
||||
--td-empty-action-margin-top | @spacer-4 | -
|
||||
--td-empty-description-color | @font-gray-3 | -
|
||||
--td-empty-description-font-size | @font-size-base | -
|
||||
--td-empty-description-line-height | 44rpx | -
|
||||
--td-empty-description-margin-top | @spacer-2 | -
|
||||
--td-empty-icon-color | @font-gray-3 | -
|
||||
15
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/empty.d.ts
vendored
Normal file
15
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/empty.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class extends SuperComponent {
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
externalClasses: string[];
|
||||
properties: import("./type").TdEmptyProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
};
|
||||
observers: {
|
||||
icon(icon: any): void;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
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 props from './props';
|
||||
import config from '../common/config';
|
||||
import { setIcon } from '../common/utils';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-empty`;
|
||||
let default_1 = class extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.externalClasses = [`${prefix}-class`, `${prefix}-class-description`, `${prefix}-class-image`];
|
||||
this.properties = props;
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
};
|
||||
this.observers = {
|
||||
icon(icon) {
|
||||
const obj = setIcon('icon', icon, '');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
default_1 = __decorate([
|
||||
wxComponent()
|
||||
], default_1);
|
||||
export default default_1;
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "../icon/icon",
|
||||
"t-image": "../image/image"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
<import src="../common/template/icon.wxml" />
|
||||
<wxs src="../common/utils.wxs" module="_" />
|
||||
<wxs src="./empty.wxs" module="utils" />
|
||||
|
||||
<view style="{{_._style([style, customStyle])}}" class="class {{prefix}}-class {{classPrefix}}">
|
||||
<view aria-hidden="true" class="{{classPrefix}}__thumb">
|
||||
<t-image wx:if="{{image}}" t-class="{{prefix}}-class-image" src="{{image}}" mode="aspectFit" />
|
||||
<template
|
||||
wx:elif="{{iconName || _.isNoEmptyObj(iconData)}}"
|
||||
is="icon"
|
||||
data="{{class: classPrefix + '__icon', name: iconName, ...iconData}}"
|
||||
/>
|
||||
<slot wx:else name="image" />
|
||||
</view>
|
||||
<view class="{{classPrefix}}__description {{prefix}}-class-description">
|
||||
<block wx:if="{{description}}"> {{description}} </block>
|
||||
<slot name="description" />
|
||||
</view>
|
||||
<view class="{{classPrefix}}__actions {{prefix}}-class-actions">
|
||||
<slot name="action" />
|
||||
</view>
|
||||
</view>
|
||||
@ -0,0 +1,12 @@
|
||||
var REGEXP = getRegExp('^\d+(\.\d+)?$');
|
||||
|
||||
function addUnit(value) {
|
||||
if (value == null) {
|
||||
return undefined;
|
||||
}
|
||||
return REGEXP.test('' + value) ? value + 'px' : value;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addUnit: addUnit,
|
||||
};
|
||||
@ -0,0 +1,49 @@
|
||||
.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-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.t-empty__icon {
|
||||
font-size: 192rpx;
|
||||
color: var(--td-empty-icon-color, var(--td-font-gray-3, rgba(0, 0, 0, 0.4)));
|
||||
}
|
||||
.t-empty__thumb + .t-empty__description:not(:empty) {
|
||||
margin-top: var(--td-empty-description-margin-top, var(--td-spacer-2, 32rpx));
|
||||
}
|
||||
.t-empty__description {
|
||||
text-align: center;
|
||||
color: var(--td-empty-description-color, var(--td-font-gray-3, rgba(0, 0, 0, 0.4)));
|
||||
font-size: var(--td-empty-description-font-size, var(--td-font-size-base, 28rpx));
|
||||
line-height: var(--td-empty-description-line-height, 44rpx);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.t-empty__description + .t-empty__actions:not(:empty) {
|
||||
margin-top: var(--td-empty-action-margin-top, var(--td-spacer-4, 64rpx));
|
||||
}
|
||||
3
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdEmptyProps } from './type';
|
||||
declare const props: TdEmptyProps;
|
||||
export default props;
|
||||
@ -0,0 +1,15 @@
|
||||
const props = {
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
externalClasses: {
|
||||
type: Array,
|
||||
},
|
||||
icon: {
|
||||
type: null,
|
||||
},
|
||||
image: {
|
||||
type: String,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
22
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/type.d.ts
vendored
Normal file
22
miniprogram/miniprogram_npm/tdesign-miniprogram/empty/type.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
export interface TdEmptyProps {
|
||||
style?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
description?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
externalClasses?: {
|
||||
type: ArrayConstructor;
|
||||
value?: ['t-class', 't-class-description', 't-class-image', 't-class-actions'];
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
image?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user