diff --git a/packages/fiori/cypress/specs/ShellBar.cy.tsx b/packages/fiori/cypress/specs/ShellBar.cy.tsx index 422fafbd6e6cf..1b03a154148a7 100644 --- a/packages/fiori/cypress/specs/ShellBar.cy.tsx +++ b/packages/fiori/cypress/specs/ShellBar.cy.tsx @@ -1425,6 +1425,45 @@ describe("ButtonBadge in ShellBar", () => { .should("have.attr", "text", "3"); }); + it("Test if overflow list item renders badge when count is set", () => { + cy.mount( + <> + + + + ); + + // Item with count: additionalText on the ListItemStandard carries the badge value + cy.get("#item-with-badge") + .shadow() + .find("[ui5-li]") + .should("have.attr", "additional-text", "42"); + + // Item without count: no additionalText attribute + cy.get("#item-no-badge") + .shadow() + .find("[ui5-li]") + .should("not.have.attr", "additional-text"); + }); + + it("Test count updates propagate to overflow badge", () => { + cy.mount( + + ); + + cy.get("#item-update") + .shadow() + .find("[ui5-li]") + .should("have.attr", "additional-text", "1"); + + cy.get("#item-update").invoke("attr", "count", "99+"); + + cy.get("#item-update") + .shadow() + .find("[ui5-li]") + .should("have.attr", "additional-text", "99+"); + }); + it("Test if overflow button shows appropriate badge when items are overflowed", () => { cy.mount( - {this.text} - + /> ); } diff --git a/packages/fiori/src/themes/ShellBarItem.css b/packages/fiori/src/themes/ShellBarItem.css index 6afd1e0ecbac4..f0eb3da16b37e 100644 --- a/packages/fiori/src/themes/ShellBarItem.css +++ b/packages/fiori/src/themes/ShellBarItem.css @@ -25,30 +25,45 @@ [ui5-li]::part(icon) { color: var(--sapList_TextColor); + align-self: center; } -[ui5-li]:after { - position: relative; - width: fit-content; +[ui5-li]::part(additional-text) { + display: inline-flex; + align-items: center; + justify-content: center; height: 1rem; min-width: 1rem; - background: var(--sapContent_BadgeBackground); - border: var(--_ui5_shellbar_button_badge_border); - color: var(--sapContent_BadgeTextColor); - bottom: calc(100% + 0.0625rem); - left: 1.25rem; padding: 0 0.3125rem; border-radius: 0.5rem; - display: flex; - justify-content: center; - align-items: center; + border: var(--_ui5_shellbar_button_badge_border); + background: var(--sapContent_BadgeBackground) !important; + color: var(--sapContent_BadgeTextColor) !important; font-size: var(--sapFontSmallSize); - font-family: var(--sapFontFamily); - z-index: 2; + font-family: var(--sapFontBoldFamily); + font-weight: bold; + white-space: nowrap; + flex-shrink: 0; box-sizing: border-box; pointer-events: none; + text-shadow: none !important; + align-self: center; } - -[ui5-li][data-count]:after { - content: attr(data-count); + display: inline-flex; + align-items: center; + justify-content: center; + height: 1rem; + min-width: 1rem; + padding: 0 0.3125rem; + border-radius: 0.5rem; + border: var(--_ui5_shellbar_button_badge_border); + background: var(--sapContent_BadgeBackground); + color: var(--sapContent_BadgeTextColor); + font-size: var(--sapFontSmallSize); + font-family: var(--sapFontBoldFamily); + font-weight: bold; + white-space: nowrap; + flex-shrink: 0; + box-sizing: border-box; + pointer-events: none; } \ No newline at end of file diff --git a/packages/fiori/src/themes/ShellBarPopover.css b/packages/fiori/src/themes/ShellBarPopover.css index 604e11f6304a8..3365d9559d09b 100644 --- a/packages/fiori/src/themes/ShellBarPopover.css +++ b/packages/fiori/src/themes/ShellBarPopover.css @@ -14,30 +14,4 @@ .ui5-shellbar-overflow-popover [ui5-li]::part(title) { font-size: var(--sapFontSize); -} - -.ui5-shellbar-overflow-popover [ui5-li]:after { - position: relative; - width: fit-content; - height: 1rem; - min-width: 1rem; - background: var(--sapContent_BadgeBackground); - border: var(--_ui5_shellbar_button_badge_border); - color: var(--sapContent_BadgeTextColor); - bottom: calc(100% + 0.0625rem); - left: 1.25rem; - padding: 0 0.3125rem; - border-radius: 0.5rem; - display: flex; - justify-content: center; - align-items: center; - font-size: var(--sapFontSmallSize); - font-family: var(--sapFontFamily); - z-index: 2; - box-sizing: border-box; - pointer-events: none; -} - -.ui5-shellbar-overflow-popover [ui5-li][data-count]:after { - content: attr(data-count); } \ No newline at end of file diff --git a/packages/fiori/test/pages/ShellBar.html b/packages/fiori/test/pages/ShellBar.html index a4729aae95ffa..98e382cdb9380 100644 --- a/packages/fiori/test/pages/ShellBar.html +++ b/packages/fiori/test/pages/ShellBar.html @@ -259,6 +259,45 @@

ShellBar in Compact

+ + +

Badge Scenarios

+ + + + Badge - Single Visible + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Custom Action Fired