Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(loading): update code sample #691

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 22 additions & 85 deletions src/loading/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,100 +17,37 @@ isComponent: true

## 代码演示

### 基础加载
### 纯icon

<img src="https://tdesign.gtimg.com/miniprogram/readme/loading-1.png" width="375px" height="50%">
{{ base }}

```html
<t-loading theme="circular" size="40rpx" loading t-class-indicator="indicator-blue"></t-loading>
<t-loading theme="spinner" size="40rpx" loading></t-loading>
<t-loading theme="dots" size="80rpx" loading></t-loading>
```
### icon加文字横向

### 图标加横向文字的加载

<img src="https://tdesign.gtimg.com/miniprogram/readme/loading-2.png" width="375px" height="50%">

```html
<t-loading
theme="circular"
size="40rpx"
loading
text="加载中..."
t-class-indicator="indicator-blue"
></t-loading>
<t-loading theme="spinner" size="40rpx" loading text="加载中..."></t-loading>
<t-loading theme="circular" size="40rpx" loading style="color: #0052d9">
<span slot="text">加载中...</span>
</t-loading>
```
{{ horizontal }}

### 图标加竖向文字的加载

<img src="https://tdesign.gtimg.com/miniprogram/readme/loading-3.png" width="375px" height="50%">

```html
<t-loading
class="loading-style"
theme="circular"
size="40rpx"
loading
text="加载中"
t-class-indicator="indicator-blue"
layout="vertical"
></t-loading>
<view class="demo-section__desc">纯文字</view>
<t-loading class="loading-style" indicator="{{false}}" text="加载中..." loading></t-loading>
<view class="demo-section__desc">加载失败</view>
<t-loading theme="error" class="loading-style" loading bind:reload="reloadPage"></t-loading>
```
### icon加文字竖向

### 进度条加载
{{ vertical }}

<img src="https://tdesign.gtimg.com/miniprogram/readme/loading-4.png" width="375px" height="50%">
### 纯文字

```html
<t-loading theme="bar" progress="{{progress}}" loading="{{isLoading}}"></t-loading>
```
{{ text }}

```js
Page({
data: {
progress: 100,
isLoading: false,
barLoadingTimeOut: null,
},

onLoad() {
const timeout = setTimeout(() => {
this.setData({ isLoading: false });
}, 10000);
this.setData({
progress: -1,
isLoading: true,
barLoadingTimeOut: timeout,
});
},

onUnload() {
clearTimeout(this.data.barLoadingTimeOut);
},
});
```
### 加载失败

### 不同状态的加载

```html
<t-loading
class="loading-style"
theme="circular"
size="40rpx"
text="加载中..."
loading
delay="{{1000}}"
t-class-indicator="indicator-blue"
></t-loading>
```
{{ error }}

### 状态

{{ status }}

### 加载速度

{{ duration }}

### 规格

{{ size }}

## API
### Loading Props
Expand Down
1 change: 1 addition & 0 deletions src/loading/_example/base/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Component({});
6 changes: 6 additions & 0 deletions src/loading/_example/base/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"components": true,
"usingComponents": {
"t-loading": "tdesign-miniprogram/loading/loading"
}
}
5 changes: 5 additions & 0 deletions src/loading/_example/base/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<view class="loading-container-flex">
<t-loading theme="circular" size="40rpx"></t-loading>
<t-loading theme="spinner" size="40rpx" t-class-indicator="indicator-black"></t-loading>
<t-loading theme="dots" size="80rpx" t-class-indicator="indicator-black"></t-loading>
</view>
13 changes: 13 additions & 0 deletions src/loading/_example/base/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.loading-container-flex {
display: flex;
align-items: center;
}

.indicator-black {
color: #000000 !important;
}

.loading-container-flex t-loading {
min-width: 20%;
margin-right: 40rpx;
}
10 changes: 10 additions & 0 deletions src/loading/_example/duration/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Component({
data: {
duration: 800,
},
methods: {
durationChange(e) {
this.setData({ duration: e.detail.value });
},
},
});
7 changes: 7 additions & 0 deletions src/loading/_example/duration/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"components": true,
"usingComponents": {
"t-loading": "tdesign-miniprogram/loading/loading",
"t-slider": "tdesign-miniprogram/slider/slider"
}
}
12 changes: 12 additions & 0 deletions src/loading/_example/duration/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<t-loading theme="circular" size="52rpx" text="加载中..." t-class-text="text-l" duration="{{duration}}"></t-loading>
<view class="slider-container">
<view>速度调整</view>
<t-slider
class="slider-class"
value="{{duration}}"
min="{{100}}"
max="{{2000}}"
label
bind:change="durationChange"
></t-slider>
</view>
9 changes: 9 additions & 0 deletions src/loading/_example/duration/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.slider-container {
display: flex;
align-items: center;
width: 718rpx;
}

.slider-class {
flex-grow: 1;
}
9 changes: 9 additions & 0 deletions src/loading/_example/error/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Component({
methods: {
reloadPage() {
wx.redirectTo({
url: '/pages/loading/loading',
});
},
},
});
6 changes: 6 additions & 0 deletions src/loading/_example/error/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"components": true,
"usingComponents": {
"t-loading": "tdesign-miniprogram/loading/loading"
}
}
1 change: 1 addition & 0 deletions src/loading/_example/error/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<t-loading theme="error" bind:reload="reloadPage"></t-loading>
Empty file.
1 change: 1 addition & 0 deletions src/loading/_example/horizontal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Component({});
6 changes: 6 additions & 0 deletions src/loading/_example/horizontal/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"components": true,
"usingComponents": {
"t-loading": "tdesign-miniprogram/loading/loading"
}
}
7 changes: 7 additions & 0 deletions src/loading/_example/horizontal/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<view class="loading-container-flex">
<t-loading theme="circular" size="40rpx" text="加载中..."></t-loading>
<t-loading theme="spinner" size="40rpx" text="加载中..." t-class-indicator="indicator-black"></t-loading>
<t-loading theme="circular" size="40rpx">
<span slot="text" style="color: #0052d9">加载中...</span>
</t-loading>
</view>
13 changes: 13 additions & 0 deletions src/loading/_example/horizontal/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.loading-container-flex {
display: flex;
align-items: center;
}

.indicator-black {
color: #000000 !important;
}

.loading-container-flex t-loading {
display: flex;
margin-right: 40rpx;
}
11 changes: 10 additions & 1 deletion src/loading/_example/loading.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
"navigationBarTitleText": "Loading",
"navigationBarBackgroundColor": "#fff",
"usingComponents": {
"t-demo": "../../components/demo-block/index"
"t-demo": "../../components/demo-block/index",
"t-button": "tdesign-miniprogram/button/button",
"base": "./base",
"horizontal": "./horizontal",
"vertical": "./vertical",
"text": "./text",
"error": "./error",
"status": "./status",
"duration": "./duration",
"size": "./size"
}
}
93 changes: 0 additions & 93 deletions src/loading/_example/loading.less
Original file line number Diff line number Diff line change
@@ -1,96 +1,3 @@
page {
background-color: #fff;
}

.demo {
.demo-title {
margin-top: 48rpx;
}

.demo-desc {
margin-top: 16rpx;
}
}

.loading-container-flex {
display: flex;
align-items: center;
margin: 36rpx 32rpx;
font-size: 24rpx;

t-loading {
min-width: 20%;
margin-right: 40rpx;
display: flex;
}
}

.loading-container-flex-column {
display: block;
margin-left: 32rpx;
font-size: 24rpx;

t-loading {
display: flex;
margin-top: 32rpx;
}
}

.loading-style {
display: flex;
margin: 36rpx 32rpx;
font-size: 24rpx;
}

.box {
margin: 0 32rpx;
}

.t-slider__container {
margin: 0 32rpx;
}

.t-switch__label {
margin-right: 0px !important;
}

.progress-btn {
display: block;
margin-top: 32rpx;
}

.text-info {
margin-left: 24rpx;
color: rgba(0, 0, 0, 0.4);
}

.text-m {
font-size: 28rpx;
}

.text-l {
font-size: 32rpx;
}

.indicator-blue {
color: #0052d9;
}

.indicator-black {
color: #000000 !important;
}

.text-blue {
color: #0052d9;
}

.slider-container {
display: flex;
align-items: center;
width: 718rpx;
padding-left: 32rpx;

.slider-class {
flex-grow: 1;
}
}
20 changes: 0 additions & 20 deletions src/loading/_example/loading.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
Page({
data: {
isCheck: false,
duration: 800,
},

switchChange() {
const { isCheck } = this.data;
this.setData({ isCheck: !isCheck });
},

durationChange(e) {
this.setData({ duration: e.detail.value });
},

goToProgress() {
wx.redirectTo({
url: '/pages/loading/loadingProgress/loadingProgress',
});
},

reloadPage() {
wx.redirectTo({
url: '/pages/loading/loading',
});
},
});
Loading