Files
HiveGrid-Wireframes/hivegrid-cloud/apps/web/app/components/ui/badges/RatingBadge.tsx
T

32 lines
931 B
TypeScript

import clsx from "~/utils/shared/ClassesUtils";
import { StarIcon } from "~/components/ui/icons/vendor";
export default function RatingBadge({ value, size = 4, starsCount = 5 }: { value: number; size?: number; starsCount?: number }) {
return (
<div>
<div className="flex items-center">
{Array.from({ length: starsCount }).map((_, index) => (
<Star key={index} size={size} color={index < value ? "yellow" : "gray"} />
))}
</div>
</div>
);
}
function Star({ color, size = 5 }: { color: "gray" | "yellow"; size?: number }) {
return (
<StarIcon
aria-hidden="true"
className={clsx(
size === 2 && "h-2 w-2",
size === 3 && "h-3 w-3",
size === 4 && "h-4 w-4",
size === 5 && "h-5 w-5",
size === 6 && "h-6 w-6",
size === 7 && "h-7 w-7",
color === "gray" ? "text-gray-300" : "text-yellow-400"
)}
/>
);
}