Skip to content

Commit e3d220e

Browse files
bso-odooloco-odoo
authored andcommitted
no image in colorpicker and working gradient editor for preset bg
1 parent 2624218 commit e3d220e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

addons/html_editor/static/src/main/font/color_plugin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
rgbaToHex,
2424
COLOR_COMBINATION_CLASSES_REGEX,
2525
} from "@web/core/utils/colors";
26+
import { backgroundImageCssToParts } from "@html_editor/utils/image";
2627
import { ColorSelector } from "./color_selector";
2728

2829
const RGBA_OPACITY = 0.6;
@@ -136,7 +137,8 @@ export class ColorPlugin extends Plugin {
136137
getElementColors(el) {
137138
const elStyle = getComputedStyle(el);
138139
const backgroundImage = elStyle.backgroundImage;
139-
const hasGradient = isColorGradient(backgroundImage);
140+
const gradient = backgroundImageCssToParts(backgroundImage).gradient;
141+
const hasGradient = isColorGradient(gradient);
140142
const hasTextGradientClass = el.classList.contains("text-gradient");
141143

142144
let backgroundColor = elStyle.backgroundColor;
@@ -155,9 +157,9 @@ export class ColorPlugin extends Plugin {
155157
}
156158

157159
return {
158-
color: hasGradient && hasTextGradientClass ? backgroundImage : rgbaToHex(elStyle.color),
160+
color: hasGradient && hasTextGradientClass ? gradient : rgbaToHex(elStyle.color),
159161
backgroundColor:
160-
hasGradient && !hasTextGradientClass ? backgroundImage : rgbaToHex(backgroundColor),
162+
hasGradient && !hasTextGradientClass ? gradient : rgbaToHex(backgroundColor),
161163
};
162164
}
163165

addons/website/static/src/builder/plugins/customize_website_plugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export class CustomizeWebsitePlugin extends Plugin {
8787
if (gradientColor) {
8888
const gradientValue = this.getWebsiteVariableValue(gradientColor);
8989
if (gradientValue) {
90-
return gradientValue;
90+
// Pass through style to restore rgb/a which might
91+
// have been lost during SCSS generation process.
92+
// TODO Remove this once colorpicker will be able
93+
// to cope with #rrggbb gradient color elements.
94+
const el = document.createElement("div");
95+
el.style.setProperty("background-image", gradientValue);
96+
return el.style.getPropertyValue("background-image");
9197
}
9298
}
9399
return getCSSVariableValue(color, style);

0 commit comments

Comments
 (0)