Commit e93f1e9a766b86dd2d4c12ab27c40cd1e0a3996a

Authored by 梁灏
1 parent 4a260ed5

update some styles

update some styles
src/components/form/form-item.vue
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <label :class="[prefixCls + '-label']" :style="labelStyles" v-if="label">{{ label }}</label> 3 <label :class="[prefixCls + '-label']" :style="labelStyles" v-if="label">{{ label }}</label>
4 <div :class="[prefixCls + '-content']" :style="contentStyles"> 4 <div :class="[prefixCls + '-content']" :style="contentStyles">
5 <slot></slot> 5 <slot></slot>
6 - <div transition="fade" :class="[prefixCls + '-error']" v-if="validateState === 'error'">{{ validateMessage }}</div> 6 + <div transition="fade" :class="[prefixCls + '-error-tip']" v-if="validateState === 'error'">{{ validateMessage }}</div>
7 </div> 7 </div>
8 </div> 8 </div>
9 </template> 9 </template>
src/styles/components/cascader.less
@@ -85,3 +85,11 @@ @@ -85,3 +85,11 @@
85 } 85 }
86 } 86 }
87 } 87 }
  88 +
  89 +.@{form-item-prefix-cls}-error{
  90 + .@{cascader-prefix-cls} {
  91 + &-arrow{
  92 + color: @error-color;
  93 + }
  94 + }
  95 +}
88 \ No newline at end of file 96 \ No newline at end of file
src/styles/components/form.less
@@ -39,6 +39,15 @@ @@ -39,6 +39,15 @@
39 font-size: @font-size-small; 39 font-size: @font-size-small;
40 } 40 }
41 41
  42 + &-error-tip{
  43 + position: absolute;
  44 + top: 100%;
  45 + left: 0;
  46 + line-height: 1;
  47 + padding-top: 6px;
  48 + color: @error-color;
  49 + }
  50 +
42 &-required { 51 &-required {
43 .@{form-item-prefix-cls}-label:before { 52 .@{form-item-prefix-cls}-label:before {
44 content: '*'; 53 content: '*';
src/styles/components/input-number.less
@@ -184,3 +184,12 @@ @@ -184,3 +184,12 @@
184 } 184 }
185 } 185 }
186 } 186 }
  187 +
  188 +.@{form-item-prefix-cls}-error {
  189 + .@{input-number-prefix-cls}{
  190 + .input-error;
  191 + &-focused {
  192 + .active-error;
  193 + }
  194 + }
  195 +}
187 \ No newline at end of file 196 \ No newline at end of file
src/styles/components/input.less
@@ -42,4 +42,16 @@ @@ -42,4 +42,16 @@
42 42
43 .@{input-prefix-cls}-group{ 43 .@{input-prefix-cls}-group{
44 .input-group(~"@{input-prefix-cls}"); 44 .input-group(~"@{input-prefix-cls}");
  45 +}
  46 +
  47 +.@{form-item-prefix-cls}-error{
  48 + .@{input-prefix-cls}{
  49 + .input-error;
  50 + &-icon{
  51 + color: @error-color;
  52 + }
  53 + }
  54 + .@{input-prefix-cls}-group{
  55 + .input-group-error;
  56 + }
45 } 57 }
46 \ No newline at end of file 58 \ No newline at end of file
src/styles/components/select.less
@@ -217,3 +217,17 @@ @@ -217,3 +217,17 @@
217 line-height: 30px; 217 line-height: 30px;
218 } 218 }
219 } 219 }
  220 +
  221 +.@{form-item-prefix-cls}-error{
  222 + .@{select-prefix-cls}{
  223 + &-selection{
  224 + border: 1px solid @error-color;
  225 + }
  226 + &-arrow{
  227 + color: @error-color;
  228 + }
  229 + &-visible .@{select-prefix-cls}-selection{
  230 + .active-error;
  231 + }
  232 + }
  233 +}
220 \ No newline at end of file 234 \ No newline at end of file
src/styles/mixins/input.less
1 .hover(@color: @input-hover-border-color) { 1 .hover(@color: @input-hover-border-color) {
2 border-color: tint(@color, 20%); 2 border-color: tint(@color, 20%);
3 } 3 }
  4 +.hover-error() {
  5 + border-color: @error-color;
  6 +}
4 7
5 .active(@color: @input-hover-border-color) { 8 .active(@color: @input-hover-border-color) {
6 border-color: tint(@color, 20%); 9 border-color: tint(@color, 20%);
7 outline: 0; 10 outline: 0;
8 box-shadow: 0 0 0 2px fade(@color, 20%); 11 box-shadow: 0 0 0 2px fade(@color, 20%);
9 } 12 }
  13 +.active-error() {
  14 + border-color: @error-color;
  15 + outline: 0;
  16 + box-shadow: 0 0 0 2px fade(@error-color, 20%);
  17 +}
10 18
11 .disabled() { 19 .disabled() {
12 background-color: @input-disabled-bg; 20 background-color: @input-disabled-bg;
@@ -78,6 +86,16 @@ @@ -78,6 +86,16 @@
78 } 86 }
79 } 87 }
80 88
  89 +.input-error() {
  90 + border: 1px solid @error-color;
  91 + &:hover {
  92 + .hover-error;
  93 + }
  94 + &:focus {
  95 + .active-error;
  96 + }
  97 +}
  98 +
81 .input-group(@inputClass) { 99 .input-group(@inputClass) {
82 display: table; 100 display: table;
83 width: 100%; 101 width: 100%;
@@ -214,3 +232,24 @@ @@ -214,3 +232,24 @@
214 .input-small(); 232 .input-small();
215 } 233 }
216 } 234 }
  235 +
  236 +.input-group-error{
  237 + &-prepend,
  238 + &-append
  239 + {
  240 + background-color: #fff;
  241 + border: 1px solid @error-color;
  242 + .@{css-prefix}select {
  243 + &-selection {
  244 + background-color: inherit;
  245 + border: 1px solid transparent;
  246 + }
  247 + }
  248 + }
  249 + &-prepend {
  250 + border-right: 0;
  251 + }
  252 + &-append {
  253 + border-left: 0;
  254 + }
  255 +}
217 \ No newline at end of file 256 \ No newline at end of file
test/routers/form.vue
@@ -7,10 +7,21 @@ @@ -7,10 +7,21 @@
7 </i-input> 7 </i-input>
8 </form-item> 8 </form-item>
9 <form-item label="密码" prop="passwd"> 9 <form-item label="密码" prop="passwd">
10 - <i-input type="password" :value.sync="form.passwd" placeholder="请输入密码">  
11 - <Icon type="ios-locked-outline" slot="prepend"></Icon> 10 + <i-input :value.sync="form.passwd">
  11 + <i-select slot="prepend" style="width: 80px">
  12 + <i-option value="http">http://</i-option>
  13 + <i-option value="https">https://</i-option>
  14 + </i-select>
  15 + <i-select slot="append" style="width: 70px">
  16 + <i-option value="com">.com</i-option>
  17 + <i-option value="org">.org</i-option>
  18 + <i-option value="io">.io</i-option>
  19 + </i-select>
12 </i-input> 20 </i-input>
13 </form-item> 21 </form-item>
  22 + <form-item label="textarea" prop="textarea">
  23 + <i-input :value.sync="form.textarea" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入..."></i-input>
  24 + </form-item>
14 <form-item label="radio" prop="single"> 25 <form-item label="radio" prop="single">
15 <radio :checked.sync="form.single">Single</radio> 26 <radio :checked.sync="form.single">Single</radio>
16 </form-item> 27 </form-item>
@@ -266,7 +277,8 @@ @@ -266,7 +277,8 @@
266 cascader: [], 277 cascader: [],
267 transfer: this.getMockData(), 278 transfer: this.getMockData(),
268 targetKeys1: this.getTargetKeys(), 279 targetKeys1: this.getTargetKeys(),
269 - input: 1 280 + input: 1,
  281 + textarea: ''
270 }, 282 },
271 rules: { 283 rules: {
272 mail: [ 284 mail: [
@@ -351,6 +363,14 @@ @@ -351,6 +363,14 @@
351 { 363 {
352 type: 'number', min: 1, max: 4 364 type: 'number', min: 1, max: 4
353 } 365 }
  366 + ],
  367 + textarea: [
  368 + {
  369 + required: true, trigger: 'blur'
  370 + },
  371 + {
  372 + type: 'string', min: 10
  373 + }
354 ] 374 ]
355 } 375 }
356 } 376 }