From b6e484ac1c6f2bf93ec45a2729e4787e1302515d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 22 Sep 2022 12:50:04 +0000 Subject: [PATCH] [IMP] website: ease defining only one font family to use in a theme Before this commit, if a theme wanted to define a main font for their theme and let the "headings", "navbar" and "buttons" ones use the same they had to add this in their map: ``` 'font': XXX, 'headings-font': null, 'navbar-font': null, 'button-font': null, ``` Indeed, without setting the "null" values, those font would use YYY which is the first font defined in the theme config, which might be different from XXX. And if forcing XXX 4 times, like most themes do at the moment, if the user wanted to change them all, he had to change the 4 ones instead of the main one. Now, only the 'font' value use the first font defined in the theme config if not explicitly set. So forcing the null values is not necessary, it will be the default behavior. The advantage is thus also functional, as most theme forced all their 4 fonts so changing the main one did not change the others. task-2993054 X-original-commit: c6b56955f62c6b837b477223daac2d87ab984efb Part-of: odoo/odoo#101068 --- .../website/static/src/scss/primary_variables.scss | 3 ++- .../static/src/scss/secondary_variables.scss | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/website/static/src/scss/primary_variables.scss b/addons/website/static/src/scss/primary_variables.scss index d4a2ca8d81d..feea57e5624 100644 --- a/addons/website/static/src/scss/primary_variables.scss +++ b/addons/website/static/src/scss/primary_variables.scss @@ -1994,7 +1994,8 @@ $o-base-website-values-palette: ( 'input-border-radius-sm': null, // Default to BS 'input-border-radius-lg': null, // Default to BS - // A key from the $o-theme-font-configs map (null = default to the first key) + // A key from the $o-theme-font-configs map (null = default to the first key + // for the base 'font' value, the others just fallback to 'font'). 'font': null, 'headings-font': null, 'navbar-font': null, diff --git a/addons/website/static/src/scss/secondary_variables.scss b/addons/website/static/src/scss/secondary_variables.scss index cef3c0e5f93..5ab1eb4427a 100644 --- a/addons/website/static/src/scss/secondary_variables.scss +++ b/addons/website/static/src/scss/secondary_variables.scss @@ -2,14 +2,14 @@ // Website customizations //------------------------------------------------------------------------------ -// Complete the base website values palette with the first defined font +// Complete the base website values palette with the first defined font in +// $o-theme-font-configs, this allows themes to just define a list of fonts and +// relying on the fact the first one will be used. $-first-font-name: nth(map-keys($o-theme-font-configs), 1); -@each $alias, $key in $o-font-aliases-to-keys { - @if map-get($o-base-website-values-palette, $key) == null { - $o-base-website-values-palette: map-merge($o-base-website-values-palette, ( - $key: $-first-font-name, - )); - } +@if map-get($o-base-website-values-palette, 'font') == null { + $o-base-website-values-palette: map-merge($o-base-website-values-palette, ( + 'font': $-first-font-name, + )); } @function o-add-font-config($values) {