mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-31 09:05:47 +02:00
Add form-validation-states Sass map (#27999)
This commit is contained in:
@@ -241,8 +241,9 @@ textarea.form-control {
|
||||
// pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
|
||||
// server side validation.
|
||||
|
||||
@include form-validation-state("valid", $form-feedback-valid-color);
|
||||
@include form-validation-state("invalid", $form-feedback-invalid-color);
|
||||
@each $state, $data in $form-validation-states {
|
||||
@include form-validation-state($state, map-get($data, color), map-get($data, icon));
|
||||
}
|
||||
|
||||
// Inline forms
|
||||
//
|
||||
|
@@ -658,6 +658,21 @@ $form-feedback-icon-valid: str-replace(url("data:image/svg+xml,%3csvg x
|
||||
$form-feedback-icon-invalid-color: $form-feedback-invalid-color !default;
|
||||
$form-feedback-icon-invalid: str-replace(url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='#{$form-feedback-icon-invalid-color}' viewBox='-2 -2 7 7'%3e%3cpath stroke='#{$form-feedback-icon-invalid-color}' d='M0 0l3 3m0-3L0 3'/%3e%3ccircle r='.5'/%3e%3ccircle cx='3' r='.5'/%3e%3ccircle cy='3' r='.5'/%3e%3ccircle cx='3' cy='3' r='.5'/%3e%3c/svg%3E"), "#", "%23") !default;
|
||||
|
||||
$form-validation-states: () !default;
|
||||
// stylelint-disable-next-line scss/dollar-variable-default
|
||||
$form-validation-states: map-merge(
|
||||
(
|
||||
"valid": (
|
||||
"color": $form-feedback-valid-color,
|
||||
"icon": $form-feedback-icon-valid
|
||||
),
|
||||
"invalid": (
|
||||
"color": $form-feedback-invalid-color,
|
||||
"icon": $form-feedback-icon-invalid
|
||||
),
|
||||
),
|
||||
$form-validation-states
|
||||
);
|
||||
|
||||
// Z-index master list
|
||||
//
|
||||
|
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
|
||||
@mixin form-validation-state($state, $color) {
|
||||
@mixin form-validation-state($state, $color, $icon) {
|
||||
.#{$state}-feedback {
|
||||
display: none;
|
||||
width: 100%;
|
||||
@@ -57,15 +57,10 @@
|
||||
|
||||
@if $enable-validation-icons {
|
||||
padding-right: $input-height-inner;
|
||||
background-image: $icon;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center right calc(#{$input-height-inner} / 4);
|
||||
background-size: calc(#{$input-height-inner} / 2) calc(#{$input-height-inner} / 2);
|
||||
|
||||
@if $state == "valid" {
|
||||
background-image: $form-feedback-icon-valid;
|
||||
} @else {
|
||||
background-image: $form-feedback-icon-invalid;
|
||||
}
|
||||
}
|
||||
|
||||
&:focus {
|
||||
@@ -97,9 +92,8 @@
|
||||
border-color: $color;
|
||||
|
||||
@if $enable-validation-icons {
|
||||
$form-feedback-icon: if($state == "valid", $form-feedback-icon-valid, $form-feedback-icon-invalid);
|
||||
padding-right: $custom-select-feedback-icon-padding-right;
|
||||
background: $custom-select-background, $form-feedback-icon no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
|
||||
background: $custom-select-background, $icon no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
|
Reference in New Issue
Block a user