From 3444e0a0dae804bd70c3bc5d3033b9aa690a2b98 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 7 Sep 2018 11:51:12 +0200 Subject: [PATCH] [FIX] web_editor, *: use explicit string keys for color maps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * website ``` $map: ( test: 1, black: 2, ); @​debug map-get($map, 'test'); @​debug map-get($map, test); @​debug map-get($map, 'black'); @​debug map-get($map, black); ``` The above code leads to a: 1 1 null 2 This is because maps' keys can be *anything* in sass (even other maps). In the example, the map is defined with unquoted `test` and `black` as keys which are understood as the string 'test' and the *color* black. When asking for the value for the 'black' string key... there isn't any. This commit forces the use of quoted string as color maps' keys. --- .../static/src/scss/bootstrap_overridden.scss | 8 +++---- .../static/src/scss/web_editor.variables.scss | 22 +++++++++---------- .../static/src/scss/primary_variables.scss | 20 ++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/addons/web_editor/static/src/scss/bootstrap_overridden.scss b/addons/web_editor/static/src/scss/bootstrap_overridden.scss index fa199849e55..6eee3def5f4 100644 --- a/addons/web_editor/static/src/scss/bootstrap_overridden.scss +++ b/addons/web_editor/static/src/scss/bootstrap_overridden.scss @@ -13,14 +13,14 @@ $-main-color-lightness: lightness($-main-color); $-palette: map-merge(( // alpha and beta colors are used to override primary and secondary BS4 // colors by default, so that theme colors affect the default Odoo layouts - primary: $-main-color, - secondary: map-get($-palette, 'beta'), + 'primary': $-main-color, + 'secondary': map-get($-palette, 'beta'), // BS light and dark colors are not used for any BS component, just // for color utilities. By default, we set them to a very light and // very dark version of a desaturate version of the primary color - light: lighten(desaturate($-main-color, 40%), min(70%, max(0%, 97% - $-main-color-lightness))), // Does not increase over 97% lightness - dark: darken(desaturate($-main-color, 40%), min(70%, max(0%, $-main-color-lightness - 10%))), // Does not lower under 10% lightness + 'light': lighten(desaturate($-main-color, 40%), min(70%, max(0%, 97% - $-main-color-lightness))), // Does not increase over 97% lightness + 'dark': darken(desaturate($-main-color, 40%), min(70%, max(0%, $-main-color-lightness - 10%))), // Does not lower under 10% lightness ), o-map-omit($-palette)); @if $-is-backend { $-palette: map-remove($-palette, 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'light', 'dark'); diff --git a/addons/web_editor/static/src/scss/web_editor.variables.scss b/addons/web_editor/static/src/scss/web_editor.variables.scss index 769c53c1609..e20636dc58e 100644 --- a/addons/web_editor/static/src/scss/web_editor.variables.scss +++ b/addons/web_editor/static/src/scss/web_editor.variables.scss @@ -231,23 +231,23 @@ $o-color-palette-number: 1; // Theme colors $o-theme-color-palettes: ( ( - alpha: $o-enterprise-primary-color, - beta: $o-enterprise-color, - gamma: #5C5B80, - delta: #5B899E, - epsilon: #E46F78, + 'alpha': $o-enterprise-primary-color, + 'beta': $o-enterprise-color, + 'gamma': #5C5B80, + 'delta': #5B899E, + 'epsilon': #E46F78, ), ) !default; $o-theme-color-palette-number: 1; // Greyscale transparent colours $o-transparent-grays: ( - black-25: rgba(black, 0.25), - black-50: rgba(black, 0.5), - black-75: rgba(black, 0.75), - white-25: rgba(white, 0.25), - white-50: rgba(white, 0.5), - white-75: rgba(white, 0.75), + 'black-25': rgba(black, 0.25), + 'black-50': rgba(black, 0.5), + 'black-75': rgba(black, 0.75), + 'white-25': rgba(white, 0.25), + 'white-50': rgba(white, 0.5), + 'white-75': rgba(white, 0.75), ) !default; $o-gray-color-palettes: ( ( diff --git a/addons/website/static/src/scss/primary_variables.scss b/addons/website/static/src/scss/primary_variables.scss index d533b9212c4..86c42c2bab1 100644 --- a/addons/website/static/src/scss/primary_variables.scss +++ b/addons/website/static/src/scss/primary_variables.scss @@ -8,16 +8,16 @@ $o-theme-layout: 'full'; $-palettes: (); @each $palette in $o-color-palettes { $-palettes: append($-palettes, map-merge(( - body: null, // Default to bootstrap - menu: #F9F9F9, - footer: #F9F9F9, - text: null, // Default to bootstrap - h1: null, // Default to text - h2: null, // Default to h1 - h3: null, // Default to h2 - h4: null, // Default to h3 - h5: null, // Default to h4 - h6: null, // Default to h5 + 'body': null, // Default to bootstrap + 'menu': #F9F9F9, + 'footer': #F9F9F9, + 'text': null, // Default to bootstrap + 'h1': null, // Default to text + 'h2': null, // Default to h1 + 'h3': null, // Default to h2 + 'h4': null, // Default to h3 + 'h5': null, // Default to h4 + 'h6': null, // Default to h5 ), $palette)); } $o-color-palettes: $-palettes;