任务明细页面
This commit is contained in:
70
components/loading/README.md
Normal file
70
components/loading/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: Loading 加载
|
||||
description: 用于表示页面或操作的加载状态,给予用户反馈的同时减缓等待的焦虑感,由一个或一组反馈动效组成。
|
||||
spline: message
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-95%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-95%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-83%25-blue" /></span>
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-loading": "tdesign-miniprogram/loading/loading"
|
||||
}
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 纯icon
|
||||
|
||||
{{ base }}
|
||||
|
||||
### icon加文字横向
|
||||
|
||||
{{ horizontal }}
|
||||
|
||||
### icon加文字竖向
|
||||
|
||||
{{ vertical }}
|
||||
|
||||
### 纯文字
|
||||
|
||||
{{ text }}
|
||||
|
||||
### 加载失败
|
||||
|
||||
{{ error }}
|
||||
|
||||
### 状态
|
||||
|
||||
{{ status }}
|
||||
|
||||
### 加载速度
|
||||
|
||||
{{ duration }}
|
||||
|
||||
### 规格
|
||||
|
||||
{{ size }}
|
||||
|
||||
## API
|
||||
### Loading Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N
|
||||
duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N
|
||||
external-classes | Array | - | 组件类名,分别用于设置加载组件外层元素,加载组件文本,加载组件指示符,加载指示符内侧同心圆等元素类名。`['t-class', 't-class-text', 't-class-indicator']` | N
|
||||
indicator | Boolean | true | 是否显示加载指示符 | N
|
||||
inherit-color | Boolean | false | 是否继承父元素颜色 | N
|
||||
layout | String | horizontal | 对齐方式。可选项:horizontal/vertical | N
|
||||
loading | Boolean | true | 是否处于加载状态 | N
|
||||
pause | Boolean | false | 是否暂停动画 | N
|
||||
progress | Number | - | 加载进度 | N
|
||||
reverse | Boolean | - | 加载动画是否反向 | N
|
||||
size | String | '40rpx' | 尺寸,示例:40rpx/20px | N
|
||||
text | String / Slot | - | 加载提示文案 | N
|
||||
theme | String | circular | 加载组件类型。可选项:circular/spinner/bar/error/dots | N
|
||||
3
components/loading/index.d.ts
vendored
Normal file
3
components/loading/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
export * from './loading';
|
||||
3
components/loading/index.js
Normal file
3
components/loading/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
export * from './loading';
|
||||
77
components/loading/loading.d.ts
vendored
Normal file
77
components/loading/loading.d.ts
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
import type { TdLoadingProps } from './type';
|
||||
export interface LoadingProps extends TdLoadingProps {
|
||||
}
|
||||
export default class Loading extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
show: boolean;
|
||||
};
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
properties: {
|
||||
delay?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
duration?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
externalClasses?: {
|
||||
type: ArrayConstructor;
|
||||
value?: ["t-class", "t-class-text", "t-class-indicator"];
|
||||
};
|
||||
indicator?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
inheritColor?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
layout?: {
|
||||
type: StringConstructor;
|
||||
value?: "horizontal" | "vertical";
|
||||
};
|
||||
loading?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
pause?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
progress?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
reverse?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
text?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: "error" | "circular" | "spinner" | "bar" | "dots";
|
||||
};
|
||||
};
|
||||
timer: any;
|
||||
observers: {
|
||||
loading(this: any, cur: any): void;
|
||||
};
|
||||
lifetimes: {
|
||||
detached(): void;
|
||||
};
|
||||
refreshPage(): void;
|
||||
}
|
||||
61
components/loading/loading.js
Normal file
61
components/loading/loading.js
Normal file
@@ -0,0 +1,61 @@
|
||||
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 props from './props';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-loading`;
|
||||
let Loading = class Loading extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.externalClasses = [`${prefix}-class`, `${prefix}-class-text`, `${prefix}-class-indicator`];
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
show: true,
|
||||
};
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.properties = Object.assign({}, props);
|
||||
this.timer = null;
|
||||
this.observers = {
|
||||
loading(cur) {
|
||||
const { delay } = this.properties;
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
if (cur) {
|
||||
if (delay) {
|
||||
this.timer = setTimeout(() => {
|
||||
this.setData({ show: cur });
|
||||
this.timer = null;
|
||||
}, delay);
|
||||
}
|
||||
else {
|
||||
this.setData({ show: cur });
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setData({ show: cur });
|
||||
}
|
||||
},
|
||||
};
|
||||
this.lifetimes = {
|
||||
detached() {
|
||||
clearTimeout(this.timer);
|
||||
},
|
||||
};
|
||||
}
|
||||
refreshPage() {
|
||||
this.triggerEvent('reload');
|
||||
}
|
||||
};
|
||||
Loading = __decorate([
|
||||
wxComponent()
|
||||
], Loading);
|
||||
export default Loading;
|
||||
4
components/loading/loading.json
Normal file
4
components/loading/loading.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
47
components/loading/loading.wxml
Normal file
47
components/loading/loading.wxml
Normal file
@@ -0,0 +1,47 @@
|
||||
<wxs src="../common/utils.wxs" module="utils" />
|
||||
<view class="{{prefix}}-class">
|
||||
<view
|
||||
wx:if="{{theme === 'bar' && theme !== 'error'}}"
|
||||
style="{{progress >= 0 ? 'width:' + progress + '%' : ''}}"
|
||||
class="{{prefix}}-class-indicator {{classPrefix}}__bar {{classPrefix}}__bar--{{progress < 0 ? 'animation' : progress < 100 ? 'static': ''}} {{progress >= 100 || !loading ? classPrefix + '__bar--loaded' : ''}}"
|
||||
></view>
|
||||
<view class="{{classPrefix}} {{classPrefix + '--' + layout}}" style="{{show ? '' : 'display:none'}}" wx:else>
|
||||
<view
|
||||
wx:if="{{ theme !== 'error' }}"
|
||||
class="{{prefix}}-class-indicator {{classPrefix}}__spinner {{classPrefix}}__spinner--{{ theme }} {{reverse ? 'reverse' : ''}}"
|
||||
style="width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}; {{inheritColor ? 'color: inherit' : ''}} {{indicator ? '' : 'display:none'}}; {{duration ? 'animation-duration: ' + duration / 1000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
|
||||
>
|
||||
<view
|
||||
wx:if="{{ theme === 'spinner' }}"
|
||||
wx:for="{{[1,2,3,4,5,6,7,8,9,10,11,12]}}"
|
||||
wx:key="index"
|
||||
class="{{classPrefix}}__dot"
|
||||
/>
|
||||
<view wx:if="{{ theme === 'circular' }}" class="{{classPrefix}}__circular" />
|
||||
<block wx:if="{{ theme === 'dots' }}">
|
||||
<view
|
||||
class="{{classPrefix}}__dot"
|
||||
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + 0 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
|
||||
></view>
|
||||
<view
|
||||
class="{{classPrefix}}__dot"
|
||||
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 1 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
|
||||
></view>
|
||||
<view
|
||||
class="{{classPrefix}}__dot"
|
||||
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 2 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
|
||||
></view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="{{prefix}}-class-text">
|
||||
<view wx:if="{{theme === 'error'}}">
|
||||
<span>加载失败</span>
|
||||
<span class="{{classPrefix}}__refresh-btn" bind:tap="refreshPage">刷新</span>
|
||||
</view>
|
||||
<view class="{{classPrefix}}__text" wx:if="{{text}}">
|
||||
<text wx:if="{{text !== 'slot'}}"> {{text}} </text>
|
||||
<slot name="text" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
235
components/loading/loading.wxss
Normal file
235
components/loading/loading.wxss
Normal file
@@ -0,0 +1,235 @@
|
||||
.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-loading {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.t-loading__spinner {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
animation: rotate 0.8s linear infinite;
|
||||
color: #0052d9;
|
||||
}
|
||||
.t-loading__spinner.reverse {
|
||||
animation-name: rotateReverse;
|
||||
}
|
||||
.t-loading__spinner--spinner {
|
||||
animation-timing-function: steps(12);
|
||||
}
|
||||
.t-loading__spinner--spinner .t-loading__dot {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.t-loading__spinner--spinner .t-loading__dot::before {
|
||||
display: block;
|
||||
width: 5rpx;
|
||||
height: 25%;
|
||||
margin: 0 auto;
|
||||
background-color: currentColor;
|
||||
border-radius: 40%;
|
||||
content: ' ';
|
||||
}
|
||||
.t-loading__spinner--circular .t-loading__circular {
|
||||
border-radius: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: conic-gradient(from 180deg at 50% 50%, rgba(255, 255, 255, 0) 0deg, rgba(255, 255, 255, 0) 60deg, currentColor 330deg, rgba(255, 255, 255, 0) 360deg);
|
||||
mask: radial-gradient(transparent calc(50% - 1rpx), #fff 50%);
|
||||
/* stylelint-disable-next-line */
|
||||
-webkit-mask: radial-gradient(transparent calc(50% - 1rpx), #fff 50%);
|
||||
}
|
||||
.t-loading__spinner--dots {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
animation: none;
|
||||
}
|
||||
.t-loading__spinner--dots .t-loading__dot {
|
||||
width: 20%;
|
||||
height: 20%;
|
||||
border-radius: 50%;
|
||||
background-color: currentColor;
|
||||
animation-duration: 1.8s;
|
||||
animation-name: dotting;
|
||||
animation-timing-function: linear;
|
||||
animation-iteration-count: infinite;
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
.t-loading--vertical {
|
||||
flex-direction: column;
|
||||
}
|
||||
.t-loading--vertical .t-loading__text {
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
.t-loading--horizontal {
|
||||
flex-direction: row;
|
||||
}
|
||||
.t-loading--horizontal .t-loading__text {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
.t-loading__refresh-btn {
|
||||
margin-left: 16rpx;
|
||||
color: #0052d9;
|
||||
}
|
||||
.t-loading__bar {
|
||||
height: 6rpx;
|
||||
width: 80%;
|
||||
transition: 0.5s;
|
||||
background-color: #0052d9;
|
||||
display: none;
|
||||
}
|
||||
.t-loading__bar--static {
|
||||
display: block;
|
||||
}
|
||||
.t-loading__bar--loaded {
|
||||
opacity: 0;
|
||||
height: 0;
|
||||
animation: t-bar-loaded 1s ease-out;
|
||||
}
|
||||
.t-loading__bar--animation {
|
||||
animation: t-bar 8s linear;
|
||||
display: block;
|
||||
}
|
||||
@keyframes t-bar {
|
||||
0% {
|
||||
width: 0;
|
||||
}
|
||||
50% {
|
||||
width: 70%;
|
||||
}
|
||||
100% {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
@keyframes t-bar-loaded {
|
||||
0% {
|
||||
height: 6rpx;
|
||||
opacity: 1;
|
||||
width: 90%;
|
||||
}
|
||||
50% {
|
||||
height: 6rpx;
|
||||
opacity: 1;
|
||||
width: 100%;
|
||||
}
|
||||
100% {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.t-loading__dot:nth-of-type(1) {
|
||||
transform: rotate(30deg);
|
||||
opacity: 0;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(2) {
|
||||
transform: rotate(60deg);
|
||||
opacity: 0.08333333;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(3) {
|
||||
transform: rotate(90deg);
|
||||
opacity: 0.16666667;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(4) {
|
||||
transform: rotate(120deg);
|
||||
opacity: 0.25;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(5) {
|
||||
transform: rotate(150deg);
|
||||
opacity: 0.33333333;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(6) {
|
||||
transform: rotate(180deg);
|
||||
opacity: 0.41666667;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(7) {
|
||||
transform: rotate(210deg);
|
||||
opacity: 0.5;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(8) {
|
||||
transform: rotate(240deg);
|
||||
opacity: 0.58333333;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(9) {
|
||||
transform: rotate(270deg);
|
||||
opacity: 0.66666667;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(10) {
|
||||
transform: rotate(300deg);
|
||||
opacity: 0.75;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(11) {
|
||||
transform: rotate(330deg);
|
||||
opacity: 0.83333333;
|
||||
}
|
||||
.t-loading__dot:nth-of-type(12) {
|
||||
transform: rotate(360deg);
|
||||
opacity: 0.91666667;
|
||||
}
|
||||
@keyframes rotate {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes rotateReverse {
|
||||
from {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
@keyframes dotting {
|
||||
0% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
1% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
33% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
34% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
100% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
3
components/loading/props.d.ts
vendored
Normal file
3
components/loading/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdLoadingProps } from './type';
|
||||
declare const props: TdLoadingProps;
|
||||
export default props;
|
||||
51
components/loading/props.js
Normal file
51
components/loading/props.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const props = {
|
||||
delay: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
value: 800,
|
||||
},
|
||||
externalClasses: {
|
||||
type: Array,
|
||||
},
|
||||
indicator: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
inheritColor: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
layout: {
|
||||
type: String,
|
||||
value: 'horizontal',
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
pause: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
progress: {
|
||||
type: Number,
|
||||
},
|
||||
reverse: {
|
||||
type: Boolean,
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
value: '40rpx',
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
value: 'circular',
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
54
components/loading/type.d.ts
vendored
Normal file
54
components/loading/type.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
export interface TdLoadingProps {
|
||||
delay?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
duration?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
externalClasses?: {
|
||||
type: ArrayConstructor;
|
||||
value?: ['t-class', 't-class-text', 't-class-indicator'];
|
||||
};
|
||||
indicator?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
inheritColor?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
layout?: {
|
||||
type: StringConstructor;
|
||||
value?: 'horizontal' | 'vertical';
|
||||
};
|
||||
loading?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
pause?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
progress?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
reverse?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
text?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: 'circular' | 'spinner' | 'bar' | 'error' | 'dots';
|
||||
};
|
||||
}
|
||||
1
components/loading/type.js
Normal file
1
components/loading/type.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user