From d6311f079750f44cd0d39ab29a4339366c103473 Mon Sep 17 00:00:00 2001 From: Dobrin Dimchev Date: Thu, 24 Oct 2024 16:19:29 +0300 Subject: [PATCH] refactor(ui5-shellbar): actions reversed ordering --- packages/fiori/cypress/specs/ShellBar.cy.ts | 105 ++++++++++++++ packages/fiori/src/ShellBar.hbs | 133 ++++++++++-------- packages/fiori/src/ShellBar.ts | 15 +- packages/fiori/src/ShellBarPopover.hbs | 4 +- packages/fiori/src/themes/ShellBar.css | 16 ++- .../fiori/test/pages/ShellBar_evolution.html | 20 +-- 6 files changed, 214 insertions(+), 79 deletions(-) create mode 100644 packages/fiori/cypress/specs/ShellBar.cy.ts diff --git a/packages/fiori/cypress/specs/ShellBar.cy.ts b/packages/fiori/cypress/specs/ShellBar.cy.ts new file mode 100644 index 000000000000..f43f89981659 --- /dev/null +++ b/packages/fiori/cypress/specs/ShellBar.cy.ts @@ -0,0 +1,105 @@ +import { html } from "lit"; +import "../../src/ShellBar.js"; + +describe("Responsiveness", () => { + beforeEach(() => { + cy.mount(html` + + + + + + + + + + + + + + + + +
Instructions
+
+ + Application 1 + Application 2 + Application 3 + Application 4 + Application 5 +
+`); + }); + + it("tests XXL Breakpoint 1920px", () => { + cy.viewport(1920, 1080); + + cy.get("#shellbar") + .as("shellbar") + .shadow() + .find(".ui5-shellbar-overflow-button") + .as("overflowButton"); + + cy.get("@shellbar") + .find("ui5-button[slot='startButton']") + .as("backButton"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-menu-button-title") + .as("primaryTitle"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-secondary-title") + .as("secondaryTitle"); + + cy.get("@shellbar") + .find("[slot='searchField']") + .as("searchField"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-custom-item") + .as("customActionIcon1"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-custom-item:nth-child(3)") + .as("customActionIcon2"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-bell-button") + .as("notificationsIcon"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-image-button") + .as("profileIcon"); + + cy.get("@shellbar") + .shadow() + .find(".ui5-shellbar-button-product-switch") + .as("productSwitchIcon"); + + cy.get("@overflowButton").should("not.exist"); + cy.get("@backButton").should("be.visible"); + cy.get("@primaryTitle").should("be.visible"); + cy.get("@secondaryTitle").should("be.visible"); + cy.get("@searchField").should("be.visible"); + cy.get("@customActionIcon1").should("be.visible"); + cy.get("@customActionIcon2").should("be.visible"); + cy.get("@notificationsIcon").should("be.visible"); + cy.get("@profileIcon").should("be.visible"); + cy.get("@productSwitchIcon").should("be.visible"); + }); +}); diff --git a/packages/fiori/src/ShellBar.hbs b/packages/fiori/src/ShellBar.hbs index 7d655c4d8ea8..87f9cb2cfd6c 100644 --- a/packages/fiori/src/ShellBar.hbs +++ b/packages/fiori/src/ShellBar.hbs @@ -13,79 +13,57 @@ {{/if}} {{#if hasMenuItems}} - {{#unless showLogoInMenuButton}} - - {{/unless}} - - {{#if showTitleInMenuButton}} -

- {{primaryTitle}} -

- {{/if}} - - {{#if showMenuButton}} - - {{/if}} + {{#if showMenuButton}} + + {{/if}} {{/if}} {{#unless hasMenuItems}} {{#if hasMenuItems}} {{/if}} -
+ + {{#if _isSBreakpoint}} {{#if hasLogo}} - + {{> singleLogo}} {{/if}} - {{#unless _isSBreakpoint}} -
- {{#if primaryTitle}} -

- {{primaryTitle}} -

- {{/if}} - {{#if secondaryTitle}} - {{#if primaryTitle}} -

{{secondaryTitle}}

- {{/if}} - {{/if}} -
- {{/unless}} -
+ {{else}} + {{> combinedLogo}} + {{/if}} {{/unless}} - - {{#if hasMidContent}}
@@ -247,4 +225,43 @@ {{/inline}} + +{{#*inline "singleLogo"}} + +{{/inline}} + +{{#*inline "combinedLogo"}} +
+ {{#if hasLogo}} + + {{/if}} +
+ {{#if primaryTitle}} +

+ {{primaryTitle}} +

+ {{/if}} + {{#if secondaryTitle}} + {{#if primaryTitle}} +

{{secondaryTitle}}

+ {{/if}} + {{/if}} +
+
+{{/inline}} + {{>include "./ShellBarPopover.hbs"}} \ No newline at end of file diff --git a/packages/fiori/src/ShellBar.ts b/packages/fiori/src/ShellBar.ts index d14a7d126f42..fd9ebc4957cf 100644 --- a/packages/fiori/src/ShellBar.ts +++ b/packages/fiori/src/ShellBar.ts @@ -658,7 +658,7 @@ class ShellBar extends UI5Element { const shouldStayOnScreen = isOverflowIcon || (isImageIcon && this.hasProfile); return isHidden && isSet && !shouldStayOnScreen; - }).toReversed(); + }); this._observeMenuItems(); } @@ -765,9 +765,10 @@ class ShellBar extends UI5Element { const itemsByPriority = this.itemsByPriority(items); for (let i = 0; i < itemsByPriority.length; i++) { + const collection = itemsByPriority.toReversed(); if (i < overflowButtons.length) { - itemsByPriority[i].classes = `${itemsByPriority[i].classes} ui5-shellbar-hidden-button`; - itemsByPriority[i].styles = { + collection[i].classes = `${collection[i].classes} ui5-shellbar-hidden-button`; + collection[i].styles = { order: -1, }; } @@ -1081,7 +1082,7 @@ class ShellBar extends UI5Element { icon: "overflow", text: "Overflow", classes: `${showOverflowButton ? "" : "ui5-shellbar-hidden-button"} ui5-shellbar-overflow-button-shown ui5-shellbar-overflow-button ui5-shellbar-button`, - priority: 8, + priority: 0, styles: { order: showOverflowButton ? 4 : -1, }, @@ -1093,7 +1094,7 @@ class ShellBar extends UI5Element { { text: "Person", classes: `${this.hasProfile ? "" : "ui5-shellbar-invisible-button"} ui5-shellbar-image-button ui5-shellbar-button`, - priority: 9, + priority: 0, styles: { order: this.hasProfile ? 5 : -10, }, @@ -1107,7 +1108,7 @@ class ShellBar extends UI5Element { icon: "grid", text: this._productsText, classes: `${this.showProductSwitch ? "" : "ui5-shellbar-invisible-button"} ui5-shellbar-button ui5-shellbar-image-button ui5-shellbar-button-product-switch`, - priority: 10, + priority: 0, styles: { order: this.showProductSwitch ? 6 : -10, }, @@ -1377,7 +1378,7 @@ class ShellBar extends UI5Element { } get accLogoRole() { - return this.accessibilityAttributes.logo?.role || "button"; + return this.accessibilityAttributes.logo?.role || "link"; } } diff --git a/packages/fiori/src/ShellBarPopover.hbs b/packages/fiori/src/ShellBarPopover.hbs index 4939bf6192a4..33b4036a485d 100644 --- a/packages/fiori/src/ShellBarPopover.hbs +++ b/packages/fiori/src/ShellBarPopover.hbs @@ -1,4 +1,4 @@ -{{!-- - --}} + - Open Menu + PR10 @@ -54,26 +54,26 @@ - Special 157.4M EUR - Under construction + PR 4 + PR3 - +
Instructions
- + PR2 - + PR1 - + PR6 - + PR7 - + PR8 - + PR9