2014-03-10 07:18:48 +01:00
|
|
|
// Form control focus state
|
|
|
|
//
|
|
|
|
// Generate a customized focus state and for any input with the specified color,
|
2017-09-26 17:14:52 +02:00
|
|
|
// which defaults to the `$input-focus-border-color` variable.
|
2014-03-10 07:18:48 +01:00
|
|
|
//
|
|
|
|
// We highly encourage you to not customize the default value, but instead use
|
|
|
|
// this to tweak colors on an as-needed basis. This aesthetic change is based on
|
|
|
|
// WebKit's default styles, but applicable to a wider range of browsers. Its
|
|
|
|
// usability and accessibility should be taken into account with any change.
|
|
|
|
//
|
|
|
|
// Example usage: change the default blue border and shadow to white for better
|
|
|
|
// contrast against a dark gray background.
|
2019-02-15 14:50:58 +01:00
|
|
|
@mixin form-control-focus($ignore-warning: false) {
|
2014-03-10 07:18:48 +01:00
|
|
|
&:focus {
|
(#22414) Rename for consistency `$input-bg-disabled`, `$input-bg-focus`, `$input-border-color-focus`, `$input-box-shadow-focus`, `$input-color-focus`, `$input-color-placeholder` to `$input-disabled-bg`, `$input-focus-bg`, `$input-focus-border-color`, `$input-focus-box-shadow`, `$input-focus-color`, `$input-placeholder-color`, respectively
2017-06-09 04:11:40 +02:00
|
|
|
color: $input-focus-color;
|
|
|
|
background-color: $input-focus-bg;
|
|
|
|
border-color: $input-focus-border-color;
|
2017-11-06 01:23:36 +01:00
|
|
|
outline: 0;
|
2017-10-19 18:03:33 +02:00
|
|
|
@if $enable-shadows {
|
2020-04-06 15:25:14 +02:00
|
|
|
@include box-shadow($input-box-shadow, $input-focus-box-shadow);
|
2017-10-19 18:03:33 +02:00
|
|
|
} @else {
|
2020-04-06 15:25:14 +02:00
|
|
|
// Avoid using mixin so we can pass custom focus shadow properly
|
2017-10-25 21:30:29 +02:00
|
|
|
box-shadow: $input-focus-box-shadow;
|
2017-10-19 18:03:33 +02:00
|
|
|
}
|
2014-03-10 07:18:48 +01:00
|
|
|
}
|
2019-11-26 18:12:00 +01:00
|
|
|
@include deprecate("The `form-control-focus()` mixin", "v4.4.0", "v5", $ignore-warning);
|
2014-03-10 07:18:48 +01:00
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
|
2019-10-12 15:07:22 +02:00
|
|
|
// This mixin uses an `if()` technique to be compatible with Dart Sass
|
|
|
|
// See https://github.com/sass/sass/issues/1873#issuecomment-152293725 for more details
|
2019-04-25 16:01:50 +02:00
|
|
|
@mixin form-validation-state-selector($state) {
|
|
|
|
@if ($state == "valid" or $state == "invalid") {
|
2019-10-12 15:07:22 +02:00
|
|
|
.was-validated #{if(&, "&", "")}:#{$state},
|
|
|
|
#{if(&, "&", "")}.is-#{$state} {
|
2019-04-25 16:01:50 +02:00
|
|
|
@content;
|
|
|
|
}
|
|
|
|
} @else {
|
2019-10-12 15:07:22 +02:00
|
|
|
#{if(&, "&", "")}.is-#{$state} {
|
2019-04-25 16:01:50 +02:00
|
|
|
@content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
|
2019-01-11 20:16:50 +01:00
|
|
|
@mixin form-validation-state($state, $color, $icon) {
|
2017-10-03 05:37:28 +02:00
|
|
|
.#{$state}-feedback {
|
|
|
|
display: none;
|
2017-12-23 00:29:49 +01:00
|
|
|
width: 100%;
|
2017-11-15 02:32:08 +01:00
|
|
|
margin-top: $form-feedback-margin-top;
|
2019-02-07 23:32:05 +01:00
|
|
|
@include font-size($form-feedback-font-size);
|
2017-10-03 05:37:28 +02:00
|
|
|
color: $color;
|
|
|
|
}
|
|
|
|
|
|
|
|
.#{$state}-tooltip {
|
|
|
|
position: absolute;
|
|
|
|
top: 100%;
|
2020-06-04 08:27:08 +02:00
|
|
|
left: 0;
|
2017-10-03 05:37:28 +02:00
|
|
|
z-index: 5;
|
|
|
|
display: none;
|
2018-01-03 06:57:56 +01:00
|
|
|
max-width: 100%; // Contain to parent when possible
|
2018-09-19 06:27:02 +02:00
|
|
|
padding: $form-feedback-tooltip-padding-y $form-feedback-tooltip-padding-x;
|
2017-10-03 05:37:28 +02:00
|
|
|
margin-top: .1rem;
|
2019-02-07 23:32:05 +01:00
|
|
|
@include font-size($form-feedback-tooltip-font-size);
|
2018-09-19 06:27:02 +02:00
|
|
|
line-height: $form-feedback-tooltip-line-height;
|
2018-07-21 01:21:40 +02:00
|
|
|
color: color-yiq($color);
|
2018-09-19 06:27:02 +02:00
|
|
|
background-color: rgba($color, $form-feedback-tooltip-opacity);
|
|
|
|
@include border-radius($form-feedback-tooltip-border-radius);
|
2020-10-30 15:15:31 +01:00
|
|
|
|
|
|
|
// See https://github.com/twbs/bootstrap/pull/31557
|
|
|
|
// Align tooltip to form elements
|
|
|
|
.form-row > .col > &,
|
|
|
|
.form-row > [class*="col-"] > & {
|
2021-07-25 19:19:02 +02:00
|
|
|
left: $form-grid-gutter-width * .5;
|
2020-10-30 15:15:31 +01:00
|
|
|
}
|
2017-10-03 05:37:28 +02:00
|
|
|
}
|
|
|
|
|
2019-08-17 15:12:08 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
|
|
|
~ .#{$state}-feedback,
|
|
|
|
~ .#{$state}-tooltip {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 00:31:18 +02:00
|
|
|
.form-control {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2018-07-09 00:31:18 +02:00
|
|
|
border-color: $color;
|
|
|
|
|
|
|
|
@if $enable-validation-icons {
|
2021-02-15 20:13:43 +01:00
|
|
|
padding-right: $input-height-inner !important; // stylelint-disable-line declaration-no-important
|
2019-07-20 03:57:12 +02:00
|
|
|
background-image: escape-svg($icon);
|
2018-07-09 00:31:18 +02:00
|
|
|
background-repeat: no-repeat;
|
2019-05-26 11:13:55 +02:00
|
|
|
background-position: right $input-height-inner-quarter center;
|
2019-02-07 23:32:05 +01:00
|
|
|
background-size: $input-height-inner-half $input-height-inner-half;
|
2018-07-09 00:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
border-color: $color;
|
|
|
|
box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-26 04:21:06 +01:00
|
|
|
// stylelint-disable-next-line selector-no-qualifying-type
|
|
|
|
select.form-control {
|
|
|
|
@include form-validation-state-selector($state) {
|
|
|
|
@if $enable-validation-icons {
|
|
|
|
padding-right: $input-padding-x * 4 !important; // stylelint-disable-line declaration-no-important
|
|
|
|
background-position: right $input-padding-x * 2 center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 20:57:09 +02:00
|
|
|
// stylelint-disable-next-line selector-no-qualifying-type
|
2018-07-09 00:31:18 +02:00
|
|
|
textarea.form-control {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2018-07-09 00:31:18 +02:00
|
|
|
@if $enable-validation-icons {
|
|
|
|
padding-right: $input-height-inner;
|
2019-02-07 23:32:05 +01:00
|
|
|
background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
|
2018-07-09 00:31:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-11 01:30:26 +02:00
|
|
|
.custom-select {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2017-06-11 01:30:26 +02:00
|
|
|
border-color: $color;
|
|
|
|
|
2018-07-09 00:31:18 +02:00
|
|
|
@if $enable-validation-icons {
|
2021-02-15 20:13:43 +01:00
|
|
|
padding-right: $custom-select-feedback-icon-padding-right !important; // stylelint-disable-line declaration-no-important
|
2020-11-13 17:58:51 +01:00
|
|
|
background: $custom-select-background, $custom-select-bg escape-svg($icon) $custom-select-feedback-icon-position / $custom-select-feedback-icon-size no-repeat;
|
2018-07-09 00:31:18 +02:00
|
|
|
}
|
|
|
|
|
2017-06-11 01:30:26 +02:00
|
|
|
&:focus {
|
2017-11-06 21:04:56 +01:00
|
|
|
border-color: $color;
|
2017-10-25 21:30:29 +02:00
|
|
|
box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
|
2017-06-11 01:30:26 +02:00
|
|
|
}
|
2018-04-24 06:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-11 01:30:26 +02:00
|
|
|
.form-check-input {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2017-12-23 01:13:01 +01:00
|
|
|
~ .form-check-label {
|
2017-06-11 01:30:26 +02:00
|
|
|
color: $color;
|
|
|
|
}
|
2018-01-05 19:55:13 +01:00
|
|
|
|
|
|
|
~ .#{$state}-feedback,
|
|
|
|
~ .#{$state}-tooltip {
|
|
|
|
display: block;
|
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.custom-control-input {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2017-12-23 01:13:01 +01:00
|
|
|
~ .custom-control-label {
|
2017-06-11 01:30:26 +02:00
|
|
|
color: $color;
|
2017-12-23 01:13:01 +01:00
|
|
|
|
|
|
|
&::before {
|
2018-10-21 09:25:07 +02:00
|
|
|
border-color: $color;
|
2017-12-23 01:13:01 +01:00
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
}
|
2017-12-24 07:47:37 +01:00
|
|
|
|
2017-11-24 23:26:56 +01:00
|
|
|
&:checked {
|
2017-12-23 01:13:01 +01:00
|
|
|
~ .custom-control-label::before {
|
2018-10-21 09:25:07 +02:00
|
|
|
border-color: lighten($color, 10%);
|
2017-11-24 23:26:56 +01:00
|
|
|
@include gradient-bg(lighten($color, 10%));
|
|
|
|
}
|
|
|
|
}
|
2017-12-24 07:47:37 +01:00
|
|
|
|
2017-10-22 05:57:19 +02:00
|
|
|
&:focus {
|
2017-12-23 01:13:01 +01:00
|
|
|
~ .custom-control-label::before {
|
2018-10-21 09:25:07 +02:00
|
|
|
box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(:checked) ~ .custom-control-label::before {
|
|
|
|
border-color: $color;
|
2017-10-22 05:57:19 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// custom file
|
|
|
|
.custom-file-input {
|
2019-04-25 16:01:50 +02:00
|
|
|
@include form-validation-state-selector($state) {
|
2017-12-24 07:47:37 +01:00
|
|
|
~ .custom-file-label {
|
2017-06-11 01:30:26 +02:00
|
|
|
border-color: $color;
|
|
|
|
}
|
2017-12-24 07:47:37 +01:00
|
|
|
|
2017-06-11 01:30:26 +02:00
|
|
|
&:focus {
|
2017-12-24 07:47:37 +01:00
|
|
|
~ .custom-file-label {
|
2018-08-26 16:15:43 +02:00
|
|
|
border-color: $color;
|
2017-10-25 21:30:29 +02:00
|
|
|
box-shadow: 0 0 0 $input-focus-width rgba($color, .25);
|
2017-10-22 21:37:45 +02:00
|
|
|
}
|
2017-06-11 01:30:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|