Skip to content

Commit

Permalink
Merge pull request #547 from vladrusu/main-patch1
Browse files Browse the repository at this point in the history
Rating component fixes
  • Loading branch information
mrholek authored Oct 21, 2024
2 parents ee2df5f + 567424b commit 46d447a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions js/src/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const CLASS_NAME_RATING_ITEM_CUSTOM_ICON = 'rating-item-custom-icon'
const CLASS_NAME_RATING_ITEM_CUSTOM_ICON_ACTIVE = 'rating-item-custom-icon-active'
const CLASS_NAME_RATING_ITEM_INPUT = 'rating-item-input'
const CLASS_NAME_RATING_ITEM_LABEL = 'rating-item-label'
const CLASS_NAME_READONLY = 'readonly'

const SELECTOR_DATA_TOGGLE = '[data-coreui-toggle="rating"]'
const SELECTOR_RATING_ITEM_INPUT = '.rating-item-input'
Expand Down Expand Up @@ -355,6 +356,10 @@ class Rating extends BaseComponent {
this._element.classList.add(CLASS_NAME_DISABLED)
}

if (this._config.readOnly) {
this._element.classList.add(CLASS_NAME_READONLY)
}

this._element.setAttribute('role', 'radiogroup')
Array.from({ length: this._config.itemCount }, (_, index) => this._createRatingItem(index))
}
Expand Down
13 changes: 6 additions & 7 deletions scss/_rating.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
}

&:not(.disabled):not(.readonly) {
.rating-item {
cursor: pointer;
.rating-item:hover {
transform: var(--#{$prefix}rating-item-scale-transform);
}

&:hover {
transform: var(--#{$prefix}rating-item-scale-transform);
}
.rating-item-icon,
.rating-item-label {
cursor: pointer;
}
}
}
Expand All @@ -47,7 +48,6 @@
font-size: var(--#{$prefix}rating-item-height);
line-height: 0;
color: var(--#{$prefix}rating-item-color);
cursor: pointer;

* {
pointer-events: none;
Expand Down Expand Up @@ -83,7 +83,6 @@
.rating-item-icon {
width: var(--#{$prefix}rating-item-height);
height: var(--#{$prefix}rating-item-height);
cursor: pointer;
background-color: var(--#{$prefix}rating-item-color);
mask: var(--#{$prefix}rating-item-icon) center / var(--#{$prefix}rating-item-height) no-repeat;
}
Expand Down

0 comments on commit 46d447a

Please sign in to comment.