feat(Field): update label style (#3357)

This commit is contained in:
neverland 2020-07-09 15:30:40 +08:00 committed by GitHub
parent fa54a19805
commit da4a5f3cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 12 deletions

View File

@ -234,6 +234,8 @@
@dialog-has-title-message-padding-top: @padding-sm; @dialog-has-title-message-padding-top: @padding-sm;
// Field // Field
@field-label-color: @gray-7;
@field-label-margin-right: @padding-sm;
@field-input-text-color: @text-color; @field-input-text-color: @text-color;
@field-input-error-text-color: @red; @field-input-error-text-color: @red;
@field-input-disabled-text-color: @gray-6; @field-input-disabled-text-color: @gray-6;

View File

@ -206,7 +206,7 @@ Page({
| clickable | 是否开启点击反馈 | _boolean_ | `false` | | clickable | 是否开启点击反馈 | _boolean_ | `false` |
| required | 是否显示表单必填星号 | _boolean_ | `false` | | required | 是否显示表单必填星号 | _boolean_ | `false` |
| password | 是否是密码类型 | _boolean_ | `false` | | password | 是否是密码类型 | _boolean_ | `false` |
| title-width | 标题宽度 | _string_ | `90px` | | title-width | 标题宽度 | _string_ | `6.2em` |
| maxlength | 最大输入长度,设置为 -1 的时候不限制最大长度 | _number_ | `-1` | | maxlength | 最大输入长度,设置为 -1 的时候不限制最大长度 | _number_ | `-1` |
| placeholder | 输入框为空时占位符 | _string_ | - | | placeholder | 输入框为空时占位符 | _string_ | - |
| placeholder-style | 指定 placeholder 的样式 | _string_ | - | | placeholder-style | 指定 placeholder 的样式 | _string_ | - |

View File

@ -4,6 +4,11 @@
.van-field { .van-field {
.theme(--cell-icon-size, '@field-icon-size'); .theme(--cell-icon-size, '@field-icon-size');
&__label {
.theme(color, '@field-label-color');
.theme(margin-right, '@field-label-margin-right');
}
&__body { &__body {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -20,16 +20,8 @@ VantComponent({
leftIcon: String, leftIcon: String,
rightIcon: String, rightIcon: String,
autosize: [Boolean, Object], autosize: [Boolean, Object],
readonly: {
type: Boolean,
observer: 'setShowClear',
},
required: Boolean, required: Boolean,
iconClass: String, iconClass: String,
clearable: {
type: Boolean,
observer: 'setShowClear',
},
clickable: Boolean, clickable: Boolean,
inputAlign: String, inputAlign: String,
customStyle: String, customStyle: String,
@ -37,13 +29,21 @@ VantComponent({
arrowDirection: String, arrowDirection: String,
showWordLimit: Boolean, showWordLimit: Boolean,
errorMessageAlign: String, errorMessageAlign: String,
readonly: {
type: Boolean,
observer: 'setShowClear',
},
clearable: {
type: Boolean,
observer: 'setShowClear',
},
border: { border: {
type: Boolean, type: Boolean,
value: true, value: true,
}, },
titleWidth: { titleWidth: {
type: String, type: String,
value: '90px', value: '6.2em',
}, },
}, },

View File

@ -4,7 +4,6 @@
<van-cell <van-cell
size="{{ size }}" size="{{ size }}"
icon="{{ leftIcon }}" icon="{{ leftIcon }}"
title="{{ label }}"
center="{{ center }}" center="{{ center }}"
border="{{ border }}" border="{{ border }}"
is-link="{{ isLink }}" is-link="{{ isLink }}"
@ -17,7 +16,10 @@
title-class="label-class" title-class="label-class"
> >
<slot name="left-icon" slot="icon" /> <slot name="left-icon" slot="icon" />
<slot name="label" slot="title" /> <view wx:if="{{ label }}" class="van-field__label" slot="title">
{{ label }}
</view>
<slot wx:else name="label" slot="title" />
<view class="{{ utils.bem('field__body', [type]) }}"> <view class="{{ utils.bem('field__body', [type]) }}">
<textarea <textarea
wx:if="{{ type === 'textarea' }}" wx:if="{{ type === 'textarea' }}"