Skip to content

Commit

Permalink
Fade disabled buttons into luminance-gray color of current plane back…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rr-it committed Jun 15, 2024
1 parent 02e24fb commit c806aaa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
34 changes: 30 additions & 4 deletions scss/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
--#{$prefix}btn-hover-border-color: transparent;
--#{$prefix}btn-box-shadow: #{$btn-box-shadow};
--#{$prefix}btn-disabled-opacity: #{$btn-disabled-opacity};
--#{$prefix}btn-disabled-fade-percentage: #{$btn-disabled-fade-percentage};
--#{$prefix}btn-focus-box-shadow: 0 0 0 #{$btn-focus-width} rgba(var(--#{$prefix}btn-focus-shadow-rgb), .5);
// scss-docs-end btn-css-vars

Expand Down Expand Up @@ -112,13 +113,38 @@
&:disabled,
&.disabled,
fieldset:disabled & {
color: var(--#{$prefix}btn-disabled-color);
--#{$prefix}btn-parent-bg-luminance-gray: lab(from var(--#{$prefix}current-plane-bg) l 0 0);

color:
color-mix(
in srgb,
var(--#{$prefix}btn-parent-bg-luminance-gray) var(--#{$prefix}btn-disabled-fade-percentage),
var(--#{$prefix}btn-disabled-color)
);
pointer-events: none;
background-color: var(--#{$prefix}btn-disabled-bg);
background-color:
color-mix(
in srgb,
var(--#{$prefix}btn-parent-bg-luminance-gray) var(--#{$prefix}btn-disabled-fade-percentage),
var(--#{$prefix}btn-disabled-bg)
);
background-image: if($enable-gradients, none, null);
border-color: var(--#{$prefix}btn-disabled-border-color);
opacity: var(--#{$prefix}btn-disabled-opacity);
@include box-shadow(none);
border-color:
color-mix(
in srgb,
var(--#{$prefix}btn-parent-bg-luminance-gray) var(--#{$prefix}btn-disabled-fade-percentage),
var(--#{$prefix}btn-disabled-border-color)
);

&.btn-link {
border-color: var(--#{$prefix}btn-disabled-border-color);
}

> * {
color: var(--#{$prefix}btn-disabled-color);
opacity: var(--#{$prefix}btn-disabled-opacity);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ $btn-box-shadow: inset 0 1px 0 rgba($white, .15), 0 1px 1px rgba($b
$btn-focus-width: $input-btn-focus-width !default;
$btn-focus-box-shadow: $input-btn-focus-box-shadow !default;
$btn-disabled-opacity: .65 !default;
$btn-disabled-fade-percentage: 35% !default;
$btn-active-box-shadow: inset 0 3px 5px rgba($black, .125) !default;

$btn-link-color: var(--#{$prefix}link-color) !default;
Expand Down

0 comments on commit c806aaa

Please sign in to comment.