Skip to content

Commit 878e26c

Browse files
author
v_guanglwen
committed
feat: 测测测测
1 parent 081711e commit 878e26c

File tree

11 files changed

+522
-0
lines changed

11 files changed

+522
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './props';
2+
export * from './type';
3+
export * from './loading';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './props';
2+
export * from './type';
3+
export * from './loading';
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { SuperComponent } from '../common/src/index';
2+
import type { TdLoadingProps } from './type';
3+
export interface LoadingProps extends TdLoadingProps {
4+
}
5+
export default class Loading extends SuperComponent {
6+
externalClasses: string[];
7+
data: {
8+
prefix: string;
9+
classPrefix: string;
10+
show: boolean;
11+
};
12+
options: {
13+
multipleSlots: boolean;
14+
};
15+
properties: {
16+
delay?: {
17+
type: NumberConstructor;
18+
value?: number;
19+
};
20+
duration?: {
21+
type: NumberConstructor;
22+
value?: number;
23+
};
24+
externalClasses?: {
25+
type: ArrayConstructor;
26+
value?: ["t-class", "t-class-text", "t-class-indicator"];
27+
};
28+
indicator?: {
29+
type: BooleanConstructor;
30+
value?: boolean;
31+
};
32+
inheritColor?: {
33+
type: BooleanConstructor;
34+
value?: boolean;
35+
};
36+
layout?: {
37+
type: StringConstructor;
38+
value?: "horizontal" | "vertical";
39+
};
40+
loading?: {
41+
type: BooleanConstructor;
42+
value?: boolean;
43+
};
44+
pause?: {
45+
type: BooleanConstructor;
46+
value?: boolean;
47+
};
48+
progress?: {
49+
type: NumberConstructor;
50+
value?: number;
51+
};
52+
reverse?: {
53+
type: BooleanConstructor;
54+
value?: boolean;
55+
};
56+
size?: {
57+
type: StringConstructor;
58+
value?: string;
59+
};
60+
text?: {
61+
type: StringConstructor;
62+
value?: string;
63+
};
64+
theme?: {
65+
type: StringConstructor;
66+
value?: "circular" | "spinner" | "dots";
67+
};
68+
};
69+
timer: any;
70+
observers: {
71+
loading(this: any, cur: any): void;
72+
};
73+
lifetimes: {
74+
detached(): void;
75+
};
76+
refreshPage(): void;
77+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4+
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;
5+
return c > 3 && r && Object.defineProperty(target, key, r), r;
6+
};
7+
import { SuperComponent, wxComponent } from '../common/src/index';
8+
import config from '../common/config';
9+
import props from './props';
10+
const { prefix } = config;
11+
const name = `${prefix}-loading`;
12+
let Loading = class Loading extends SuperComponent {
13+
constructor() {
14+
super(...arguments);
15+
this.externalClasses = [`${prefix}-class`, `${prefix}-class-text`, `${prefix}-class-indicator`];
16+
this.data = {
17+
prefix,
18+
classPrefix: name,
19+
show: true,
20+
};
21+
this.options = {
22+
multipleSlots: true,
23+
};
24+
this.properties = Object.assign({}, props);
25+
this.timer = null;
26+
this.observers = {
27+
loading(cur) {
28+
const { delay } = this.properties;
29+
if (this.timer) {
30+
clearTimeout(this.timer);
31+
}
32+
if (cur) {
33+
if (delay) {
34+
this.timer = setTimeout(() => {
35+
this.setData({ show: cur });
36+
this.timer = null;
37+
}, delay);
38+
}
39+
else {
40+
this.setData({ show: cur });
41+
}
42+
}
43+
else {
44+
this.setData({ show: cur });
45+
}
46+
},
47+
};
48+
this.lifetimes = {
49+
detached() {
50+
clearTimeout(this.timer);
51+
},
52+
};
53+
}
54+
refreshPage() {
55+
this.triggerEvent('reload');
56+
}
57+
};
58+
Loading = __decorate([
59+
wxComponent()
60+
], Loading);
61+
export default Loading;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"component": true,
3+
"styleIsolation": "apply-shared",
4+
"usingComponents": {}
5+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<wxs src="../common/utils.wxs" module="_" />
2+
<view
3+
style="{{_._style([style, customStyle, !text ? ('width: ' + _.addUnit(size) + '; height: ' + _.addUnit(size)) : '', show ? '' : 'display: none', inheritColor ? 'color: inherit' : ''])}}"
4+
class="class {{prefix}}-class {{classPrefix}} {{classPrefix + '--' + layout}}"
5+
>
6+
<view
7+
wx:if="{{indicator}}"
8+
class="{{prefix}}-class-indicator {{classPrefix}}__spinner {{classPrefix}}__spinner--{{ theme }} {{reverse ? 'reverse' : ''}}"
9+
style="width: {{ _.addUnit(size) }}; height: {{ _.addUnit(size) }}; {{inheritColor ? 'color: inherit;' : ''}} {{indicator ? '' : 'display: none;'}} {{duration ? 'animation-duration: ' + duration / 1000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
10+
aria-role="{{ariaRole || 'img'}}"
11+
aria-label="{{ ariaLabel || text || '加载中' }}"
12+
>
13+
<view
14+
wx:if="{{ theme === 'spinner' }}"
15+
wx:for="{{12}}"
16+
wx:key="index"
17+
class="{{classPrefix}}__dot {{classPrefix}}__dot-{{index}}"
18+
/>
19+
<view wx:if="{{ theme === 'circular' }}" class="{{classPrefix}}__circular" />
20+
<block wx:if="{{ theme === 'dots' }}">
21+
<view
22+
class="{{classPrefix}}__dot"
23+
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + 0 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
24+
></view>
25+
<view
26+
class="{{classPrefix}}__dot"
27+
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 1 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
28+
></view>
29+
<view
30+
class="{{classPrefix}}__dot"
31+
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 2 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
32+
></view>
33+
</block>
34+
<slot name="indicator" />
35+
</view>
36+
<view
37+
class="{{_.cls(classPrefix + '__text', [layout])}} {{prefix}}-class-text"
38+
aria-hidden="{{indicator}}"
39+
aria-label="{{ ariaLabel || text }}"
40+
>
41+
<block wx:if="{{text}}">{{text}}</block>
42+
<slot name="text" />
43+
<slot />
44+
</view>
45+
</view>

0 commit comments

Comments
 (0)