From 66c99b86b38ea3c5771bdc0e47d7e3249c862adb Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 28 May 2020 10:04:58 +0000 Subject: [PATCH] [IMP] web, *: stop automatic color for text for transparent bg classes * web_editor Now, if the opacity of the bg color for a bg classes is lower than x (currently 0.3), the class will only control the bg and not the text and other components anymore. This behavior is disabled for presets though (otherwise the text color would be "undefined"). Part of https://github.com/odoo/odoo/pull/45856 task-2197038 --- addons/web/static/src/scss/bs_mixins_overrides.scss | 9 ++++++--- addons/web_editor/static/src/scss/web_editor.common.scss | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/scss/bs_mixins_overrides.scss b/addons/web/static/src/scss/bs_mixins_overrides.scss index 9ae6db9ecc1..e12c41b7def 100644 --- a/addons/web/static/src/scss/bs_mixins_overrides.scss +++ b/addons/web/static/src/scss/bs_mixins_overrides.scss @@ -27,15 +27,18 @@ $enable-deprecation-messages: false !default; } } +$o-yiq-min-opacity-threshold: 0.3 !default; $o-color-extras-nesting-selector: '&' !default; -@mixin o-bg-color($color, $text-color: null, $with-extras: true, $important: true, $nesting-selector: $o-color-extras-nesting-selector) { +@mixin o-bg-color($color, $text-color: null, $with-extras: true, $important: true, $yiq-min-opacity-threshold: $o-yiq-min-opacity-threshold, $nesting-selector: $o-color-extras-nesting-selector) { @if ($color) { - $-yiq-color: if($text-color, $text-color, color-yiq($color)); + $-yiq-threshold-met: alpha($color) > $yiq-min-opacity-threshold; + + $-yiq-color: if($text-color, $text-color, if($-yiq-threshold-met, color-yiq($color), null)); background-color: $color#{if($important, ' !important', '')}; color: $-yiq-color; // not important so that text utilities still work - @if $with-extras { + @if $with-extras and $-yiq-threshold-met { #{$nesting-selector} { @extend %o-bg-color-component-color-reset; diff --git a/addons/web_editor/static/src/scss/web_editor.common.scss b/addons/web_editor/static/src/scss/web_editor.common.scss index 08a202263fc..7da88635a5f 100644 --- a/addons/web_editor/static/src/scss/web_editor.common.scss +++ b/addons/web_editor/static/src/scss/web_editor.common.scss @@ -615,7 +615,7 @@ blockquote { // bg and text utility classes. ** .o_cc#{$index} { // Background & Text - @include o-bg-color(o-color($-bg), o-color($-text), $important: false); + @include o-bg-color(o-color($-bg), o-color($-text), $important: false, $yiq-min-opacity-threshold: 0); #{$o-color-extras-nesting-selector} { // Headings