mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
fix(input): fix material design success/error highlighting on inputs
references #6040 references #5052
This commit is contained in:
@ -19,6 +19,8 @@ $text-input-md-input-clear-icon-color: #5b5b5b !default;
|
|||||||
$text-input-md-input-clear-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><polygon fill='" + $text-input-md-input-clear-icon-color + "' points='405,136.798 375.202,107 256,226.202 136.798,107 107,136.798 226.202,256 107,375.202 136.798,405 256,285.798 375.202,405 405,375.202 285.798,256'/></svg>" !default;
|
$text-input-md-input-clear-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><polygon fill='" + $text-input-md-input-clear-icon-color + "' points='405,136.798 375.202,107 256,226.202 136.798,107 107,136.798 226.202,256 107,375.202 136.798,405 256,285.798 375.202,405 405,375.202 285.798,256'/></svg>" !default;
|
||||||
$text-input-md-input-clear-icon-size: 22px !default;
|
$text-input-md-input-clear-icon-size: 22px !default;
|
||||||
|
|
||||||
|
$text-input-md-show-success-highlight: true !default;
|
||||||
|
$text-input-md-show-error-highlight: true !default;
|
||||||
|
|
||||||
|
|
||||||
// Material Design Default Input
|
// Material Design Default Input
|
||||||
@ -44,7 +46,7 @@ $text-input-md-input-clear-icon-size: 22px !default;
|
|||||||
// Material Design Highlighted Input
|
// Material Design Highlighted Input
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
ion-input::after {
|
.item-input::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@ -56,16 +58,32 @@ ion-input::after {
|
|||||||
content: "";
|
content: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-has-focus::after {
|
.item-input.input-has-focus::after {
|
||||||
border-bottom-color: $text-input-md-highlight-color;
|
border-bottom-color: $text-input-md-highlight-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-input.ng-valid.input-has-value::after {
|
@if($text-input-md-show-success-highlight) {
|
||||||
border-bottom-color: $text-input-md-hightlight-color-valid;
|
.item-input.ng-valid.input-has-value {
|
||||||
|
&::after {
|
||||||
|
border-bottom-color: $text-input-md-hightlight-color-valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.input-has-focus::after {
|
||||||
|
border-bottom-color: $text-input-md-highlight-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-input.ng-invalid.ng-touched::after {
|
@if($text-input-md-show-error-highlight) {
|
||||||
border-bottom-color: $text-input-md-hightlight-color-invalid;
|
.item-input.ng-invalid.ng-touched {
|
||||||
|
&::after {
|
||||||
|
border-bottom-color: $text-input-md-hightlight-color-invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.input-has-focus::after {
|
||||||
|
border-bottom-color: $text-input-md-highlight-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,30 +1,44 @@
|
|||||||
import {App} from '../../../../../src';
|
import {App} from '../../../../../src';
|
||||||
import {FormBuilder, Validators} from '@angular/common';
|
import {FormBuilder, Validators, Control} from '@angular/common';
|
||||||
|
|
||||||
|
|
||||||
@App({
|
@App({
|
||||||
templateUrl: 'main.html'
|
templateUrl: 'main.html'
|
||||||
})
|
})
|
||||||
class E2EApp {
|
class E2EApp {
|
||||||
|
loginForm: any;
|
||||||
|
|
||||||
|
login = {
|
||||||
|
email: 'help@ionic.io',
|
||||||
|
username: 'admin'
|
||||||
|
};
|
||||||
|
|
||||||
|
user = {
|
||||||
|
username: 'asdf',
|
||||||
|
password: '82'
|
||||||
|
};
|
||||||
|
|
||||||
|
submitted: boolean = false;
|
||||||
|
isTextAreaDisabled: boolean;
|
||||||
|
|
||||||
constructor(fb: FormBuilder) {
|
constructor(fb: FormBuilder) {
|
||||||
this.loginForm = fb.group({
|
this.loginForm = fb.group({
|
||||||
email: ["", Validators.required],
|
email: ["", Validators.compose([
|
||||||
|
Validators.required,
|
||||||
|
this.emailValidator
|
||||||
|
])],
|
||||||
username: [""],
|
username: [""],
|
||||||
password: ["", Validators.required],
|
password: ["", Validators.required],
|
||||||
comments: ["", Validators.required]
|
comments: ["", Validators.required]
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.login = {
|
emailValidator(control) {
|
||||||
email: 'help@ionic.io',
|
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
|
||||||
username: 'admin'
|
|
||||||
};
|
|
||||||
|
|
||||||
this.user = {
|
if (!EMAIL_REGEXP.test(control.value)) {
|
||||||
username: 'asdf',
|
return {invalidEmail: true};
|
||||||
password: '82'
|
}
|
||||||
};
|
|
||||||
|
|
||||||
this.submitted = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit(ev, value) {
|
submit(ev, value) {
|
||||||
|
Reference in New Issue
Block a user