[FIX] website: better allow color extensions in the future
This commit is contained in:
@@ -504,13 +504,8 @@ var ThemeCustomizeDialog = Dialog.extend({
|
||||
}).then(function (data) {
|
||||
var files = data.scss[0][1];
|
||||
var file = _.find(files, function (file) {
|
||||
switch (colorType) {
|
||||
case 'theme':
|
||||
return file.url === '/website/static/src/scss/options/colors/user_theme_color_palette.scss';
|
||||
case 'typo':
|
||||
return file.url === '/website/static/src/scss/options/colors/user_color_palette_typo.scss';
|
||||
}
|
||||
return file.url === '/website/static/src/scss/options/colors/user_color_palette_' + colorName + '.scss';
|
||||
var baseURL = '/website/static/src/scss/options/colors/';
|
||||
return file.url === _.str.sprintf('%suser_%scolor_palette.scss', baseURL, (colorType ? (colorType + '_') : ''));
|
||||
});
|
||||
|
||||
var colors = {};
|
||||
@@ -524,7 +519,16 @@ var ThemeCustomizeDialog = Dialog.extend({
|
||||
|
||||
var updatedFileContent = file.arch;
|
||||
_.each(colors, function (colorValue, colorName) {
|
||||
updatedFileContent = updatedFileContent.replace(new RegExp(colorName + ': (?:null|#[a-fA-F0-9]{6}),'), colorName + ': ' + colorValue + ',');
|
||||
var pattern = _.str.sprintf("'%s': %%s,\n", colorName);
|
||||
var regex = new RegExp(_.str.sprintf(pattern, ".+"));
|
||||
var replacement = _.str.sprintf(pattern, colorValue);
|
||||
if (regex.test(updatedFileContent)) {
|
||||
updatedFileContent = updatedFileContent
|
||||
.replace(regex, replacement);
|
||||
} else {
|
||||
updatedFileContent = updatedFileContent
|
||||
.replace(/( *)(.*hook.*)/, _.str.sprintf('$1%s$1$2', replacement));
|
||||
}
|
||||
});
|
||||
|
||||
return self._rpc({
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
$o-user-color-palette: map-merge($o-user-color-palette, o-map-omit((
|
||||
// -- hook --
|
||||
)));
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
$o-user-color-palette: map-merge((
|
||||
body: null,
|
||||
), o-map-omit($o-user-color-palette));
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
$o-user-color-palette: map-merge((
|
||||
footer: null,
|
||||
), o-map-omit($o-user-color-palette));
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
$o-user-color-palette: map-merge((
|
||||
menu: null,
|
||||
), o-map-omit($o-user-color-palette));
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
$o-user-color-palette: map-merge((
|
||||
text: null,
|
||||
h1: null,
|
||||
h2: null,
|
||||
h3: null,
|
||||
h4: null,
|
||||
h5: null,
|
||||
h6: null,
|
||||
), o-map-omit($o-user-color-palette));
|
||||
@@ -1,20 +1,4 @@
|
||||
|
||||
$o-user-theme-color-palette: map-merge((
|
||||
// Theme colors
|
||||
alpha: null,
|
||||
beta: null,
|
||||
gamma: null,
|
||||
epsilon: null,
|
||||
delta: null,
|
||||
|
||||
// Depending on the theme, alpha and beta may not be equal to
|
||||
// primary and secondary
|
||||
primary: null,
|
||||
secondary: null,
|
||||
|
||||
// BS state colors
|
||||
success: null,
|
||||
info: null,
|
||||
warning: null,
|
||||
danger: null,
|
||||
), o-map-omit($o-user-theme-color-palette));
|
||||
$o-user-theme-color-palette: map-merge($o-user-theme-color-palette, o-map-omit((
|
||||
// -- hook --
|
||||
)));
|
||||
|
||||
@@ -22,12 +22,13 @@ $-palettes: ();
|
||||
}
|
||||
$o-color-palettes: $-palettes;
|
||||
|
||||
// By default, all user color palette values are null. Each null value is automatically replaced
|
||||
// with corresponsing color of color palette 1.
|
||||
// By default, all user color palette values are null. Each null value is
|
||||
// automatically replaced with corresponsing color of chosen color palette.
|
||||
$o-user-color-palette: () !default;
|
||||
|
||||
// By default, all user theme color palette values are null. Each null value is automatically
|
||||
// replaced with corresponsing color of theme color palette 1.
|
||||
// By default, all user theme color palette values are null. Each null value
|
||||
// is automatically replaced with corresponsing color of chosen theme color
|
||||
// palette.
|
||||
$o-user-theme-color-palette: () !default;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
<div>
|
||||
<h6>Text colors</h6>
|
||||
<t t-foreach="{'text': _t('Text'), 'h1': _t('Headings 1'), 'h2': _t('Headings 2'), 'h3': _t('Headings 3'), 'h4': _t('Headings 4'), 'h5': _t('Headings 5'), 'h6': _t('Headings 6')}" t-as="color">
|
||||
<t t-call="website.theme_customize_color_palette_button">
|
||||
<t t-set="color_type" t-value="'typo'"/>
|
||||
</t>
|
||||
<t t-call="website.theme_customize_color_palette_button"/>
|
||||
</t>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
<template id="_assets_primary_variables" inherit_id="web._assets_primary_variables">
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/primary_variables.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_body.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_footer.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_menu.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_typo.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette.scss"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_theme_color_palette.scss"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user