From ebc56f7605c2e515fbcad10f44e344795132a734 Mon Sep 17 00:00:00 2001 From: Brieuc-brd Date: Fri, 11 Jun 2021 07:47:56 +0000 Subject: [PATCH] [IMP] web_editor: add label for animated shapes This commit adds a little label on the top corner of animated shapes previews. Part of #70843 task-2319488 Related: odoo/design-themes#17 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: qsm-odoo --- .../static/src/js/editor/snippets.options.js | 11 ++++ .../static/src/scss/wysiwyg_snippets.scss | 15 +++++ addons/web_editor/views/snippets.xml | 66 +++++++++---------- 3 files changed, 59 insertions(+), 33 deletions(-) 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 bbf24fd5eb1..1b9f5e1e756 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -5139,6 +5139,17 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ btnContentInnerDiv.classList.add('o_we_shape'); btnContent.appendChild(btnContentInnerDiv); + if (btn.dataset.animated) { + const animatedLabelEl = document.createElement('span'); + animatedLabelEl.classList.add('o_we_shape_animated_label'); + const labelStr = _t("Animated"); + animatedLabelEl.textContent = labelStr[0]; + const spanEl = document.createElement('span'); + spanEl.textContent = labelStr.substr(1); + animatedLabelEl.appendChild(spanEl); + btnContent.appendChild(animatedLabelEl); + } + const {shape} = btn.dataset; const shapeEl = btnContent.querySelector('.o_we_shape'); shapeEl.classList.add(`o_${shape.replace(/\//g, '_')}`); diff --git a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss index 11a41e07ce8..03209e32a3c 100644 --- a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss +++ b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss @@ -2134,6 +2134,21 @@ we-select.o_we_shape_menu { } } } +.o_we_shape_animated_label { + @include o-position-absolute(0, 0); + padding: 0 6px; + background: $o-we-color-success; + color: white; + + > span { + @include o-text-overflow(inline-block); + max-width: 0; + } +} +we-button:hover .o_we_shape_animated_label > span { + max-width: 150px; + transition: max-width 0.5s ease 0s; +} .o_we_ui_loading { @include o-position-absolute(0, 0, 0, 0); diff --git a/addons/web_editor/views/snippets.xml b/addons/web_editor/views/snippets.xml index 59bf16aeb59..30fafa97b0e 100644 --- a/addons/web_editor/views/snippets.xml +++ b/addons/web_editor/views/snippets.xml @@ -238,24 +238,24 @@ - - - + + + - - + + - + - - + + @@ -263,10 +263,10 @@ - - - - + + + + @@ -275,7 +275,7 @@ - + @@ -289,7 +289,7 @@ - + @@ -319,37 +319,37 @@ - - - + + + - - + + - - + + - - - - - - - - - - - - + + + + + + + + + + + +