Skip to content

Commit cfb96d8

Browse files
committed
Improvement - VueUiRating - Add formatter for rating value
1 parent 82dcb47 commit cfb96d8

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

src/components/vue-ui-rating.vue

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@ defineExpose({
168168

169169
<!-- RATING POSITION TOP -->
170170
<div data-cy="rating-position-top" v-if="FINAL_CONFIG.style.rating.show && FINAL_CONFIG.style.rating.position === 'top'" :style="`width:100%;text-align:center;margin-bottom:${FINAL_CONFIG.style.rating.offsetY}px;font-size:${FINAL_CONFIG.style.rating.fontSize}px;font-weight:${FINAL_CONFIG.style.rating.bold ? 'bold' : 'normal'};margin-left:${FINAL_CONFIG.style.rating.offsetX}px`">
171-
{{ isNaN(currentRating) ? '' : currentRating.toFixed(FINAL_CONFIG.style.rating.roundingValue) }}
171+
{{ applyDataLabel(
172+
FINAL_CONFIG.style.rating.formatter,
173+
currentRating,
174+
dataLabel({
175+
v: currentRating,
176+
r: FINAL_CONFIG.style.rating.roundingValue
177+
}),
178+
FINAL_CONFIG
179+
)
180+
}}
172181
</div>
173182

174183
<!-- RATING SECTION -->
@@ -179,7 +188,16 @@ defineExpose({
179188

180189
<!-- RATING POSITION LEFT -->
181190
<div data-cy="rating-position-left" v-if="FINAL_CONFIG.style.rating.show && FINAL_CONFIG.style.rating.position === 'left'" :style="`width:fit-content;text-align:center;margin-bottom:${FINAL_CONFIG.style.rating.offsetY}px;font-size:${FINAL_CONFIG.style.rating.fontSize}px;font-weight:${FINAL_CONFIG.style.rating.bold ? 'bold' : 'normal'};padding-right:${FINAL_CONFIG.style.rating.offsetX}px`">
182-
{{ isNaN(currentRating) ? '' : currentRating.toFixed(FINAL_CONFIG.style.rating.roundingValue) }}
191+
{{ applyDataLabel(
192+
FINAL_CONFIG.style.rating.formatter,
193+
currentRating,
194+
dataLabel({
195+
v: currentRating,
196+
r: FINAL_CONFIG.style.rating.roundingValue
197+
}),
198+
FINAL_CONFIG
199+
)
200+
}}
183201
</div>
184202

185203
<!-- STARS | IMAGES -->
@@ -347,15 +365,33 @@ defineExpose({
347365
</template>
348366

349367
<!-- RATING POSITION RIGHT -->
350-
<div data-cy="rating-position-right" v-if="FINAL_CONFIG.style.rating.show && FINAL_CONFIG.style.rating.position === 'right'" :style="`width:fit-content;text-align:center;margin-bottom:${FINAL_CONFIG.style.rating.offsetY}px;font-size:${FINAL_CONFIG.style.rating.fontSize}px;font-weight:${FINAL_CONFIG.style.rating.bold ? 'bold' : 'normal'};padding-left:${FINAL_CONFIG.style.rating.offsetX}px`">
351-
{{ isNaN(currentRating) ? '' : currentRating.toFixed(FINAL_CONFIG.style.rating.roundingValue) }}
352-
</div>
368+
<div data-cy="rating-position-right" v-if="FINAL_CONFIG.style.rating.show && FINAL_CONFIG.style.rating.position === 'right'" :style="`width:fit-content;text-align:center;margin-bottom:${FINAL_CONFIG.style.rating.offsetY}px;font-size:${FINAL_CONFIG.style.rating.fontSize}px;font-weight:${FINAL_CONFIG.style.rating.bold ? 'bold' : 'normal'};padding-left:${FINAL_CONFIG.style.rating.offsetX}px`"
369+
>
370+
{{ applyDataLabel(
371+
FINAL_CONFIG.style.rating.formatter,
372+
currentRating,
373+
dataLabel({
374+
v: currentRating,
375+
r: FINAL_CONFIG.style.rating.roundingValue
376+
}),
377+
FINAL_CONFIG
378+
) }}
379+
</div>
353380

354381
</div>
355382

356383
<!-- RATING POSITION BOTTOM -->
357384
<div data-cy="rating-position-bottom" v-if="FINAL_CONFIG.style.rating.show && FINAL_CONFIG.style.rating.position === 'bottom'" :style="`width:100%;text-align:center;margin-top:${FINAL_CONFIG.style.rating.offsetY}px;font-size:${FINAL_CONFIG.style.rating.fontSize}px;font-weight:${FINAL_CONFIG.style.rating.bold ? 'bold' : 'normal'};margin-left:${FINAL_CONFIG.style.rating.offsetX}px`">
358-
{{ isNaN(currentRating) ? '' : currentRating.toFixed(FINAL_CONFIG.style.rating.roundingValue) }}
385+
{{ applyDataLabel(
386+
FINAL_CONFIG.style.rating.formatter,
387+
currentRating,
388+
dataLabel({
389+
v: currentRating,
390+
r: FINAL_CONFIG.style.rating.roundingValue
391+
}),
392+
FINAL_CONFIG
393+
)
394+
}}
359395
</div>
360396
</div>
361397
</template>

0 commit comments

Comments
 (0)