From 7fb599530920c58eef9ca3b2315aa6b94bd7a86e Mon Sep 17 00:00:00 2001 From: simaQ Date: Tue, 7 Jul 2015 11:32:08 +0800 Subject: [PATCH] add form and input style --- components/form/demo/explain-text.md | 19 ---- components/form/demo/feedback-input.md | 51 --------- components/form/demo/input-group.md | 60 ---------- components/form/demo/sizing.md | 61 ---------- components/form/demo/static-control.md | 27 ----- style/components/form.less | 148 +++++++++++++++---------- style/components/index.less | 1 + style/components/typography.less | 11 +- style/core/base.less | 6 + style/mixins/form.less | 20 ++-- style/mixins/input.less | 61 ++++------ style/themes/default/custom.less | 14 +-- 12 files changed, 142 insertions(+), 337 deletions(-) delete mode 100644 components/form/demo/explain-text.md delete mode 100644 components/form/demo/feedback-input.md delete mode 100644 components/form/demo/input-group.md delete mode 100644 components/form/demo/sizing.md delete mode 100644 components/form/demo/static-control.md diff --git a/components/form/demo/explain-text.md b/components/form/demo/explain-text.md deleted file mode 100644 index 55eaeb95db..0000000000 --- a/components/form/demo/explain-text.md +++ /dev/null @@ -1,19 +0,0 @@ -# Form explain - -- order: 11 - -表单辅助文本 - -针对表单控件的块级辅助文本。 - ---- - -````html -
-
- - -
这里是提示信息。
-
-
-```` diff --git a/components/form/demo/feedback-input.md b/components/form/demo/feedback-input.md deleted file mode 100644 index f91983b59f..0000000000 --- a/components/form/demo/feedback-input.md +++ /dev/null @@ -1,51 +0,0 @@ -# Feedback input - -- order: 8 - -带反馈图标的输入框 - -为输入框添加反馈图标,可以更好地反馈当前的状态。只需用 `.has-feedback` 类包裹 input 输入框即可。 - -另外可为 `label` 标签添加 `required` 属性,表示该项必选。 - -> 注意: 反馈图标只能使用在文本输入框 `` 元素上哦~ - ---- - -````html - -
- -
- - -
-
- - -
- -
- - -
-
该项必选
-
- - -
- -
- - -
-
- -
- -
- - -
-
-```` diff --git a/components/form/demo/input-group.md b/components/form/demo/input-group.md deleted file mode 100644 index 609459a64f..0000000000 --- a/components/form/demo/input-group.md +++ /dev/null @@ -1,60 +0,0 @@ -# Input group - -- order: 9 - -输入框组合 - - - ---- - -````html -

带标签的输入框

-
- Http:// - -
-
-
- - .com -
-
-
- Http:// - - .com -
- -

作为额外元素的按钮式下拉菜单

-
- -
- -
-
- -

带按钮的菜单

-
- -
- -
-
- -

微调输入框

-
- -
- - -
-
-```` diff --git a/components/form/demo/sizing.md b/components/form/demo/sizing.md deleted file mode 100644 index 0bbdaffc00..0000000000 --- a/components/form/demo/sizing.md +++ /dev/null @@ -1,61 +0,0 @@ -# Sizing options - -- order: 10 - -关于尺寸,我们提供大、中、小三种尺寸,默认为中尺寸。 - -待续... - ---- - -````html -

input

- - -
- - -
- - - -

input-group

- -
- -
- -
-
- -
- -
- -
- -
-
- -
- -
- -
- -
-
- -

form-item

-故事未完待续... - -```` diff --git a/components/form/demo/static-control.md b/components/form/demo/static-control.md deleted file mode 100644 index c49d8fb99b..0000000000 --- a/components/form/demo/static-control.md +++ /dev/null @@ -1,27 +0,0 @@ -# Static control - -- order: 5 - -静态文本表单控件:将一行静态文本和 label 标签置于同一行。 - -为 `

` 标签添加 `.ant-form-text` 类即可。 - ---- - -````html -

-
- -
-

Ant

-
-
-
- -
- -
-
- -
-```` diff --git a/style/components/form.less b/style/components/form.less index 3c9d31a7cb..911c1b2150 100644 --- a/style/components/form.less +++ b/style/components/form.less @@ -2,48 +2,43 @@ .reset-form(); -label[required]:before { - position: absolute; - display: inline-block; - content: "*"; - color: @label-required-color; - font-family: SimSun; - font-size: 12px; - .translate3d(-10px; 0; 0); +label { + position: relative; + &[required]:before { + position: absolute; + display: inline-block; + left: ~"-5px \9"; // ie8-9 + content: "*"; + color: @label-required-color; + font-family: SimSun; + font-size: 12px; + .translate3d(-10px; 0; 0); + } + + > .@{iconfont-css-prefix} { + vertical-align: top; + font-size: 12px; + } } -// Form groups -// You should vrap labels and controls in .@{css-prefix}form-item for optimum spacing +// Form items +// You should wrap labels and controls in .@{css-prefix}form-item for optimum spacing .@{css-prefix}form-item { - margin-bottom: 20px; + margin-bottom: @form-item-margin-bottom; + + label { + color: @label-color; + text-align: right; + padding-right: 8px; + } } // Input styles -// Shared size and type resets for form controls. Apply `.form-control` to any -// of the following form controls: -// -// select -// textarea -// input[type="text"] -// input[type="password"] -// input[type="datetime"] -// input[type="datetime-local"] -// input[type="date"] -// input[type="month"] -// input[type="time"] -// input[type="week"] -// input[type="number"] -// input[type="email"] -// input[type="url"] -// input[type="search"] -// input[type="tel"] -// input[type="color"] .@{css-prefix}input { .input; } //== Input type: with extra icon -// TODO: sizing options .has-feedback { .input-with-icon(); } @@ -53,7 +48,34 @@ label[required]:before { .input-group(~"@{css-prefix}input"); } -// Other form controls +// 表单下的输入框尺寸唯一: 大尺寸 +form { + .@{css-prefix}input { + height: @input-height-lg; + font-size: 12px; + padding: @input-padding-horizontal; + } + .has-feedback { + .@{iconfont-css-prefix} { + .square(@input-height-lg); + line-height: @input-height-lg; + } + } + + .@{css-prefix}input-group > .@{css-prefix}input, + .@{css-prefix}input-group > .@{css-prefix}input-group-addon, + .@{css-prefix}input-group > .@{css-prefix}input-group-btn > .input-btn { + .input-lg(); + } + + // input[type=file] + .@{css-prefix}upload { + height: 32px; + font-size: 12px; + padding: 7px; + } +} + // Radio & Checkbox .@{css-prefix}radio, .@{css-prefix}checkbox { @@ -61,10 +83,11 @@ label[required]:before { display: block; margin-top: 10px; margin-bottom: 10px; + height: @input-height-lg; label { min-height: @line-height-computed; - padding-left: 20px; + padding: 7px 0 7px 20px; margin-bottom: 0; font-weight: normal; cursor: pointer; @@ -81,7 +104,7 @@ label[required]:before { .@{css-prefix}radio + .@{css-prefix}radio, .@{css-prefix}checkbox + .@{css-prefix}checkbox { - margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing + margin-top: -5px; } // Radios and checkboxes on same line @@ -89,22 +112,15 @@ label[required]:before { .@{css-prefix}checkbox-inline { position: relative; display: inline-block; - padding-left: 20px; + padding: 7px 20px; + padding-right: 0!important; margin-bottom: 0; + margin-right: 10px; vertical-align: middle; font-weight: normal; cursor: pointer; } -.@{css-prefix}radio-inline + .@{css-prefix}radio-inline, -.@{css-prefix}checkbox-inline + .@{css-prefix}checkbox-inline { - margin-top: 0; - margin-left: 10px; // space out consecutive inline controls -} -// Apply same disabled cursor tweak as for inputs -// Some special care is needed because