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
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
Loading