Commit e93f1e9a766b86dd2d4c12ab27c40cd1e0a3996a
1 parent
4a260ed5
update some styles
update some styles
Showing
8 changed files
with
115 additions
and
4 deletions
Show diff stats
src/components/form/form-item.vue
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <label :class="[prefixCls + '-label']" :style="labelStyles" v-if="label">{{ label }}</label> |
4 | 4 | <div :class="[prefixCls + '-content']" :style="contentStyles"> |
5 | 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 | 7 | </div> |
8 | 8 | </div> |
9 | 9 | </template> | ... | ... |
src/styles/components/cascader.less
src/styles/components/form.less
... | ... | @@ -39,6 +39,15 @@ |
39 | 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 | 51 | &-required { |
43 | 52 | .@{form-item-prefix-cls}-label:before { |
44 | 53 | content: '*'; | ... | ... |
src/styles/components/input-number.less
src/styles/components/input.less
... | ... | @@ -42,4 +42,16 @@ |
42 | 42 | |
43 | 43 | .@{input-prefix-cls}-group{ |
44 | 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 | 58 | \ No newline at end of file | ... | ... |
src/styles/components/select.less
... | ... | @@ -217,3 +217,17 @@ |
217 | 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 | 234 | \ No newline at end of file | ... | ... |
src/styles/mixins/input.less
1 | 1 | .hover(@color: @input-hover-border-color) { |
2 | 2 | border-color: tint(@color, 20%); |
3 | 3 | } |
4 | +.hover-error() { | |
5 | + border-color: @error-color; | |
6 | +} | |
4 | 7 | |
5 | 8 | .active(@color: @input-hover-border-color) { |
6 | 9 | border-color: tint(@color, 20%); |
7 | 10 | outline: 0; |
8 | 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 | 19 | .disabled() { |
12 | 20 | background-color: @input-disabled-bg; |
... | ... | @@ -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 | 99 | .input-group(@inputClass) { |
82 | 100 | display: table; |
83 | 101 | width: 100%; |
... | ... | @@ -214,3 +232,24 @@ |
214 | 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 | 256 | \ No newline at end of file | ... | ... |
test/routers/form.vue
... | ... | @@ -7,10 +7,21 @@ |
7 | 7 | </i-input> |
8 | 8 | </form-item> |
9 | 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 | 20 | </i-input> |
13 | 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 | 25 | <form-item label="radio" prop="single"> |
15 | 26 | <radio :checked.sync="form.single">Single</radio> |
16 | 27 | </form-item> |
... | ... | @@ -266,7 +277,8 @@ |
266 | 277 | cascader: [], |
267 | 278 | transfer: this.getMockData(), |
268 | 279 | targetKeys1: this.getTargetKeys(), |
269 | - input: 1 | |
280 | + input: 1, | |
281 | + textarea: '' | |
270 | 282 | }, |
271 | 283 | rules: { |
272 | 284 | mail: [ |
... | ... | @@ -351,6 +363,14 @@ |
351 | 363 | { |
352 | 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 | } | ... | ... |