diff --git a/components/form/demo/basic.md b/components/form/demo/basic.md new file mode 100644 index 0000000000000000000000000000000000000000..a6f5a708193c48ea4c82113026fd64bc7a6c5ea2 --- /dev/null +++ b/components/form/demo/basic.md @@ -0,0 +1,30 @@ +# Basic from + +- order: 1 + +表单基本实例 + +`.ant-input` 类为 ``、``、`` 元素默认设置了 `width: 100%`。 + +为了获得更好的排列,请将 label 元素和 ``、``、`` 控件包裹在 `.ant-form-item` 中。 + +--- + +````html + + + Username + + + + Password + + + + + Remember me! + + + + +```` diff --git a/components/form/demo/disabled.md b/components/form/demo/disabled.md new file mode 100644 index 0000000000000000000000000000000000000000..181e25379b6bba98c1a39fc4defe90704d8bd794 --- /dev/null +++ b/components/form/demo/disabled.md @@ -0,0 +1,38 @@ +# Disabled status + +- order: 6 + +禁用状态 + + 1. 单独为输入框设置 disabled 属性 + 2. 为 设置 disabled 属性,可以禁用 中包含的所有控件 + +--- + +````html +禁用的表单控件 + + +禁用的fieldset + + + + Disabled input + + + + Disabled select + + Disabled select + + + + + Disabled checkbox + + + Submit + + + +```` diff --git a/components/form/demo/explain-text.md b/components/form/demo/explain-text.md new file mode 100644 index 0000000000000000000000000000000000000000..55eaeb95db2fa41a9d37362f9881647dcb527ef8 --- /dev/null +++ b/components/form/demo/explain-text.md @@ -0,0 +1,19 @@ +# Form explain + +- order: 11 + +表单辅助文本 + +针对表单控件的块级辅助文本。 + +--- + +````html + + + Username + + 这里是提示信息。 + + +```` diff --git a/components/form/demo/feedback-input.md b/components/form/demo/feedback-input.md new file mode 100644 index 0000000000000000000000000000000000000000..f91983b59fe5a2b86bf2ed20968826149ae2c51a --- /dev/null +++ b/components/form/demo/feedback-input.md @@ -0,0 +1,51 @@ +# Feedback input + +- order: 8 + +带反馈图标的输入框 + +为输入框添加反馈图标,可以更好地反馈当前的状态。只需用 `.has-feedback` 类包裹 input 输入框即可。 + +另外可为 `label` 标签添加 `required` 属性,表示该项必选。 + +> 注意: 反馈图标只能使用在文本输入框 `` 元素上哦~ + +--- + +````html + + + Username + + + + + + + + + Username + + + + + 该项必选 + + + + + Username + + + + + + + + Username + + + + + +```` diff --git a/components/form/demo/form-controls.md b/components/form/demo/form-controls.md new file mode 100644 index 0000000000000000000000000000000000000000..f0c95a7294ba428b2ec1bce32cf60144c9a6d9fa --- /dev/null +++ b/components/form/demo/form-controls.md @@ -0,0 +1,87 @@ +# Form controls + +- order: 4 + +表单控件 + +展示所有支持的表单控件。 + +1. 输入框:只有正确设置了 type 属性的输入控件才能被赋予正确的样式。 + +--- + +````html +input 输入框 + + + +textarea 文本域 + + +select 下拉列表 + + 1 + 2 + 3 + 4 + 5 + + +checkbox 复选框 + + + + Apple + + + + + + + Banana disabled + + + + + + 1 + + + 2 + + + 3 + + +radio 单选框 + + + + Apple + + + + + + Peach + + + + + + + Banana + + + + + + 1 + + + 2 + + + 3 + +```` diff --git a/components/form/demo/horizontal-form.md b/components/form/demo/horizontal-form.md new file mode 100644 index 0000000000000000000000000000000000000000..2fa14116f775a08318fd043bf55ffa74213b6490 --- /dev/null +++ b/components/form/demo/horizontal-form.md @@ -0,0 +1,34 @@ +# Horizontal form + +- order: 2 + +水平排列的表单 + +为 `` 标签添加 `.ant-form-horizontal` 类(这让 `.ant-form-item` 表现为栅格系统中的 row),并结合使用我们提供的 [栅格系统](http://ant.design/components/layout/),可以实现 label 标签和表单控件的水平并排排列。 + +--- + +````html + + + Username + + + + + + Password + + + + + + + + Remember me! + + + + + +```` diff --git a/components/form/demo/inline-form.md b/components/form/demo/inline-form.md new file mode 100644 index 0000000000000000000000000000000000000000..dc0494a7aabb86362de04f73e869e912c70b7b7e --- /dev/null +++ b/components/form/demo/inline-form.md @@ -0,0 +1,23 @@ +# Horizontal form + +- order: 3 + +内联的表单 + +在**视口宽度大于等于 768px **时,你可以为 `` 标签添加 `.ant-form-inline` 类可使其表现为 inline-block 级别的控件。 + +--- + +````html + + + Username + + + + Password + + + + +```` diff --git a/components/form/demo/input-group.md b/components/form/demo/input-group.md new file mode 100644 index 0000000000000000000000000000000000000000..609459a64f3cc187e52857b5113ca978b48a405d --- /dev/null +++ b/components/form/demo/input-group.md @@ -0,0 +1,60 @@ +# Input group + +- order: 9 + +输入框组合 + + + +--- + +````html +带标签的输入框 + + Http:// + + + + + + .com + + + + Http:// + + .com + + +作为额外元素的按钮式下拉菜单 + + + + + .com + + + + + +带按钮的菜单 + + + + Go! + + + +微调输入框 + + + + + + + + + + + +```` diff --git a/components/form/demo/sizing.md b/components/form/demo/sizing.md new file mode 100644 index 0000000000000000000000000000000000000000..0bbdaffc001acb75e31b886fcc15acc7858ee76c --- /dev/null +++ b/components/form/demo/sizing.md @@ -0,0 +1,61 @@ +# Sizing options + +- order: 10 + +关于尺寸,我们提供大、中、小三种尺寸,默认为中尺寸。 + +待续... + +--- + +````html +input + + + + + + + + + +input-group + + + + + + .com + + + + + + + + + + + + .com + + + + + + + + + + + + .com + + + + + +form-item +故事未完待续... + +```` diff --git a/components/form/demo/static-control.md b/components/form/demo/static-control.md new file mode 100644 index 0000000000000000000000000000000000000000..c49d8fb99bb0c173f02f0b804801cb014c621caf --- /dev/null +++ b/components/form/demo/static-control.md @@ -0,0 +1,27 @@ +# Static control + +- order: 5 + +静态文本表单控件:将一行静态文本和 label 标签置于同一行。 + +为 `` 标签添加 `.ant-form-text` 类即可。 + +--- + +````html + + + Username + + Ant + + + + Password + + + + + + +```` diff --git a/components/form/demo/validate.md b/components/form/demo/validate.md new file mode 100644 index 0000000000000000000000000000000000000000..ff3ca4b6c0f6ec44ef5bf2c0a13b751f8a96ccc7 --- /dev/null +++ b/components/form/demo/validate.md @@ -0,0 +1,35 @@ +# Validate status + +- order: 7 + +校验状态 + +提供三种校验状态类:`.has-success` `.has-error` `.has-warning`, 分别代表成功、失败、警告 + +为 `ant-form-item` 类添加以上三种校验状态类即可。 + +--- + +````html +成功 + + Username + + + Yes, I know you are ant. + + + +失败 + + Username + + + +警告 + + Username + + + +```` diff --git a/components/form/index.md b/components/form/index.md new file mode 100644 index 0000000000000000000000000000000000000000..9759701b92a266c202b8e729ef8bf0dff2338ce1 --- /dev/null +++ b/components/form/index.md @@ -0,0 +1,11 @@ +# Form + +- category: CSS +- chinese: 表单 +- order: 3 + +--- + +## 如何使用 + +孵化中,待完善...... diff --git a/style/components/form.less b/style/components/form.less index 81d37a8df96011cf6f4b55158c963b9eac4ebc54..3c9d31a7cb8e4d3056f771e02e63dd9f29f76db5 100644 --- a/style/components/form.less +++ b/style/components/form.less @@ -19,7 +19,25 @@ label[required]:before { } // Input styles -//== Basic +// 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; } @@ -35,12 +53,106 @@ label[required]:before { .input-group(~"@{css-prefix}input"); } +// Other form controls +// Radio & Checkbox +.@{css-prefix}radio, +.@{css-prefix}checkbox { + position: relative; + display: block; + margin-top: 10px; + margin-bottom: 10px; + + label { + min-height: @line-height-computed; + padding-left: 20px; + margin-bottom: 0; + font-weight: normal; + cursor: pointer; + } +} +.@{css-prefix}radio input[type="radio"], +.@{css-prefix}radio-inline input[type="radio"], +.@{css-prefix}checkbox input[type="checkbox"], +.@{css-prefix}checkbox-inline input[type="checkbox"] { + position: absolute; + margin-left: -20px; + margin-top: 4px \9; +} + +.@{css-prefix}radio + .@{css-prefix}radio, +.@{css-prefix}checkbox + .@{css-prefix}checkbox { + margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing +} + +// Radios and checkboxes on same line +.@{css-prefix}radio-inline, +.@{css-prefix}checkbox-inline { + position: relative; + display: inline-block; + padding-left: 20px; + margin-bottom: 0; + 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 s don't inherit their parent's `cursor`. +// +// Note: Neither radios nor checkboxes can be readonly. +input[type="radio"], +input[type="checkbox"] { + &[disabled], + &.disabled, + fieldset[disabled] & { + cursor: @cursor-disabled; + } +} +// These classes are used directly on s +.@{css-prefix}radio-inline, +.@{css-prefix}checkbox-inline { + &.disabled, + fieldset[disabled] & { + cursor: @cursor-disabled; + } +} +// These classes are used on elements with descendants +.@{css-prefix}radio, +.@{css-prefix}checkbox { + &.disabled, + fieldset[disabled] & { + label { + cursor: @cursor-disabled; + } + } +} + // Form layout //== Horizontal Form .@{css-prefix}form-horizontal { .@{css-prefix}form-item { .make-row; } + + .@{css-prefix}radio, + .@{css-prefix}checkbox, + .@{css-prefix}radio-inline, + .@{css-prefix}checkbox-inline { + margin-top: 0; + margin-bottom: 0; + padding-top: (@input-padding-vertical-base + 1); // Default padding plus a border + } + // Account for padding we're adding to ensure the alignment and of help text + // and other content below items + .@{css-prefix}radio, + .@{css-prefix}checkbox { + min-height: (@line-height-computed + (@input-padding-vertical-base + 1)); + } } //== Inline Form @@ -60,9 +172,42 @@ label[required]:before { vertical-align: middle; } + .@{css-prefix}form-text { + display: inline-block; + } + .has-feedback { display: inline-block; } + + .@{css-prefix}radio, + .@{css-prefix}checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; + + label { + padding-left: 0; + } + } + .@{css-prefix}radio input[type="radio"], + .@{css-prefix}checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; + } + + } +} + +.@{css-prefix}form-text { + // min-height: (@line-height-computed + @font-size-base); + margin: 0!important; + + &.@{css-prefix}input-lg, + &.@{css-prefix}input-sm { + padding-left: 0; + padding-right: 0; } } diff --git a/style/mixins/input.less b/style/mixins/input.less index b40993907658c2df541d3b5059e3d4abd545782a..c09a1537a0094700d353347b12d7969037c91dad 100644 --- a/style/mixins/input.less +++ b/style/mixins/input.less @@ -50,7 +50,7 @@ .placeholder(); .transition(~"border @{duration-300} @{ease-in-out}, background @{duration-300} @{ease-in-out}, box-shadow @{duration-300} @{ease-in-out}"); - &:not([disabled]):hover { + &:hover { border-color: @input-hover-border-color; } @@ -66,6 +66,9 @@ fieldset[disabled] & { background-color: @input-disabled-bg; opacity: 1; + &:hover { + border-color: @input-border-color; + } } &[disabled], @@ -171,6 +174,7 @@ .button-variant(@input-color; #eee; @input-border-color); .@{iconfont-css-prefix} { + line-height: 1; margin-left: 8px; } } @@ -265,9 +269,6 @@ &-sm > &-btn > .@{inputBtn} { .input-sm(); } - &-sm > &-btn > .@{inputBtn} { - top: -2px; - } // TODO: input-group-btn-vertical: different button size } diff --git a/style/themes/default/custom.less b/style/themes/default/custom.less index 24e80a3b3f858ebd645a60c91942ae8b38c35602..0211fa3214e379abcde1e6d9e75af786de46e76c 100644 --- a/style/themes/default/custom.less +++ b/style/themes/default/custom.less @@ -15,6 +15,8 @@ @text-color : #666; @font-size-base : 12px; @line-height-base : 1.5; +@line-height-computed: floor((@font-size-base * @line-height-base)); + // ICONFONT @iconfont-css-prefix : anticon;
` 标签添加 `.ant-form-text` 类即可。 + +--- + +````html +
Ant