From bb5902b85fb239e9129e0c66d720cad3c585d197 Mon Sep 17 00:00:00 2001 From: Elena Stoyanova Date: Wed, 27 Nov 2024 14:36:34 +0200 Subject: [PATCH 1/2] fix(ui5-rating-indicator): correct half icon appearance --- .../main/cypress/specs/RatingIndicator.cy.ts | 39 +++++++++++++++++++ packages/main/src/RatingIndicator.hbs | 2 +- packages/main/src/RatingIndicator.ts | 8 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 packages/main/cypress/specs/RatingIndicator.cy.ts diff --git a/packages/main/cypress/specs/RatingIndicator.cy.ts b/packages/main/cypress/specs/RatingIndicator.cy.ts new file mode 100644 index 000000000000..83150cfdd07c --- /dev/null +++ b/packages/main/cypress/specs/RatingIndicator.cy.ts @@ -0,0 +1,39 @@ +import { html } from "lit"; +import "../../src/RatingIndicator.js"; + +describe("RatingIndicator", () => { + describe("Half Icon appearance", () => { + it("Half icon should be filled when rating indicator is disabled", () => { + const attributeValue = "favorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + + it("Half icon should be filled when rating indicator is readonly", () => { + const attributeValue = "favorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + + it("Half icon should be border only when rating indicator is regular", () => { + const attributeValue = "unfavorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + }); +}); diff --git a/packages/main/src/RatingIndicator.hbs b/packages/main/src/RatingIndicator.hbs index 29c1d3fda23b..e016ed38e150 100644 --- a/packages/main/src/RatingIndicator.hbs +++ b/packages/main/src/RatingIndicator.hbs @@ -27,7 +27,7 @@ {{else if this.halfStar}}
  • - +
    diff --git a/packages/main/src/RatingIndicator.ts b/packages/main/src/RatingIndicator.ts index aa989847ce76..47480776772b 100644 --- a/packages/main/src/RatingIndicator.ts +++ b/packages/main/src/RatingIndicator.ts @@ -289,6 +289,14 @@ class RatingIndicator extends UI5Element { this._focused = false; } + get halfStarIconName() { + if (this.disabled || this.readonly) { + return "favorite"; + } else { + return "unfavorite"; + } + } + get effectiveTabIndex() { const tabindex = this.getAttribute("tabindex"); return this.disabled ? "-1" : tabindex || "0"; From 3eebe0f146c3a355be5e7e76651ba5915e7c860a Mon Sep 17 00:00:00 2001 From: Elena Stoyanova Date: Wed, 27 Nov 2024 15:36:56 +0200 Subject: [PATCH 2/2] fix: fix lint --- packages/main/src/RatingIndicator.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/main/src/RatingIndicator.ts b/packages/main/src/RatingIndicator.ts index 47480776772b..bdd191175b11 100644 --- a/packages/main/src/RatingIndicator.ts +++ b/packages/main/src/RatingIndicator.ts @@ -290,11 +290,7 @@ class RatingIndicator extends UI5Element { } get halfStarIconName() { - if (this.disabled || this.readonly) { - return "favorite"; - } else { - return "unfavorite"; - } + return this.disabled || this.readonly ? "favorite" : "unfavorite"; } get effectiveTabIndex() {