From fb20b16d48fe475ef26a1812927f36888b4a3d27 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 5 Oct 2021 12:10:41 +0000 Subject: [PATCH] [FIX] web_editor, *: review icon buttons sizing and paddings *: mass_mailing, website, website_sale Before this commit, it was impossible to add `fa-fw` directly on a `we-button` as it would make the icon half invisible, since the whole `we-button` would have the font-awesome `.fa-fw` css rule applied on it; width: ~1.28em. Then, one would need to insert a `` tag inside the `we-button` for it to work. This commit improves that behavior by handling automatically such cases, and will preserve the purpose of the `fa-fw` class which is to have a fixed width for those icons. Note that the util class introduced in [1] (o_we_button_icon renamed here in o_we_icon_button) is still useful to handle the case of svg images, they are not allowed to shrink, the same way the fa buttons are. [1]: https://github.com/odoo/odoo/commit/e4233643b93b521454cc146c6a2ae876781fb9ba Related to task-2172311 closes odoo/odoo#77980 X-original-commit: e8ab9d76b802e80bb386812e4c8566825cbc2c92 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: Younn Olivier Co-authored-by: qsm-odoo --- addons/mass_mailing/views/snippets/s_hr.xml | 6 +-- addons/mass_mailing/views/snippets_themes.xml | 12 ++--- .../static/src/js/editor/snippets.options.js | 23 +++++---- .../static/src/scss/wysiwyg_snippets.scss | 23 +++++++-- addons/web_editor/static/src/xml/snippets.xml | 4 +- addons/web_editor/views/snippets.xml | 29 +++++------ .../src/snippets/s_website_form/options.js | 5 +- .../website/views/snippets/s_embed_code.xml | 6 +-- addons/website/views/snippets/s_hr.xml | 6 +-- .../views/snippets/s_image_gallery.xml | 8 +-- .../views/snippets/s_table_of_content.xml | 6 +-- addons/website/views/snippets/s_tabs.xml | 10 ++-- addons/website/views/snippets/snippets.xml | 49 +++++++------------ .../website_sale/views/snippets/snippets.xml | 4 +- 14 files changed, 93 insertions(+), 98 deletions(-) diff --git a/addons/mass_mailing/views/snippets/s_hr.xml b/addons/mass_mailing/views/snippets/s_hr.xml index da434e10fca..94f2a4f43ab 100644 --- a/addons/mass_mailing/views/snippets/s_hr.xml +++ b/addons/mass_mailing/views/snippets/s_hr.xml @@ -21,9 +21,9 @@ 100% - - - + + + diff --git a/addons/mass_mailing/views/snippets_themes.xml b/addons/mass_mailing/views/snippets_themes.xml index 70becfa2b80..61123795e6a 100644 --- a/addons/mass_mailing/views/snippets_themes.xml +++ b/addons/mass_mailing/views/snippets_themes.xml @@ -853,9 +853,9 @@
- - - + + +
@@ -870,9 +870,9 @@
- - - + + +
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 3540db98aa4..5131efdbfcb 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -665,16 +665,6 @@ const ButtonUserValueWidget = UserValueWidget.extend({ 'mouseleave': '_onUserValueReset', }, - /** - * @override - */ - start: function (parent, title, options) { - if (this.options && this.options.childNodes) { - this.options.childNodes.forEach(node => this.containerEl.appendChild(node)); - } - - return this._super(...arguments); - }, /** * @override */ @@ -689,11 +679,24 @@ const ButtonUserValueWidget = UserValueWidget.extend({ */ _makeDescriptive() { const $el = this._super(...arguments); + if (this.imgEl) { + $el[0].classList.add('o_we_icon_button'); + } if (this.activeImgEl) { this.containerEl.appendChild(this.activeImgEl); } return $el; }, + /** + * @override + */ + start: function (parent, title, options) { + if (this.options && this.options.childNodes) { + this.options.childNodes.forEach(node => this.containerEl.appendChild(node)); + } + + return this._super(...arguments); + }, //-------------------------------------------------------------------------- // Public diff --git a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss index 3f1405ec24f..098e57f2e60 100644 --- a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss +++ b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss @@ -793,10 +793,15 @@ body.editor_enable.editor_has_snippets { we-button { margin-top: 0 !important; margin-left: $o-we-sidebar-content-field-multi-spacing; - padding: 0 $o-we-sidebar-content-field-multi-spacing; + padding: 0 $o-we-sidebar-content-field-multi-spacing !important; - &.fa, &[data-img] { + &.fa, &.o_we_icon_button { + box-sizing: content-box; + width: 1.29em; // Fix width and override potential fa-fw + padding: 0 0.15em !important; margin-left: $o-we-sidebar-content-field-label-spacing; + text-align: center; + justify-content: center; } } } @@ -888,9 +893,17 @@ body.editor_enable.editor_has_snippets { } } - // Buttons with an icon but no text, so no possible overflow - we-button.o_we_button_icon { - flex: 0 0 auto; + we-button { + // Prevent icon buttons to shrink + &.o_we_icon_button, &.fa { + flex: 0 0 auto; + } + // Buttons being `fa-fw`, prevent font-awesome hardcoded width + &.fa-fw { + padding: 0 .5em; + width: 2.29em; // .fa-fw = 1.28571429em (font-awesome.css) + justify-content: center; + } } // Checkboxes diff --git a/addons/web_editor/static/src/xml/snippets.xml b/addons/web_editor/static/src/xml/snippets.xml index e4aa11f69d1..13486f83f42 100644 --- a/addons/web_editor/static/src/xml/snippets.xml +++ b/addons/web_editor/static/src/xml/snippets.xml @@ -58,9 +58,7 @@ NoneReset - + @@ -140,12 +140,11 @@ - - Cover Repeat pattern - - - + @@ -356,8 +353,8 @@ - - + + @@ -502,7 +499,7 @@ - + @@ -518,13 +515,11 @@
- + Reset - - - + Reset @@ -547,10 +542,10 @@ - - - - + + + + diff --git a/addons/website/static/src/snippets/s_website_form/options.js b/addons/website/static/src/snippets/s_website_form/options.js index 34246b1696d..f38a65c946c 100644 --- a/addons/website/static/src/snippets/s_website_form/options.js +++ b/addons/website/static/src/snippets/s_website_form/options.js @@ -704,14 +704,11 @@ options.registry.WebsiteFormEditor = FormEditor.extend({ * @returns {HTMLElement} */ _addCreateButton: function (element, action) { - const iconEl = document.createElement('i'); - iconEl.classList.add('fa', 'fa-fw', 'fa-plus'); const linkButtonEl = document.createElement('we-button'); linkButtonEl.title = _t("Create new"); linkButtonEl.dataset.noPreview = 'true'; linkButtonEl.dataset.promptSaveRedirect = action; - linkButtonEl.classList.add('o_we_button_icon'); - linkButtonEl.append(iconEl); + linkButtonEl.classList.add('fa', 'fa-fw', 'fa-plus'); const projectRowEl = document.createElement('we-row'); projectRowEl.append(element); projectRowEl.append(linkButtonEl); diff --git a/addons/website/views/snippets/s_embed_code.xml b/addons/website/views/snippets/s_embed_code.xml index e56ec7037d6..6e53cf218cb 100644 --- a/addons/website/views/snippets/s_embed_code.xml +++ b/addons/website/views/snippets/s_embed_code.xml @@ -19,9 +19,9 @@ title="Edit embedded code">Edit - - - + + +
diff --git a/addons/website/views/snippets/s_hr.xml b/addons/website/views/snippets/s_hr.xml index adaac74fd41..fc03ec21787 100644 --- a/addons/website/views/snippets/s_hr.xml +++ b/addons/website/views/snippets/s_hr.xml @@ -21,9 +21,9 @@ 100% - - - + + + diff --git a/addons/website/views/snippets/s_image_gallery.xml b/addons/website/views/snippets/s_image_gallery.xml index e2e36c12851..f85e0b53621 100644 --- a/addons/website/views/snippets/s_image_gallery.xml +++ b/addons/website/views/snippets/s_image_gallery.xml @@ -121,10 +121,10 @@
- - - - + + + +
diff --git a/addons/website/views/snippets/s_table_of_content.xml b/addons/website/views/snippets/s_table_of_content.xml index 0c15c359131..2f30d6fbbc6 100644 --- a/addons/website/views/snippets/s_table_of_content.xml +++ b/addons/website/views/snippets/s_table_of_content.xml @@ -60,9 +60,9 @@
- - - + + +
diff --git a/addons/website/views/snippets/s_tabs.xml b/addons/website/views/snippets/s_tabs.xml index 9fffe4845a8..2e8be00bfbc 100644 --- a/addons/website/views/snippets/s_tabs.xml +++ b/addons/website/views/snippets/s_tabs.xml @@ -84,11 +84,11 @@ - - - - - + + + + +
diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index e87127463d8..fd2bda6d0a6 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -179,13 +179,11 @@