mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[improvement] Stepper: size support small middle large (#306)
This commit is contained in:
parent
876c75a388
commit
c05710acd5
@ -14,6 +14,7 @@
|
|||||||
<!-- small size -->
|
<!-- small size -->
|
||||||
<zan-panel title="不同尺寸-小尺寸类型">
|
<zan-panel title="不同尺寸-小尺寸类型">
|
||||||
<view style="padding: 40px 15px">
|
<view style="padding: 40px 15px">
|
||||||
|
<view style="margin-bottom: 5px">small:</view>
|
||||||
<zan-stepper
|
<zan-stepper
|
||||||
stepper="{{ stepper2.stepper }}"
|
stepper="{{ stepper2.stepper }}"
|
||||||
min="{{ stepper2.min }}"
|
min="{{ stepper2.min }}"
|
||||||
@ -21,8 +22,27 @@
|
|||||||
size="small"
|
size="small"
|
||||||
data-component-id="stepper2"
|
data-component-id="stepper2"
|
||||||
bind:change="handleZanStepperChange"
|
bind:change="handleZanStepperChange"
|
||||||
>
|
|
||||||
</zan-stepper>
|
></zan-stepper>
|
||||||
|
|
||||||
|
<view style="margin: 10px 0 5px;">middle:</view>
|
||||||
|
<zan-stepper
|
||||||
|
stepper="{{ stepper2.stepper }}"
|
||||||
|
min="{{ stepper2.min }}"
|
||||||
|
max="{{ stepper2.max }}"
|
||||||
|
data-component-id="stepper2-1"
|
||||||
|
bind:change="handleZanStepperChange"
|
||||||
|
></zan-stepper>
|
||||||
|
|
||||||
|
<view style="margin: 10px 0 5px;">large:</view>
|
||||||
|
<zan-stepper
|
||||||
|
stepper="{{ stepper2.stepper }}"
|
||||||
|
min="{{ stepper2.min }}"
|
||||||
|
max="{{ stepper2.max }}"
|
||||||
|
size="large"
|
||||||
|
data-component-id="stepper2-2"
|
||||||
|
bind:change="handleZanStepperChange"
|
||||||
|
></zan-stepper>
|
||||||
</view>
|
</view>
|
||||||
</zan-panel>
|
</zan-panel>
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ Page({
|
|||||||
min: 1,
|
min: 1,
|
||||||
// 最大可到的数字
|
// 最大可到的数字
|
||||||
max: 1,
|
max: 1,
|
||||||
// 小尺寸, 默认大尺寸
|
// 尺寸
|
||||||
size: 'small'
|
size: 'small'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -58,7 +58,7 @@ Page({
|
|||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 | 必须 |
|
| 参数 | 说明 | 类型 | 默认值 | 必须 |
|
||||||
|-----------|-----------|-----------|-------------|-------------|
|
|-----------|-----------|-----------|-------------|-------------|
|
||||||
| size | 计数器尺寸 | String | - | |
|
| size | 计数器尺寸:small、middle、large | String | middle | |
|
||||||
| stepper | 计数器的值 | Number | `1` | 必须 |
|
| stepper | 计数器的值 | Number | `1` | 必须 |
|
||||||
| min | 计数器最小值 | Number | `1` | |
|
| min | 计数器最小值 | Number | `1` | |
|
||||||
| max | 计数器最大值 | Number | 无穷大 | |
|
| max | 计数器最大值 | Number | 无穷大 | |
|
||||||
|
@ -4,7 +4,10 @@ const VERY_LARGE_NUMBER = 2147483647;
|
|||||||
|
|
||||||
Component({
|
Component({
|
||||||
properties: {
|
properties: {
|
||||||
size: String,
|
size: {
|
||||||
|
type: String,
|
||||||
|
value: 'middle'
|
||||||
|
},
|
||||||
stepper: {
|
stepper: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 1
|
value: 1
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
}
|
}
|
||||||
.zan-stepper view {
|
.zan-stepper view {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
line-height: 20px;
|
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
min-width: 40px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@ -21,12 +19,9 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
height: 30px;
|
|
||||||
width: 40px;
|
|
||||||
/* 重置 input 默认样式 */
|
/* 重置 input 默认样式 */
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 30px;
|
|
||||||
}
|
}
|
||||||
.zan-stepper .zan-stepper__plus {
|
.zan-stepper .zan-stepper__plus {
|
||||||
border-left: none;
|
border-left: none;
|
||||||
@ -46,3 +41,23 @@
|
|||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zan-stepper--middle view {
|
||||||
|
min-width: 40px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
.zan-stepper--middle .zan-stepper__text {
|
||||||
|
width: 40px;
|
||||||
|
line-height: 30px;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zan-stepper--large view {
|
||||||
|
min-width: 44px;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
.zan-stepper--large .zan-stepper__text {
|
||||||
|
width: 44px;
|
||||||
|
line-height: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<view class="zan-stepper {{ size === 'small' ? 'zan-stepper--small' : '' }}">
|
<view class="zan-stepper zan-stepper--{{ size }}">
|
||||||
<view
|
<view
|
||||||
class="zan-stepper__minus {{ stepper <= min ? 'zan-stepper--disabled' : '' }}"
|
class="zan-stepper__minus {{ stepper <= min ? 'zan-stepper--disabled' : '' }}"
|
||||||
data-disabled="{{ stepper <= min }}"
|
data-disabled="{{ stepper <= min }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user