Skip to content

Commit 46d447a

Browse files
authored
Merge pull request #547 from vladrusu/main-patch1
Rating component fixes
2 parents ee2df5f + 567424b commit 46d447a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

js/src/rating.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const CLASS_NAME_RATING_ITEM_CUSTOM_ICON = 'rating-item-custom-icon'
4141
const CLASS_NAME_RATING_ITEM_CUSTOM_ICON_ACTIVE = 'rating-item-custom-icon-active'
4242
const CLASS_NAME_RATING_ITEM_INPUT = 'rating-item-input'
4343
const CLASS_NAME_RATING_ITEM_LABEL = 'rating-item-label'
44+
const CLASS_NAME_READONLY = 'readonly'
4445

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

359+
if (this._config.readOnly) {
360+
this._element.classList.add(CLASS_NAME_READONLY)
361+
}
362+
358363
this._element.setAttribute('role', 'radiogroup')
359364
Array.from({ length: this._config.itemCount }, (_, index) => this._createRatingItem(index))
360365
}

scss/_rating.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
}
1818

1919
&:not(.disabled):not(.readonly) {
20-
.rating-item {
21-
cursor: pointer;
20+
.rating-item:hover {
21+
transform: var(--#{$prefix}rating-item-scale-transform);
22+
}
2223

23-
&:hover {
24-
transform: var(--#{$prefix}rating-item-scale-transform);
25-
}
24+
.rating-item-icon,
25+
.rating-item-label {
26+
cursor: pointer;
2627
}
2728
}
2829
}
@@ -47,7 +48,6 @@
4748
font-size: var(--#{$prefix}rating-item-height);
4849
line-height: 0;
4950
color: var(--#{$prefix}rating-item-color);
50-
cursor: pointer;
5151

5252
* {
5353
pointer-events: none;
@@ -83,7 +83,6 @@
8383
.rating-item-icon {
8484
width: var(--#{$prefix}rating-item-height);
8585
height: var(--#{$prefix}rating-item-height);
86-
cursor: pointer;
8786
background-color: var(--#{$prefix}rating-item-color);
8887
mask: var(--#{$prefix}rating-item-icon) center / var(--#{$prefix}rating-item-height) no-repeat;
8988
}

0 commit comments

Comments
 (0)