[FIX] web: adjust frontend disabled input colors
=== Maintain border consistency of frontend inputs === Prior to this commit, `form-select` borders overlapped the background color, which is not the case with `form-control`. This is because `form-control` uses the `background-clip` property. As we're using a semi-transparent border on frontend inputs, this creates a color issue: when a `form-select` input is disabled, the border color is darker than that of the `form-control`. This commit adapts the `background-clip` on `form-select` input to maintain color consistency between inputs. === Make disabled inputs more recognizable === Prior to this commit, disabled inputs were not sufficiently distinct from regular inputs, especially `website_sale` inputs which had a gray background. Steps to reproduce: - Make sure your instance has website_sale_renting installed. - Go to the Shop page. - Look for a product with a rental period (eg. Printer). - Click on Add to cart, this will disable the rental period input. => The gray search bar and the disabled input have almost the same style This commit adapts the style of disabled inputs in the frontend to make them more recognizable. task-3702675 Part-of: odoo/odoo#150886
This commit is contained in:
@@ -21,6 +21,7 @@ $min-contrast-ratio: $o-frontend-min-contrast-ratio !default;
|
||||
// Body
|
||||
|
||||
$body-bg: $white !default; // BS Default
|
||||
$body-color: $o-main-text-color !default;
|
||||
|
||||
// Components
|
||||
//
|
||||
@@ -59,15 +60,24 @@ $table-color: inherit !default;
|
||||
|
||||
// Forms
|
||||
|
||||
$input-color: $body-color !default;
|
||||
$input-bg: $body-bg !default;
|
||||
$input-transition: background-color .05s ease-in-out, border-color .05s ease-in-out, box-shadow .05s ease-in-out !default;
|
||||
|
||||
$input-disabled-bg: $gray-200 !default;
|
||||
$input-disabled-border-color: rgba($input-color, 0.15) !default;
|
||||
|
||||
$form-check-input-border: $border-width solid $gray-400 !default;
|
||||
$form-check-input-border-radius: 0 !default;
|
||||
$form-select-disabled-color: mix($input-color, $input-bg) !default;
|
||||
$form-select-disabled-bg: $input-disabled-bg !default;
|
||||
$form-select-disabled-border-color: $input-disabled-border-color !default;
|
||||
|
||||
$form-range-track-height: .1rem !default;
|
||||
$form-range-thumb-border: $border-width solid $primary !default;
|
||||
$form-range-thumb-bg: $body-bg !default;
|
||||
$form-range-thumb-active-bg: $primary !default;
|
||||
$form-range-thumb-disabled-bg: $input-disabled-bg !default;
|
||||
|
||||
// Figures
|
||||
|
||||
|
||||
+6
-1
@@ -93,10 +93,15 @@
|
||||
}
|
||||
|
||||
// Force field label pointer to cursor
|
||||
.form-check, .form-select {
|
||||
.form-check {
|
||||
@include o-field-pointer();
|
||||
}
|
||||
|
||||
// Update the border color when hovering form-select elements
|
||||
.form-select:where(:not(:disabled)):hover {
|
||||
border-color: $form-check-input-checked-border-color;
|
||||
}
|
||||
|
||||
// Disable RTL for the dropdown position
|
||||
.dropdown-menu {
|
||||
&[x-placement^="top"],
|
||||
|
||||
@@ -236,3 +236,36 @@ $-color-for-gray-200-bg: adjust-color-to-background($body-color, $gray-200);
|
||||
color: adjust-color-to-background($text-muted, $dropdown-bg, mute-color($color-contrast-light), mute-color($color-contrast-dark)) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// The following code adapts the style of disabled inputs to maintain color
|
||||
// consistency and make them more recognizable.
|
||||
.form-select {
|
||||
// This is necessary to achieve a consistent "border rendering behaviour"
|
||||
// across form-select and form-control when using semi-transparent
|
||||
// borders and a background color (eg. disabled inputs).
|
||||
// Otherwise, the color rendering of the semi-transparent border may be altered
|
||||
// (the color may be darker depending on the background color used).
|
||||
background-clip: padding-box;
|
||||
|
||||
&:disabled:not([multiple]):where(:not([size]), [size="1"]) {
|
||||
background-image: str-replace($form-select-indicator, #{$form-select-indicator-color}, str-replace(#{$form-select-disabled-color}, "#", "%23"));
|
||||
}
|
||||
}
|
||||
|
||||
.form-control {
|
||||
&:disabled, &[readonly] {
|
||||
color: $form-select-disabled-color;
|
||||
}
|
||||
}
|
||||
|
||||
.form-check-input:disabled:not(:checked) {
|
||||
background-color: $input-disabled-bg;
|
||||
|
||||
.form-switch & {
|
||||
background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-select-disabled-color}'/></svg>"));
|
||||
}
|
||||
}
|
||||
|
||||
.form-range:disabled::-webkit-slider-thumb {
|
||||
border-color: $input-disabled-border-color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user