Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions packages/calcite-components/src/components/rating/rating.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ describe("calcite-rating", () => {
expect(changeEvent).toHaveReceivedEventTimes(0);

expect(await page.find("calcite-rating >>> .fraction")).toBeNull();
expect(icons[0]).toEqualAttribute("icon", "star");
expect(icons[1]).toEqualAttribute("icon", "star");
expect(icons[2]).toEqualAttribute("icon", "star");
expect(icons[0]).toEqualAttribute("icon", "star-f");
expect(icons[1]).toEqualAttribute("icon", "star-f");
expect(icons[2]).toEqualAttribute("icon", "star-f");
expect(icons[3]).toEqualAttribute("icon", "star");
expect(icons[4]).toEqualAttribute("icon", "star");
expect(labels[0]).not.toHaveClass("selected");
Expand Down Expand Up @@ -499,7 +499,7 @@ describe("calcite-rating", () => {
expect(icons[0]).toEqualAttribute("icon", "star-f");
expect(icons[1]).toEqualAttribute("icon", "star-f");
expect(icons[2]).toEqualAttribute("icon", "star-f");
expect(icons[3]).toEqualAttribute("icon", "star");
expect(icons[3]).toEqualAttribute("icon", "star-f");
expect(icons[4]).toEqualAttribute("icon", "star");
expect(labels[0]).toHaveClass("selected");
expect(labels[1]).toHaveClass("selected");
Expand Down Expand Up @@ -675,7 +675,7 @@ describe("calcite-rating", () => {
await page.keyboard.press("Tab");
await page.waitForChanges();

expect(icons[0]).toEqualAttribute("icon", "star");
expect(icons[0]).toEqualAttribute("icon", "star-f");
expect(icons[1]).toEqualAttribute("icon", "star");
expect(icons[2]).toEqualAttribute("icon", "star");
expect(icons[3]).toEqualAttribute("icon", "star");
Expand Down Expand Up @@ -810,21 +810,20 @@ describe("calcite-rating", () => {
shadowSelector: `.${CSS.star}`,
targetProp: "color",
},
"--calcite-rating-color-press": {
shadowSelector: `.${CSS.star}`,
targetProp: "color",
state: { press: `calcite-rating >>> .${CSS.star}` },
},
});
});
describe("selected", () => {
themed(html`<calcite-rating value="2"></calcite-rating>`, {
"--calcite-rating-color-hover": [
{
shadowSelector: `.${CSS.star}[data-value='3']`,
targetProp: "color",
state: "hover",
},
{
shadowSelector: `.${CSS.selected}`,
targetProp: "color",
},
],
"--calcite-rating-color-hover": {
shadowSelector: `.${CSS.star}[data-value='3']`,
targetProp: "color",
state: "hover",
},
});
});
describe("average", () => {
Expand Down
11 changes: 9 additions & 2 deletions packages/calcite-components/src/components/rating/rating.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*
* @prop --calcite-rating-spacing-unit: [Deprecated] Use `--calcite-rating-spacing`. Specifies the amount of left and right margin spacing between each item.
* @prop --calcite-rating-spacing: Specifies the amount of left and right margin spacing between each item.
* @prop --calcite-rating-color-hover: Specifies the component's item color when hovered or selected.
* @prop --calcite-rating-color-hover: Specifies the component's item color when hovered.
* @prop --calcite-rating-color-press: Specifies the component's item color when active.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@geospatialem @DitwanP @matgalla for CSS prop doc review.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and in alignment with other component styles ⭐🚀⭐

* @prop --calcite-rating-color: Specifies the component's item color.
* @prop --calcite-rating-average-color: Specifies the component's item color when average is set.
* @prop --calcite-rating-average-text-color: Specifies the component's average text color.
Expand Down Expand Up @@ -58,6 +59,12 @@
flex-direction: column;
cursor: pointer;
color: var(--calcite-rating-color, theme("borderColor.color.input"));
&:hover {
color: var(--calcite-rating-color-hover, var(--calcite-color-brand-hover));
}
&:active {
color: var(--calcite-rating-color-press, var(--calcite-color-brand-press));
}
&:focus {
@apply focus-outset;
}
Expand All @@ -70,7 +77,7 @@

.hovered,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is .hovered still applicable here? It seems like it might be overridden above.

.selected {
color: var(--calcite-rating-color-hover, theme("colors.brand"));
color: var(--calcite-rating-color, theme("colors.brand"));
}

.fraction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export class Rating
type="radio"
value={value}
/>
<StarIcon full={selected || average} scale={this.scale} />
<StarIcon full={selected || average || hovered} scale={this.scale} />
{partial && (
<div class="fraction" style={{ width: `${fraction * 100}%` }}>
<StarIcon full partial scale={this.scale} />
Expand Down
1 change: 1 addition & 0 deletions packages/calcite-components/src/custom-theme/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { html } from "../../support/formatting";
export const ratingTokens = {
calciteRatingSpacing: "",
calciteRatingColorHover: "",
calciteRatingColorPress: "",
calciteRatingColor: "",
calciteRatingAverageColor: "",
calciteRatingAverageTextColor: "",
Expand Down