[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
This commit is contained in:
qsm-odoo
2022-09-26 11:36:49 +02:00
parent 0087f2746e
commit b6e484ac1c
2 changed files with 9 additions and 8 deletions
@@ -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,
@@ -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) {