summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/common/utils.js
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-06-26 09:17:15 +0000
committerqsm-odoo <qsm@odoo.com>2020-08-07 15:15:52 +0000
commit995b20fd6ac3eb121ed469df70492845c00ffb58 (patch)
tree12ad52c7c3eaed0bc39b86ddd2a8117b5f5b8489 /addons/web_editor/static/src/js/common/utils.js
parent8bf5381d136f168d9bd5a562960afef7c7c35175 (diff)
[REF] web_editor: move normalizeColor function to we-utils for reuse
Part of https://github.com/odoo/odoo/pull/53017 task-2210790
Diffstat (limited to 'addons/web_editor/static/src/js/common/utils.js')
-rw-r--r--addons/web_editor/static/src/js/common/utils.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/common/utils.js b/addons/web_editor/static/src/js/common/utils.js
index 61e8f648ee8..aaa02c58589 100644
--- a/addons/web_editor/static/src/js/common/utils.js
+++ b/addons/web_editor/static/src/js/common/utils.js
@@ -187,6 +187,19 @@ function _getCSSVariableValue(key, htmlStyle) {
// double-quotes when reading them through getPropertyValue...
return value.replace(/"/g, "'");
}
+/**
+ * Normalize a color in case it is a variable name so it can be used outside of
+ * css.
+ *
+ * @param {string} color the color to normalize into a css value
+ * @returns {string} the normalized color
+ */
+function _normalizeColor(color) {
+ if (ColorpickerWidget.isCSSColor(color)) {
+ return color;
+ }
+ return _getCSSVariableValue(color);
+}
return {
CSS_SHORTHANDS: CSS_SHORTHANDS,
@@ -199,5 +212,6 @@ return {
isColorCombinationName: _isColorCombinationName,
computeColorClasses: _computeColorClasses,
getCSSVariableValue: _getCSSVariableValue,
+ normalizeColor: _normalizeColor,
};
});