diff --git a/assets/dev/scss/frontend/widgets/rating.scss b/assets/dev/scss/frontend/widgets/rating.scss index 93d27c58c8f..7f604327dbd 100644 --- a/assets/dev/scss/frontend/widgets/rating.scss +++ b/assets/dev/scss/frontend/widgets/rating.scss @@ -1,9 +1,9 @@ .elementor-widget-rating { --e-rating-gap: 0px; - --e-rating-star-font-size: 16px; - --e-rating-star-color: #{$gray-mouse}; - --e-rating-star-marked-color: #{$orange}; - --e-rating-star-marked-width: 100%; + --e-rating-icon-font-size: 16px; + --e-rating-icon-color: #{$gray-mouse}; + --e-rating-icon-marked-color: #{$orange}; + --e-rating-icon-marked-width: 100%; --e-rating-justify-content: flex-start; .e-rating { @@ -17,14 +17,14 @@ width: fit-content; } - .e-star { + .e-icon { position: relative; &-wrapper { - &.e-star-marked { - --e-rating-star-color: var(--e-rating-star-marked-color); - width: var(--e-rating-star-marked-width); + &.e-icon-marked { + --e-rating-icon-color: var(--e-rating-icon-marked-color); + width: var(--e-rating-icon-marked-width); position: absolute; z-index: $first-layer; height: 100%; @@ -39,14 +39,14 @@ } i { - font-size: var(--e-rating-star-font-size); - color: var(--e-rating-star-color); + font-size: var(--e-rating-icon-font-size); + color: var(--e-rating-icon-color); } svg { - width: var(--e-rating-star-font-size); - height: var(--e-rating-star-font-size); - fill: var(--e-rating-star-color); + width: var(--e-rating-icon-font-size); + height: var(--e-rating-icon-font-size); + fill: var(--e-rating-icon-color); } } } diff --git a/includes/widgets/rating.php b/includes/widgets/rating.php index 5c10a04e991..bac9607bf00 100644 --- a/includes/widgets/rating.php +++ b/includes/widgets/rating.php @@ -61,7 +61,54 @@ private function add_style_tab() { ], 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ - '{{WRAPPER}}' => '--e-rating-star-font-size: {{SIZE}}{{UNIT}}', + '{{WRAPPER}}' => '--e-rating-icon-font-size: {{SIZE}}{{UNIT}}', + ], + ] + ); + + $this->add_responsive_control( + 'icon_gap', + [ + 'label' => esc_html__( 'Spacing', 'elementor' ), + 'type' => Controls_Manager::SLIDER, + 'range' => [ + 'em' => [ + 'min' => 0, + 'max' => 10, + 'step' => 0.1, + ], + 'rem' => [ + 'min' => 0, + 'max' => 10, + 'step' => 0.1, + ], + ], + 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ], + 'selectors' => [ + '{{WRAPPER}}' => '--e-rating-gap: {{SIZE}}{{UNIT}}', + ], + ] + ); + + $this->add_control( + 'icon_color', + [ + 'label' => esc_html__( 'Color', 'elementor' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}}' => '--e-rating-icon-marked-color: {{VALUE}}', + ], + 'separator' => 'before', + ] + ); + + $this->add_control( + 'icon_unmasked_color', + [ + 'label' => esc_html__( 'Unmarked Color', 'elementor' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}}' => '--e-rating-icon-color: {{VALUE}}', ], ] ); @@ -224,7 +271,7 @@ protected function get_rating_scale(): int { return intval( $this->get_settings_for_display( 'rating_scale' )['size'] ); } - protected function get_star_marked_width( $star_index ): string { + protected function get_icon_marked_width( $icon_index ): string { $initial_value = $this->get_rating_scale(); $rating_value = $this->get_rating_value(); @@ -234,39 +281,40 @@ protected function get_star_marked_width( $star_index ): string { $width = '0%'; - if ( $rating_value >= $star_index ) { + if ( $rating_value >= $icon_index ) { $width = '100%'; - } elseif ( intval( ceil( $rating_value ) ) === $star_index ) { - $width = ( $rating_value - ( $star_index - 1 ) ) * 100 . '%'; + + } elseif ( intval( ceil( $rating_value ) ) === $icon_index ) { + $width = ( $rating_value - ( $icon_index - 1 ) ) * 100 . '%'; } return $width; } - protected function get_star_markup(): string { + protected function get_icon_markup(): string { $icon = $this->get_settings_for_display( 'rating_icon' ); $rating_scale = $this->get_rating_scale(); ob_start(); for ( $index = 1; $index <= $rating_scale; $index++ ) { - $this->add_render_attribute( 'star_marked_' . $index, [ - 'class' => 'e-star-wrapper e-star-marked', + $this->add_render_attribute( 'icon_marked_' . $index, [ + 'class' => 'e-icon-wrapper e-icon-marked', ] ); - $star_marked_width = $this->get_star_marked_width( $index ); + $icon_marked_width = $this->get_icon_marked_width( $index ); - if ( '100%' !== $star_marked_width ) { - $this->add_render_attribute( 'star_marked_' . $index, [ - 'style' => '--e-rating-star-marked-width: ' . $star_marked_width . ';', + if ( '100%' !== $icon_marked_width ) { + $this->add_render_attribute( 'icon_marked_' . $index, [ + 'style' => '--e-rating-icon-marked-width: ' . $icon_marked_width . ';', ] ); } ?> -
-
print_render_attribute_string( 'star_marked_' . $index ); ?>> +
+
print_render_attribute_string( 'icon_marked_' . $index ); ?>> 'true' ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
-
+
'true' ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
@@ -299,7 +347,7 @@ protected function render() {
print_render_attribute_string( 'widget_wrapper' ); ?>> - get_star_markup(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> + get_icon_markup(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>