-
-
Notifications
You must be signed in to change notification settings - Fork 78.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fade disabled buttons into luminance-gray color of current plane background #40559
base: main
Are you sure you want to change the base?
Conversation
…lor via `var()`-name in `.bg-<COLOR>` classes ```css body { --bs-current-plane-bg: var(--bs-body-bg); } .bg-primary { --bs-current-plane-bg: var(--bs-primary); } .bg-secondary { --bs-current-plane-bg: var(--bs-secondary); } .bg-success { --bs-current-plane-bg: var(--bs-success); } […] ```
…ground ### Before: Disabled buttons simply used `opacity` and color-cross-fading happened. E.g. a disabled red button on a blue plane became purple. ### With this change: Disabled buttons color is mixed with a gray having the identical luminance as the background-color. This results in the following color change of disabled buttons. #### Lightness: Lightened on light background and darkened on dark background. In comparison: Identical behaviour as before. Buttons lightness is slightly (`fade-percentage`) fading into the background. #### Saturation: Slightly desaturated. In comparison: On black/white gray background: Identical behaviour as before. On colorful background: Before there was an unintentional mix between bg-color and button-color saturation. Now the button is simply slightly (`fade-percentage`) desaturated. #### Hue Stays identical. In comparison: On black/white gray background: Identical behaviour as before. On colorful background: Before there was an unintentional cross-fading between bg-color and button-color resulting in unfortunate dyeing of the button. Now the button keeps its color hue.
…r that might contain buttons
faa19cb
to
6a48cf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes Made:
• Added the variable --#{$prefix}current-plane-bg to both the modal and modal-footer sections to reflect their respective background colors.
Improvements:
- Commenting on Changes:
o Add comments explaining the purpose of the new --#{$prefix}current-plane-bg variable to make the code more understandable. - Consistency:
o Ensure that the SCSS code is consistently formatted and properly indented. - Reusability:
o If the --#{$prefix}current-plane-bg variable is intended for broader use, consider documenting its purpose and usage in the relevant style guide or documentation. - Fallbacks for CSS Variables:
o Include fallback values for CSS variables to ensure the styles are rendered even if the custom properties are not defined.
Improved Code:
scss
Copy code
color: var(--#{$prefix}modal-color);
pointer-events: auto;
background-color: var(--#{$prefix}modal-bg);
--#{$prefix}current-plane-bg: var(--#{$prefix}modal-bg); // Set current plane background for modal
background-clip: padding-box;
border: var(--#{$prefix}modal-border-width) solid var(--#{$prefix}modal-border-color);
@include border-radius(var(--#{$prefix}modal-border-radius));
...
justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
padding: calc(var(--#{$prefix}modal-padding) - var(--#{$prefix}modal-footer-gap) * 0.5);
background-color: var(--#{$prefix}modal-footer-bg);
--#{$prefix}current-plane-bg: var(--#{$prefix}modal-footer-bg); // Set current plane background for modal footer
border-top: var(--#{$prefix}modal-footer-border-width) solid var(--#{$prefix}modal-footer-border-color);
@include border-bottom-radius(var(--#{$prefix}modal-inner-border-radius));
Key Points:
• Explain the purpose of new variables with comments.
• Maintain consistent formatting.
• Ensure reusability by documenting new additions.
• Use fallback values for CSS variables for robustness.
@Imran-imtiaz48 Thank you for your review. In GeneralTo get a full idea on this PR please have a look at the changes introduced by this PR. E.g. See additions to bootstrap.css (Click to open).btn {
--bs-btn-disabled-opacity: 0.65;
--bs-btn-disabled-fade-percentage: 35%;
}
.btn:disabled, .btn.disabled, fieldset:disabled .btn {
--bs-btn-parent-bg-luminance-gray: lab(from var(--bs-current-plane-bg) l 0 0);
color: color-mix(in srgb, var(--bs-btn-parent-bg-luminance-gray) var(--bs-btn-disabled-fade-percentage), var(--bs-btn-disabled-color));
background-color: color-mix(in srgb, var(--bs-btn-parent-bg-luminance-gray) var(--bs-btn-disabled-fade-percentage), var(--bs-btn-disabled-bg));
border-color: color-mix(in srgb, var(--bs-btn-parent-bg-luminance-gray) var(--bs-btn-disabled-fade-percentage), var(--bs-btn-disabled-border-color));
}
.btn:disabled.btn-link, .btn.disabled.btn-link, fieldset:disabled .btn.btn-link {
border-color: var(--bs-btn-disabled-border-color);
}
.btn:disabled > *, .btn.disabled > *, fieldset:disabled .btn > * {
color: var(--bs-btn-disabled-color);
opacity: var(--bs-btn-disabled-opacity);
}
body {
background-color: var(--bs-body-bg);
--bs-current-plane-bg: var(--bs-body-bg);
}
.table > :not(caption) > * > * {
background-color: var(--bs-table-bg);
--bs-current-plane-bg: var(--bs-table-bg);
}
.toast {
background-color: var(--bs-toast-bg);
--bs-current-plane-bg: var(--bs-toast-bg);
}
.toast-header {
background-color: var(--bs-toast-header-bg);
--bs-current-plane-bg: var(--bs-toast-header-bg);
}
.modal-content {
background-color: var(--bs-modal-bg);
--bs-current-plane-bg: var(--bs-modal-bg);
}
.modal-footer {
background-color: var(--bs-modal-footer-bg);
--bs-current-plane-bg: var(--bs-modal-footer-bg);
}
.tooltip-inner {
background-color: var(--bs-tooltip-bg);
--bs-current-plane-bg: var(--bs-tooltip-bg);
}
.popover {
background-color: var(--bs-popover-bg);
--bs-current-plane-bg: var(--bs-popover-bg);
}
.popover-header {
background-color: var(--bs-popover-header-bg);
--bs-current-plane-bg: var(--bs-popover-header-bg);
}
.bg-primary {
--bs-current-plane-bg: var(--bs-primary);
}
.bg-secondary {
--bs-current-plane-bg: var(--bs-secondary);
}
.bg-success {
--bs-current-plane-bg: var(--bs-success);
}
.bg-info {
--bs-current-plane-bg: var(--bs-info);
}
.bg-warning {
--bs-current-plane-bg: var(--bs-warning);
}
.bg-danger {
--bs-current-plane-bg: var(--bs-danger);
}
.bg-light {
--bs-current-plane-bg: var(--bs-light);
}
.bg-dark {
--bs-current-plane-bg: var(--bs-dark);
}
.bg-black {
--bs-current-plane-bg: var(--bs-black);
}
.bg-white {
--bs-current-plane-bg: var(--bs-white);
}
.bg-body {
--bs-current-plane-bg: var(--bs-body-bg);
}
.bg-body-secondary {
--bs-current-plane-bg: var(--bs-secondary-bg);
}
.bg-body-tertiary {
--bs-current-plane-bg: var(--bs-tertiary-bg);
} About "1. Commenting on Changes:" and "3. Reusability:"If the implemented approach to solve the issue is accepted, then comments can be added or the documentation can be changed. About "2. Consistency:"
These checks give no code-style errors:
So I do not see any code style issues here. |
Description
Fade disabled buttons into luminance-gray color of current plane background.
Disabled buttons color is mixed with a gray having the identical luminance as the background-color. This results in the following color change of disabled buttons.
https://codepen.io/rr-it/pen/LYoOKrx
https://codepen.io/rr-it/pen/jOoYVMm
Lightness:
Lightened on light background and darkened on dark background.
In comparison:
Identical behaviour as before. Buttons lightness is slightly (
fade-percentage
) fading into the background.Saturation:
Slightly desaturated.
In comparison:
On black/white gray background: Identical behaviour as before.
On colorful background: Before there was an unintentional mix between bg-color and button-color saturation. Now the button is simply slightly (
fade-percentage
) desaturated.Hue:
Stays identical.
In comparison:
On black/white gray background: Identical behaviour as before.
On colorful background: Before there was an unintentional cross-fading between bg-color and button-color resulting in unfortunate dyeing of the button. Now the button keeps its color hue.
Introduction of new css-var
--bs-current-plane-bg
This introduces the css-var
--bs-current-plane-bg
to hold a reference to the bg-color of the current plane.Motivation:
inherit
is currently not usable inside CSS functions. See w3c/csswg-drafts#9757This css-var is set in
body
-tag.bg-<COLOR>
classesThis css-var should also be set for custom elements that set their own background-color.
Motivation & Context
Before disabled buttons simply used
opacity
and color-cross-fading happened.E.g. a disabled red button on a blue plane became purple.
More real world example:
Gray disabled button in a button-group on selected row with blue background:
![grafik](https://private-user-images.githubusercontent.com/29690343/340019848-0c83b23b-3c3c-45f3-8058-3800b5a458f7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0MjY2MjQsIm5iZiI6MTcyMTQyNjMyNCwicGF0aCI6Ii8yOTY5MDM0My8zNDAwMTk4NDgtMGM4M2IyM2ItM2MzYy00NWYzLTgwNTgtMzgwMGI1YTQ1OGY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE5VDIxNTg0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYyODBhNGEwY2NjNjcyMzM1NGIzMDdlZjJlMGY4OThjYTE2Y2ZiNjU0ZGRhZTAyNjYyMmQ0OTBkYzcyZjA5MjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.VwFVnsBPGtphMnZeqYvMqldOci2-MrPwUdj8HvF9Ya4)
This 'disabled' button has a blueish look and thereby looks somehow activated.
Type of changes
Checklist
npm run lint
)Live previews
@deploy-preview-40559
)@5.3.3
)Related issues
Resolves #40557