mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
refactor(Loading): rewrite wxml and style (#2215)
This commit is contained in:
parent
af62dcfb5f
commit
83597f5c86
@ -1,28 +1,17 @@
|
|||||||
<demo-block title="Circular" padding>
|
<demo-block title="加载类型" padding>
|
||||||
<van-loading custom-class="loading" />
|
<van-loading custom-class="demo-loading" />
|
||||||
<van-loading custom-class="loading shadow" color="#fff" />
|
<van-loading custom-class="demo-loading" type="spinner" />
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block title="Spinner" padding>
|
<demo-block title="自定义颜色" padding>
|
||||||
<van-loading custom-class="loading" type="spinner" />
|
<van-loading custom-class="demo-loading" color="#1989fa" />
|
||||||
<van-loading custom-class="loading shadow" type="spinner" color="#fff" />
|
<van-loading custom-class="demo-loading" type="spinner" color="#1989fa" />
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block title="加载文案" padding>
|
<demo-block title="加载文案" padding>
|
||||||
<van-loading custom-class="loading">
|
<van-loading custom-class="demo-loading" size="24px">加载中...</van-loading>
|
||||||
加载中……
|
|
||||||
</van-loading>
|
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block title="加载文案大小调整" padding>
|
<demo-block title="垂直排列" padding>
|
||||||
<van-loading custom-class="loading" text-size="12" vertical>
|
<van-loading custom-class="demo-loading" size="24px" vertical>加载中...</van-loading>
|
||||||
加载中……
|
|
||||||
</van-loading>
|
|
||||||
</demo-block>
|
|
||||||
|
|
||||||
|
|
||||||
<demo-block title="加载文案竖直排列" padding>
|
|
||||||
<van-loading custom-class="loading" vertical>
|
|
||||||
加载中……
|
|
||||||
</van-loading>
|
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
.loading {
|
.demo-loading {
|
||||||
margin-right: 20px;
|
margin: 4px 16px 4px 0;
|
||||||
}
|
|
||||||
|
|
||||||
.shadow {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: rgba(0, 0, 0, .5);
|
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,14 @@
|
|||||||
@info-dot-size: 8px;
|
@info-dot-size: 8px;
|
||||||
@info-font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
@info-font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
||||||
|
|
||||||
|
// Loading
|
||||||
|
@loading-text-color: @gray-dark;
|
||||||
|
@loading-text-font-size: @font-size-md;
|
||||||
|
@loading-text-line-height: 20px;
|
||||||
|
@loading-spinner-color: @gray;
|
||||||
|
@loading-spinner-size: 30px;
|
||||||
|
@loading-spinner-animation-duration: .8s;
|
||||||
|
|
||||||
// NavBar
|
// NavBar
|
||||||
@nav-bar-height: 44px;
|
@nav-bar-height: 44px;
|
||||||
|
|
||||||
|
@ -12,18 +12,30 @@
|
|||||||
|
|
||||||
## 代码演示
|
## 代码演示
|
||||||
|
|
||||||
### Circular
|
### 加载类型
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-loading />
|
<van-loading />
|
||||||
<van-loading color="#fff" />
|
<van-loading type="spinner" />
|
||||||
```
|
```
|
||||||
|
|
||||||
### Spinner
|
### 自定义颜色
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-loading type="spinner" />
|
<van-loading color="#1989fa" />
|
||||||
<van-loading type="spinner" color="#fff" />
|
<van-loading type="spinner" color="#1989fa" />
|
||||||
|
```
|
||||||
|
|
||||||
|
### 加载文案
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-loading size="24px">加载中...</van-loading>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 垂直排列
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
@ -35,9 +47,8 @@
|
|||||||
| color | 颜色 | *string* | `#c9c9c9` | - |
|
| color | 颜色 | *string* | `#c9c9c9` | - |
|
||||||
| type | 类型,可选值为 `spinner` | *string* | `circular` | - |
|
| type | 类型,可选值为 `spinner` | *string* | `circular` | - |
|
||||||
| size | 加载图标大小,默认单位为 `px` | *string \| number* | `30px` | - |
|
| size | 加载图标大小,默认单位为 `px` | *string \| number* | `30px` | - |
|
||||||
| text-size | 文字大小,默认单位为为 `px` | *string \| number* | `14px` | 1.0 |
|
| text-size | 文字大小,默认单位为为 `px` | *string \| number* | `14px` | 1.0.0 |
|
||||||
| vertical | 是否垂直排列图标和文字内容 | *boolean* | `false` | 1.0 |
|
| vertical | 是否垂直排列图标和文字内容 | *boolean* | `false` | 1.0.0 |
|
||||||
|
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
@import '../common/style/var.less';
|
@import '../common/style/var.less';
|
||||||
|
|
||||||
.van-loading {
|
.van-loading {
|
||||||
&__wrapper {
|
|
||||||
position: relative;
|
|
||||||
z-index: 0;
|
|
||||||
display: inline-block;
|
|
||||||
line-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
color: @loading-spinner-color;
|
||||||
&--vertical {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__spinner {
|
&__spinner {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: -1;
|
|
||||||
display: inline-block;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: @loading-spinner-size;
|
||||||
height: 100%;
|
// compatible for 0.x, users may set width or height in root element
|
||||||
animation: van-rotate 0.8s linear infinite;
|
max-width: 100%;
|
||||||
|
height: @loading-spinner-size;
|
||||||
|
max-height: 100%;
|
||||||
|
animation: van-rotate @loading-spinner-animation-duration linear infinite;
|
||||||
|
|
||||||
&--spinner {
|
&--spinner {
|
||||||
animation-timing-function: steps(12);
|
animation-timing-function: steps(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
&--circular {
|
&--circular {
|
||||||
border: 1px solid;
|
border: 1px solid transparent;
|
||||||
border-color: transparent;
|
|
||||||
border-top-color: currentColor;
|
border-top-color: currentColor;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__text {
|
&__text {
|
||||||
margin-left: 8px;
|
margin-left: @padding-xs;
|
||||||
color: #969799;
|
color: @loading-text-color;
|
||||||
|
font-size: @loading-text-font-size;
|
||||||
|
line-height: @loading-text-line-height;
|
||||||
|
|
||||||
&--vertical {
|
&:empty {
|
||||||
margin: 8px 0 0;
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--vertical {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.van-loading__text {
|
||||||
|
margin: @padding-xs 0 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { addUnit } from '../common/utils';
|
|||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
props: {
|
props: {
|
||||||
|
vertical: Boolean,
|
||||||
size: {
|
size: {
|
||||||
type: String,
|
type: String,
|
||||||
observer: 'setSizeWithUnit'
|
observer: 'setSizeWithUnit'
|
||||||
@ -18,8 +19,7 @@ VantComponent({
|
|||||||
textSize: {
|
textSize: {
|
||||||
type: String,
|
type: String,
|
||||||
observer: 'setTextSizeWithUnit'
|
observer: 'setTextSizeWithUnit'
|
||||||
},
|
}
|
||||||
vertical: Boolean
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
<view class="van-loading {{vertical ? 'van-loading--vertical' : ''}}">
|
<view class="custom-class van-loading van-loading--{{ type }} {{ vertical ? 'van-loading--vertical' : '' }}">
|
||||||
<view
|
<view
|
||||||
class="van-loading__wrapper custom-class"
|
class="van-loading__spinner van-loading__spinner--{{ type }}"
|
||||||
style="width: {{ sizeWithUnit }}; height: {{ sizeWithUnit }}"
|
style="color: {{ color }}; width: {{ sizeWithUnit }}; height: {{ sizeWithUnit }}"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
class="van-loading__spinner van-loading__spinner--{{ type }}"
|
wx:if="{{ type === 'spinner' }}"
|
||||||
style="color: {{ color }};"
|
wx:for="item in 12"
|
||||||
>
|
wx:key="index"
|
||||||
<view
|
class="van-loading__dot"
|
||||||
wx:if="{{ type === 'spinner' }}"
|
/>
|
||||||
wx:for="item in 12"
|
|
||||||
wx:key="index"
|
|
||||||
class="van-loading__dot"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
style="font-size: {{textSizeWithUnit}};"
|
style="font-size: {{ textSizeWithUnit }};"
|
||||||
class="van-loading__text {{vertical ? 'van-loading__text--vertical' : ''}}"
|
class="van-loading__text {{vertical ? 'van-loading__text--vertical' : ''}}"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user