@heycar-uikit/core
Version:
The React UI library from HeyCar
19 lines (16 loc) • 585 B
JavaScript
import { MAX_SCORE, ARROW_DIFF_DEG, MAX_CIRCLE_POINT } from '../constants/ReviewRating.constants.js';
const getParsedScore = (score) => {
let parsedScore = !score || isNaN(score) ? 0 : Math.round(score);
if (parsedScore < 0)
parsedScore = 0;
if (parsedScore > MAX_SCORE)
parsedScore = MAX_SCORE;
return parsedScore;
};
const getPositionData = (score) => {
return {
arrowRotation: (score / MAX_SCORE) * ARROW_DIFF_DEG,
donutStrokeLength: (score / MAX_SCORE) * MAX_CIRCLE_POINT,
};
};
export { getParsedScore, getPositionData };