Skip to content

Commit

Permalink
docs(Field): consistent with demo (#11707)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Mar 26, 2023
1 parent 1c1e2e3 commit 81d36aa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"lint": "pnpm --dir ./packages/vant lint",
"test": "pnpm --dir ./packages/vant test",
"test:watch": "pnpm --dir ./packages/vant test:watch",
"test:update": "pnpm --dir ./packages/vant test:update",
"build": "pnpm --dir ./packages/vant build",
"build:site": "pnpm --dir ./packages/vant build:site"
},
Expand Down
24 changes: 21 additions & 3 deletions packages/vant/src/field/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,34 @@ Use `input-align` prop to align the input value.

### Label Align

Use `label-align` prop to align the input value.
Use `label-align` prop to align the input value, can be set to `center`, `right` or `top`.

```html
<van-cell-group inset>
<van-field
v-model="value"
label="Tel"
placeholder="Please input tel number"
label="Label"
placeholder="Align Top"
label-align="top"
/>
<van-field
v-model="value2"
label="Label"
placeholder="Align Left"
label-align="left"
/>
<van-field
v-model="value3"
label="Label"
placeholder="Align Center"
label-align="center"
/>
<van-field
v-model="value4"
label="Label"
placeholder="Align Right"
label-align="right"
/>
</van-cell-group>
```

Expand Down
22 changes: 20 additions & 2 deletions packages/vant/src/field/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,28 @@ export default {
<van-cell-group inset>
<van-field
v-model="value"
label="手机号"
placeholder="请输入手机号"
label="文本"
placeholder="顶部对齐"
label-align="top"
/>
<van-field
v-model="value2"
label="文本"
placeholder="左对齐"
label-align="left"
/>
<van-field
v-model="value3"
label="文本"
placeholder="居中对齐"
label-align="center"
/>
<van-field
v-model="value4"
label="文本"
placeholder="右对齐"
label-align="right"
/>
</van-cell-group>
```

Expand Down
20 changes: 10 additions & 10 deletions packages/vant/src/field/demo/LabelAlign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { useTranslate } from '../../../docs/site';
const t = useTranslate({
'zh-CN': {
text: '文本',
label: '文本',
top: '顶部对齐',
center: '居中对齐',
left: '左对齐',
right: '右对齐',
labelAlign: '输入框文本位置',
},
'en-US': {
text: 'Text',
top: 'Top Align',
center: 'Center Align',
left: 'Left Align',
right: 'Right Align',
label: 'Label',
top: 'Align Top',
center: 'Align Center',
left: 'Align Left',
right: 'Align Right',
labelAlign: 'Label Align',
},
});
Expand All @@ -31,25 +31,25 @@ const value = ref('');
<van-cell-group inset>
<van-field
v-model="value"
:label="t('text')"
:label="t('label')"
:placeholder="t('top')"
label-align="top"
/>
<van-field
v-model="value"
:label="t('text')"
:label="t('label')"
:placeholder="t('left')"
label-align="left"
/>
<van-field
v-model="value"
:label="t('text')"
:label="t('label')"
:placeholder="t('center')"
label-align="center"
/>
<van-field
v-model="value"
:label="t('text')"
:label="t('label')"
:placeholder="t('right')"
label-align="right"
/>
Expand Down
16 changes: 8 additions & 8 deletions packages/vant/src/field/test/__snapshots__/demo.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ exports[`should render demo and match snapshot 1`] = `
<label id="van-field-label"
for="van-field-input"
>
Text
Label
</label>
</div>
<div class="van-cell__value van-field__value">
<div class="van-field__body">
<input type="text"
id="van-field-input"
class="van-field__control"
placeholder="Top Align"
placeholder="Align Top"
aria-labelledby="van-field-label"
>
</div>
Expand All @@ -443,15 +443,15 @@ exports[`should render demo and match snapshot 1`] = `
<label id="van-field-label"
for="van-field-input"
>
Text
Label
</label>
</div>
<div class="van-cell__value van-field__value">
<div class="van-field__body">
<input type="text"
id="van-field-input"
class="van-field__control"
placeholder="Left Align"
placeholder="Align Left"
aria-labelledby="van-field-label"
>
</div>
Expand All @@ -462,15 +462,15 @@ exports[`should render demo and match snapshot 1`] = `
<label id="van-field-label"
for="van-field-input"
>
Text
Label
</label>
</div>
<div class="van-cell__value van-field__value">
<div class="van-field__body">
<input type="text"
id="van-field-input"
class="van-field__control"
placeholder="Center Align"
placeholder="Align Center"
aria-labelledby="van-field-label"
>
</div>
Expand All @@ -481,15 +481,15 @@ exports[`should render demo and match snapshot 1`] = `
<label id="van-field-label"
for="van-field-input"
>
Text
Label
</label>
</div>
<div class="van-cell__value van-field__value">
<div class="van-field__body">
<input type="text"
id="van-field-input"
class="van-field__control"
placeholder="Right Align"
placeholder="Align Right"
aria-labelledby="van-field-label"
>
</div>
Expand Down

0 comments on commit 81d36aa

Please sign in to comment.