From d0885afa626bce23cac445c626d3ea32c05331e0 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 8 Aug 2023 12:08:21 +0000 Subject: [PATCH] [IMP] website: better vertical align and horizontal spacing in systray ---- Horizontal spacing issue ---- The horizontal spacing between systray items in the patched website systray is too small. It was using the regular margin of the default Odoo systray which is composed of almost only icons for which a small spacing is what we need. But the website patched systray contains a lot of text, where we want a bigger spacing, exactly how we do for the app menus. ---- New class on systray ---- To target the website systray in scss, a new class was added on it. There is no clean way in JS to add that class, as the website systray patch is only altering the method in charge of returning the systray items. The rest is left up to the base NavBar class component, including rendering. That NavBar component does not come with a built in way to add a class. We could have targeted the DOM directly in the patch through `this.root.el` and added the class in JS directly but that seems like an owl anti pattern. ---- Vertical align issue ---- Before this commit, the btn in the systray didn't have the same line height as other elements: both the "Edit" (in main lang) and "Translate" (in alternate lang) buttons had a (1-2px) vertical alignment issue. This was because, despite having the same font style and font size, they had a different line-height making it glitch 1-2px vertically. It's a bit less visible for the Edit button as there is a pencil icon between this text and the text next to it. For the translate button, it's quite visible directly. For testing purpose, you can simply remove the icons and the left-right margins of those systray items so the text are glued to each other and you clearly see the misindentation. ---- Misc ---- For tracking purpose, there is multiple cases to be tested regarding those buttons: - Community vs Enterprise (where those are colored) - Regular mode vs translate mode closes odoo/odoo#135956 X-original-commit: 066e4a1ddd9faf7ba866c5428c943b5af8115191 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: "stefanorigano (SRI)" --- addons/website/__manifest__.py | 2 ++ .../static/src/components/navbar/navbar.js | 9 ++++++++- .../static/src/components/navbar/navbar.scss | 9 +++++++++ .../static/src/components/navbar/navbar.xml | 10 ++++++++++ .../static/src/systray_items/edit_website.scss | 7 +++++++ .../static/src/systray_items/edit_website.xml | 12 +++++++----- .../static/src/systray_items/mobile_preview.xml | 4 ++-- .../static/src/systray_items/new_content.xml | 2 +- .../website/static/src/systray_items/publish.js | 2 +- .../src/systray_items/translate_website.scss | 7 +++++++ .../src/systray_items/translate_website.xml | 15 +++++++++------ .../static/src/systray_items/website_switcher.xml | 2 +- .../tests/tours/snippet_table_of_content.js | 2 +- .../static/src/js/tours/website_blog.js | 4 ++-- 14 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 addons/website/static/src/components/navbar/navbar.scss create mode 100644 addons/website/static/src/components/navbar/navbar.xml diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index 6c911e67330..2288e6296d7 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -273,6 +273,8 @@ 'website/static/src/components/editor/editor.scss', 'website/static/src/components/editor/editor.xml', 'website/static/src/components/navbar/navbar.js', + 'website/static/src/components/navbar/navbar.scss', + 'website/static/src/components/navbar/navbar.xml', 'website/static/src/components/burger_menu/burger_menu.js', 'website/static/src/components/switch/switch.js', 'website/static/src/components/switch/switch.scss', diff --git a/addons/website/static/src/components/navbar/navbar.js b/addons/website/static/src/components/navbar/navbar.js index d4f198c8c64..8d373a0c010 100644 --- a/addons/website/static/src/components/navbar/navbar.js +++ b/addons/website/static/src/components/navbar/navbar.js @@ -44,11 +44,18 @@ patch(NavBar.prototype, { useBus(websiteSystrayRegistry, 'CONTENT-UPDATED', renderAndAdapt); }, + get shouldDisplayWebsiteSystray() { + return this.websiteService.currentWebsite && this.websiteService.isRestrictedEditor; + }, + + // Somehow a setter is needed in `patch()` to avoid an owl error. + set shouldDisplayWebsiteSystray(_) {}, + /** * @override */ get systrayItems() { - if (this.websiteService.currentWebsite && this.websiteService.isRestrictedEditor) { + if (this.shouldDisplayWebsiteSystray) { return websiteSystrayRegistry .getEntries() .map(([key, value], index) => ({ key, ...value, index })) diff --git a/addons/website/static/src/components/navbar/navbar.scss b/addons/website/static/src/components/navbar/navbar.scss new file mode 100644 index 00000000000..e5a99466791 --- /dev/null +++ b/addons/website/static/src/components/navbar/navbar.scss @@ -0,0 +1,9 @@ +.o_menu_systray.o_website_systray { + @if $o-navbar-use-pills { + --NavBar-entry-margin-left: #{$o-navbar-entry-padding-h * 0.5}; + --NavBar-entry-margin-right: #{$o-navbar-entry-padding-h * 0.5}; + } @else { + --NavBar-entry-padding-left: #{$o-navbar-entry-padding-h}; + --NavBar-entry-padding-right: #{$o-navbar-entry-padding-h}; + } +} diff --git a/addons/website/static/src/components/navbar/navbar.xml b/addons/website/static/src/components/navbar/navbar.xml new file mode 100644 index 00000000000..9a6292a0dbc --- /dev/null +++ b/addons/website/static/src/components/navbar/navbar.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/addons/website/static/src/systray_items/edit_website.scss b/addons/website/static/src/systray_items/edit_website.scss index d82eeabc07f..acc5452260a 100644 --- a/addons/website/static/src/systray_items/edit_website.scss +++ b/addons/website/static/src/systray_items/edit_website.scss @@ -1,3 +1,10 @@ .o_edit_website_container { margin: -$o-navbar-padding-v 0; + + &.o_not_translatable .o_nav_entry { + &, &:hover { + background-color: inherit; + color: inherit; + } + } } diff --git a/addons/website/static/src/systray_items/edit_website.xml b/addons/website/static/src/systray_items/edit_website.xml index 21417080edf..081f7fb7ebb 100644 --- a/addons/website/static/src/systray_items/edit_website.xml +++ b/addons/website/static/src/systray_items/edit_website.xml @@ -1,11 +1,13 @@ -
- - - - + diff --git a/addons/website/static/src/systray_items/mobile_preview.xml b/addons/website/static/src/systray_items/mobile_preview.xml index ada0138cde1..4a41a70ba5f 100644 --- a/addons/website/static/src/systray_items/mobile_preview.xml +++ b/addons/website/static/src/systray_items/mobile_preview.xml @@ -2,9 +2,9 @@ diff --git a/addons/website/static/src/systray_items/new_content.xml b/addons/website/static/src/systray_items/new_content.xml index b03f2883c06..7bc26b9bf06 100644 --- a/addons/website/static/src/systray_items/new_content.xml +++ b/addons/website/static/src/systray_items/new_content.xml @@ -41,7 +41,7 @@
- New + New
diff --git a/addons/website/static/src/systray_items/publish.js b/addons/website/static/src/systray_items/publish.js index 01038609012..8d1f05f5fe0 100644 --- a/addons/website/static/src/systray_items/publish.js +++ b/addons/website/static/src/systray_items/publish.js @@ -58,7 +58,7 @@ PublishSystray.template = xml` `; PublishSystray.components = { diff --git a/addons/website/static/src/systray_items/translate_website.scss b/addons/website/static/src/systray_items/translate_website.scss index 4397f19ce20..8f7f53168e3 100644 --- a/addons/website/static/src/systray_items/translate_website.scss +++ b/addons/website/static/src/systray_items/translate_website.scss @@ -1,3 +1,10 @@ .o_translate_website_container { margin: -$o-navbar-padding-v 0; + + .btn .o_nav_entry { + &, &:hover { + background-color: inherit; + color: inherit; + } + } } diff --git a/addons/website/static/src/systray_items/translate_website.xml b/addons/website/static/src/systray_items/translate_website.xml index 41499849783..f46dd9522ea 100644 --- a/addons/website/static/src/systray_items/translate_website.xml +++ b/addons/website/static/src/systray_items/translate_website.xml @@ -1,12 +1,15 @@ - - + + diff --git a/addons/website/static/src/systray_items/website_switcher.xml b/addons/website/static/src/systray_items/website_switcher.xml index d5cc7c9022a..229deed7ec3 100644 --- a/addons/website/static/src/systray_items/website_switcher.xml +++ b/addons/website/static/src/systray_items/website_switcher.xml @@ -4,7 +4,7 @@
- +
diff --git a/addons/website/static/tests/tours/snippet_table_of_content.js b/addons/website/static/tests/tours/snippet_table_of_content.js index 9587a153ade..0c5c0a2dd03 100644 --- a/addons/website/static/tests/tours/snippet_table_of_content.js +++ b/addons/website/static/tests/tours/snippet_table_of_content.js @@ -68,7 +68,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_table_of_content', { }, { content: "Toggle the mobile view", - trigger: '.o_mobile_preview', + trigger: '.o_mobile_preview > a', }, { content: "Check that we have the good TOC on mobile", diff --git a/addons/website_blog/static/src/js/tours/website_blog.js b/addons/website_blog/static/src/js/tours/website_blog.js index 9c6e109ed34..6619175d1cc 100644 --- a/addons/website_blog/static/src/js/tours/website_blog.js +++ b/addons/website_blog/static/src/js/tours/website_blog.js @@ -75,11 +75,11 @@ }, ...wTourUtils.clickOnSave(), { - trigger: ".o_menu_systray_item.o_mobile_preview", + trigger: ".o_menu_systray_item.o_mobile_preview > a", content: markup(_t("Use this icon to preview your blog post on mobile devices.")), position: "bottom", }, { - trigger: ".o_menu_systray_item.o_mobile_preview", + trigger: ".o_menu_systray_item.o_mobile_preview > a", extra_trigger: '.o_website_preview.o_is_mobile', content: _t("Once you have reviewed the content on mobile, you can switch back to the normal view by clicking here again"), position: "right",