Automatically invert selection based on contrast

So now inverting the selection for brand-secondary backgrounds will
depend on the value of brand-secondary.
This commit is contained in:
Javi Martín
2022-10-28 17:25:22 +02:00
parent 35e95121e2
commit e248a40ff3
3 changed files with 16 additions and 15 deletions

View File

@@ -125,7 +125,7 @@ button,
.button {
@extend %button;
@include inverted-selection;
@include inverted-selection($brand);
background: $brand;
&.medium {

View File

@@ -19,7 +19,7 @@
@mixin regular-button($color: $brand) {
@include button($background: $color);
@include inverted-selection;
@include inverted-selection($color);
@include base-button;
}

View File

@@ -1,14 +1,14 @@
@mixin background-with-text-contrast($color) {
@mixin background-with-text-contrast($color, $check-invert-selection: true) {
background-color: $color;
color: color-pick-contrast($color);
@if $check-invert-selection {
@include inverted-selection($color);
}
}
@mixin brand-background($color: $brand, $invert-selection: true) {
@mixin brand-background($color: $brand) {
@include background-with-text-contrast($color);
@if $invert-selection {
@include inverted-selection;
}
}
@mixin brand-text {
@@ -25,16 +25,17 @@
&::selection,
*::selection {
@include brand-background($invert-selection: false);
@include background-with-text-contrast($brand, $check-invert-selection: false);
}
}
@mixin inverted-selection {
&::selection,
*::selection {
background-color: rgba(color-pick-contrast($brand), 0.99);
color: $brand;
@mixin inverted-selection($background-color) {
@if color-contrast($background-color, $brand) < 4.5 {
&::selection,
*::selection {
background-color: rgba(color-pick-contrast($brand), 0.99);
color: $brand;
}
}
}