From fb7089fd350da918accef03ecd5db525b684f452 Mon Sep 17 00:00:00 2001 From: cookfront Date: Tue, 14 Feb 2017 17:05:43 +0800 Subject: [PATCH] field component --- docs/examples/field.md | 49 +++++++++++++++++++++++++ packages/cell/src/cell.vue | 2 +- packages/field/src/field.vue | 69 +++++++++++++++++++++++++++++++++-- packages/zanui/src/cell.pcss | 1 + packages/zanui/src/field.pcss | 47 ++++++++++++++++++++++++ packages/zanui/src/index.pcss | 1 + 6 files changed, 164 insertions(+), 5 deletions(-) diff --git a/docs/examples/field.md b/docs/examples/field.md index 6dc8f9b27..f70b90e0c 100644 --- a/docs/examples/field.md +++ b/docs/examples/field.md @@ -1,7 +1,55 @@ + + ## Field组件 表单中`input`或`textarea`的输入框。 +### 基础用法 + +:::demo 根据`type`属性显示不同的输入框。 +```html + + + + + +``` +::: + +### 无label的输入框 + +:::demo 根据`type`属性显示不同的输入框。 +```html + + + +``` +::: + +### 监听change事件 + +:::demo 根据`type`属性显示不同的输入框。 +```html + + + +``` +::: + ### API | 参数 | 说明 | 类型 | 默认值 | 可选值 | @@ -12,4 +60,5 @@ | label | 输入框标签 | string | '' | | | disabled | 是否禁用输入框 | boolean | false | | | readonly | 输入框是否只读 | boolean | false | | +| maxlength | 输入框maxlength | [String, Number] | '' | | diff --git a/packages/cell/src/cell.vue b/packages/cell/src/cell.vue index e3bc36753..910284e2c 100644 --- a/packages/cell/src/cell.vue +++ b/packages/cell/src/cell.vue @@ -6,7 +6,7 @@ - +
diff --git a/packages/field/src/field.vue b/packages/field/src/field.vue index 10e54372f..93c5d26bd 100644 --- a/packages/field/src/field.vue +++ b/packages/field/src/field.vue @@ -1,17 +1,78 @@ diff --git a/packages/zanui/src/cell.pcss b/packages/zanui/src/cell.pcss index 8e923d2ee..27151fcdf 100644 --- a/packages/zanui/src/cell.pcss +++ b/packages/zanui/src/cell.pcss @@ -16,6 +16,7 @@ overflow: hidden; position: relative; padding: 10px 10px 10px 0; + box-sizing: border-box; line-height: 22px; background-color: $c-white; color: #333; diff --git a/packages/zanui/src/field.pcss b/packages/zanui/src/field.pcss index e69de29bb..df8d9dc73 100644 --- a/packages/zanui/src/field.pcss +++ b/packages/zanui/src/field.pcss @@ -0,0 +1,47 @@ +@import "./common/var.pcss"; +@import "./mixins/border_retina.pcss"; + +@component-namespace o2 { + @component field { + width: 100%; + display: table; + overflow: hidden; + + @when nolabel { + .o2-cell-title { + display: none; + } + + .o2-cell-value { + width: 100%; + } + } + + .o2-cell-title, + .o2-cell-value { + float: none; + display: table-cell; + box-sizing: border-box; + } + + .o2-cell-title { + width: 90px; + text-align: right; + } + + .o2-cell-value { + width: 90%; + padding-left: 10px; + } + + @descendent control { + border: 0; + font-size: 14px; + line-height: 22px; + display: block; + width: 100%; + resize: none; + outline: 0; + } + } +} diff --git a/packages/zanui/src/index.pcss b/packages/zanui/src/index.pcss index d734655e7..469e089fc 100644 --- a/packages/zanui/src/index.pcss +++ b/packages/zanui/src/index.pcss @@ -3,5 +3,6 @@ */ @import './button.pcss'; @import './cell.pcss'; +@import './field.pcss'; @import './icon.pcss'; @import './switch.pcss';