Files
resume-builder-mern/frontend/resume-builder/src/components/ResumeSections/RatingInput.jsx
2025-07-07 00:52:41 +05:30

38 lines
905 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from "react";
const RatingInput = ({
value = 0,
total = 5,
onChange = () => {},
color = "#9125E6",
bgColor = "#E9D4FF",
}) => {
// Convert 0100 to 05 scale
const displayValue = Math.round((value / 100) * total);
const handleClick = (index) => {
// Convert 05 scale back to 0100 for DB
const newValue = Math.round(((index + 1) / total) * 100);
onChange(newValue);
};
return <div className="flex gap-3 cursor-pointer">
{[...Array(total)].map((_, index) => {
const isActive = index < displayValue;
return (
<div
key={index}
onClick={() => handleClick(index)}
className="w-4 h-4 rounded transition-all"
style={{
backgroundColor: isActive ? color : bgColor,
}}
></div>
);
})}
</div>
};
export default RatingInput;